subtle.wrapKey(format, key, wrappingKey, wrapAlgorithm)


在密码学中,“封装密钥”指的是导出然后加密密钥材料。这种方法会将密钥材料导出为 format 指定的格式,然后使用 wrapAlgorithm 指定的方法和参数,以及 wrappingKey 提供的密钥材料来进行加密。它相当于调用 subtle.exportKey(),使用 formatkey 作为参数,然后将结果传给 subtle.encrypt() 方法,使用 wrappingKeywrapAlgorithm 作为输入。如果成功,返回的 promise 将会被解决,并带有一个包含加密密钥数据的 <ArrayBuffer>

🌐 In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. This method exports the keying material into the format identified by format, then encrypts it using the method and parameters specified by wrapAlgorithm and the keying material provided by wrappingKey. It is the equivalent to calling subtle.exportKey() using format and key as the arguments, then passing the result to the subtle.encrypt() method using wrappingKey and wrapAlgorithm as inputs. If successful, the returned promise will be resolved with an <ArrayBuffer> containing the encrypted key data.

目前支持的环绕算法包括:

🌐 The wrapping algorithms currently supported include:

  • 'AES-CBC'
  • 'AES-CTR'
  • 'AES-GCM'
  • 'AES-KW'
  • 'AES-OCB'[^现代算法]
  • 'ChaCha20-Poly1305'4
  • 'RSA-OAEP'