000023678 - JsafeJCE provider mac.getMacLength() method always returns -1

Document created by RSA Customer Support Employee on Jun 16, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000023678
Applies ToBSAFE/Crypto-J 3.6
IssueJsafeJCE provider mac.getMacLength() method always returns -1

Using the Crypto-J JCE provider, mac.getMacLength() always returns -1 if the mac object has not been initialized before.  Here's some code that illustrates the problem:

java.security.Provider p = new com.rsa.jsafe.provider.JsafeJCE();

java.security.Security.addProvider(p);

javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSha1", p);

int length = mac.getMacLength();

The mac.getMacLength() method always returns -1.  It only returns the correct value (of 20) if the mac.init(java.security.Key) method has been called earlier. 

ResolutionThis is a known problem and shall be fixed in a later release.  For now, just do a init() call before calling the getMacLength().
Legacy Article IDa34992

Attachments

    Outcomes