decryptRsaOaepOrThrow
Decrypt an RSA-OAEP ciphertext with the matching private key.
The key must have been generated or imported with { kind: 'rsa', scheme: 'oaep' }, and options.label must repeat the label used at encryption time (if any).
ts
function decryptRsaOaepOrThrow(
privateKey: CryptoKey,
ciphertext: Uint8Array,
_: unknown,
): Promise<Uint8Array>Parameters
privateKey:CryptoKey— RSA-OAEP privateCryptoKeywithdecryptusageciphertext:Uint8Array— Ciphertext produced byencryptRsaOaep(or any RSA-OAEP encryptor)_:unknown
Throws
Error— If the key is not an RSA-OAEP private decryption key, or decryption fails — wrong key, wrong label, or corrupted ciphertext (OAEP deliberately does not reveal which)
See also
encryptRsaOaepOrThrowfor the inverse operationdecryptRsaOaepfor the Result-returning variant
Examples
ts
const plaintext = await decryptRsaOaepOrThrow(keys.privateKey, ciphertext);