Skip to content

Commit

Permalink
refactor: deprecate the RSA1_5 JWE Algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Nov 9, 2023
1 parent 18a26ff commit f746da1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/runtime/node/rsaes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { KeyObject, publicEncrypt, constants, privateDecrypt } from 'node:crypto'
import { deprecate } from 'node:util'

import type { RsaEsDecryptFunction, RsaEsEncryptFunction } from '../interfaces.d'
import checkKeyLength from './check_key_length.js'
import { isCryptoKey } from './webcrypto.js'
Expand All @@ -14,6 +16,11 @@ const checkKey = (key: KeyObject, alg: string) => {
checkKeyLength(key, alg)
}

const RSA1_5 = deprecate(
() => constants.RSA_PKCS1_PADDING,
'The RSA1_5 "alg" (JWE Algorithm) is deprecated and will be removed in the next major revision.',
)

const resolvePadding = (alg: string) => {
switch (alg) {
case 'RSA-OAEP':
Expand All @@ -22,7 +29,7 @@ const resolvePadding = (alg: string) => {
case 'RSA-OAEP-512':
return constants.RSA_PKCS1_OAEP_PADDING
case 'RSA1_5':
return constants.RSA_PKCS1_PADDING
return RSA1_5()
default:
return undefined
}
Expand Down

0 comments on commit f746da1

Please sign in to comment.