You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@calvinmetcalf Is that process completely symmetric? My initial hunch was that the result from crypto.privateDecrypt() would get bumped to cipher block size even with RSA_NO_PADDING, and a quick test seems to confirm that.
varoptions={key: key,padding: constants.RSA_NO_PADDING};varencrypted=crypto.privateDecrypt(options,'plaintext');// encrypted.length == 128vardecrypted=crypto.publicEncrypt(options,encrypted);// decrypted.length == 128// decrypted consists of 119 zero bytes followed by the original plaintext
throws an error unless you left pad it with zeros yourself, privateDecrypt left pads it for you because the output of publicEncrypt will omit a leading zeros (for instance with this keyvar encrypted = crypto.privateDecrypt(options, new Buffer('plaintext')); creates an output of 127 bytes.
Activity
calvinmetcalf commentedon Jan 17, 2015
I'm not sure the question, they are in iojs
Fishrock123 commentedon Jan 19, 2015
@calvinmetcalf Those are the opposite of what they are asking.
publicEncrypt & privateDecrypt vs (their) privateEncrypt & publicDecrypt, assuming they are wanting the correct things.
fuson commentedon Jan 19, 2015
Fishrock123, correct.
calvinmetcalf commentedon Jan 19, 2015
ah missred, if you turn off padding and use privateDecrypt on plain text you will get ciphertext that can be decrypted with publicEncrypt
bnoordhuis commentedon Jan 19, 2015
@calvinmetcalf Is that process completely symmetric? My initial hunch was that the result from crypto.privateDecrypt() would get bumped to cipher block size even with RSA_NO_PADDING, and a quick test seems to confirm that.
calvinmetcalf commentedon Jan 19, 2015
what do you mean by cipher block size in this context modulus size?
bnoordhuis commentedon Jan 19, 2015
@calvinmetcalf This, basically:
calvinmetcalf commentedon Jan 19, 2015
yes it's left padded up to the modulus length, it likely does it when you do
as well (can't check at the moment). It's enough functionality to write your own padding/unpadding on top of it
calvinmetcalf commentedon Jan 21, 2015
to follow up , @bnoordhuis you are correct that it is not symmetric,
throws an error unless you left pad it with zeros yourself, privateDecrypt left pads it for you because the output of publicEncrypt will omit a leading zeros (for instance with this key
var encrypted = crypto.privateDecrypt(options, new Buffer('plaintext'));creates an output of 127 bytes.indutny commentedon Jan 27, 2015
It can't be symmetric, there is a prefix byte that does a thing.
indutny commentedon Jan 27, 2015
I'm going to work on it.
crypto: implement privateEncrypt/publicDecrypt
indutny commentedon Jan 27, 2015
See #625
indutny commentedon Jan 27, 2015
Shall be fixed in 87e62bd
Tweaks for node.js
crypto: implement privateEncrypt/publicDecrypt