jsencrypt icon indicating copy to clipboard operation
jsencrypt copied to clipboard

No support for RSA decryption using public key.

Open ssaguiar opened this issue 4 years ago • 3 comments

At present time, this excellent library doesn't have support to decryption using RSA and public key. Is there any development for this? Thanks.

ssaguiar avatar May 07 '21 15:05 ssaguiar

Are you asking about RSA or AES decryption in this issue as the title says RSA and the description refers to AES?

davidquon avatar May 07 '21 23:05 davidquon

Sorry it's RSA. I have a RSA (RSA/ECB/PKCS1Padding) buffer content which must be decrypted using a public key, generating a key. This will produce the key I will need to decrypt another buffer using the AES/CBC/PKCSSPadding and an IV.

So, I will need to decrypt the first buffer using RSA and a public key to generate the key to decrypt another buffer using AES and anIV wch is in another buffer.

This is how data is present in main buffer:

main buffer bytes:

0 255 ENCRYPTED_LICENSE_KEY 256 271 IV 272 END ENCRYPTED_LICENSE_BODY

LICENSE_KEY = ENCRYPTED_LICENSE_KEY decrypted with public key (RSA/ECB/PKCS1Padding)

LICENSE_BODY = ENCRYPTED_LICENSE_BODY decrypted with LICENSE_KEY & IV (AES/CBC/PKCS5Padding)

Can I do it with jsencrypt?

Thank you very much.

ssaguiar avatar May 08 '21 00:05 ssaguiar

You can rewrite the RSAKey.prototype.decrypt method, change doPrivate to doPublic, and then modify the pkcs1unpad2 method to remove the second input parameter and related processing logic. It works for me!

puregardenia avatar May 23 '24 07:05 puregardenia