use of com.google.crypto.tink.aead.subtle.AesGcmSiv in project tink by google.
the class AesGcmSivKeyManagerTest method getPrimitive.
@Test
public void getPrimitive() throws Exception {
AesGcmSivKey key = factory.createKey(AesGcmSivKeyFormat.newBuilder().setKeySize(16).build());
Aead managerAead = manager.getPrimitive(key, Aead.class);
Aead directAead = new AesGcmSiv(key.getKeyValue().toByteArray());
byte[] plaintext = Random.randBytes(20);
byte[] associatedData = Random.randBytes(20);
assertThat(directAead.decrypt(managerAead.encrypt(plaintext, associatedData), associatedData)).isEqualTo(plaintext);
}
Aggregations