MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / scrambleValidation

Function scrambleValidation

IceFireDB-SQLProxy/pkg/mysql/server/auth.go:76–94  ·  view source on GitHub ↗
(cached, nonce, scramble []byte)

Source from the content-addressed store, hash-verified

74}
75
76func scrambleValidation(cached, nonce, scramble []byte) bool {
77 // SHA256(SHA256(SHA256(STORED_PASSWORD)), NONCE)
78 crypt := sha256.New()
79 crypt.Write(cached)
80 crypt.Write(nonce)
81 message2 := crypt.Sum(nil)
82 // SHA256(PASSWORD)
83 if len(message2) != len(scramble) {
84 return false
85 }
86 for i := range message2 {
87 message2[i] ^= scramble[i]
88 }
89 // SHA256(SHA256(PASSWORD)
90 crypt.Reset()
91 crypt.Write(message2)
92 m := crypt.Sum(nil)
93 return bytes.Equal(m, cached)
94}
95
96func (c *Conn) compareNativePasswordAuthData(clientAuthData []byte, password string) error {
97 if bytes.Equal(CalcPassword(c.salt, []byte(password)), clientAuthData) {

Callers 1

Calls 2

EqualMethod · 0.65
ResetMethod · 0.45

Tested by

no test coverage detected