I face some trouble when calculating a 4 byte MAC based on "Signature.ALG_DES_MAC4_ISO9797_M1".
The applet doesn't found the same mac value received in the command, even if the data, key, algo are the same.
But when I change the padding mode (see modification below) then every thing is OK.
The modification is done in SymmetricSignatureImpl.java exactly in the init function :
case ALG_DES_MAC4_ISO9797_M1:
// engine = new CBCBlockCipherMac(cipher, 32, new ZeroBytePadding()); //old code
engine = new CBCBlockCipherMac(cipher, 32, null); // new code
break;
I don't know what is the diffrence between the two padding mode. However, for this algo, the padding should respect the following definition: " add bits with value 0 to the end of the data until the padded data is a multiple of n. (If the original data was already a multiple of n, no bits are added.)" see https://en.wikipedia.org/wiki/ISO/IEC_9797-1
Hi,
I face some trouble when calculating a 4 byte MAC based on "Signature.ALG_DES_MAC4_ISO9797_M1". The applet doesn't found the same mac value received in the command, even if the data, key, algo are the same. But when I change the padding mode (see modification below) then every thing is OK.
The modification is done in SymmetricSignatureImpl.java exactly in the init function :
case ALG_DES_MAC4_ISO9797_M1: // engine = new CBCBlockCipherMac(cipher, 32, new ZeroBytePadding()); //old code engine = new CBCBlockCipherMac(cipher, 32, null); // new code break;
I don't know what is the diffrence between the two padding mode. However, for this algo, the padding should respect the following definition: " add bits with value 0 to the end of the data until the padded data is a multiple of n. (If the original data was already a multiple of n, no bits are added.)" see https://en.wikipedia.org/wiki/ISO/IEC_9797-1
BR, Abdeslam