Search in sources :

Example 1 with PrfAesCmac

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

the class AesCmacPrfKeyManagerTest method getPrimitive_works.

@Test
public void getPrimitive_works() throws Exception {
    AesCmacPrfKeyManager manager = new AesCmacPrfKeyManager();
    AesCmacPrfKey validKey = manager.keyFactory().createKey(makeAesCmacPrfKeyFormat(32));
    Prf managerPrf = manager.getPrimitive(validKey, Prf.class);
    Prf directPrf = new PrfAesCmac(validKey.getKeyValue().toByteArray());
    byte[] message = Random.randBytes(50);
    assertThat(managerPrf.compute(message, 16)).isEqualTo(directPrf.compute(message, 16));
}
Also used : PrfAesCmac(com.google.crypto.tink.subtle.PrfAesCmac) AesCmacPrfKey(com.google.crypto.tink.proto.AesCmacPrfKey) Test(org.junit.Test)

Example 2 with PrfAesCmac

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

the class AesCmacKeyManagerTest method getPrimitive_works.

@Test
public void getPrimitive_works() throws Exception {
    AesCmacKeyManager manager = new AesCmacKeyManager();
    AesCmacKey validKey = manager.keyFactory().createKey(makeAesCmacKeyFormat(32, 16));
    Mac managerMac = manager.getPrimitive(validKey, Mac.class);
    Mac directMac = new PrfMac(new PrfAesCmac(validKey.getKeyValue().toByteArray()), validKey.getParams().getTagSize());
    byte[] message = Random.randBytes(50);
    managerMac.verifyMac(directMac.computeMac(message), message);
}
Also used : PrfAesCmac(com.google.crypto.tink.subtle.PrfAesCmac) PrfMac(com.google.crypto.tink.subtle.PrfMac) AesCmacKey(com.google.crypto.tink.proto.AesCmacKey) Mac(com.google.crypto.tink.Mac) PrfMac(com.google.crypto.tink.subtle.PrfMac) Test(org.junit.Test)

Aggregations

PrfAesCmac (com.google.crypto.tink.subtle.PrfAesCmac)2 Test (org.junit.Test)2 Mac (com.google.crypto.tink.Mac)1 AesCmacKey (com.google.crypto.tink.proto.AesCmacKey)1 AesCmacPrfKey (com.google.crypto.tink.proto.AesCmacPrfKey)1 PrfMac (com.google.crypto.tink.subtle.PrfMac)1