Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit ca1404e

Browse files
authored
Merge pull request #13 from polezaivsani/fix_timming_sidechannel
Spoil timming side-channel attack when comparing macs
2 parents 2eb16e9 + eddce24 commit ca1404e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

algorithms.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (a *Algorithm) validateSignature(encoded string) error {
142142

143143
b64SignedAttempt := base64.RawURLEncoding.EncodeToString([]byte(signedAttempt))
144144

145-
if strings.Compare(b64Signature, b64SignedAttempt) != 0 {
145+
if !hmac.Equal([]byte(b64Signature), []byte(b64SignedAttempt)) {
146146
return errors.New("invalid signature")
147147
}
148148

0 commit comments

Comments
 (0)