|
|
| version 1.25, 2003/04/04 09:42:04 | version 1.27, 2003/04/15 07:17:42 |
|---|---|
| Line 152 static void _crypt(Request& r, const Str | Line 152 static void _crypt(Request& r, const Str |
| if(strncmp(normal_salt, PA_MD5PW_ID, PA_MD5PW_IDLEN) == 0) { | if(strncmp(normal_salt, PA_MD5PW_ID, PA_MD5PW_IDLEN) == 0) { |
| const size_t sample_size=120; | const size_t sample_size=120; |
| char *sample_buf=(char *)pool.malloc(sample_size); | char *sample_buf=(char *)pool.malloc(sample_size); |
| pa_MD5Encode((const unsigned char *)password, | PA_MD5Encode((const unsigned char *)password, |
| (const unsigned char *)normal_salt, sample_buf, sample_size); | (const unsigned char *)normal_salt, 1/*TRUE: mix in magic string*/, |
| sample_buf, sample_size); | |
| r.write_pass_lang(*new(pool) String(pool, sample_buf)); | r.write_pass_lang(*new(pool) String(pool, sample_buf)); |
| } else { | } else { |
| #ifdef HAVE_CRYPT | #ifdef HAVE_CRYPT |
| Line 174 static void _crypt(Request& r, const Str | Line 175 static void _crypt(Request& r, const Str |
| } | } |
| } | } |
| static void _md5(Request& r, const String& method_name, MethodParams *params) { | |
| Pool& pool=r.pool(); | |
| const char *string=params->as_string(0, "parameter must be string").cstr(); | |
| PA_MD5_CTX context; | |
| unsigned char digest[16]; | |
| PA_MD5Init(&context); | |
| PA_MD5Update(&context, (const unsigned char*)string, strlen(string)); | |
| PA_MD5Final(digest, &context); | |
| char *digest_bytes_hex=(char *)pool.malloc(sizeof(digest)*2/*byte->hh*/+1/*for zero-teminator*/); | |
| unsigned char *src=digest; | |
| unsigned char *end=digest+sizeof(digest); | |
| char *dest=digest_bytes_hex; | |
| while(src<end) | |
| dest+=snprintf(dest, 3, "%02x", *src++); | |
| r.write_pass_lang(*new(pool) String(pool, digest_bytes_hex)); | |
| } | |
| // constructor | // constructor |
| MMath::MMath(Pool& apool) : Methoded(apool, "math") { | MMath::MMath(Pool& apool) : Methoded(apool, "math") { |
| Line 200 MMath::MMath(Pool& apool) : Methoded(apo | Line 222 MMath::MMath(Pool& apool) : Methoded(apo |
| // ^crypt[password;salt] | // ^crypt[password;salt] |
| ADD2(crypt); | ADD2(crypt); |
| // ^md5[string] | |
| ADD1(md5); | |
| } | } |
| // in MSVC each thread has it's own pseudo-random sequence | // in MSVC each thread has it's own pseudo-random sequence |