Test RSA_OAEP_256 with A256CBC_HS512

Issue #203 invalid
Connect2id OSS created an issue

Bug reported by email to support:

Caused by: com.nimbusds.jose.JOSEException: Data must not be longer than 62
bytes
at com.nimbusds.jose.crypto.RSA_OAEP_256.encryptCEK(RSA_OAEP_256.java:81)
at com.nimbusds.jose.crypto.RSAEncrypter.encrypt(RSAEncrypter.java:147)
at com.nimbusds.jose.JWEObject.encrypt(JWEObject.java:370)
at
com.ca.jwt.nimbus.crypto.AbstractEncrypter.encrypt(AbstractEncrypter.java:76)
... 35 more
Caused by: javax.crypto.IllegalBlockSizeException: Data must not be longer
than 62 bytes
at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:344)
at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:389)
at javax.crypto.Cipher.doFinal(Cipher.java:2165)
at com.nimbusds.jose.crypto.RSA_OAEP_256.encryptCEK(RSA_OAEP_256.java:73)
... 38 more

Comments (1)

  1. Vladimir Dzhuvinov

    The used RSA key is too short to encrypt the content encryption key for A256CBC_HS512 with RSA/OAEP/SHA256, see new test

    https://bitbucket.org/connect2id/nimbus-jose-jwt/src/9b824fa2c30306d8255c1cd41eb75c0ced53227c/src/test/java/com/nimbusds/jose/crypto/RSA_OAEP_256_Test.java?at=master&fileviewer=file-view-default#RSA_OAEP_256_Test.java-135

    Updates the JOSEException message to better signal such conditions. Also refactored the RSA encryption tests. See commit: 9b824fa

  2. Log in to comment