Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALG_DES_MAC4_ISO9797_M1 padding issue #93

Open
AbdesElo opened this issue Sep 22, 2016 · 0 comments
Open

ALG_DES_MAC4_ISO9797_M1 padding issue #93

AbdesElo opened this issue Sep 22, 2016 · 0 comments

Comments

@AbdesElo
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant