亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 JS 中導出 AES-KW 密鑰

在 JS 中導出 AES-KW 密鑰

素胚勾勒不出你 2022-05-22 15:57:25
我嘗試在 js 中派生一個 AES-KW 密鑰,例如:let { publicKey: pub, privateKey: key } =   await crypto.subtle.generateKey(    { name: 'ECDH', namedCurve: 'P-521' },    true,    ['deriveKey'],  )await crypto.subtle.deriveKey(  { name: 'ECDH', public: pub },  key,  { name: 'AES-KW', length: 256 },  false,  ["encrypt", "decrypt"],)錯誤:未捕獲(承諾)DOMException:無法使用指定的密鑰用法創建密鑰。我不知道為什么,因為AES-GCM可以成功。
查看完整描述

1 回答

?
梵蒂岡之花

TA貢獻1900條經驗 獲得超5個贊

從技術上講,ascrypto.subtle.deriveKey提供了一個密鑰,可用于根據RFC 3394包裝另一個密鑰,另請參閱。因為這必須用作代替,另請參見此示例 ( )。name: 'AES-KW'derivedKeyAlgorithmAES-KW['wrapKey', 'unwrapKey']keyUsages['encrypt', 'decrypt']getKey


提供了name: 'AES-GCM'asderivedKeyAlgorithm和['encrypt', 'decrypt']askeyUsages密鑰,可用于使用AES-GCM進行加密和解密。


示例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);

        })

    })


查看完整回答
反對 回復 2022-05-22
  • 1 回答
  • 0 關注
  • 235 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號