The data decryption will run in JAVA using RSA/ECB/OAEPWithSHA-256AndMGF1Padding
algorithm. So I have to encrypt the data with public key using the algorithm equivalent to RSA/ECB/OAEPWithSHA-256AndMGF1Padding
in node.js
.
I tried with crypto.publicEncrypt(key, buffer)
which uses crypto.constants.RSA_PKCS1_OAEP_PADDING which is not similar to the above algorithm.
So I need algorithm equivalent to "RSA/ECB/OAEPWithSHA-256AndMGF1Padding" or how to achieve the same in node.js
Firstly, you shouldn't use "ECB" mode cipher, because:
MSC61-J. Do not use insecure or weak cryptographic algorithms
So, in this case, you just need to use OAEP for RSA encryption, because it's a padding scheme and it helpts to prevent Oracle Padding for asymetric algorithms, then change your code for:
RSA/None/OAEPWithSHA-256AndMGF1Padding
. Maybe, you could get compatibility with Node.js. Also, I recommend you visit the official web site:JCA Reference Guide
I hope this information helps you.
Good luck.
I finally found the answer. Equivalent to "RSA/ECB/OAEPWithSHA-256AndMGF1Padding" can be achieved via node-forge npm module. https://www.npmjs.com/package/node-forge#rsa
Thank you