~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/mysql_protocol/mysql_password.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
using namespace std;
22
22
 
23
 
namespace drizzle_plugin
24
 
{
 
23
namespace drizzle_plugin {
25
24
 
26
25
const char* MySQLPasswordName = "mysql_password";
27
26
 
28
 
MySQLPassword::MySQLPassword(void):
29
 
  Item_str_func()
30
 
{ }
31
 
 
32
27
const char *MySQLPassword::func_name() const
33
28
{
34
29
  return MySQLPasswordName;
41
36
 
42
37
bool MySQLPassword::check_argument_count(int n)
43
38
{
44
 
  return (n == 1);
 
39
  return n == 1;
45
40
}
46
41
 
47
42
drizzled::String *MySQLPassword::val_str(drizzled::String *str)
48
43
{
49
 
  drizzled::String argument;
50
 
  drizzled::String *password= args[0]->val_str(&argument);
51
 
  drizzled::SHA1_CTX ctx;
52
44
  uint8_t hash_tmp1[SHA1_DIGEST_LENGTH];
53
45
  uint8_t hash_tmp2[SHA1_DIGEST_LENGTH];
54
46
 
55
 
  drizzled::SHA1Init(&ctx);
56
 
  drizzled::SHA1Update(&ctx, reinterpret_cast<uint8_t *>(password->ptr()),
57
 
                       password->length());
58
 
  drizzled::SHA1Final(hash_tmp1, &ctx);
59
 
 
60
 
  drizzled::SHA1Init(&ctx);
61
 
  drizzled::SHA1Update(&ctx, hash_tmp1, SHA1_DIGEST_LENGTH);
62
 
  drizzled::SHA1Final(hash_tmp2, &ctx);
 
47
  drizzled::String argument;
 
48
  drizzled::do_sha1(*args[0]->val_str(&argument), hash_tmp1);
 
49
  drizzled::do_sha1(data_ref(hash_tmp1, SHA1_DIGEST_LENGTH), hash_tmp2);
63
50
 
64
51
  str->realloc(SHA1_DIGEST_LENGTH * 2);
65
 
  drizzled::drizzled_string_to_hex(str->ptr(),
66
 
                                   reinterpret_cast<const char*>(hash_tmp2),
67
 
                                   SHA1_DIGEST_LENGTH);
 
52
  drizzled::drizzled_string_to_hex(str->ptr(), reinterpret_cast<const char*>(hash_tmp2), SHA1_DIGEST_LENGTH);
68
53
  str->length(SHA1_DIGEST_LENGTH * 2);
69
54
 
70
55
  return str;