mirror of
https://github.com/bolucat/Archive.git
synced 2025-12-24 13:28:37 +08:00
Update On Mon Sep 8 20:41:11 CEST 2025
This commit is contained in:
@@ -17,8 +17,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotFound = errors.New("user do not exist")
|
||||
ErrReplay = errors.New("replayed request")
|
||||
ErrNotFound = errors.New("user do not exist")
|
||||
ErrNeagtiveTime = errors.New("timestamp is negative")
|
||||
ErrInvalidTime = errors.New("invalid timestamp, perhaps unsynchronized time")
|
||||
ErrReplay = errors.New("replayed request")
|
||||
)
|
||||
|
||||
func CreateAuthID(cmdKey []byte, time int64) [16]byte {
|
||||
@@ -102,11 +104,11 @@ func (a *AuthIDDecoderHolder) Match(authID [16]byte) (interface{}, error) {
|
||||
}
|
||||
|
||||
if t < 0 {
|
||||
continue
|
||||
return nil, ErrNeagtiveTime
|
||||
}
|
||||
|
||||
if math.Abs(math.Abs(float64(t))-float64(time.Now().Unix())) > 120 {
|
||||
continue
|
||||
return nil, ErrInvalidTime
|
||||
}
|
||||
|
||||
if !a.filter.Check(authID[:]) {
|
||||
|
||||
@@ -9,5 +9,5 @@ import (
|
||||
|
||||
func NewAEADAESGCMBasedOnSeed(seed string) cipher.AEAD {
|
||||
hashedSeed := sha256.Sum256([]byte(seed))
|
||||
return crypto.NewAesGcm(hashedSeed[:])
|
||||
return crypto.NewAesGcm(hashedSeed[:16])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user