Re: Puzzled at "method_t method". :-(

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Wed, 17 Apr 2002 09:05:30 +0200

method_t is an enum, defined in enums.h.

MD5 calculates a 16 bytes hash of the provided data.

In: Any amount of binary data (bytes)
Out: 16 bytes hash almost guaranteed to be unique for the specific
combination of input data.

The cast of method_t to a "unsigned char" is to convert it into a
form suitable as platform independent input to MD5.

The store key in Squid is

Public keys:

   MD5((byte)method, url)

Private keys:

   MD5(request id, method, url)

The private key is only ever used within the same Squid process, but
the public keys are used in digest exchanges and need to have a
format that is identical on all platforms regardless of how the
platform stores enum types in memory. As the number of possible
method_t values is small, a single byte (unsigned char) is
sufficient.

Regards
Henrik

On Wednesday 17 April 2002 08:06, maer727@sohu.com wrote:
> Hi pals,
>
> I want to know the function and meaning of "method_t method", but
> I meet with troubles. Here is my trouble,
>
> In storeGetPublic, storeKeyPublic(uri, method) is called. The
> second parameter of storeKeyPublic is "method" whose type is
> method_t. I trace the calling chain. I find storeKeyPublic is
> defined in store_key_md5.c, line 111. In this function, method_t
> is changed to "unsigned char", using the following statement,
> unsigned char m = (unsigned char) method;
>
> Then MD5Update is called using m. I also trace in MD5Update.
> It is defined in md5.c, line 148. Then MD5_memcpy is called with
> the same parameter. MD5_memcpy simply copies "input"
> to "context->buffer[index]". Then MD5Transform is called using
> "context->buffer[index]". I am puzzled here. I can not
> trace anymore because I am not familiar with MD5 algorithm.
>
> So, if anyone can give me a simple explanation about the function
> and meaning of "method_t method", I will be very thankful. :-)
>
> Best regards,
> George, Ma
Received on Wed Apr 17 2002 - 01:26:43 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:15:11 MST