Fixed issue with conflicting standards and custom implementation of

extended standard
This commit is contained in:
TheArrayser 2023-09-24 14:48:51 +02:00
parent 9e96fdad7e
commit ce1c2322f0

View File

@ -60,7 +60,9 @@ public class HOTP extends OTP {
// compute hmac hash
byte[] hash = this.getAlgorithm().hash(secret, text);
byte[] hashIncorrectLength = this.getAlgorithm().hash(secret, text);
byte[] hash = new byte[160 >> 3 > hashIncorrectLength.length ? 160 >> 3 : hashIncorrectLength.length];
System.arraycopy(hashIncorrectLength, 0, hash, 0, hash.length < hashIncorrectLength.length ? hash.length : hashIncorrectLength.length);
// put selected bytes into result int
int offset = hash[hash.length - 1] & 0xf;