Skip to content

Commit

Permalink
Add constant time compare.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Feb 14, 2023
1 parent 11a6f15 commit 16a4b99
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cipher/ascon/ascon.go
Expand Up @@ -5,7 +5,7 @@
package ascon

import (
"bytes"
"crypto/subtle"
"encoding/binary"
"errors"
"math/bits"
Expand Down Expand Up @@ -127,7 +127,7 @@ func (a *Cipher) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, er
a.procText(ciphertext, plaintext, false)
a.finalize(tag1)

if !bytes.Equal(tag0, tag1) {
if subtle.ConstantTimeCompare(tag0, tag1) == 0 {
return nil, ErrDecryption
}

Expand Down

0 comments on commit 16a4b99

Please sign in to comment.