diff options
Diffstat (limited to 'daemon/digest.h')
-rw-r--r-- | daemon/digest.h | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/daemon/digest.h b/daemon/digest.h index f763133..a889024 100644 --- a/daemon/digest.h +++ b/daemon/digest.h @@ -25,33 +25,37 @@ typedef struct digest_header } digest_header_t; -/* Kept by the server for validating the client */ -typedef struct digest_record +typedef struct digest_context { - unsigned char nonce[DIGEST_NONCE_LEN]; - unsigned char userhash[MD5_LEN]; - unsigned char ha1[MD5_LEN]; - unsigned int nc; -} -digest_record_t; - -digest_record_t* digest_makerec(unsigned char* nonce, const char* user); + digest_header_t client; -int ha_digestparse(char* header, ha_buffer_t* buf, digest_header_t* rec, - unsigned char* nonce); + long server_nc; + const char* server_uri; + const char* server_method; -int ha_digestnonce(time_t* tm, unsigned char* nonce); + unsigned char ha1[MD5_LEN]; +} +digest_context_t; -int digest_check(digest_header_t* dg, digest_record_t* rec, const ha_context_t* opts, - ha_buffer_t* buf, const char* method, const char* uri); +void digest_makeha1(unsigned char* digest, const char* user, + const char* realm, const char* password); -const char* digest_respond(ha_buffer_t* buf, digest_header_t* dg, - digest_record_t* rec, unsigned char* next); +int digest_parse(const char* header, ha_buffer_t* buf, digest_header_t* dg); const char* digest_challenge(ha_buffer_t* buf, const char* nonce_str, const char* realm, const char* domains, int stale); -void digest_makeha1(unsigned char* digest, const char* user, - const char* realm, const char* password); +/* + * Validate digest headers once they've been parsed. Note that it's up + * to the caller to validate the 'username' and 'nonce' fields. + */ +int digest_check(digest_context_t* dg, const ha_context_t* opts, ha_buffer_t* buf); +int digest_pre_check(digest_context_t* dg, const ha_context_t* opts, ha_buffer_t* buf); + +/* This assumes a digest_context that's been prechecked successfully */ +int digest_complete_check(digest_context_t* dg, ha_buffer_t* buf); + +/* This assumes a digest_context that's been checked and validated successfully */ +const char* digest_respond(digest_context_t* dg, ha_buffer_t* buf, unsigned char* next); #endif /* __DIGEST_H__ */ |