1 回答

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊
從技術(shù)上講,ascrypto.subtle.deriveKey提供了一個(gè)密鑰,可用于根據(jù)RFC 3394包裝另一個(gè)密鑰,另請參閱。因?yàn)檫@必須用作代替,另請參見此示例 ( )。name: 'AES-KW'derivedKeyAlgorithmAES-KW['wrapKey', 'unwrapKey']keyUsages['encrypt', 'decrypt']getKey
提供了name: 'AES-GCM'asderivedKeyAlgorithm和['encrypt', 'decrypt']askeyUsages密鑰,可用于使用AES-GCM進(jìn)行加密和解密。
示例AES-KW:
crypto.subtle.generateKey(
{ name: 'ECDH', namedCurve: 'P-521' },
true,
['deriveKey']
).then(function(keypair){
crypto.subtle.deriveKey(
{ name: 'ECDH', public: keypair.publicKey }, // In practice, this is the public key of the recipient
keypair.privateKey, // In practice, this is the own private key
{ name: 'AES-KW', length: 256 },
true,
["wrapKey", "unwrapKey"],
).then(function(wrappingKey){
console.log(wrappingKey);
})
})
添加回答
舉報(bào)