From 1d8e8702a8696837a7270c31c532b87306b0e964 Mon Sep 17 00:00:00 2001 From: Mark Gregory Date: Wed, 21 Oct 2026 10:39:23 +0100 Subject: [PATCH] row editing --- DBSyn/MySQLProtocol.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/DBSyn/MySQLProtocol.swift b/DBSyn/MySQLProtocol.swift index 51b0a8f..1627420 100644 --- a/DBSyn/MySQLProtocol.swift +++ b/DBSyn/MySQLProtocol.swift @@ -136,8 +136,14 @@ private func authResponse(password: String, salt: [UInt8], plugin: String) throw return zip(first, last).map { $0 ^ $1 } } if plugin == "caching_sha2_password" { - let first = sha256(pwd), second = sha256(sha256(pwd)) - let last = sha256(second + salt) + // MySQL caching_sha2_password authentication: + // XOR(SHA256(password), + // SHA256(SHA256(SHA256(password)) + challenge)) + let first = sha256(pwd) + let second = sha256(first) + let third = sha256(second) + let last = sha256(third + salt) + return zip(first, last).map { $0 ^ $1 } } throw MySQLWireError(message: "Authentication plugin \(plugin) is not yet supported") @@ -314,7 +320,7 @@ private final class MySQLSocketTransport { guard SecTrustEvaluateWithError(trust, &trustError) else { throw MySQLWireError( - message: "MySQL server verification failed: \(trustError?.localizedDescription ?? "untrusted server")" + message: "MySQL server verification failed (verifyTLS=\(verify)): \(trustError?.localizedDescription ?? "untrusted server")" ) } }