forge icon indicating copy to clipboard operation
forge copied to clipboard

Randomly thrown "Invalid RSAES-OAEP padding." error with a valid key

Open marckong opened this issue 1 year ago • 3 comments

We are using the forge package for password based authentication, which randomly throws the "Invalid RSAES-OAEP padding." error with an actually VALID password. What could be the potential cause for this?

Found a similar issue that is still not resolved (despite it being encryption related) - https://github.com/digitalbazaar/forge/issues/621

marckong avatar Jun 14 '24 19:06 marckong

cc: @subnetmarco

marckong avatar Jun 14 '24 19:06 marckong

I'm facing exact same problem. It is occuring if I have any character which is not an alphabet in source text. That is what I figured until now.

chanzxxx avatar Jan 23 '25 00:01 chanzxxx

Problem solved. Had to call forge.util.encodeUtf8 before pass it to encrypt function. Like below

pk.encrypt(forge.util.encodeUtf8(text), 'RSA-OAEP');

chanzxxx avatar Jan 23 '25 01:01 chanzxxx