69 const string &scramble_bytes,
70 const string &client_password)
72 if (scramble_bytes.size() != SHA1_DIGEST_LENGTH
73 || client_password.size() != SHA1_DIGEST_LENGTH)
76 uint8_t real_password_hash[SHA1_DIGEST_LENGTH];
77 drizzled_hex_to_string(
78 reinterpret_cast<char *
>(real_password_hash),
79 real_password.c_str(),
80 SHA1_DIGEST_LENGTH * 2);
84 uint8_t temp_hash[SHA1_DIGEST_LENGTH];
86 SHA1Update(&ctx,
reinterpret_cast<const uint8_t*
>(scramble_bytes.c_str()), SHA1_DIGEST_LENGTH);
87 SHA1Update(&ctx, real_password_hash, SHA1_DIGEST_LENGTH);
88 SHA1Final(temp_hash, &ctx);
92 for (
int x= 0; x < SHA1_DIGEST_LENGTH; x++)
93 temp_hash[x]= temp_hash[x] ^ client_password[x];
96 uint8_t client_password_hash[SHA1_DIGEST_LENGTH];
98 SHA1Update(&ctx, temp_hash, SHA1_DIGEST_LENGTH);
99 SHA1Final(client_password_hash, &ctx);
102 return memcmp(real_password_hash, client_password_hash, SHA1_DIGEST_LENGTH) == 0;
113 if (sctx.getPasswordType() != identifier::User::MYSQL_HASH)
126 identifier::user::mptr user_id= identifier::User::make_shared();
127 user_id->setUser(
"auth_schema");
133 string sql=
"SELECT password FROM " + sysvar_table +
" WHERE user='" + user +
"' LIMIT 1;";
136 execute.run(sql, result_set);
138 drizzled::error_t err= exception.getErrorCode();
139 if ((err != EE_OK) && (err != ER_EMPTY_QUERY))
141 errmsg_printf(error::ERROR,
142 _(
"Error querying authentication schema: %s (error code %d. Query: %s"),
143 exception.getErrorMessage().c_str(), exception.getErrorCode(), sql.c_str());
149 if (result_set.next() and not result_set.isNull(0))
151 string real_password= result_set.getString(0);
155 sctx.getPasswordContext(),
180 if (_ident_re != NULL)
182 pcre2_match_data *match_data= pcre2_match_data_create_from_pattern(_ident_re, NULL);
183 if (match_data != NULL)
185 int match_result= pcre2_match(
186 _ident_re,
reinterpret_cast<PCRE2_SPTR
>(input.c_str()),
187 input.length(), 0, 0, match_data, NULL);
188 pcre2_match_data_free(match_data);
189 if (match_result >= 0)
194 const char *pos= input.c_str();
195 const char *end= input.c_str()+input.length();
198 for (; pos != end ; pos++)
202 ident.push_back(
'\\');
203 ident.push_back(
'`');
206 ident.push_back(
'\\');
207 ident.push_back(
'\\');
210 ident.push_back(*pos);
215 ident.push_back(
'`');