summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-keygen.js
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2019-03-10 00:51:56 +0100
committerTobias Nießen <tniessen@tnie.de>2019-03-18 21:59:47 +0100
commit3a9592496cbb2b4667a72f53126ec626da104f53 (patch)
tree1f127ca630c40394cbc172b69a2464366a1cda79 /test/parallel/test-crypto-keygen.js
parent1a6fb71f71faf37e0b213cfc69021a5a27faea1f (diff)
downloadandroid-node-v8-3a9592496cbb2b4667a72f53126ec626da104f53.tar.gz
android-node-v8-3a9592496cbb2b4667a72f53126ec626da104f53.tar.bz2
android-node-v8-3a9592496cbb2b4667a72f53126ec626da104f53.zip
crypto: add support for EdDSA key pair generation
PR-URL: https://github.com/nodejs/node/pull/26554 Refs: https://github.com/nodejs/node/pull/26319 Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'test/parallel/test-crypto-keygen.js')
-rw-r--r--test/parallel/test-crypto-keygen.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js
index 43f2196115..ae29c9af40 100644
--- a/test/parallel/test-crypto-keygen.js
+++ b/test/parallel/test-crypto-keygen.js
@@ -425,7 +425,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
type: TypeError,
code: 'ERR_INVALID_ARG_VALUE',
message: "The argument 'type' must be one of " +
- "'rsa', 'dsa', 'ec'. Received 'rsa2'"
+ "'rsa', 'dsa', 'ec', 'ed25519', 'ed448'. Received 'rsa2'"
});
}
@@ -437,6 +437,15 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
message: 'The "options" argument must be of ' +
'type object. Received type undefined'
});
+
+ // Even if no options are required, it should be impossible to pass anything
+ // but an object (or undefined).
+ common.expectsError(() => generateKeyPair('ed448', 0, common.mustNotCall()), {
+ type: TypeError,
+ code: 'ERR_INVALID_ARG_TYPE',
+ message: 'The "options" argument must be of ' +
+ 'type object. Received type number'
+ });
}
{
@@ -774,6 +783,23 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}));
}
+// Test EdDSA key generation.
+{
+ if (!/^1\.1\.0/.test(process.versions.openssl)) {
+ ['ed25519', 'ed448'].forEach((keyType) => {
+ generateKeyPair(keyType, common.mustCall((err, publicKey, privateKey) => {
+ assert.ifError(err);
+
+ assert.strictEqual(publicKey.type, 'public');
+ assert.strictEqual(publicKey.asymmetricKeyType, keyType);
+
+ assert.strictEqual(privateKey.type, 'private');
+ assert.strictEqual(privateKey.asymmetricKeyType, keyType);
+ }));
+ });
+ }
+}
+
// Test invalid key encoding types.
{
// Invalid public key type.