forked from oracle/graaljs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: split JWK async elliptic curve keygen tests
PR-URL: nodejs/node#49221 Refs: nodejs/node#49202 Refs: nodejs/node#41206 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
- Loading branch information
Showing
3 changed files
with
97 additions
and
84 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
graal-nodejs/test/parallel/test-crypto-keygen-async-elliptic-curve-jwk-ec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const { | ||
generateKeyPair, | ||
} = require('crypto'); | ||
|
||
// Test async elliptic curve key generation with 'jwk' encoding and named | ||
// curve. | ||
['P-384', 'P-256', 'P-521', 'secp256k1'].forEach((curve) => { | ||
generateKeyPair('ec', { | ||
namedCurve: curve, | ||
publicKeyEncoding: { | ||
format: 'jwk' | ||
}, | ||
privateKeyEncoding: { | ||
format: 'jwk' | ||
} | ||
}, common.mustSucceed((publicKey, privateKey) => { | ||
assert.strictEqual(typeof publicKey, 'object'); | ||
assert.strictEqual(typeof privateKey, 'object'); | ||
assert.strictEqual(publicKey.x, privateKey.x); | ||
assert.strictEqual(publicKey.y, privateKey.y); | ||
assert(!publicKey.d); | ||
assert(privateKey.d); | ||
assert.strictEqual(publicKey.kty, 'EC'); | ||
assert.strictEqual(publicKey.kty, privateKey.kty); | ||
assert.strictEqual(publicKey.crv, curve); | ||
assert.strictEqual(publicKey.crv, privateKey.crv); | ||
})); | ||
}); |
38 changes: 38 additions & 0 deletions
38
graal-nodejs/test/parallel/test-crypto-keygen-async-elliptic-curve-jwk-rsa.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const assert = require('assert'); | ||
const { | ||
generateKeyPair, | ||
} = require('crypto'); | ||
|
||
// Test async elliptic curve key generation with 'jwk' encoding and RSA. | ||
{ | ||
generateKeyPair('rsa', { | ||
modulusLength: 4096, | ||
publicKeyEncoding: { | ||
format: 'jwk' | ||
}, | ||
privateKeyEncoding: { | ||
format: 'jwk' | ||
} | ||
}, common.mustSucceed((publicKey, privateKey) => { | ||
assert.strictEqual(typeof publicKey, 'object'); | ||
assert.strictEqual(typeof privateKey, 'object'); | ||
assert.strictEqual(publicKey.kty, 'RSA'); | ||
assert.strictEqual(publicKey.kty, privateKey.kty); | ||
assert.strictEqual(typeof publicKey.n, 'string'); | ||
assert.strictEqual(publicKey.n, privateKey.n); | ||
assert.strictEqual(typeof publicKey.e, 'string'); | ||
assert.strictEqual(publicKey.e, privateKey.e); | ||
assert.strictEqual(typeof privateKey.d, 'string'); | ||
assert.strictEqual(typeof privateKey.p, 'string'); | ||
assert.strictEqual(typeof privateKey.q, 'string'); | ||
assert.strictEqual(typeof privateKey.dp, 'string'); | ||
assert.strictEqual(typeof privateKey.dq, 'string'); | ||
assert.strictEqual(typeof privateKey.qi, 'string'); | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters