Search in sources :

Example 1 with IndCpaCipher

use of com.google.crypto.tink.subtle.IndCpaCipher in project tink by google.

the class AesCtrKeyManagerTest method getPrimitive.

@Test
public void getPrimitive() throws Exception {
    AesCtrKey key = factory.createKey(createFormat(14, 32));
    IndCpaCipher managerCipher = manager.getPrimitive(key, IndCpaCipher.class);
    IndCpaCipher directCipher = new AesCtrJceCipher(key.getKeyValue().toByteArray(), 14);
    byte[] plaintext = Random.randBytes(20);
    assertThat(directCipher.decrypt(managerCipher.encrypt(plaintext))).isEqualTo(plaintext);
}
Also used : AesCtrKey(com.google.crypto.tink.proto.AesCtrKey) IndCpaCipher(com.google.crypto.tink.subtle.IndCpaCipher) AesCtrJceCipher(com.google.crypto.tink.subtle.AesCtrJceCipher) Test(org.junit.Test)

Aggregations

AesCtrKey (com.google.crypto.tink.proto.AesCtrKey)1 AesCtrJceCipher (com.google.crypto.tink.subtle.AesCtrJceCipher)1 IndCpaCipher (com.google.crypto.tink.subtle.IndCpaCipher)1 Test (org.junit.Test)1