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));
}
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);
}
Aggregations