Skip to main content
webcrypto.SubtleCrypto.unwrapKey - node__crypto.d.ts - Node documentation
method webcrypto.SubtleCrypto.unwrapKey

Usage in Deno

```typescript import { type webcrypto } from "node:node__crypto.d.ts"; ```
SubtleCrypto.unwrapKey(
format: KeyFormat,
wrappedKey: BufferSource,
unwrappingKey: CryptoKey,
extractable: boolean,
keyUsages: KeyUsage[],
): Promise<CryptoKey>
In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `` instance. It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input) then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs. If successful, the returned promise is resolved with a `` object. The wrapping algorithms currently supported include: - `'RSA-OAEP'` - `'AES-CTR'` - `'AES-CBC'` - `'AES-GCM'` - `'AES-KW'` The unwrapped key algorithms supported include: - `'RSASSA-PKCS1-v1_5'` - `'RSA-PSS'` - `'RSA-OAEP'` - `'ECDSA'` - `'Ed25519'` - `'Ed448'` - `'ECDH'` - `'X25519'` - `'X448'` - `'HMAC'` - `'AES-CTR'` - `'AES-CBC'` - `'AES-GCM'` - `'AES-KW'`

Parameters

format: KeyFormat
Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
wrappedKey: BufferSource
unwrappingKey: CryptoKey
extractable: boolean
keyUsages: KeyUsage[]
See [Key usages](https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages).

Return Type

Promise<CryptoKey>