[webkit-dev] MD5 in WebCore

Maciej Stachowiak mjs at apple.com
Tue Apr 20 04:12:17 PDT 2010


On Apr 20, 2010, at 3:32 AM, Fumitoshi Ukai (鵜飼文敏) wrote:

> I'm implementing new protocol of WebSocket ( http://www.whatwg.org/specs/web-socket-protocol/ 
>  ).
> Since it now requires MD5 in handshake, I wonder how I could add MD5  
> in WebCore.  For now, there is no MD5 in WebCore.  It is in  
> WebKitTools/DumpRenderTree to get message digest of image file.
>
> I'm thinking to add new header file as WebCore/platform/MD5.h, which  
> provides the following functions.
>
>   struct MD5_CTX;
>   void MD5_Init(MD5_CTX*);
>   void MD5_Update(MD5_CTX*, unsigned char* input, unsigned length);
>   void MD5_Final(unsigned char hash[16], MD5_CTX*);
>
> In Windows platform, it is implemented using "Cryptdll.dll".   Is it  
> ok to copy WebKitTools/DumpRenderTree/win/MD5.cpp to WebCore/ 
> platform/win/MD5.cpp, or move?
> In Mac platform, it is provided by <CommonCrypto/CommonDigest.h>  
> with #define COMMON_DIGEST_FOR_OPENSSL ?
> In Chromium, there is chrome/src/base/md5.{h,cc}.   Should I copy  
> this in WebCore/platform/chromium, or add dependency to base from  
> WebCore?
> How about other ports?  is it ok to link openssl or some other  
> library?  (or use implementation used in chromium?)
>
> I'm also wonder I need to put these functions in namespace WebCore.

If you put this code in WebCore, it should go in the WebCore  
namespace. I think it would also be a good idea to turn the API into  
something more WebCore-ish, something like:

namespace WebCore {

     class MD5 {
         MD5(); // what was MD5_Init
         addBytes(uint8_t* input, size_t length); // what was  
MD5_Update ; or maybe this should take a Vector<uint8_t>?
         Vector<uint8_t, 16> checksum(); // what was MD5_Final
     };
}

(The key point being to match the coding style guidelines for names,  
but it also seems better to use a class here instead of a struct and  
functions that take a pointer to it.)

Regards,
Maciej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100420/63864124/attachment.html>


More information about the webkit-dev mailing list