Skip to content

Commit b0c675e

Browse files
committed
Address 2FA PR feedback
1 parent 0ec93ca commit b0c675e

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

datastore/password_states.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ import (
1313
const (
1414
NormalStateExpiration = 30 * time.Second
1515
TwoFAStateExpiration = 5 * time.Minute
16-
17-
// "Compile-time assertion" to ensure that the 2FA expiration time is greater
18-
_ = uint64(TwoFAStateExpiration - NormalStateExpiration)
1916
)
2017

2118
// InterimPasswordState represents the state of an OPAQUE Authenticated Key Exchange or Registration operation

util/util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"crypto/rand"
7+
"crypto/subtle"
78
"encoding/base64"
89
"encoding/json"
910
"fmt"
@@ -98,7 +99,7 @@ func VerifyRecoveryKeyHash(recoveryKey string, storedHash []byte) bool {
9899

99100
computedHash := generateRecoveryKeyHash(recoveryKey, salt)
100101

101-
return bytes.Equal(computedHash, expectedHash)
102+
return subtle.ConstantTimeCompare(computedHash, expectedHash) == 1
102103
}
103104

104105
func ExtractAuthToken(r *http.Request) (string, error) {

0 commit comments

Comments
 (0)