(cached, nonce, scramble []byte)
| 74 | } |
| 75 | |
| 76 | func 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 | |
| 96 | func (c *Conn) compareNativePasswordAuthData(clientAuthData []byte, password string) error { |
| 97 | if bytes.Equal(CalcPassword(c.salt, []byte(password)), clientAuthData) { |
no test coverage detected