Skip to content

Commit

Permalink
Merge pull request #2 from dchest/patch-1
Browse files Browse the repository at this point in the history
Make SIV comparison constant time in Decrypt
  • Loading branch information
jacobsa committed May 25, 2015
2 parents 54f78ed + 71014fd commit 662882d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions siv/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package siv

import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/subtle"
"fmt"
)

Expand Down Expand Up @@ -93,7 +93,7 @@ func Decrypt(key, ciphertext []byte, associated [][]byte) ([]byte, error) {
panic(fmt.Sprintf("Unexpected output of S2V: %v", t))
}

if !bytes.Equal(t, v) {
if subtle.ConstantTimeCompare(t, v) != 1 {
return nil, &NotAuthenticError{
"Couldn't validate the authenticity of the ciphertext and " +
"associated data."}
Expand Down

0 comments on commit 662882d

Please sign in to comment.