Random access of encrypted data AES GCM mode

人走茶凉 提交于 2019-12-03 21:02:06

GCM mode uses counter mode for confidentiality. So it is possible to decrypt the ciphertext without authentication; take a look at my answer here. To encrypt or decrypt from a given offset you can alter the counter to alter the bytes for the given offset and XOR the resulting ciphertext. However, you would be unable to verify any ciphertext if you skip even a single byte.

So with GCM it is better to divide the plaintext into chunks and encrypt those separately.

AES GCM uses a mode called GCTR. It's CTR-like, but is defined in a very specific way.

When the IV is not 12 bytes, it is first hashed to get a 12-byte IV (the GHASH function is specified as a single multiplication with the Galois field, the same one used for the MAC).

Then the 12-byte IV is concatenated with a 4-byte counter (starting from 1), to get the 16-byte CTR block.

So treating the IV as a BigInteger and incrementing it like you do in your example will definitely not work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!