use of com.google.crypto.tink.proto.AesGcmSivKey in project tink by google.
the class AesGcmSivKeyManagerTest method createKey_16Bytes.
@Test
public void createKey_16Bytes() throws Exception {
AesGcmSivKey key = factory.createKey(AesGcmSivKeyFormat.newBuilder().setKeySize(16).build());
assertThat(key.getKeyValue()).hasSize(16);
}
use of com.google.crypto.tink.proto.AesGcmSivKey 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