@Test
  public void testNistVectors() throws Exception {
    for (NistTestVector t : nistTestVectors) {
      if (t.iv.length != 12 || t.tag.length != 16) {
        // We support only 12-byte IV and 16-byte tag.
        continue;
      }
      AesGcmParameters parameters =
          AesGcmParameters.builder()
              .setIvSizeBytes(12)
              .setKeySizeBytes(t.keyValue.length)
              .setTagSizeBytes(16)
              .setVariant(AesGcmParameters.Variant.NO_PREFIX)
              .build();
      AesGcmKey key =
          AesGcmKey.builder()
              .setParameters(parameters)
              .setKeyBytes(SecretBytes.copyFrom(t.keyValue, InsecureSecretKeyAccess.get()))
              .build();
      Aead aead =
          KeysetHandle.newBuilder()
              .addEntry(KeysetHandle.importKey(key).makePrimary().withRandomId())
              .build()
              .getPrimitive(Aead.class);
      try {
        byte[] ciphertext = Bytes.concat(t.iv, t.ciphertext, t.tag);
        byte[] plaintext = aead.decrypt(ciphertext, t.aad);
        assertArrayEquals(plaintext, t.plaintext);
      } catch (GeneralSecurityException e) {
        fail("Should not fail at " + t.name + ", but thrown exception " + e);
      }
    }
  }
Test for AesGcmJce and its key manager.
java_src/src/test/java/com/google/crypto/tink/aead/AesGcmKeyManagerTest.java