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

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

節點:AWS KMS 從內存中擦除公鑰

節點:AWS KMS 從內存中擦除公鑰

斯蒂芬大帝 2021-11-04 16:30:32
來自 KMS 操作的文檔GenerateDataKey https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.htmlWe recommend that you use the following pattern to encrypt data locally in your application:Use the GenerateDataKey operation to get a data encryption key.Use the plaintext data key (returned in the Plaintext field of the response) to encrypt data locally, then erase the plaintext data key from memory.這段代碼是否足以確保明文密鑰在使用完畢后已從內存中刪除。const aws = require("aws-sdk");const kms = new aws.KMS({...config});(async () => {    /** {Plaintext: Buffer, CiphertextBlob: Buffer} **/    let dataKey = await kms.generateDataKey({...options}).promise();    let encryptedString = MyEncryptionFunction(dataKey.Plaintext, "Hello World");    dataKey.Plaintext.fill(0); //overwrite the buffer with zeroes to erase from memory;})();function MyEncryptionFunction(key, dataString) {    let iv = crypto.randomBytes(16);    let cipher = crypto.createCipheriv("aes256", key, iv);    return cipher.update(dataString, "utf8", "hex") + cipher.final("hex");}假設 aws sdk 不會將密鑰泄漏/復制到內存的其他部分是否安全,并且與createCipheriv內置加密庫的功能相同,因此只需Plaintext用零覆蓋緩沖區就足以從內存中擦除密鑰?
查看完整描述

1 回答

?
瀟瀟雨雨

TA貢獻1833條經驗 獲得超4個贊

這就是適用于 JavaScript 的 AWS 加密開發工具包所做的 [1]。事實上,如果加密 SDK 提供了您需要的功能,我會建議您使用它。

aws-sdk 將此值視為敏感值,并在 Node.js[2] 中創建一個隔離的 Buffer。這意味著明文密鑰的作用域是這個函數,只要它不共享它,就沒有其他副本,也沒有人可以訪問。(通常的“沒有壞人可以訪問您的服務器”適用)

跟蹤節點 [3]..[4] 中的調用 createCipheriv 它將密鑰的引用傳遞給 openSSL,而不是副本。

[1] https://github.com/aws/aws-encryption-sdk-javascript/blob/master/modules/material-management/src/cryptographic_material.ts#L343

[2] https://github.com/aws/aws-sdk-js/pull/2622/files

[3] https://github.com/nodejs/node/blob/master/lib/crypto.js#L114

[4] https://github.com/nodejs/node/blob/master/src/node_crypto.cc#L4099


查看完整回答
反對 回復 2021-11-04
  • 1 回答
  • 0 關注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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