gpt4 book ai didi

node.js - Node.js 加密是否在 GCM 模式下使用固定标签大小?

转载 作者:太空宇宙 更新时间:2023-11-04 00:47:31 24 4
gpt4 key购买 nike

我正在node.js中以GCM模式实现一个密码方案。

我必须在密文中附加/前置 GCM 标记才能检查完整性。但是,我不确定标签有多大!

关于crypto++ wiki ,我读到大小可能会有所不同,它实际上是 GCM 模式的一个参数。引用自 wiki,强调我的:

The parameters which must be supplied and used by both parties are:

  • key and key size
  • iv and iv size
  • tag size

但是,在 node documentation ,与标签大小无关。只是标签存在。引用自文档:

cipher.getAuthTag()

For authenticated encryption modes (currently supported: GCM), this method returns a Buffer that represents the authentication tag that has been computed from the given data. Should be called after encryption has been completed using the final method!

我是否应该预期标签大小会发生变化并仅将标签大小与密文一起保存?或者我可以假设标签大小始终小于 128 位并在左侧填充零吗?

最佳答案

node.js 和 browserify-crypto 都使用 128 位标签。

我还没有找到实际的代码,但通过查看测试就很明显了。

Node.js tests here , crypto-browserify tests here .

关于node.js - Node.js 加密是否在 GCM 模式下使用固定标签大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33976117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com