@Test public void testBasicAesCtrHmacAead() throws Exception { byte[] aesCtrKeyValue = Random.randBytes(AES_KEY_SIZE); byte[] hmacKeyValue = Random.randBytes(HMAC_KEY_SIZE); int ivSize = 12; int tagSize = 16; KeysetHandle keysetHandle = TestUtil.createKeysetHandle( TestUtil.createKeyset( TestUtil.createKey( TestUtil.createAesCtrHmacAeadKeyData( aesCtrKeyValue, ivSize, hmacKeyValue, tagSize), 42, KeyStatusType.ENABLED, OutputPrefixType.TINK))); Aead aead = new AeadWrapper().wrap(Registry.getPrimitives(keysetHandle, Aead.class)); byte[] plaintext = Random.randBytes(20); byte[] associatedData = Random.randBytes(20); byte[] ciphertext = aead.encrypt(plaintext, associatedData); byte[] decrypted = aead.decrypt(ciphertext, associatedData); assertArrayEquals(plaintext, decrypted); }
@Override public Aead wrap(final PrimitiveSet<Aead> pset) throws GeneralSecurityException { return new WrappedAead(pset); }
AeadWrapper implements PrimitiveWrapper<Aead, Aead> { @Override public Aead wrap(final PrimitiveSet<Aead> pset) throws GeneralSecurityException { return new WrappedAead(pset); } }
AeadWrapper implements PrimitiveWrapper<Aead, Aead> { @Override public Aead wrap(final PrimitiveSet<Aead> pset) throws GeneralSecurityException { return new WrappedAead(pset); } AeadWrapper(); }
AeadWrapper implements PrimitiveWrapper<Aead, Aead> { @Override public Aead wrap(final PrimitiveSet<Aead> pset) throws GeneralSecurityException { return new WrappedAead(pset); } AeadWrapper(); @Override Aead wrap(final PrimitiveSet<Aead> pset); @Override Class<Aead> getPrimitiveClass(); @Override Class<Aead> getInputPrimitiveClass(); static void register(); }
AeadWrapper implements PrimitiveWrapper<Aead, Aead> { @Override public Aead wrap(final PrimitiveSet<Aead> pset) throws GeneralSecurityException { return new WrappedAead(pset); } AeadWrapper(); @Override Aead wrap(final PrimitiveSet<Aead> pset); @Override Class<Aead> getPrimitiveClass(); @Override Class<Aead> getInputPrimitiveClass(); static void register();  }