Expand description

Code related to AES_KW mode

Functions

Export an AES_KW key into the specified format

example
const jwk = await AES_KW.exportKey("jwk", key.self);
example
const jwk = await key.exportKey("jwk");

Parameters

Returns Promise<ArrayBuffer | JsonWebKey>

Generate a new AES_KW key

example
const key = await AES_KW.generateKey();

Parameters

  • algorithm: Omit<EnforcedAesKeyGenParams, "name"> = { length: 256, }
  • extractable: boolean = true
  • Optional keyUsages: KeyUsage[]

Returns Promise<AesKwProxiedCryptoKey>

Import an AES_KW key from the specified format

example
const key = await AES_KW.importKey("jwk", jwk);

Parameters

  • format: KeyFormat
  • key: BufferSource | JsonWebKey
  • Optional extractable: boolean
  • Optional keyUsages: KeyUsage[]

Returns Promise<AesKwProxiedCryptoKey>

Unwrap a wrapped key using the key encryption key

example
const dek = await AES_KW.unwrapKey("raw", wrappedKey, {name: "AES_GCM"}, kek.self);
example
const dek = await kek.unwrapKey("raw", wrappedKey, {name: "AES_GCM"});

Parameters

Returns Promise<CryptoKey>

Wrap another key with an AES_KW key

example
const kek = await AES_KW.generateKey({length: 256}, true, ['wrapKey', 'unwrapKey']);
const dek = await AES_GCM.generateKey();
const wrappedKey = await AES_KW.wrapKey("raw", dek.self, kek.self);
example
const kek = await AES_KW.generateKey({length: 256}, true, ['wrapKey', 'unwrapKey']);
const dek = await AES_GCM.generateKey();
const wrappedKey = await kek.wrapKey("raw", dek.self);

Parameters

Returns Promise<ArrayBuffer>