Skip to content

Commit

Permalink
Add more mac factory tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickfav committed Oct 3, 2017
1 parent fa431a3 commit 04715ed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/test/java/at/favre/lib/crypto/HkdfMacFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void hmacSha512() throws Exception {

@Test
public void hmacSha1() throws Exception {
testHmacFactory(new HkdfMacFactory.Default("HmacSHA1", null), 20);
testHmacFactory(HkdfMacFactory.Default.hmacSha1(), 20);
}

@Test
Expand All @@ -39,6 +39,11 @@ public void hmacInstanceNotExisting() throws Exception {
new HkdfMacFactory.Default("HmacNotExisting", null).createInstance(new byte[16]);
}

@Test(expected = RuntimeException.class)
public void hmacUsingEmptyKey() throws Exception {
HkdfMacFactory.Default.hmacSha256().createInstance(new byte[0]);
}

private void testHmacFactory(HkdfMacFactory macFactory, int refLength) {
Mac mac = macFactory.createInstance(new byte[refLength]);
assertNotNull(mac);
Expand Down

0 comments on commit 04715ed

Please sign in to comment.