1

I´ve been trying for the last few days to Decrypt RSA base64 strings in node. But most of the modules are poorly documented or I´m missing something. The problem is that the private key is passphrase protected and therefore to use crypto.privateDecrypt(private_key, buffer) the key is needed to be inserted as an object.

private_key can be an object or a string. If private_key is a string, it is treated as the key with no passphrase and will use RSA_PKCS1_OAEP_PADDING. If private_key is an object, it is interpreted as a hash object with the keys:

key : <String> - PEM encoded private key
passphrase : <String> - Optional passphrase for the private key
padding : An optional padding value, one of the following:
crypto.constants.RSA_NO_PADDING
crypto.constants.RSA_PKCS1_PADDING
crypto.constants.RSA_PKCS1_OAEP_PADDING

All paddings are defined in crypto.constants.

Since node js is not my native framework, is anyone kind enough to tell me how said object is created ? I already have the PEM string and the passphrase needed.

Thanks in advance.

1 Answer 1

1

Nodejs is not really a framework, more a Javascript engine...
I guess you can use pure Javascript here:

private_key = {
    key: 'PEM encoded private key',
    passphrase: 'Optional passphrase for the private key',
    padding: crypto.constants.RSA_PKCS1_OAEP_PADDING
}
Sign up to request clarification or add additional context in comments.

1 Comment

This worked, still have more problems. "Fixing the lightbulb i noticed the sink leaks."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.