AesGcmParams - Web APIs 编辑

The AesGcmParams dictionary of the Web Crypto API represents the object that should be passed as the algorithm parameter into SubtleCrypto.encrypt(), SubtleCrypto.decrypt()SubtleCrypto.wrapKey(), or SubtleCrypto.unwrapKey(), when using the AES-GCM algorithm.

For details of how to supply appropriate values for this parameter, see the specification for AES-GCM: NIST SP800-38D, in particular section 5.2.1.1 on Input Data.

Properties

name
A DOMString. This should be set to AES-GCM.
iv
A BufferSource — the initialization vector. This must be unique for every encryption operation carried out with a given key. Put another way: never reuse an IV with the same key. The AES-GCM specification recommends that the IV should be 96 bits long, and typically contains bits from a random number generator. Section 8.2 of the specification outlines methods for constructing IVs. Note that the IV does not have to be secret, just unique: so it is OK, for example, to transmit it in the clear alongside the encrypted message.
additionalData Optional

A BufferSource. This contains additional data that will not be encrypted but will be authenticated along with the encrypted data. If additionalData is given here then the same data must be given in the corresponding call to decrypt():  if the data given to the decrypt() call does not match the original data, the decryption will throw an exception. This gives you a way to authenticate associated data without having to encrypt it.

The bit length of additionalData must be ≤ 264-1.

The additionalData property is optional and may be omitted without compromising the security of the encryption operation.

tagLength Optional

A Number. This determines the size in bits of the authentication tag generated in the encryption operation and used for authentication in the corresponding decryption.

According to the Web Crypto specification this must have one of the following values: 32, 64, 96, 104, 112, 120, or 128. The AES-GCM specification recommends that it should be 96, 104, 112, 120 or 128, although 32 or 64 bits may be acceptable in some applications: Appendix C of the specification provides additional guidance here.

tagLength is optional and defaults to 128 if it is not specified.

Examples

See the examples for SubtleCrypto.encrypt() and SubtleCrypto.decrypt().

Specifications

SpecificationStatusComment
Web Cryptography API
The definition of 'SubtleCrypto.AesGcmParams' in that specification.
Recommendation 

Browser compatibility

Browsers that support the "AES-GCM" algorithm for the SubtleCrypto.encrypt(), SubtleCrypto.decrypt()SubtleCrypto.wrapKey(), or SubtleCrypto.unwrapKey() methods will support this type.

See also

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:46 次

字数:5924

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文