From ce1c2322f010113271f124bdb9232ee27618668f Mon Sep 17 00:00:00 2001 From: TheArrayser Date: Sun, 24 Sep 2023 14:48:51 +0200 Subject: [PATCH] Fixed issue with conflicting standards and custom implementation of extended standard --- .../cringe_authenticator_library/impl/HOTP.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cringe_studios/cringe_authenticator_library/impl/HOTP.java b/src/main/java/com/cringe_studios/cringe_authenticator_library/impl/HOTP.java index 3d94cc6..d4d8643 100644 --- a/src/main/java/com/cringe_studios/cringe_authenticator_library/impl/HOTP.java +++ b/src/main/java/com/cringe_studios/cringe_authenticator_library/impl/HOTP.java @@ -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;