我正在阅读node-forge documentation并继续看到对'tag'变量的引用。什么是标签及其意义是什么?
答案 0 :(得分:2)
在给出的示例中,他们在Galois/Counter Mode (GCM)中使用AES。 GCM既提供机密性(类似于CTR模式),也提供消息完整性(类似于除AES之外还使用HMAC)。
标签是身份验证标签。它是根据每个密文块计算出来的,用于验证没有人篡改过你的数据。
你可以在这里看到这些行:
var pass = decipher.finish();
// pass is false if there was a failure (eg: authentication tag didn't match)
if (pass) {
// outputs decrypted hex
console.log(decipher.output.toHex());
}
进行检查以查看验证标记是否已正确验证。