|
|
| version 1.24.2.12.2.14, 2003/05/26 09:44:01 | version 1.39.8.1, 2005/08/05 13:02:57 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b math parser class. | Parser: @b math parser class. |
| Copyright(c) 2001-2003 ArtLebedev Group(http://www.artlebedev.com) | Copyright(c) 2001-2005 ArtLebedev Group(http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru>(http://paf.design.ru) |
| portions from gen_uuid.c, | portions from gen_uuid.c, |
| Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o. | Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o. |
| */ | */ |
| static const char* IDENT_MATH_C="$Date$"; | static const char * const IDENT_MATH_C="$Date$"; |
| #include "pa_vmethod_frame.h" | #include "pa_vmethod_frame.h" |
| #include "pa_common.h" | #include "pa_common.h" |
| Line 227 inline bool is_salt_body_char(int c) { | Line 227 inline bool is_salt_body_char(int c) { |
| return isalnum(c) || c == '.' || c=='/'; | return isalnum(c) || c == '.' || c=='/'; |
| } | } |
| static size_t calc_prefix_size(const char* salt) { | static size_t calc_prefix_size(const char* salt) { |
| if(size_t salt_size=strlen(salt)) { | if(strlen(salt)) { |
| if(!is_salt_body_char(salt[0])) { // $... {... | if(!is_salt_body_char((unsigned char)salt[0])) { // $... {... |
| const char* cur=salt+1; // skip | const char* cur=salt+1; // skip |
| while(is_salt_body_char(*cur++)) // ...$ ...} | while(is_salt_body_char((unsigned char)*cur++)) // ...$ ...} |
| ; | ; |
| return cur-salt; | return cur-salt; |
| } else | } else |
| Line 263 static void _crypt(Request& r, MethodPar | Line 263 static void _crypt(Request& r, MethodPar |
| 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=new(PointerFreeGC) char[sample_size]; | char *sample_buf=new(PointerFreeGC) char[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, sample_buf, sample_size); |
| String sample(sample_buf); | String sample(sample_buf); |
| r.write_pass_lang(sample); | r.write_pass_lang(sample); |
| Line 294 static const char* hex_string(unsigned c | Line 294 static const char* hex_string(unsigned c |
| static const char *hex=upcase?"0123456789ABCDEF":"0123456789abcdef"; | static const char *hex=upcase?"0123456789ABCDEF":"0123456789abcdef"; |
| const char *format=upcase?"%02X":"%02x"; | |
| for(; src<end; src++) { | for(; src<end; src++) { |
| *dest++=hex[*src/0x10]; | *dest++=hex[*src/0x10]; |
| *dest++=hex[*src%0x10]; | *dest++=hex[*src%0x10]; |
| Line 310 static void _md5(Request& r, MethodParam | Line 309 static void _md5(Request& r, MethodParam |
| PA_MD5_CTX context; | PA_MD5_CTX context; |
| unsigned char digest[16]; | unsigned char digest[16]; |
| PA_MD5Init(&context); | pa_MD5Init(&context); |
| PA_MD5Update(&context, (const unsigned char*)string, strlen(string)); | pa_MD5Update(&context, (const unsigned char*)string, strlen(string)); |
| PA_MD5Final(digest, &context); | pa_MD5Final(digest, &context); |
| r.write_pass_lang(*new String(hex_string(digest, sizeof(digest), false))); | r.write_pass_lang(*new String(hex_string(digest, sizeof(digest), false))); |
| } | } |
| Line 348 static void _uuid(Request& r, MethodPara | Line 347 static void _uuid(Request& r, MethodPara |
| uuid.time_hi_and_version = (uuid.time_hi_and_version & 0x0FFF) | 0x4000; | uuid.time_hi_and_version = (uuid.time_hi_and_version & 0x0FFF) | 0x4000; |
| // format | // format |
| const int uuid_cstr_bufsize=32+1/*for zero-teminator*/; | const int uuid_cstr_bufsize=36+1/*for zero-teminator*/+1/*for faulty snprintfs*/; |
| char *uuid_cstr=new(PointerFreeGC) char[uuid_cstr_bufsize]; | char *uuid_cstr=new(PointerFreeGC) char[uuid_cstr_bufsize]; |
| snprintf(uuid_cstr, uuid_cstr_bufsize, | snprintf(uuid_cstr, uuid_cstr_bufsize, |
| "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", | "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", |