• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

HTTPClientAuth.h

Go to the documentation of this file.
00001 
00002 #ifndef HTTP_CLIENT_AUTH_H
00003 #define HTTP_CLIENT_AUTH_H
00004 
00005 #include "HTTPClientWrapper.h"  // Cross platform support
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 // Base 64 Related
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 // Digest Related
00040 // Generates a 32 byte random hexadecimal string such as "4f6ba982..."
00041 void HTTPDigestGenerateCNonce(char *outbuff);
00042 
00043 // Calculate H(A1) as per HTTP Digest spec
00044 void HTTPDigestCalcHA1(
00045                    IN int    nAlg,     /* 0 = MD5, 1 = MD5-Sess */
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 // Calculate request-digest/response-digest as per HTTP Digest spec
00057 void HTTPDigestCalcResponse(
00058                         IN HASHHEX HA1,             // H(A1)
00059                         IN char * pszNonce,         // nonce from server
00060                         IN int    nNonceLength,     // Length of nonce
00061                         IN char * pszNonceCount,    // 8 hex digits
00062                         IN char * pszCNonce,        // client nonce
00063                         IN char * pszQop,           // qop-value: "", "auth", "auth-int"
00064                         IN int    nQopLength,       // qop param length
00065                         IN char * pszMethod,        // method from the request
00066                         IN char * pszDigestUri,     // requested URL
00067                         IN int    nDigestUriLebgth, // Uri Length
00068                         IN HASHHEX HEntity,         // H(entity body) if qop="auth-int"
00069                         OUT HASHHEX Response        // request-digest or response-digest
00070                         );
00071 
00072 // MD5 structures and functions
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 // This is needed to make RSAREF happy on some MS-DOS compilers.
00087 typedef struct MD5Context MD5_CTX;
00088 
00089 #endif

Generated on Fri Mar 31 2017 00:17:47 for ZenLib by  doxygen 1.7.1