Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Httpauth digest response #944

Merged
merged 8 commits into from
Oct 20, 2023
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
Loading