Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e63990e

Browse filesBrowse files
khriztianmorenotargos
authored andcommitted
test: eliminate duplicate statements
PR-URL: #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>
1 parent b822545 commit e63990e
Copy full SHA for e63990e

File tree

Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-crypto-rsa-dsa.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-rsa-dsa.js
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const decryptError = {
3838
{
3939
const input = 'I AM THE WALRUS';
4040
const bufferToEncrypt = Buffer.from(input);
41+
const bufferPassword = Buffer.from('password');
4142

4243
let encryptedBuffer = crypto.publicEncrypt(rsaPubPem, bufferToEncrypt);
4344

@@ -66,33 +67,33 @@ const decryptError = {
6667

6768
encryptedBuffer = crypto.privateEncrypt({
6869
key: rsaKeyPemEncrypted,
69-
passphrase: Buffer.from('password')
70+
passphrase: bufferPassword
7071
}, bufferToEncrypt);
7172

7273
decryptedBufferWithPassword = crypto.publicDecrypt({
7374
key: rsaKeyPemEncrypted,
74-
passphrase: Buffer.from('password')
75+
passphrase: bufferPassword
7576
}, encryptedBuffer);
7677
assert.strictEqual(decryptedBufferWithPassword.toString(), input);
7778

7879
// Now with explicit RSA_PKCS1_PADDING.
7980
encryptedBuffer = crypto.privateEncrypt({
8081
padding: crypto.constants.RSA_PKCS1_PADDING,
8182
key: rsaKeyPemEncrypted,
82-
passphrase: Buffer.from('password')
83+
passphrase: bufferPassword
8384
}, bufferToEncrypt);
8485

8586
decryptedBufferWithPassword = crypto.publicDecrypt({
8687
padding: crypto.constants.RSA_PKCS1_PADDING,
8788
key: rsaKeyPemEncrypted,
88-
passphrase: Buffer.from('password')
89+
passphrase: bufferPassword
8990
}, encryptedBuffer);
9091
assert.strictEqual(decryptedBufferWithPassword.toString(), input);
9192

9293
// Omitting padding should be okay because RSA_PKCS1_PADDING is the default.
9394
decryptedBufferWithPassword = crypto.publicDecrypt({
9495
key: rsaKeyPemEncrypted,
95-
passphrase: Buffer.from('password')
96+
passphrase: bufferPassword
9697
}, encryptedBuffer);
9798
assert.strictEqual(decryptedBufferWithPassword.toString(), input);
9899

@@ -101,13 +102,13 @@ const decryptError = {
101102
encryptedBuffer = crypto.privateEncrypt({
102103
padding: crypto.constants.RSA_NO_PADDING,
103104
key: rsaKeyPemEncrypted,
104-
passphrase: Buffer.from('password')
105+
passphrase: bufferPassword
105106
}, Buffer.from(plaintext));
106107

107108
decryptedBufferWithPassword = crypto.publicDecrypt({
108109
padding: crypto.constants.RSA_NO_PADDING,
109110
key: rsaKeyPemEncrypted,
110-
passphrase: Buffer.from('password')
111+
passphrase: bufferPassword
111112
}, encryptedBuffer);
112113
assert.strictEqual(decryptedBufferWithPassword.toString(), plaintext);
113114

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.