Diff for /parser3/src/classes/math.C between versions 1.26 and 1.27

version 1.26, 2003/04/14 14:59:29 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, 1/*TRUE: mix in magic string*/,                          (const unsigned char *)normal_salt, 1/*TRUE: mix in magic string*/,
                         sample_buf, sample_size,                          sample_buf, sample_size);
                         0, 0);  
                 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 179  static void _crypt(Request& r, const Str Line 178  static void _crypt(Request& r, const Str
 static void _md5(Request& r, const String& method_name, MethodParams *params) {  static void _md5(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         const char *string=params->as_string(0, "parameter must be string").cstr();          const char *string=params->as_string(0, "parameter must be string").cstr();
         const size_t sample_size=120;  
         char sample_buf[sample_size];  
         const int sample_bytes_count=12;          PA_MD5_CTX context;
         unsigned char sample_bytes[sample_bytes_count];          unsigned char digest[16];
         pa_MD5Encode((const unsigned char *)string,          PA_MD5Init(&context);
                 (const unsigned char *)"",  0/*FALSE: mix in magic string*/,          PA_MD5Update(&context, (const unsigned char*)string, strlen(string));
                 sample_buf, sample_size,          PA_MD5Final(digest, &context);
                 sample_bytes, sample_bytes_count);  
         char *sample_bytes_hex=(char *)pool.malloc(sample_bytes_count*2/*byte->hh*/+1/*for zero-teminator*/);          char *digest_bytes_hex=(char *)pool.malloc(sizeof(digest)*2/*byte->hh*/+1/*for zero-teminator*/);
         unsigned char *src=sample_bytes;          unsigned char *src=digest;
         unsigned char *end=sample_bytes+sample_bytes_count;          unsigned char *end=digest+sizeof(digest);
         char *dest=sample_bytes_hex;          char *dest=digest_bytes_hex;
         while(src<end)          while(src<end)
                 dest+=snprintf(dest, 3, "%02x", *src++);                  dest+=snprintf(dest, 3, "%02x", *src++);
   
         r.write_pass_lang(*new(pool) String(pool, sample_bytes_hex));          r.write_pass_lang(*new(pool) String(pool, digest_bytes_hex));
 }  }
   
 // constructor  // constructor

Removed from v.1.26  
changed lines
  Added in v.1.27


E-mail: