@Test
  public void test_24byte_primitiveCreation_throws() throws Exception {
    // We currently disallow creation of AesGcmKeys with 24 bytes (Tink doesn't support using these
    // for consistency among the languages, so we also disallow creation at the moment).
    AesGcmParameters p =
        AesGcmParameters.builder()
            .setIvSizeBytes(12)
            .setTagSizeBytes(16)
            .setKeySizeBytes(24)
            .build();
    AesGcmKey key =
        AesGcmKey.builder().setParameters(p).setKeyBytes(SecretBytes.randomBytes(24)).build();
    KeysetHandle keysetHandle =
        KeysetHandle.newBuilder()
            .addEntry(KeysetHandle.importKey(key).makePrimary().withRandomId())
            .build();
    assertThrows(GeneralSecurityException.class, () -> keysetHandle.getPrimitive(Aead.class));
  }
Test for AesGcmJce and its key manager.
java_src/src/test/java/com/google/crypto/tink/aead/AesGcmKeyManagerTest.java