use of com.google.crypto.tink.subtle.PrfMac in project tink by google.
the class HmacKeyManagerTest method getPrimitive_worksForSha256.
@Test
public void getPrimitive_worksForSha256() throws Exception {
HmacKey validKey = factory.createKey(makeHmacKeyFormat(16, 29, HashType.SHA256));
Mac managerMac = manager.getPrimitive(validKey, Mac.class);
Mac directMac = new PrfMac(new PrfHmacJce("HMACSHA256", new SecretKeySpec(validKey.getKeyValue().toByteArray(), "HMAC")), 29);
byte[] message = Random.randBytes(50);
managerMac.verifyMac(directMac.computeMac(message), message);
}
Aggregations