000026055 - How many bytes of data can be passed to the JSAFE_AsymmetricCipher.encryptUpdate method in RSA BSAFE Crypto-J for RSA encryption?

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 Number000026055
Applies ToRSA BSAFE Crypto-J
Sun Java Runtime Environment (JRE)
IssueHow many bytes of data can be passed to the JSAFE_AsymmetricCipher.encryptUpdate method in RSA BSAFE Crypto-J for RSA encryption?
The customer attempts to pass a byte array to the JSAFE_AsymmetricCipher.encryptUpdate method with an integer for the start point for encryption and integer for the amount of bytes to be processed. However, user gets the following exception when executing the class:

com.rsa.jsafe.JSAFE_InputException: Invalid Input Length  
        at com.rsa.jsafe.JG_AsymmetricCipher.doEncryptUpdate(JG_AsymmetricCipher.java:376)
                at com.rsa.jsafe.JSAFE_AsymmetricCipher.encryptUpdate(JSAFE_AsymmetricCipher.java:1112)
               at RSAEncrypt.go(RSAEncrypt.java:290)
               at RSAEncrypt.main(RSAEncrypt.java:148)Exception in thread "main" com.rsa.jsafe.JSAFE_InputException: Invalid Input Length
               at com.rsa.jsafe.JG_AsymmetricCipher.doEncryptUpdate(JG_AsymmetricCipher.java:376)
                at com.rsa.jsafe.JSAFE_AsymmetricCipher.encryptUpdate(JSAFE_AsymmetricCipher.java:1112)
               at RSAEncrypt.go(RSAEncrypt.java:290)
               at RSAEncrypt.main(RSAEncrypt.java:148
   
CauseThe customer is attempting to use RSA, which has limits on the amount of data that may be encrypted.  On p.23 of the Crypto-J 3.0 Library Reference Manual where the JSAFE_AsymmetricCipher.getInstance() method is documented, there is a section that discusses the transformation values.  The input constraints for RSA are listed there.  The most common case is "PKCS1Block02Pad", where the maximum number of bytes that can be encrypted is 11 less than the modulus length.
ResolutionYou can also determine the maximum number of bytes that are allowed for encryption by calling the JSAFE_AsymmetricCipher.getMaxInputLen() method.  Note that the maxiumum number of bytes that are allowed for encryption using RSA is dependent on the key size supplied during the call to encryptInit().

See the chapter "JSAFE_AsymmetricCipher - Instantiation Methods" in the RSA BSAFE Crypto-J Library Reference Manual for details on how the padding values effect the amount of input bytes allowed.
Legacy Article IDa3788

Attachments

    Outcomes