@@ -50,6 +50,8 @@ const {
50
50
PublicKeyObject,
51
51
createPublicKey,
52
52
createPrivateKey,
53
+ kAlgorithm,
54
+ kKeyType,
53
55
} = require ( 'internal/crypto/keys' ) ;
54
56
55
57
const {
@@ -95,7 +97,7 @@ function rsaOaepCipher(mode, key, data, algorithm) {
95
97
validateRsaOaepAlgorithm ( algorithm ) ;
96
98
97
99
const type = mode === kWebCryptoCipherEncrypt ? 'public' : 'private' ;
98
- if ( key . type !== type ) {
100
+ if ( key [ kKeyType ] !== type ) {
99
101
throw lazyDOMException (
100
102
'The requested operation is not valid for the provided key' ,
101
103
'InvalidAccessError' ) ;
@@ -107,7 +109,7 @@ function rsaOaepCipher(mode, key, data, algorithm) {
107
109
key [ kKeyObject ] [ kHandle ] ,
108
110
data ,
109
111
kKeyVariantRSA_OAEP ,
110
- normalizeHashName ( key . algorithm . hash . name ) ,
112
+ normalizeHashName ( key [ kAlgorithm ] . hash . name ) ,
111
113
algorithm . label ) ) ;
112
114
}
113
115
@@ -201,7 +203,7 @@ function rsaExportKey(key, format) {
201
203
kCryptoJobAsync ,
202
204
format ,
203
205
key [ kKeyObject ] [ kHandle ] ,
204
- kRsaVariants [ key . algorithm . name ] ) ) ;
206
+ kRsaVariants [ key [ kAlgorithm ] . name ] ) ) ;
205
207
}
206
208
207
209
function rsaImportKey (
@@ -329,16 +331,16 @@ function rsaSignVerify(key, data, { saltLength }, signature) {
329
331
const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify ;
330
332
const type = mode === kSignJobModeSign ? 'private' : 'public' ;
331
333
332
- if ( key . type !== type )
334
+ if ( key [ kKeyType ] !== type )
333
335
throw lazyDOMException ( `Key must be a ${ type } key` , 'InvalidAccessError' ) ;
334
336
335
337
return jobPromise ( ( ) => {
336
- if ( key . algorithm . name === 'RSA-PSS' ) {
338
+ if ( key [ kAlgorithm ] . name === 'RSA-PSS' ) {
337
339
validateInt32 (
338
340
saltLength ,
339
341
'algorithm.saltLength' ,
340
342
0 ,
341
- MathCeil ( ( key . algorithm . modulusLength - 1 ) / 8 ) - getDigestSizeInBytes ( key . algorithm . hash . name ) - 2 ) ;
343
+ MathCeil ( ( key [ kAlgorithm ] . modulusLength - 1 ) / 8 ) - getDigestSizeInBytes ( key [ kAlgorithm ] . hash . name ) - 2 ) ;
342
344
}
343
345
344
346
return new SignJob (
@@ -349,9 +351,9 @@ function rsaSignVerify(key, data, { saltLength }, signature) {
349
351
undefined ,
350
352
undefined ,
351
353
data ,
352
- normalizeHashName ( key . algorithm . hash . name ) ,
354
+ normalizeHashName ( key [ kAlgorithm ] . hash . name ) ,
353
355
saltLength ,
354
- key . algorithm . name === 'RSA-PSS' ? RSA_PKCS1_PSS_PADDING : undefined ,
356
+ key [ kAlgorithm ] . name === 'RSA-PSS' ? RSA_PKCS1_PSS_PADDING : undefined ,
355
357
undefined ,
356
358
signature ) ;
357
359
} ) ;
0 commit comments