Changeset 726


Ignore:
Timestamp:
01/17/12 12:47:13 (4 months ago)
Author:
shiretu
Message:

-- minor refactoring on md5 function

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/sources/common/include/utils/misc/crypto.h

    r395 r726  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    7575        */ 
    7676        bool CreateSharedKey(uint8_t *pPeerPublicKey, int32_t length); 
    77          
     77 
    7878        /*! 
    7979                @brief Copies the shared secret key. 
     
    9090                RC4_KEY *rc4keyIn, RC4_KEY *rc4keyOut); 
    9191DLLEXP string md5(string source, bool textResult); 
     92DLLEXP string md5(uint8_t *pBuffer, uint32_t length, bool textResult); 
    9293DLLEXP void HMACsha256(const void *pData, uint32_t dataLength, const void *pKey, 
    9394                uint32_t keyLength, void *pResult); 
  • branches/1.0/sources/common/src/utils/misc/crypto.cpp

    r653 r726  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    217217 
    218218string md5(string source, bool textResult) { 
     219        return md5((uint8_t*) source.c_str(), source.length(), textResult); 
     220} 
     221 
     222string md5(uint8_t *pBuffer, uint32_t length, bool textResult) { 
    219223        EVP_MD_CTX mdctx; 
    220224        unsigned char md_value[EVP_MAX_MD_SIZE]; 
     
    222226 
    223227        EVP_DigestInit(&mdctx, EVP_md5()); 
    224         EVP_DigestUpdate(&mdctx, STR(source), source.length()); 
     228        EVP_DigestUpdate(&mdctx, pBuffer, length); 
    225229        EVP_DigestFinal_ex(&mdctx, md_value, &md_len); 
    226230        EVP_MD_CTX_cleanup(&mdctx); 
  • trunk/sources/common/include/utils/misc/crypto.h

    r395 r726  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    7575        */ 
    7676        bool CreateSharedKey(uint8_t *pPeerPublicKey, int32_t length); 
    77          
     77 
    7878        /*! 
    7979                @brief Copies the shared secret key. 
     
    9090                RC4_KEY *rc4keyIn, RC4_KEY *rc4keyOut); 
    9191DLLEXP string md5(string source, bool textResult); 
     92DLLEXP string md5(uint8_t *pBuffer, uint32_t length, bool textResult); 
    9293DLLEXP void HMACsha256(const void *pData, uint32_t dataLength, const void *pKey, 
    9394                uint32_t keyLength, void *pResult); 
  • trunk/sources/common/src/utils/misc/crypto.cpp

    r722 r726  
    1 /*  
     1/* 
    22 *  Copyright (c) 2010, 
    33 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com) 
     
    217217 
    218218string md5(string source, bool textResult) { 
     219        return md5((uint8_t*) source.c_str(), source.length(), textResult); 
     220} 
     221 
     222string md5(uint8_t *pBuffer, uint32_t length, bool textResult) { 
    219223        EVP_MD_CTX mdctx; 
    220224        unsigned char md_value[EVP_MAX_MD_SIZE]; 
     
    222226 
    223227        EVP_DigestInit(&mdctx, EVP_md5()); 
    224         EVP_DigestUpdate(&mdctx, STR(source), source.length()); 
     228        EVP_DigestUpdate(&mdctx, pBuffer, length); 
    225229        EVP_DigestFinal_ex(&mdctx, md_value, &md_len); 
    226230        EVP_MD_CTX_cleanup(&mdctx); 
Note: See TracChangeset for help on using the changeset viewer.