11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst { 91cb0ef41Sopenharmony_ci generateKeyPair, 101cb0ef41Sopenharmony_ci} = require('crypto'); 111cb0ef41Sopenharmony_ciconst { 121cb0ef41Sopenharmony_ci testSignVerify, 131cb0ef41Sopenharmony_ci spkiExp, 141cb0ef41Sopenharmony_ci sec1Exp, 151cb0ef41Sopenharmony_ci} = require('../common/crypto'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci// Test async explicit elliptic curve key generation, e.g. for ECDSA, 181cb0ef41Sopenharmony_ci// with a SEC1 private key with paramEncoding explicit. 191cb0ef41Sopenharmony_ci{ 201cb0ef41Sopenharmony_ci generateKeyPair('ec', { 211cb0ef41Sopenharmony_ci namedCurve: 'prime256v1', 221cb0ef41Sopenharmony_ci paramEncoding: 'explicit', 231cb0ef41Sopenharmony_ci publicKeyEncoding: { 241cb0ef41Sopenharmony_ci type: 'spki', 251cb0ef41Sopenharmony_ci format: 'pem' 261cb0ef41Sopenharmony_ci }, 271cb0ef41Sopenharmony_ci privateKeyEncoding: { 281cb0ef41Sopenharmony_ci type: 'sec1', 291cb0ef41Sopenharmony_ci format: 'pem' 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci }, common.mustSucceed((publicKey, privateKey) => { 321cb0ef41Sopenharmony_ci assert.strictEqual(typeof publicKey, 'string'); 331cb0ef41Sopenharmony_ci assert.match(publicKey, spkiExp); 341cb0ef41Sopenharmony_ci assert.strictEqual(typeof privateKey, 'string'); 351cb0ef41Sopenharmony_ci assert.match(privateKey, sec1Exp); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci testSignVerify(publicKey, privateKey); 381cb0ef41Sopenharmony_ci })); 391cb0ef41Sopenharmony_ci} 40