test: eliminate duplicate statements
PR-URL: https://github.com/nodejs/node/pull/28342 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
23416936bc
commit
a10962187f
@ -38,6 +38,7 @@ const decryptError = {
|
||||
{
|
||||
const input = 'I AM THE WALRUS';
|
||||
const bufferToEncrypt = Buffer.from(input);
|
||||
const bufferPassword = Buffer.from('password');
|
||||
|
||||
let encryptedBuffer = crypto.publicEncrypt(rsaPubPem, bufferToEncrypt);
|
||||
|
||||
@ -66,12 +67,12 @@ const decryptError = {
|
||||
|
||||
encryptedBuffer = crypto.privateEncrypt({
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: Buffer.from('password')
|
||||
passphrase: bufferPassword
|
||||
}, bufferToEncrypt);
|
||||
|
||||
decryptedBufferWithPassword = crypto.publicDecrypt({
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: Buffer.from('password')
|
||||
passphrase: bufferPassword
|
||||
}, encryptedBuffer);
|
||||
assert.strictEqual(decryptedBufferWithPassword.toString(), input);
|
||||
|
||||
@ -79,20 +80,20 @@ const decryptError = {
|
||||
encryptedBuffer = crypto.privateEncrypt({
|
||||
padding: crypto.constants.RSA_PKCS1_PADDING,
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: Buffer.from('password')
|
||||
passphrase: bufferPassword
|
||||
}, bufferToEncrypt);
|
||||
|
||||
decryptedBufferWithPassword = crypto.publicDecrypt({
|
||||
padding: crypto.constants.RSA_PKCS1_PADDING,
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: Buffer.from('password')
|
||||
passphrase: bufferPassword
|
||||
}, encryptedBuffer);
|
||||
assert.strictEqual(decryptedBufferWithPassword.toString(), input);
|
||||
|
||||
// Omitting padding should be okay because RSA_PKCS1_PADDING is the default.
|
||||
decryptedBufferWithPassword = crypto.publicDecrypt({
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: Buffer.from('password')
|
||||
passphrase: bufferPassword
|
||||
}, encryptedBuffer);
|
||||
assert.strictEqual(decryptedBufferWithPassword.toString(), input);
|
||||
|
||||
@ -101,13 +102,13 @@ const decryptError = {
|
||||
encryptedBuffer = crypto.privateEncrypt({
|
||||
padding: crypto.constants.RSA_NO_PADDING,
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: Buffer.from('password')
|
||||
passphrase: bufferPassword
|
||||
}, Buffer.from(plaintext));
|
||||
|
||||
decryptedBufferWithPassword = crypto.publicDecrypt({
|
||||
padding: crypto.constants.RSA_NO_PADDING,
|
||||
key: rsaKeyPemEncrypted,
|
||||
passphrase: Buffer.from('password')
|
||||
passphrase: bufferPassword
|
||||
}, encryptedBuffer);
|
||||
assert.strictEqual(decryptedBufferWithPassword.toString(), plaintext);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user