Skip to content

Commit a3647aa

Browse files
committed
fixup! benchmark: add crypto.create*Key
1 parent 7cf917d commit a3647aa

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

benchmark/crypto/create-keyobject.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,21 @@ const fs = require('fs');
66
const path = require('path');
77
const fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/');
88

9+
function readKey(name) {
10+
return fs.readFileSync(`${fixtures_keydir}/${name}.pem`, 'utf8');
11+
}
12+
13+
function readKeyPair(publicKeyName, privateKeyName) {
14+
return {
15+
publicKey: readKey(publicKeyName),
16+
privateKey: readKey(privateKeyName)
17+
};
18+
}
19+
920
const keyFixtures = {
10-
ec: {
11-
publicKey:
12-
fs.readFileSync(`${fixtures_keydir}/ec_p256_public.pem`).toString(),
13-
privateKey:
14-
fs.readFileSync(`${fixtures_keydir}/ec_p256_private.pem`).toString(),
15-
},
16-
rsa: {
17-
publicKey:
18-
fs.readFileSync(`${fixtures_keydir}/rsa_public_2048.pem`).toString(),
19-
privateKey:
20-
fs.readFileSync(`${fixtures_keydir}/rsa_private_2048.pem`).toString(),
21-
},
22-
ed25519: {
23-
publicKey:
24-
fs.readFileSync(`${fixtures_keydir}/ed25519_public.pem`).toString(),
25-
privateKey:
26-
fs.readFileSync(`${fixtures_keydir}/ed25519_private.pem`).toString(),
27-
},
21+
ec: readKeyPair('ec_p256_public', 'ec_p256_private'),
22+
rsa: readKeyPair('rsa_public_2048', 'rsa_private_2048'),
23+
ed25519: readKeyPair('ed25519_public', 'ed25519_private')
2824
};
2925

3026
const bench = common.createBenchmark(main, {

0 commit comments

Comments
 (0)