Merge branch 'feature/iam-15-timing-safe-vergleich-als-projektweite-coding-konvention' into feature/qa-05-abnahme-compliance-pruefung-core
This commit is contained in:
@@ -7,12 +7,13 @@ import (
|
||||
"crypto/hmac"
|
||||
"crypto/rand"
|
||||
"crypto/sha1"
|
||||
"crypto/subtle"
|
||||
"encoding/base32"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"gitea.perlbach24.de/scripte/nexarch/internal/timingsafe"
|
||||
)
|
||||
|
||||
// StepSeconds ist das TOTP-Zeitfenster (RFC-6238-Standard: 30 Sekunden).
|
||||
@@ -70,7 +71,7 @@ func Validate(secret, code string, t time.Time) (bool, error) {
|
||||
|
||||
for delta := -DefaultSkewSteps; delta <= DefaultSkewSteps; delta++ {
|
||||
candidate := hotp(key, uint64(counter+int64(delta)))
|
||||
if subtle.ConstantTimeCompare([]byte(candidate), []byte(code)) == 1 {
|
||||
if timingsafe.EqualString(candidate, code) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user