Changeset 6492 for trunk/licq

Show
Ignore:
Timestamp:
08/24/08 00:32:58 (3 months ago)
Author:
flynd
Message:

Digest from md5 function might contain null bytes so we can't use normal string handling on it. Changed function call to same as for openssl function so we can return all 16 bytes even if there is a null in them.

Location:
trunk/licq
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/licq/include/licq_md5.h

    r6486 r6492  
    1010#define MD5_H 
    1111 
    12 #include <string> 
    13  
    14 std::string md5(const std::string&); 
     12#define MD5_DIGEST_LENGTH 16 
    1513 
    1614#define UINT8 unsigned char 
    1715#define UINT32 unsigned long 
     16 
     17void md5(const UINT8* buf, unsigned int len, UINT8* digest); 
    1818 
    1919struct MD5Context { 
  • trunk/licq/src/md5.cpp

    r6486 r6492  
    2020 
    2121#include <cstring>      /* for memcpy() */ 
    22 #include <string> 
    2322 
    2423#include "licq_md5.h" 
    2524 
    26 std::string md5(const std::string& toHash) 
     25void md5(const UINT8* buf, unsigned int len, UINT8* digest) 
    2726{ 
    2827  MD5Context context; 
    29   UINT8 digest[16]; 
    3028 
    3129  MD5Init(&context); 
    32   MD5Update(&context, reinterpret_cast<const unsigned char *>(toHash.c_str()), toHash.size()); 
     30  MD5Update(&context, buf, len); 
    3331  MD5Final(digest, &context); 
    34  
    35   std::string result(reinterpret_cast<const char *>(digest)); 
    36   return result; 
    3732} 
    3833