]> code.citadel.org Git - citadel.git/blob - rss2ctdl/digcalc.h
225163945e816e19091f2f8108ceb31a53d40edc
[citadel.git] / rss2ctdl / digcalc.h
1 /*
2  * $Id$
3  * 
4  * Copyright 2003-2004 Oliver Feiler <kiza@kcore.de>
5  *
6  * digcalc.h
7  * 
8  * This is the sample implementation from RFC 2617.
9  * The code has been modified to work with Colin Plumb's
10  * MD5 implementation rather than using RSA's.
11  */
12
13 #define HASHLEN 16
14 typedef char HASH[HASHLEN];
15 #define HASHHEXLEN 32
16 typedef char HASHHEX[HASHHEXLEN+1];
17 #define IN
18 #define OUT
19
20 void CvtHex(
21     IN HASH Bin,
22     OUT HASHHEX Hex
23     );
24
25 /* calculate H(A1) as per HTTP Digest spec */
26 void DigestCalcHA1(
27     IN char * pszAlg,
28     IN char * pszUserName,
29     IN char * pszRealm,
30     IN char * pszPassword,
31     IN char * pszNonce,
32     IN char * pszCNonce,
33     OUT HASHHEX SessionKey
34     );
35
36 /* calculate request-digest/response-digest as per HTTP Digest spec */
37 void DigestCalcResponse(
38     IN HASHHEX HA1,           /* H(A1) */
39     IN char * pszNonce,       /* nonce from server */
40     IN char * pszNonceCount,  /* 8 hex digits */
41     IN char * pszCNonce,      /* client nonce */
42     IN char * pszQop,         /* qop-value: "", "auth", "auth-int" */
43     IN char * pszMethod,      /* method from the request */
44     IN char * pszDigestUri,   /* requested URL */
45     IN HASHHEX HEntity,       /* H(entity body) if qop="auth-int" */
46     OUT HASHHEX Response      /* request-digest or response-digest */
47     );