-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/test/java/com/eatthepath/noise/crypto/AbstractBlake2HmacTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.eatthepath.noise.crypto; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.crypto.Mac; | ||
import javax.crypto.spec.SecretKeySpec; | ||
|
||
import java.security.InvalidKeyException; | ||
import java.security.Key; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
abstract class AbstractBlake2HmacTest { | ||
|
||
protected abstract Mac getHmac(); | ||
|
||
@Test | ||
void getMacLength() throws InvalidKeyException { | ||
final Key key = new SecretKeySpec(new byte[32], "RAW"); | ||
|
||
final Mac hmac = getHmac(); | ||
hmac.init(key); | ||
hmac.update(new byte[32]); | ||
|
||
assertEquals(hmac.getMacLength(), hmac.doFinal().length); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/java/com/eatthepath/noise/crypto/HmacBlake2b512MacTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.eatthepath.noise.crypto; | ||
|
||
import javax.crypto.Mac; | ||
|
||
class HmacBlake2b512MacTest extends AbstractBlake2HmacTest { | ||
|
||
@Override | ||
protected Mac getHmac() { | ||
return new HmacBlake2b512Mac(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/java/com/eatthepath/noise/crypto/HmacBlake2s256MacTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.eatthepath.noise.crypto; | ||
|
||
import javax.crypto.Mac; | ||
|
||
class HmacBlake2s256MacTest extends AbstractBlake2HmacTest { | ||
|
||
@Override | ||
protected Mac getHmac() { | ||
return new HmacBlake2s256Mac(); | ||
} | ||
} |