Skip to content

Commit

Permalink
Httpauth digest response (#944)
Browse files Browse the repository at this point in the history
* httpauth: http digest challenge response using RFC 7616
  + definition of response struct using char* to save the parameters
  + added decoding for new fields in http digest challenge struct
  + response calculation supports qop: none, auth, auth-int
  + supported hash algorithm: MD5, SHA1, SHA265 and -sess variants

* httpauth: test cases for http digest response calculation and printing

* httpauth: fix mentioned review points

* httpauth: remove SHA1 support

* httpauth: save cnonce and nc as uint32_t in struct.

* httpauth: change loop counter to size_t

* httpauth: remove unused enum

* README: update RFC list, add RFC 7616 - HTTP Digest Access Authentication
  • Loading branch information
cHuberCoffee authored Oct 20, 2023
1 parent 24baaed commit e922af5
Show file tree
Hide file tree
Showing 6 changed files with 613 additions and 35 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ legend:
* [RFC 6455](https://tools.ietf.org/html/rfc6455) - The WebSocket Protocol
* [RFC 7159](https://tools.ietf.org/html/rfc7159) - JavaScript Object Notation (JSON)
* [RFC 7350](https://tools.ietf.org/html/rfc7350) - DTLS as Transport for STUN
* [RFC 7616](https://tools.ietf.org/html/rfc7616) - HTTP Digest Access Authentication
* [RFC 7714](https://tools.ietf.org/html/rfc7714) - AES-GCM Authenticated Encryption in SRTP


Expand Down
37 changes: 37 additions & 0 deletions include/re_httpauth.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ struct httpauth_digest_chall {
struct pl userhash;
};

struct httpauth_digest_enc_resp {
char *realm;
char *nonce;
char *opaque;
char *algorithm;
char *qop;

/* response specific */
char *response;
char *username;
char *username_star;
char *uri;
uint32_t cnonce;
uint32_t nc;

/* optional */
char *charset;
bool userhash;
void (*hashh)(const uint8_t *, size_t, uint8_t *);
size_t hash_length;
};

/** HTTP Digest response */
struct httpauth_digest_resp {
struct pl realm;
Expand Down Expand Up @@ -81,6 +103,21 @@ int httpauth_digest_response_encode(const struct httpauth_digest_resp *resp,
struct mbuf *mb);


int httpauth_digest_response_print(struct re_printf *pf,
const struct httpauth_digest_enc_resp *resp);
int httpauth_digest_response_set_cnonce(struct httpauth_digest_enc_resp *resp,
const struct httpauth_digest_chall *chall, const struct pl *method,
const char *user, const char *passwd, const char *entitybody,
const uint32_t cnonce, const uint32_t nc_);
int httpauth_digest_response(struct httpauth_digest_enc_resp **presp,
const struct httpauth_digest_chall *chall, const struct pl *method,
const char *uri, const char *user, const char *passwd, const char *qop,
const char *entitybody);
int httpauth_digest_response_full(struct httpauth_digest_enc_resp **presp,
const struct httpauth_digest_chall *chall, const struct pl *method,
const char *uri, const char *user, const char *passwd, const char *qop,
const char *entitybody, const char *charset, const bool userhash);

int httpauth_digest_chall_req_print(struct re_printf *pf,
const struct httpauth_digest_chall_req *req);
int httpauth_digest_chall_request(struct httpauth_digest_chall_req **preq,
Expand Down
Loading

0 comments on commit e922af5

Please sign in to comment.