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_ci 121cb0ef41Sopenharmony_ci// This tests check that generateKeyPair returns correct bit length in 131cb0ef41Sopenharmony_ci// KeyObject's asymmetricKeyDetails. 141cb0ef41Sopenharmony_ci// https://github.com/nodejs/node/issues/46102#issuecomment-1372153541 151cb0ef41Sopenharmony_ci{ 161cb0ef41Sopenharmony_ci generateKeyPair('rsa', { 171cb0ef41Sopenharmony_ci modulusLength: 513, 181cb0ef41Sopenharmony_ci }, common.mustSucceed((publicKey, privateKey) => { 191cb0ef41Sopenharmony_ci assert.strictEqual(privateKey.asymmetricKeyDetails.modulusLength, 513); 201cb0ef41Sopenharmony_ci assert.strictEqual(publicKey.asymmetricKeyDetails.modulusLength, 513); 211cb0ef41Sopenharmony_ci })); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci generateKeyPair('rsa-pss', { 241cb0ef41Sopenharmony_ci modulusLength: 513, 251cb0ef41Sopenharmony_ci }, common.mustSucceed((publicKey, privateKey) => { 261cb0ef41Sopenharmony_ci assert.strictEqual(privateKey.asymmetricKeyDetails.modulusLength, 513); 271cb0ef41Sopenharmony_ci assert.strictEqual(publicKey.asymmetricKeyDetails.modulusLength, 513); 281cb0ef41Sopenharmony_ci })); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci if (common.hasOpenSSL3) { 311cb0ef41Sopenharmony_ci generateKeyPair('dsa', { 321cb0ef41Sopenharmony_ci modulusLength: 2049, 331cb0ef41Sopenharmony_ci divisorLength: 256, 341cb0ef41Sopenharmony_ci }, common.mustSucceed((publicKey, privateKey) => { 351cb0ef41Sopenharmony_ci assert.strictEqual(privateKey.asymmetricKeyDetails.modulusLength, 2049); 361cb0ef41Sopenharmony_ci assert.strictEqual(publicKey.asymmetricKeyDetails.modulusLength, 2049); 371cb0ef41Sopenharmony_ci })); 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci} 40