16#include "../dlib/dlib.h"
19static const char *
QOP2STR[] = { NULL,
"auth",
"auth-int" };
20static const char hexchars[] =
"0123456789abcdef";
33 for (i = 0; i < 16; i++)
44 char *result =
dNew(
char, 33);
45 for (i = 0; i < 32; i++)
77 MSG(
"a_Digest_create_auth: Unknown algorithm.\n");
93 const char *digest_uri,
94 const Dstr *entity_body)
114 MSG(
"a_Digest_create_auth: Unknown qop value.\n");
121 "%s:%s:%08x:%s:%s:%s",
139 return request_digest;
144 const char *value,
int quoted)
150 while ((c = *value++)) {
170 const char *digest_uri)
173 Dstr *response, *result;
180 result =
dStr_new(
"Authorization: Digest ");
static const char hexchars[]
static Dstr * md5hexdigest(const Dstr *data)
int a_Digest_compute_digest(AuthRealm_t *realm, const char *username, const char *passwd)
This portion only has to be calculated once.
static const char * QOP2STR[]
char * a_Digest_create_cnonce(void)
Returns a pointer to a newly allocated string containing a cnonce.
static const char * ALGORITHM2STR[]
static void Digest_Dstr_append_token_value(Dstr *str, int delimiter, const char *token, const char *value, int quoted)
char * a_Digest_authorization_hdr(AuthRealm_t *realm, const DilloUrl *url, const char *digest_uri)
Construct Digest Authorization header.
static Dstr * Digest_create_response(AuthRealm_t *realm, const char *method, const char *digest_uri, const Dstr *entity_body)
This portion is calculatd for each request.
void dStr_sprintfa(Dstr *ds, const char *format,...)
Printf-like function that appends.
void dStr_append(Dstr *ds, const char *s)
Append a C string to a Dstr.
Dstr * dStr_sized_new(int sz)
Create a new string with a given size.
void dStr_free(Dstr *ds, int all)
Free a dillo string.
void dStr_append_c(Dstr *ds, int c)
Append one character.
void dStr_sprintf(Dstr *ds, const char *format,...)
Printf-like function.
Dstr * dStr_new(const char *s)
Create a new string.
void dStr_shred(Dstr *ds)
Clear a Dstr.
#define dNew(type, count)
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
Append a string to the message.
void md5_init(md5_state_t *pms)
Initialize the algorithm.
void md5_finish(md5_state_t *pms, md5_byte_t digest[16])
Finish the message and return the digest.
enum AuthParseDigestQOP_t qop
enum AuthParseDigestAlgorithm_t algorithm
Define the state of the MD5 Algorithm.