Scramble algorithm used in cached_sha2_password fast path. XOR(SHA256(password), SHA256(SHA256(SHA256(password)), nonce))
(password, nonce)
| 191 | |
| 192 | |
| 193 | def scramble_caching_sha2(password, nonce): |
| 194 | # (bytes, bytes) -> bytes |
| 195 | """Scramble algorithm used in cached_sha2_password fast path. |
| 196 | |
| 197 | XOR(SHA256(password), SHA256(SHA256(SHA256(password)), nonce)) |
| 198 | """ |
| 199 | if not password: |
| 200 | return b"" |
| 201 | |
| 202 | p1 = hashlib.sha256(password).digest() |
| 203 | p2 = hashlib.sha256(p1).digest() |
| 204 | p3 = hashlib.sha256(p2 + nonce).digest() |
| 205 | |
| 206 | res = bytearray(p1) |
| 207 | for i in range(len(p3)): |
| 208 | res[i] ^= p3[i] |
| 209 | |
| 210 | return bytes(res) |
| 211 | |
| 212 | |
| 213 | def caching_sha2_password_auth(conn, pkt): |
no outgoing calls
no test coverage detected
searching dependent graphs…