cipher.setAAD(buffer[, options])


使用经过认证的加密模式时(目前支持 GCM、CCM、OCB、SIV、GCM-SIV 和 chacha20-poly1305),cipher.setAAD() 方法用于设置 额外认证数据(AAD)输入参数的值。

🌐 When using an authenticated encryption mode (GCM, CCM, OCB, SIV, GCM-SIV, and chacha20-poly1305 are currently supported), the cipher.setAAD() method sets the value used for the additional authenticated data (AAD) input parameter.

plaintextLength 选项对于 GCM、OCB、SIV 和 GCM-SIV 是可选的。使用 CCM 时,必须指定 plaintextLength 选项,并且其值必须与明文的字节长度相匹配。请参阅 CCM 模式。

🌐 The plaintextLength option is optional for GCM, OCB, SIV, and GCM-SIV. When using CCM, the plaintextLength option must be specified and its value must match the length of the plaintext in bytes. See CCM mode.

cipher.setAAD() 方法必须在 cipher.update() 之前调用。

🌐 The cipher.setAAD() method must be called before cipher.update().