@@ -123,10 +123,18 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
123
123
assert . strictEqual ( typeof publicKey , 'object' ) ;
124
124
assert . strictEqual ( publicKey . type , 'public' ) ;
125
125
assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa' ) ;
126
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , {
127
+ modulusLength : 512 ,
128
+ publicExponent : 65537
129
+ } ) ;
126
130
127
131
assert . strictEqual ( typeof privateKey , 'object' ) ;
128
132
assert . strictEqual ( privateKey . type , 'private' ) ;
129
133
assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa' ) ;
134
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , {
135
+ modulusLength : 512 ,
136
+ publicExponent : 65537
137
+ } ) ;
130
138
}
131
139
132
140
{
@@ -268,9 +276,17 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
268
276
} , common . mustSucceed ( ( publicKey , privateKey ) => {
269
277
assert . strictEqual ( publicKey . type , 'public' ) ;
270
278
assert . strictEqual ( publicKey . asymmetricKeyType , 'rsa-pss' ) ;
279
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , {
280
+ modulusLength : 512 ,
281
+ publicExponent : 65537
282
+ } ) ;
271
283
272
284
assert . strictEqual ( privateKey . type , 'private' ) ;
273
285
assert . strictEqual ( privateKey . asymmetricKeyType , 'rsa-pss' ) ;
286
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , {
287
+ modulusLength : 512 ,
288
+ publicExponent : 65537
289
+ } ) ;
274
290
275
291
// Unlike RSA, RSA-PSS does not allow encryption.
276
292
assert . throws ( ( ) => {
@@ -342,6 +358,28 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
342
358
} ) ) ;
343
359
}
344
360
361
+ {
362
+ // Test async DSA key object generation.
363
+ generateKeyPair ( 'dsa' , {
364
+ modulusLength : 512 ,
365
+ divisorLength : 256
366
+ } , common . mustSucceed ( ( publicKey , privateKey ) => {
367
+ assert . strictEqual ( publicKey . type , 'public' ) ;
368
+ assert . strictEqual ( publicKey . asymmetricKeyType , 'dsa' ) ;
369
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , {
370
+ modulusLength : 512 ,
371
+ divisorLength : 256
372
+ } ) ;
373
+
374
+ assert . strictEqual ( privateKey . type , 'private' ) ;
375
+ assert . strictEqual ( privateKey . asymmetricKeyType , 'dsa' ) ;
376
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , {
377
+ modulusLength : 512 ,
378
+ divisorLength : 256
379
+ } ) ;
380
+ } ) ) ;
381
+ }
382
+
345
383
{
346
384
// Test async elliptic curve key generation, e.g. for ECDSA, with a SEC1
347
385
// private key.
@@ -925,16 +963,24 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
925
963
// It should recognize both NIST and standard curve names.
926
964
generateKeyPair ( 'ec' , {
927
965
namedCurve : 'P-256' ,
928
- publicKeyEncoding : { type : 'spki' , format : 'pem' } ,
929
- privateKeyEncoding : { type : 'pkcs8' , format : 'pem' }
930
966
} , common . mustSucceed ( ( publicKey , privateKey ) => {
967
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , {
968
+ namedCurve : 'prime256v1'
969
+ } ) ;
970
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , {
971
+ namedCurve : 'prime256v1'
972
+ } ) ;
931
973
} ) ) ;
932
974
933
975
generateKeyPair ( 'ec' , {
934
976
namedCurve : 'secp256k1' ,
935
- publicKeyEncoding : { type : 'spki' , format : 'pem' } ,
936
- privateKeyEncoding : { type : 'pkcs8' , format : 'pem' }
937
977
} , common . mustSucceed ( ( publicKey , privateKey ) => {
978
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , {
979
+ namedCurve : 'secp256k1'
980
+ } ) ;
981
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , {
982
+ namedCurve : 'secp256k1'
983
+ } ) ;
938
984
} ) ) ;
939
985
}
940
986
@@ -945,9 +991,11 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
945
991
generateKeyPair ( keyType , common . mustSucceed ( ( publicKey , privateKey ) => {
946
992
assert . strictEqual ( publicKey . type , 'public' ) ;
947
993
assert . strictEqual ( publicKey . asymmetricKeyType , keyType ) ;
994
+ assert . deepStrictEqual ( publicKey . asymmetricKeyDetails , { } ) ;
948
995
949
996
assert . strictEqual ( privateKey . type , 'private' ) ;
950
997
assert . strictEqual ( privateKey . asymmetricKeyType , keyType ) ;
998
+ assert . deepStrictEqual ( privateKey . asymmetricKeyDetails , { } ) ;
951
999
} ) ) ;
952
1000
} ) ;
953
1001
}
0 commit comments