Closed sn99 closed 5 months ago
It is defined as :
RSA_PKCS1_OAEP_PADDING EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an empty encoding parameter. This mode is recommended for all new applications.
I am trying to copy node.js behavior defined here: https://nodejs.org/api/crypto.html#cryptopublicencryptkey-buffer. For something like: crypto.publicEncrypt(this.publicKey(), Buffer.from(data)).
crypto.publicEncrypt(this.publicKey(), Buffer.from(data))
Would this actually be correct Rust implementation:
let public_key = RsaPublicKey::from_public_key_pem(&public_key)?; let padding = Oaep::new_with_mgf_hash::<Sha256, Sha1>(); let encrypted_data = public_key.encrypt(&mut rng, padding, data.as_bytes())?;
Yes, that looks about right. You can also use the types in the rsa::oaep module like EncryptingKey.
rsa::oaep
EncryptingKey
It is defined as :
I am trying to copy node.js behavior defined here: https://nodejs.org/api/crypto.html#cryptopublicencryptkey-buffer. For something like:
crypto.publicEncrypt(this.publicKey(), Buffer.from(data))
.Would this actually be correct Rust implementation: