diff --git a/src/lib/decrypt_key_management.ts b/src/lib/decrypt_key_management.ts index 86ae599424..c56177aa27 100644 --- a/src/lib/decrypt_key_management.ts +++ b/src/lib/decrypt_key_management.ts @@ -20,11 +20,11 @@ async function decryptKeyManagement( joseHeader: JWEHeaderParameters, options?: DecryptOptions, ): Promise { + checkKeyType(alg, key, 'decrypt') + // @ts-ignore key = (await normalize.normalizePrivateKey?.(key, alg)) || key - checkKeyType(alg, key, 'decrypt') - switch (alg) { case 'dir': { // Direct Encryption diff --git a/src/lib/encrypt_key_management.ts b/src/lib/encrypt_key_management.ts index cc06921463..a96b5a3b85 100644 --- a/src/lib/encrypt_key_management.ts +++ b/src/lib/encrypt_key_management.ts @@ -32,11 +32,11 @@ async function encryptKeyManagement( let parameters: (JWEHeaderParameters & { epk?: JWK }) | undefined let cek: KeyLike | Uint8Array + checkKeyType(alg, key, 'encrypt') + // @ts-ignore key = (await normalize.normalizePublicKey?.(key, alg)) || key - checkKeyType(alg, key, 'encrypt') - switch (alg) { case 'dir': { // Direct Encryption