use of com.google.crypto.tink.subtle.PrfHmacJce in project tink by google.
the class HmacKeyManagerTest method getPrimitive_worksForSha1.
@Test
public void getPrimitive_worksForSha1() throws Exception {
HmacKey validKey = factory.createKey(makeHmacKeyFormat(16, 19, HashType.SHA1));
Mac managerMac = manager.getPrimitive(validKey, Mac.class);
Mac directMac = new PrfMac(new PrfHmacJce("HMACSHA1", new SecretKeySpec(validKey.getKeyValue().toByteArray(), "HMAC")), 19);
byte[] message = Random.randBytes(50);
managerMac.verifyMac(directMac.computeMac(message), message);
}
use of com.google.crypto.tink.subtle.PrfHmacJce 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);
}
use of com.google.crypto.tink.subtle.PrfHmacJce in project tink by google.
the class HmacPrfKeyManagerTest method getPrimitive_worksForSha1.
@Test
public void getPrimitive_worksForSha1() throws Exception {
HmacPrfKey validKey = factory.createKey(makeHmacPrfKeyFormat(16, HashType.SHA1));
Prf managerPrf = manager.getPrimitive(validKey, Prf.class);
Prf directPrf = new PrfHmacJce("HMACSHA1", new SecretKeySpec(validKey.getKeyValue().toByteArray(), "HMAC"));
byte[] message = Random.randBytes(50);
assertThat(managerPrf.compute(message, 19)).isEqualTo(directPrf.compute(message, 19));
}
Aggregations