@Test
  public void importExistingKey_decrypts() throws Exception {
    byte[] rawAesKey = Random.randBytes(16);
    Aead jceAead = new AesGcmJce(rawAesKey);
    byte[] plaintext = "plaintext".getBytes(UTF_8);
    byte[] associatedData = "associatedData".getBytes(UTF_8);
    byte[] ciphertext = jceAead.encrypt(plaintext, associatedData);

    KeysetHandle handle =
        MyCustomKeyManager.aesGcm128KeyToKeysetHandle(
            rawAesKey, /* keyId= */ 0x11223344, OutputPrefixType.RAW);
    Aead aead = handle.getPrimitive(Aead.class);
    byte[] decrypted = aead.decrypt(ciphertext, associatedData);
    assertThat(decrypted).isEqualTo(plaintext);
  }
A custom implementation of {@link com.google.crypto.tink.KeyManager} for AES GCM 128.

<p>It only implements the methods of the KeyManager interface that are needed.
java_src/src/test/java/com/google/crypto/tink/custom/CustomAeadKeyManagerTest.java