简体   繁体   English

AES GCM和文件传输

[英]AES GCM and file transfer

I would like to implement a file transfer using AES GCM, both peers share the same key. 我想使用AES GCM实施文件传输,两个对等方共享相同的密钥。 However the GCM tag that is used to verify the data integrity is computed at the end of the encryption process. 但是,用于验证数据完整性的GCM标签是在加密过程结束时计算的。 So should the sender also send the tag to the receiver so he can decrypt and validate them ? 那么发送方是否也应该将标签发送给接收方,以便他可以解密并验证它们? Or is it considered unsafe ? 还是被认为是不安全的? (assuming the tag is encrypted and sent the same way the data are) (假设标签已加密并以与数据相同的方式发送)

You can send the tag and you even have to, as most proper implementations of GCM will fail to decrypt the ciphertext unless you provide them with a valid tag. 您可以发送标签,甚至必须发送标签,因为GCM的大多数正确实现都无法解密密文,除非您为它们提供有效的标签。

To decrypt succesfully, you must have the ciphertext, the key, and the nonce. 要成功解密,必须具有密文,密钥和随机数。 To verify the authenticity you must have the ciphertext,the tag, the key, the nonce and the assosiated data (if some was used during encryption) 要验证真实性,您必须具有密文,标签,密钥,随机数和相关数据(如果在加密过程中使用了某些数据)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM