Reputation: 588
Looking through Java Cryptography Architecture and code examples, I have learned how to calculate the Mac using Mac class:
Mac mac = Mac.getInstance("HmacMD5");
mac.init(<secretKeyHere>);
byte[] macHash = mac.doFinal(<encryptedTextHere>);
But I am actually looking for a way to calculate Mac using the ISO 9797-1 Algorithm 3(Retail MAC).
Can someone suggest me a code example in Java?
Upvotes: 1
Views: 1738
Reputation: 42009
It is not available in any of the Oracle providers, however if you add the Bouncycastle provider then that mac algorithm will be available, e.g.
Security.addProvider(new BouncyCastleProvider());
Mac mac = Mac.getInstance("ISO9797ALG3MAC");
Note: that Mac algorithm has been obsolete for decades.
Upvotes: 4
Reputation: 14194
I believe you want to look at javacard.security.Signature.getInstance(Signature.ALG_DES_MAC4_ISO9797_1_M2_ALG3)
and then use the init()
, update()
, and sign()
methods to generate that specific signature.
Upvotes: 1