mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-19 13:29:13 +00:00
Fixed the TOTP test
This commit is contained in:
parent
b14eb42b12
commit
b3957bb76f
1 changed files with 15 additions and 5 deletions
|
@ -35,14 +35,24 @@ public class TOTPTest {
|
||||||
new testVector(){{ Time = "0000000027BC86AA"; OTP = "47863826"; Mode = "HmacSHA512"; }}
|
new testVector(){{ Time = "0000000027BC86AA"; OTP = "47863826"; Mode = "HmacSHA512"; }}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final String _seed = "3132333435363738393031323334353637383930";
|
private final byte[] _seed = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||||
private final String _seed32 = "3132333435363738393031323334353637383930313233343536373839303132";
|
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30
|
||||||
private final String _seed64 = "31323334353637383930313233343536373839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334";
|
};
|
||||||
|
private final byte[] _seed32 = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
|
||||||
|
0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32,
|
||||||
|
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32
|
||||||
|
};
|
||||||
|
private final byte[] _seed64 = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
|
||||||
|
0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32,
|
||||||
|
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
|
||||||
|
0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30,
|
||||||
|
0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34
|
||||||
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void vectors_match() throws Exception {
|
public void vectors_match() throws Exception {
|
||||||
for (testVector v : _vectors) {
|
for (testVector v : _vectors) {
|
||||||
String seed;
|
byte[] seed;
|
||||||
|
|
||||||
switch (v.Mode) {
|
switch (v.Mode) {
|
||||||
case "HmacSHA1":
|
case "HmacSHA1":
|
||||||
|
@ -59,7 +69,7 @@ public class TOTPTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String otp = TOTP.generateTOTP(seed, v.Time, "8", v.Mode);
|
String otp = TOTP.generateTOTP(seed, v.Time, 8, v.Mode);
|
||||||
assertEquals(v.OTP, otp);
|
assertEquals(v.OTP, otp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue