Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Replace HMAC check with time-constant check
Browse files Browse the repository at this point in the history
  • Loading branch information
matsjj committed Apr 28, 2017
1 parent 33c985a commit ac98216
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.Arrays;

public class CryptoTools {

Expand Down Expand Up @@ -48,7 +47,8 @@ public static void checkHMAC (byte[] hmac, byte[] rest, byte[] keyBytes) {
mac.init(keySpec);
byte[] result = mac.doFinal(rest);

if (!Arrays.equals(result, hmac)) {

if (!MessageDigest.isEqual(result, hmac)){
throw new RuntimeException("HMAC does not match..");
}
} catch (Exception e) {

This comment has been minimized.

Copy link
@Hnriqun

Hnriqun Aug 7, 2021

Brigado

Expand Down

0 comments on commit ac98216

Please sign in to comment.