node.js crypto 在 GCM 模式下使用固定标签大小吗?
Does node.js crypto use fixed tag size with GCM mode?
我正在 node.js.
中以 GCM 模式实施密码方案
我必须 append/prepend GCM 标记密文以检查完整性。但是,我不确定标签会有多大!
在 crypto++ wiki,我读到大小可能会有所不同,它实际上是 GCM 模式的一个参数。引用自维基,强调我的:
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.
中以 GCM 模式实施密码方案我必须 append/prepend GCM 标记密文以检查完整性。但是,我不确定标签会有多大!
在 crypto++ wiki,我读到大小可能会有所不同,它实际上是 GCM 模式的一个参数。引用自维基,强调我的:
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 位标签。
我还没有找到实际的代码,但是通过查看测试很明显。