@@ -50,6 +50,8 @@ const {
5050 PublicKeyObject,
5151 createPublicKey,
5252 createPrivateKey,
53+ kAlgorithm,
54+ kKeyType,
5355} = require ( 'internal/crypto/keys' ) ;
5456
5557const {
@@ -95,7 +97,7 @@ function rsaOaepCipher(mode, key, data, algorithm) {
9597 validateRsaOaepAlgorithm ( algorithm ) ;
9698
9799 const type = mode === kWebCryptoCipherEncrypt ? 'public' : 'private' ;
98- if ( key . type !== type ) {
100+ if ( key [ kKeyType ] !== type ) {
99101 throw lazyDOMException (
100102 'The requested operation is not valid for the provided key' ,
101103 'InvalidAccessError' ) ;
@@ -107,7 +109,7 @@ function rsaOaepCipher(mode, key, data, algorithm) {
107109 key [ kKeyObject ] [ kHandle ] ,
108110 data ,
109111 kKeyVariantRSA_OAEP ,
110- normalizeHashName ( key . algorithm . hash . name ) ,
112+ normalizeHashName ( key [ kAlgorithm ] . hash . name ) ,
111113 algorithm . label ) ) ;
112114}
113115
@@ -201,7 +203,7 @@ function rsaExportKey(key, format) {
201203 kCryptoJobAsync ,
202204 format ,
203205 key [ kKeyObject ] [ kHandle ] ,
204- kRsaVariants [ key . algorithm . name ] ) ) ;
206+ kRsaVariants [ key [ kAlgorithm ] . name ] ) ) ;
205207}
206208
207209function rsaImportKey (
@@ -329,16 +331,16 @@ function rsaSignVerify(key, data, { saltLength }, signature) {
329331 const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify ;
330332 const type = mode === kSignJobModeSign ? 'private' : 'public' ;
331333
332- if ( key . type !== type )
334+ if ( key [ kKeyType ] !== type )
333335 throw lazyDOMException ( `Key must be a ${ type } key` , 'InvalidAccessError' ) ;
334336
335337 return jobPromise ( ( ) => {
336- if ( key . algorithm . name === 'RSA-PSS' ) {
338+ if ( key [ kAlgorithm ] . name === 'RSA-PSS' ) {
337339 validateInt32 (
338340 saltLength ,
339341 'algorithm.saltLength' ,
340342 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 ) ;
342344 }
343345
344346 return new SignJob (
@@ -349,9 +351,9 @@ function rsaSignVerify(key, data, { saltLength }, signature) {
349351 undefined ,
350352 undefined ,
351353 data ,
352- normalizeHashName ( key . algorithm . hash . name ) ,
354+ normalizeHashName ( key [ kAlgorithm ] . hash . name ) ,
353355 saltLength ,
354- key . algorithm . name === 'RSA-PSS' ? RSA_PKCS1_PSS_PADDING : undefined ,
356+ key [ kAlgorithm ] . name === 'RSA-PSS' ? RSA_PKCS1_PSS_PADDING : undefined ,
355357 undefined ,
356358 signature ) ;
357359 } ) ;
0 commit comments