ZenLib

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

HTTPClientAuth.h
Go to the documentation of this file.
1
2 #ifndef HTTP_CLIENT_AUTH_H
3 #define HTTP_CLIENT_AUTH_H
4
5 #include "HTTPClientWrapper.h" // Cross platform support
6
7
8 #define HASHLEN 16
9 #define HASHHEXLEN 32
10 #define IN
11 #define OUT
12
13 typedef char HASH[HASHLEN];
14 typedef char HASHHEX[HASHHEXLEN+1];
15 typedef unsigned long uint32;
16
17 // Base 64 Related
18 #define DECODE64(c) (isascii(c) ? base64val[c] : BAD)
19 #define BAD -1
20
21 static const char base64digits[] =
22 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
23
24 static const char base64val[] = {
25 BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
26 BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
27 BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD, 62, BAD,BAD,BAD, 63,
28 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,BAD,BAD, BAD,BAD,BAD,BAD,
29 BAD, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
30 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,BAD, BAD,BAD,BAD,BAD,
31 BAD, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
32 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,BAD, BAD,BAD,BAD,BAD
33 };
34
35 void HTTPBase64Encoder(unsigned char *out, const unsigned char *in, int inlen);
36 int HTTPBase64Decoder(char *out, const char *in);
37
38
39 // Digest Related
40 // Generates a 32 byte random hexadecimal string such as "4f6ba982..."
41 void HTTPDigestGenerateCNonce(char *outbuff);
42
43 // Calculate H(A1) as per HTTP Digest spec
44 void HTTPDigestCalcHA1(
45 IN int nAlg, /* 0 = MD5, 1 = MD5-Sess */
46 IN char * pszUserName,
47 IN char * pszRealm,
48 IN int nRealmLength,
49 IN char * pszPassword,
50 IN char * pszNonce,
51 IN int nNonceLength,
52 IN char * pszCNonce,
53 OUT HASHHEX SessionKey
54 );
55
56 // Calculate request-digest/response-digest as per HTTP Digest spec
57 void HTTPDigestCalcResponse(
58 IN HASHHEX HA1, // H(A1)
59 IN char * pszNonce, // nonce from server
60 IN int nNonceLength, // Length of nonce
61 IN char * pszNonceCount, // 8 hex digits
62 IN char * pszCNonce, // client nonce
63 IN char * pszQop, // qop-value: "", "auth", "auth-int"
64 IN int nQopLength, // qop param length
65 IN char * pszMethod, // method from the request
66 IN char * pszDigestUri, // requested URL
67 IN int nDigestUriLebgth, // Uri Length
68 IN HASHHEX HEntity, // H(entity body) if qop="auth-int"
69 OUT HASHHEX Response // request-digest or response-digest
70 );
71
72 // MD5 structures and functions
73 struct MD5Context
74 {
75 uint32 buf[4];
76 uint32 bits[2];
77 unsigned char in[64];
78 };
79
80 void HTTPMD5Init (struct MD5Context *context);
81 void HTTPMD5Update (struct MD5Context *context, unsigned char const *buf,unsigned len);
82 void HTTPMD5Final (unsigned char digest[16], struct MD5Context *context);
83 void HTTPMD5Transform (uint32 buf[4], uint32 const in[16]);
84
85
86 // This is needed to make RSAREF happy on some MS-DOS compilers.
87 typedef struct MD5Context MD5_CTX;
88
89 #endif
MD5Context::in
unsigned char in[64]
Definition: HTTPClientAuth.h:77
IN
#define IN
Definition: HTTPClientAuth.h:10
HTTPMD5Init
void HTTPMD5Init(struct MD5Context *context)
MD5Context::buf
uint32 buf[4]
Definition: HTTPClientAuth.h:75
HTTPDigestCalcHA1
void HTTPDigestCalcHA1(IN int nAlg, IN char *pszUserName, IN char *pszRealm, IN int nRealmLength, IN char *pszPassword, IN char *pszNonce, IN int nNonceLength, IN char *pszCNonce, OUT HASHHEX SessionKey)
HTTPMD5Update
void HTTPMD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
BAD
#define BAD
Definition: HTTPClientAuth.h:19
HTTPDigestGenerateCNonce
void HTTPDigestGenerateCNonce(char *outbuff)
OUT
#define OUT
Definition: HTTPClientAuth.h:11
MD5Context::bits
uint32 bits[2]
Definition: HTTPClientAuth.h:76
HTTPDigestCalcResponse
void HTTPDigestCalcResponse(IN HASHHEX HA1, IN char *pszNonce, IN int nNonceLength, IN char *pszNonceCount, IN char *pszCNonce, IN char *pszQop, IN int nQopLength, IN char *pszMethod, IN char *pszDigestUri, IN int nDigestUriLebgth, IN HASHHEX HEntity, OUT HASHHEX Response)
HTTPClientWrapper.h
HASHHEX
char HASHHEX[HASHHEXLEN+1]
Definition: HTTPClientAuth.h:14
HTTPBase64Encoder
void HTTPBase64Encoder(unsigned char *out, const unsigned char *in, int inlen)
MD5Context
Definition: HTTPClientAuth.h:73
HASHHEXLEN
#define HASHHEXLEN
Definition: HTTPClientAuth.h:9
HTTPMD5Transform
void HTTPMD5Transform(uint32 buf[4], uint32 const in[16])
uint32
unsigned long uint32
Definition: HTTPClientAuth.h:15
HTTPBase64Decoder
int HTTPBase64Decoder(char *out, const char *in)
HASHLEN
#define HASHLEN
Definition: HTTPClientAuth.h:8
HTTPMD5Final
void HTTPMD5Final(unsigned char digest[16], struct MD5Context *context)
HASH
char HASH[HASHLEN]
Definition: HTTPClientAuth.h:13