wrapKey
Collapse the table of content
Expand the table of content

wrapKey method

Returns a Promise object which will asynchronously return an array containing the key material of key, encrypted with keyEncryptionKey using the specified keyWrappingAlgorithm.

Important  As of Microsoft Edge, this method returns a Promise object. See Web Cryptography API updates for more info.
IE11

 

Syntax

var retVal = SubtleCrypto.wrapKey(key, keyEncryptionKey, keyWrappingAlgorithm);

Parameters

key [in]

Type: Key

The Key object whose key material is to be extracted.

keyEncryptionKey [in]

Type: Key

This Key object is used to encrypt the key material.

keyWrappingAlgorithm [in]

Type: any

An object identifying the cryptographic algorithm to use for encrypting the key material (along with any required algorithmic parameters). The supported cryptographic algorithms are as follows:

  • AES-KW
  • RSA-OAEP
  • AES-GCM

Return value

Type: Promise

An Promise object that will return the encrypted key material.

Note  IE11 returns a KeyOperation. See Web Cryptography API updates for more info.

Remarks

The Key object received by the keyEncryptionKey parameter is used to encrypt the content master key, not the key itself (this key is encrypted using the content master key.

The wrapKey method protects key material in a JSON Web Key (JWK) structure encapsulated with JSON Web Encryption (JWE). Specifically, the key material of key is encrypted using a randomly-generated content encryption key, which in turn is encrypted with keyEncryptionKey using the specified keyWrappingAlgorithm.

The algorithm used for the content encryption key is always AES-GCM. The wrapKey method can be used to wrap the key material for any Key object.

For a code example, see unwrapKey.

See also

SubtleCrypto

 

 

Show:
© 2016 Microsoft