Digest Problems

Hi, 
 
I've been implementing "draft-ietf-http-digest-aa-05.txt" and 
run into a couple of problems. I've done MD5 in things like 
POP3 APOP before, so I don't think that is the problem, but 
when I try to run the example in section 2.4 through my code 
I don't get the right answer. 
 
The code is: 
 
int main(int argc, char *argv[]) 
{ 
  char szNonce[]    = "dcd98b7102dd2f0e8b11d0f600bfb0c093", 
       szRealm[]    = "testrealm@host.com", 
       szUserName[] = "Mufasa", 
       szPass[]     = "CircleOfLife", 
       szUri[]      = "/dir/index.html", 
       szMethod[]   = "GET", 
       szResp[]     = "e966c932a9242554e42c8ee200cec7f6", 
       szBuf[256], szBufr[256], 
       szA1[256], szA1r[256], 
       szA2[256], szA2r[256]; 
 
  sprintf(szA1, "%s:%s:%s", szUserName, szRealm, szPass); 
  MD5Encode(szA1, szA1r); 
 
  sprintf(szA2, "%s:%s", szMethod, szUri); 
  MD5Encode(szA2, szA2r); 
 
  sprintf(szBuf, "%s:%s:%s", szA1r, szNonce, szA2r); 
  MD5Encode(szBuf, szBufr); 
 
  printf("spec = %s\n", szResp); 
  printf("calc = %s\n", szBufr); 
 
  return 0; 
} 
 
void MD5Encode(char *szSrc, char *szResult) 
{ 
  MD5_CTX context; 
  unsigned char digest[16]; 
  unsigned int len = strlen (szSrc); 
  unsigned int i; 
  char szTmp[32]; 
 
  MD5Init (&context); 
  MD5Update (&context, (unsigned char *)szSrc, len); 
  MD5Final (digest, &context); 
  memset(szResult, 0, 256); 
 
  for (i = 0; i < 16; i++) 
    { 
      sprintf(szTmp, "%02x", digest[i]); 
      strcat(szResult, szTmp); 
    } 
} 
 
I've just hardcoded the values from the spec in for right now 
and what I get out is: 
 
spec = e966c932a9242554e42c8ee200cec7f6 
calc = 1949323746fe6a43ef61f9606e7febea 
 
The MD5 code is straight from the RFC. Is there something 
I'm missing here? I've looked through the Apache code for it 
and it seems to perform the same function. 
 
Any help appreciated. 
 
thanks, 
 
Paul 
 
 


Paul Hethmon 
phethmon@utk.edu 
phethmon@hethmon.com 
---------------------------------------------------------- 
Inet.Mail for OS/2 -- Internet Mail Server 
---------------------------------------------------------- 
www.hethmon.com -- ftp.hethmon.com 
----------------------------------------------------------

Received on Sunday, 1 December 1996 15:45:51 UTC