00001
00002 #ifndef HTTP_CLIENT_AUTH_H
00003 #define HTTP_CLIENT_AUTH_H
00004
00005 #include "HTTPClientWrapper.h"
00006
00007
00008 #define HASHLEN 16
00009 #define HASHHEXLEN 32
00010 #define IN
00011 #define OUT
00012
00013 typedef char HASH[HASHLEN];
00014 typedef char HASHHEX[HASHHEXLEN+1];
00015 typedef unsigned long uint32;
00016
00017
00018 #define DECODE64(c) (isascii(c) ? base64val[c] : BAD)
00019 #define BAD -1
00020
00021 static const char base64digits[] =
00022 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
00023
00024 static const char base64val[] = {
00025 BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
00026 BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
00027 BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD, 62, BAD,BAD,BAD, 63,
00028 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,BAD,BAD, BAD,BAD,BAD,BAD,
00029 BAD, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
00030 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,BAD, BAD,BAD,BAD,BAD,
00031 BAD, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
00032 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,BAD, BAD,BAD,BAD,BAD
00033 };
00034
00035 void HTTPBase64Encoder(unsigned char *out, const unsigned char *in, int inlen);
00036 int HTTPBase64Decoder(char *out, const char *in);
00037
00038
00039
00040
00041 void HTTPDigestGenerateCNonce(char *outbuff);
00042
00043
00044 void HTTPDigestCalcHA1(
00045 IN int nAlg,
00046 IN char * pszUserName,
00047 IN char * pszRealm,
00048 IN int nRealmLength,
00049 IN char * pszPassword,
00050 IN char * pszNonce,
00051 IN int nNonceLength,
00052 IN char * pszCNonce,
00053 OUT HASHHEX SessionKey
00054 );
00055
00056
00057 void HTTPDigestCalcResponse(
00058 IN HASHHEX HA1,
00059 IN char * pszNonce,
00060 IN int nNonceLength,
00061 IN char * pszNonceCount,
00062 IN char * pszCNonce,
00063 IN char * pszQop,
00064 IN int nQopLength,
00065 IN char * pszMethod,
00066 IN char * pszDigestUri,
00067 IN int nDigestUriLebgth,
00068 IN HASHHEX HEntity,
00069 OUT HASHHEX Response
00070 );
00071
00072
00073 struct MD5Context
00074 {
00075 uint32 buf[4];
00076 uint32 bits[2];
00077 unsigned char in[64];
00078 };
00079
00080 void HTTPMD5Init (struct MD5Context *context);
00081 void HTTPMD5Update (struct MD5Context *context, unsigned char const *buf,unsigned len);
00082 void HTTPMD5Final (unsigned char digest[16], struct MD5Context *context);
00083 void HTTPMD5Transform (uint32 buf[4], uint32 const in[16]);
00084
00085
00086
00087 typedef struct MD5Context MD5_CTX;
00088
00089 #endif