Java AES/GCM/NoPadding encryption does not increment the counter of the IV after doFinal
问题 When I initialize a Cipher object with the default AES/GCM algorithm, it has a reandom 12 bytes IV but the first 4 byte does not get incremented ater doFinal is called and throws the java.lang.IllegalStateException: Cannot re-use same key and IV for multiple encryptions exception. SecretKey secretKey = ... final Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); byte[] iv1 = encCipher.getIV(); byte[] ctext = encCipher.doFinal("a".getBytes());