File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed
packages/react-native-quick-crypto/src Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -417,14 +417,35 @@ function rsaFunctionFor(
417417 defaultPadding : number ,
418418 keyType : 'public' | 'private' ,
419419) {
420- return ( options : EncodingOptions , buffer : BinaryLike ) => {
420+ return ( options : EncodingOptions | BinaryLike , buffer : BinaryLike ) => {
421421 const { format, type, data, passphrase } =
422422 keyType === 'private'
423423 ? preparePrivateKey ( options )
424424 : preparePublicOrPrivateKey ( options ) ;
425- const padding = options . padding || defaultPadding ;
426- const { oaepHash, encoding } = options ;
427- let { oaepLabel } = options ;
425+
426+ const padding =
427+ options &&
428+ typeof options === 'object' &&
429+ 'padding' in options &&
430+ typeof options . padding === 'number'
431+ ? options . padding
432+ : defaultPadding ;
433+
434+ const oaepHash =
435+ options && typeof options === 'object' && 'oaepHash' in options
436+ ? options . oaepHash
437+ : undefined ;
438+
439+ const encoding =
440+ options && typeof options === 'object' && 'encoding' in options
441+ ? options . encoding
442+ : undefined ;
443+
444+ let oaepLabel =
445+ options && typeof options === 'object' && 'oaepLabel' in options
446+ ? options . oaepLabel
447+ : undefined ;
448+
428449 if ( oaepHash !== undefined ) validateString ( oaepHash , 'key.oaepHash' ) ;
429450 if ( oaepLabel !== undefined )
430451 oaepLabel = binaryLikeToArrayBuffer ( oaepLabel , encoding ) ;
You can’t perform that action at this time.
0 commit comments