使用 AES 封装密钥时生成替代初始值

发布于 2025-01-16 15:58:56 字数 995 浏览 2 评论 0原文

我按照 https://datatracker.ietf.org/doc/html 上的说明进行操作/rfc5649#section-3 我已经到了需要为替代初始值生成LSB(32,A)的地步(AIV)。我使用 NodeJS缓冲区来实现算法。我的理解是 32-bits === buffer.length == 4 或者换句话说,buffer的长度4就是文章中引用的32位。我在转换缓冲区后填充了密钥,然后用 8 - (length % 8) 的长度值填充 0s 作为文章中所示的值。现在我无法弄清楚的是获取 32 位 MLI 的值。我如何获得MLI,我只知道它的消息长度指示器,但这就是我所知道的全部。

示例:

const key = Buffer.from('base64 key', 'base64');
const kek = Buffer.from('A65959A6', 'hex');

现在这里我只有 MSB(32, A) 而没有 LSB(32, A),我如何获取该值,以及我正在做什么错误,请帮助我已经花了很多时间试图解决这个问题。

场景:假设我的密钥长度是 75,现在我必须填充剩余的 5 个字符,使其成为 8 的倍数,现在如何生成 LSB(32, A) 在这种情况下?

Am following the instructions on https://datatracker.ietf.org/doc/html/rfc5649#section-3 and I have gotten to a point where I need to generate the LSB(32,A) for the Alternative Initial Value (AIV). Am using NodeJS with buffers to implement the algorithm. My understanding is 32-bits === buffer.length == 4 or in other words, length 4 of buffer is the 32-bits referenced in the article. I have padded the key after converting it buffer then padding with the length value of 8 - (length % 8) with 0s as value as indicated in the article. Now the thing I have not been able to figure out is getting the value of 32-bit MLI. How do I get the MLI, I just know its Message Length Indicator but thats all I know about it.

Example:

const key = Buffer.from('base64 key', 'base64');
const kek = Buffer.from('A65959A6', 'hex');

Now here I have only MSB(32, A) but not LSB(32, A), how do I get the value, and is there anything I am doing wrong, please help I have already spent alot of time trying to figure this out.

Scenario: Let's say my key length is 75, now I have to pad the remaining 5 characters for it to be multiples of 8, now how do I generate LSB(32, A) in this case?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文