Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SubtleCrypto.importKey()

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

The SubtleCrypto.importKey() method returns a Promise of the CryptoKey generated from the data given in parameters.

Syntax

var result = crypto.importKey(format, keyData, algo, extractable, usages);

Parameters

  • format is an enumerated value describing the data format of the key to imported. It can be one of the following:
  • keyData is an ArrayBuffer or a JSONWebKey containing the key in the given format.
  • algo is a DOMString defining the signature function to use. Supported values are: AES-CTR, AES-CBC, AES-GCM, RSA-OAEP, AES-KW, HMAC, RSASSA-PKCS1-v1_5, ECDSA, ECDH, DH.
  • extractable is a Boolean indicating if the key can be extracted from the CryptoKey object at a later stage.
  • usages is an Array indicating what can be done with the key. Possible values of the array are:
    • "encrypt", allowing the key to be used for encrypting messages.
    • "decrypt", allowing the key to be used for decrypting messages.
    • "sign", allowing the key to be used for signing messages.
    • "verify", allowing the key to be used for verifying the signature of messages.
    • "deriveKey", allowing the key to be used as a base key when deriving a new key.
    • "deriveBits", allowing the key to be used as a base key when deriving bits of data for use in cryptographic primitives.
    • "wrapKey", allowing the key to wrap a symmetric key for usage (transfer, storage) in unsecure environments.
    • "unwrapKey", allowing the key to unwrap a symmetric key for usage (transfer, storage) in unsecure environments.

Return value

Exceptions

The promise is rejected when one of the following exceptions is encountered:

  • SyntaxError when keyUsages is empty but the unwrapped key is of type "secret" or "private".
  • TypeError when trying to use an invalid format or if the keyData is not suited for that format.

Specifications

Specification Status Comment
Web Cryptography API
The definition of 'SubtleCrypto.importKey()' in that specification.
Candidate Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 37 34 (34) No support ? No support
ECDH ? 41 (41) ? ? ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 37 34.0 (34) No support ? No support
ECDH ? ? 41 (41) ? ? ?

See also

ドキュメントのタグと貢献者

 このページの貢献者: oughter, teoli
 最終更新者: oughter,