| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 89d3905 commit 82b2d9c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,21 +109,22 @@ const data = Buffer.from('hello store'); | |||
| 109 | 109 | ||
| 110 | 110 | { | |
| 111 | 111 | // Encrypted PKCS#8 with passphrase via { key: url, passphrase }. | |
| 112 | + const passphrase = 'correct-passphrase'; | ||
| 112 | 113 | const { privateKey, publicKey } = generateKeyPairSync('ed25519'); | |
| 113 | 114 | const file = path.join(tmpdir.path, 'enc.pem'); | |
| 114 | 115 | fs.writeFileSync(file, privateKey.export({ | |
| 115 | - format: 'pem', type: 'pkcs8', cipher: 'aes-256-cbc', passphrase: 'pw', | ||
| 116 | + format: 'pem', type: 'pkcs8', cipher: 'aes-256-cbc', passphrase, | ||
| 116 | 117 | })); | |
| 117 | 118 | const url = pathToFileURL(file); | |
| 118 | 119 | ||
| 119 | - const sig = sign(null, data, { key: url, passphrase: Buffer.from('pw') }); | ||
| 120 | + const sig = sign(null, data, { key: url, passphrase: Buffer.from(passphrase) }); | ||
| 120 | 121 | assert.strictEqual(verify(null, data, publicKey, sig), true); | |
| 121 | 122 | ||
| 122 | 123 | assert.throws(() => createPrivateKey(url), { | |
| 123 | 124 | code: 'ERR_MISSING_PASSPHRASE', | |
| 124 | 125 | }); | |
| 125 | 126 | ||
| 126 | - assert.throws(() => createPrivateKey({ key: url, passphrase: 'bad' }), | ||
| 127 | + assert.throws(() => createPrivateKey({ key: url, passphrase: 'wrong-passphrase' }), | ||
| 127 | 128 | common.expectsError({ | |
| 128 | 129 | name: 'Error', | |
| 129 | 130 | code: /^ERR_OSSL_/, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ if (isMainThread) { | |||
| 30 | 30 | const derivations = [ | |
| 31 | 31 | ['HKDF', () => crypto.hkdfSync('sha256', Buffer.alloc(32), Buffer.alloc(8), | |
| 32 | 32 | Buffer.alloc(0), 32)], | |
| 33 | - ['PBKDF2', () => crypto.pbkdf2Sync('secret', Buffer.alloc(16), 1000, 32, | ||
| 33 | + ['PBKDF2', () => crypto.pbkdf2Sync('passphrase', Buffer.alloc(16), 1000, 32, | ||
| 34 | 34 | 'sha256')], | |
| 35 | 35 | ]; | |
| 36 | 36 | for (const { 0: name, 1: derive } of derivations) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments