Compare commits
4 Commits
66c7e45597
...
55cdd506fb
Author | SHA1 | Date | |
---|---|---|---|
55cdd506fb | |||
9791cfb0f8 | |||
985a58c407 | |||
5e2c7651ff |
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.cringe_studios</groupId>
|
<groupId>com.cringe_studios</groupId>
|
||||||
<artifactId>CringeAuthenticatorLibrary</artifactId>
|
<artifactId>CringeAuthenticatorLibrary</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.5</version>
|
||||||
<name>CringeAuthenticatorLibrary</name>
|
<name>CringeAuthenticatorLibrary</name>
|
||||||
<description>The Library of the Cringe Authenticator</description>
|
<description>The Library of the Cringe Authenticator</description>
|
||||||
<build>
|
<build>
|
||||||
|
@ -7,11 +7,13 @@ import javax.crypto.Mac;
|
|||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
public enum OTPAlgorithm{
|
public enum OTPAlgorithm{
|
||||||
SHA1("HmacSHA1"),
|
SHA1 ("HmacSHA1"),
|
||||||
SHA224("HmacSHA224"),
|
SHA224("HmacSHA224"),
|
||||||
SHA256("HmacSHA256"),
|
SHA256("HmacSHA256"),
|
||||||
SHA384("HmacSHA384"),
|
SHA384("HmacSHA384"),
|
||||||
SHA512("HmacSHA512");
|
SHA512("HmacSHA512"),
|
||||||
|
MD5 ("HmacMD5");
|
||||||
|
|
||||||
|
|
||||||
private String javaName;
|
private String javaName;
|
||||||
|
|
||||||
|
@ -52,6 +52,27 @@ public class OTPTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void md5Test() {
|
||||||
|
String secret = String.format("%x", new BigInteger(1, "MD5".getBytes()));
|
||||||
|
|
||||||
|
String base32secret = Base32.encode(hexStr2Bytes(secret));
|
||||||
|
|
||||||
|
//System.out.println("MD5 String: " + base32secret);
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
OTP testOTP1 = OTPType.HOTP.instance(base32secret, OTPAlgorithm.MD5, 6, 0, 30, false);
|
||||||
|
for(int i = 0; i < 5; i++) {
|
||||||
|
String calculatedPin = testOTP1.getPin();
|
||||||
|
testOTP1.incrementCounter();
|
||||||
|
if(VERBOSE) {
|
||||||
|
System.out.println("Calculated MD5 pin - counter: " + i + " pin: " + calculatedPin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lengthTest() {
|
public void lengthTest() {
|
||||||
assertDoesNotThrow(() -> {
|
assertDoesNotThrow(() -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user