AES GCM implementation with authentication Tag in Java

前端 未结 1 835
滥情空心
滥情空心 2020-12-28 20:46

I\'m using AES GCM authentication in my android project and it works fine. But getting some issues with authentication tag when it compare with openssl API generate tag. Ple

相关标签:
1条回答
  • 2020-12-28 21:23

    In Java the tag is unfortunately added at the end of the ciphertext. You can configure the size (in bits, using a multiple of 8) using GCMParameterSpec. You can therefore grab it using Arrays.copyOfRange(ciphertext, ciphertext.length - (tagSize / Byte.SIZE), ciphertext.length) if you really want to.

    It is unfortunate since the tag does not have to be put at the end, and it makes messes up the online nature of GCM decryption - requiring internal buffering instead of being able to directly return the plaintext. On the other hand, the tag is automatically verified during decryption.

    0 讨论(0)
提交回复
热议问题