GNU libmicrohttpd 1.0.1
Loading...
Searching...
No Matches
digestauth.c File Reference

Implements HTTP digest authentication. More...

#include "digestauth.h"
#include "gen_auth.h"
#include "platform.h"
#include "mhd_limits.h"
#include "internal.h"
#include "response.h"
#include "mhd_locks.h"
#include "mhd_mono_clock.h"
#include "mhd_str.h"
#include "mhd_compat.h"
#include "mhd_bithelpers.h"
#include "mhd_assert.h"
Include dependency graph for digestauth.c:

Go to the source code of this file.

Macros

#define REUSE_TIMEOUT   30
 
#define DAUTH_JUMPBACK_MAX   (0x7F)
 
#define TIMESTAMP_BIN_SIZE   (48 / 8)
 
#define TRIM_TO_TIMESTAMP(value)
 
#define TIMESTAMP_CHARS_LEN   (TIMESTAMP_BIN_SIZE * 2)
 
#define NONCE_STD_LEN(digest_size)
 
#define VLA_ARRAY_LEN_DIGEST(n)
 
#define VLA_CHECK_LEN_DIGEST(n)
 
#define MAX_USERNAME_LENGTH   128
 
#define MAX_REALM_LENGTH   256
 
#define MAX_AUTH_RESPONSE_LENGTH   (MAX_DIGEST * 2)
 
#define MHD_DAUTH_EXT_PARAM_PREFIX   "UTF-8'"
 
#define MHD_DAUTH_EXT_PARAM_MIN_LEN    MHD_STATICSTR_LEN_ (MHD_DAUTH_EXT_PARAM_PREFIX "'")
 
#define digest_setup_zero(da)
 
#define digest_deinit(da)
 
#define digest_ext_error(da)
 
#define _MHD_STATIC_UNQ_BUFFER_SIZE   128
 

Enumerations

enum  MHD_CheckNonceNC_ { MHD_CHECK_NONCENC_OK = MHD_DAUTH_OK , MHD_CHECK_NONCENC_STALE = MHD_DAUTH_NONCE_STALE , MHD_CHECK_NONCENC_WRONG = MHD_DAUTH_NONCE_WRONG }
 
enum  MHD_GetRqNCResult {
  MHD_GET_RQ_NC_NONE = -1 , MHD_GET_RQ_NC_VALID = 0 , MHD_GET_RQ_NC_TOO_LONG = 1 , MHD_GET_RQ_NC_TOO_LARGE = 2 ,
  MHD_GET_RQ_NC_BROKEN = 3
}
 
enum  _MHD_GetUnqResult { _MHD_UNQ_OK = 0 , _MHD_UNQ_TOO_LARGE = -7 , _MHD_UNQ_OUT_OF_MEM = 3 }
 

Functions

_MHD_static_inline enum MHD_DigestBaseAlgo get_base_digest_algo (enum MHD_DigestAuthAlgo3 algo3)
 
_MHD_static_inline size_t digest_get_hash_size (enum MHD_DigestAuthAlgo3 algo3)
 
_MHD_EXTERN size_t MHD_digest_get_hash_size (enum MHD_DigestAuthAlgo3 algo3)
 
_MHD_static_inline unsigned int digest_get_size (struct DigestAlgorithm *da)
 
_MHD_static_inline bool digest_init_one_time (struct DigestAlgorithm *da, enum MHD_DigestBaseAlgo algo)
 
_MHD_static_inline void digest_update (struct DigestAlgorithm *da, const void *data, size_t length)
 
_MHD_static_inline void digest_update_str (struct DigestAlgorithm *da, const char *str)
 
_MHD_static_inline void digest_update_with_colon (struct DigestAlgorithm *da)
 
_MHD_static_inline void digest_calc_hash (struct DigestAlgorithm *da, uint8_t *digest)
 
_MHD_static_inline void digest_reset (struct DigestAlgorithm *da)
 
static bool get_nonce_timestamp (const char *const nonce, size_t noncelen, uint64_t *const ptimestamp)
 
static MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ uint32_t fast_simple_hash (const uint8_t *data, size_t data_size)
 
static MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ size_t get_nonce_nc_idx (size_t arr_size, const char *nonce, size_t noncelen)
 
static enum MHD_CheckNonceNC_ check_nonce_nc (struct MHD_Connection *connection, const char *nonce, size_t noncelen, uint64_t nonce_time, uint64_t nc)
 
_MHD_static_inline enum MHD_DigestAuthUsernameType get_rq_uname_type (const struct MHD_RqDAuth *params)
 
_MHD_static_inline size_t get_rq_unames_size (const struct MHD_RqDAuth *params, enum MHD_DigestAuthUsernameType uname_type)
 
static size_t get_rq_param_unquoted_copy_z (const struct MHD_RqDAuthParam *param, char *buf)
 
static ssize_t get_rq_extended_uname_copy_z (const char *uname_ext, size_t uname_ext_len, char *buf, size_t buf_size)
 
static size_t get_rq_uname (const struct MHD_RqDAuth *params, enum MHD_DigestAuthUsernameType uname_type, struct MHD_DigestAuthUsernameInfo *uname_info, uint8_t *buf, size_t buf_size)
 
static enum MHD_GetRqNCResult get_rq_nc (const struct MHD_RqDAuth *params, uint32_t *nc)
 
_MHD_EXTERN struct MHD_DigestAuthInfoMHD_digest_auth_get_request_info3 (struct MHD_Connection *connection)
 
_MHD_EXTERN struct MHD_DigestAuthUsernameInfoMHD_digest_auth_get_username3 (struct MHD_Connection *connection)
 
_MHD_EXTERN char * MHD_digest_auth_get_username (struct MHD_Connection *connection)
 
static void calculate_nonce (uint64_t nonce_time, enum MHD_HTTP_Method mthd_e, const char *method, const char *rnd, size_t rnd_size, const struct sockaddr_storage *saddr, size_t saddr_size, const char *uri, size_t uri_len, const struct MHD_HTTP_Req_Header *first_header, const char *realm, size_t realm_len, unsigned int bind_options, struct DigestAlgorithm *da, char *nonce)
 
static bool is_slot_available (const struct MHD_NonceNc *const nn, const uint64_t now, const char *const new_nonce, size_t new_nonce_len)
 
static bool calculate_add_nonce (struct MHD_Connection *const connection, uint64_t timestamp, const char *realm, size_t realm_len, struct DigestAlgorithm *da, char *nonce)
 
static MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ bool calculate_add_nonce_with_retry (struct MHD_Connection *const connection, const char *realm, struct DigestAlgorithm *da, char *nonce)
 
MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ _MHD_static_inline void calc_userdigest (struct DigestAlgorithm *da, const char *username, const size_t username_len, const char *realm, const size_t realm_len, const char *password, uint8_t *ha1_bin)
 
_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userdigest (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, const char *password, void *userdigest_bin, size_t bin_buf_size)
 
_MHD_static_inline void calc_userhash (struct DigestAlgorithm *da, const char *username, const size_t username_len, const char *realm, const size_t realm_len, uint8_t *digest_bin)
 
_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, void *userhash_bin, size_t bin_buf_size)
 
_MHD_EXTERN enum MHD_Result MHD_digest_auth_calc_userhash_hex (enum MHD_DigestAuthAlgo3 algo3, const char *username, const char *realm, char *userhash_hex, size_t hex_buf_size)
 
static enum MHD_Result test_header (void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind)
 
static bool check_argument_match (struct MHD_Connection *connection, char *args)
 
static bool check_uri_match (struct MHD_Connection *connection, char *uri, size_t uri_len)
 
static char * get_buffer_for_size (char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE], char **ptmp2, size_t *ptmp2_size, size_t required_size)
 
static enum _MHD_GetUnqResult get_unquoted_param (const struct MHD_RqDAuthParam *param, char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE], char **ptmp2, size_t *ptmp2_size, struct _MHD_str_w_len *unquoted)
 
static enum _MHD_GetUnqResult get_unquoted_param_copy (const struct MHD_RqDAuthParam *param, char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE], char **ptmp2, size_t *ptmp2_size, struct _MHD_mstr_w_len *unquoted)
 
_MHD_static_inline bool is_param_equal (const struct MHD_RqDAuthParam *param, const char *const str, const size_t str_len)
 
_MHD_static_inline bool is_param_equal_caseless (const struct MHD_RqDAuthParam *param, const char *const str, const size_t str_len)
 
static enum MHD_DigestAuthResult digest_auth_check_all_inner (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, const uint8_t *userdigest, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3, char **pbuf, struct DigestAlgorithm *da)
 
static enum MHD_DigestAuthResult digest_auth_check_all (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, const uint8_t *userdigest, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3)
 
_MHD_EXTERN int MHD_digest_auth_check (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout)
 
_MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check3 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3)
 
_MHD_EXTERN enum MHD_DigestAuthResult MHD_digest_auth_check_digest3 (struct MHD_Connection *connection, const char *realm, const char *username, const void *userdigest, size_t userdigest_size, unsigned int nonce_timeout, uint32_t max_nc, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3)
 
_MHD_EXTERN int MHD_digest_auth_check2 (struct MHD_Connection *connection, const char *realm, const char *username, const char *password, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN int MHD_digest_auth_check_digest2 (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t *digest, size_t digest_size, unsigned int nonce_timeout, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN int MHD_digest_auth_check_digest (struct MHD_Connection *connection, const char *realm, const char *username, const uint8_t digest[MHD_MD5_DIGEST_SIZE], unsigned int nonce_timeout)
 
static enum MHD_Result queue_auth_required_response3_inner (struct MHD_Connection *connection, const char *realm, const char *opaque, const char *domain, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 malgo3, int userhash_support, int prefer_utf8, char **buf_ptr, struct DigestAlgorithm *da)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_required_response3 (struct MHD_Connection *connection, const char *realm, const char *opaque, const char *domain, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthMultiQOP mqop, enum MHD_DigestAuthMultiAlgo3 algo, int userhash_support, int prefer_utf8)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale, enum MHD_DigestAuthAlgorithm algo)
 
_MHD_EXTERN enum MHD_Result MHD_queue_auth_fail_response (struct MHD_Connection *connection, const char *realm, const char *opaque, struct MHD_Response *response, int signal_stale)
 

Detailed Description

Implements HTTP digest authentication.

Author
Amr Ali
Matthieu Speder
Christian Grothoff (RFC 7616 support)
Karlson2k (Evgeny Grin) (fixes, new API, improvements, large rewrite, many RFC 7616 features implementation, old RFC 2069 support)
Amr Ali
Matthieu Speder
Christian Grothoff (RFC 7616 support)
Karlson2k (Evgeny Grin)

Definition in file digestauth.c.

Macro Definition Documentation

◆ _MHD_STATIC_UNQ_BUFFER_SIZE

#define _MHD_STATIC_UNQ_BUFFER_SIZE   128

The size of the unquoting buffer in stack

Definition at line 2311 of file digestauth.c.

Referenced by digest_auth_check_all_inner(), get_buffer_for_size(), get_unquoted_param(), and get_unquoted_param_copy().

◆ DAUTH_JUMPBACK_MAX

#define DAUTH_JUMPBACK_MAX   (0x7F)

The maximum value of artificial timestamp difference to avoid clashes. The value must be suitable for bitwise AND operation.

Definition at line 65 of file digestauth.c.

Referenced by calculate_add_nonce_with_retry().

◆ digest_deinit

#define digest_deinit ( da)

◆ digest_ext_error

◆ digest_setup_zero

#define digest_setup_zero ( da)
Value:
(void)0

Definition at line 429 of file digestauth.c.

Referenced by digest_auth_check_all(), and MHD_queue_auth_required_response3().

◆ MAX_AUTH_RESPONSE_LENGTH

#define MAX_AUTH_RESPONSE_LENGTH   (MAX_DIGEST * 2)

Maximum length of the response in digest authentication.

Definition at line 167 of file digestauth.c.

◆ MAX_REALM_LENGTH

#define MAX_REALM_LENGTH   256

Maximum length of a realm for digest authentication.

Definition at line 162 of file digestauth.c.

◆ MAX_USERNAME_LENGTH

#define MAX_USERNAME_LENGTH   128

Maximum length of a username for digest authentication.

Definition at line 157 of file digestauth.c.

◆ MHD_DAUTH_EXT_PARAM_MIN_LEN

#define MHD_DAUTH_EXT_PARAM_MIN_LEN    MHD_STATICSTR_LEN_ (MHD_DAUTH_EXT_PARAM_PREFIX "'")

The minimal size of the prefix for parameter with the extended notation

Definition at line 177 of file digestauth.c.

Referenced by digest_auth_check_all_inner(), get_rq_extended_uname_copy_z(), get_rq_uname_type(), and get_rq_unames_size().

◆ MHD_DAUTH_EXT_PARAM_PREFIX

#define MHD_DAUTH_EXT_PARAM_PREFIX   "UTF-8'"

The required prefix of parameter with the extended notation

Definition at line 172 of file digestauth.c.

Referenced by get_rq_extended_uname_copy_z().

◆ NONCE_STD_LEN

#define NONCE_STD_LEN ( digest_size)
Value:
((digest_size) * 2 + TIMESTAMP_CHARS_LEN)
#define TIMESTAMP_CHARS_LEN
Definition digestauth.c:84

Standard server nonce length, not including terminating null,

Parameters
digest_sizedigest size

Definition at line 92 of file digestauth.c.

Referenced by calculate_add_nonce(), calculate_add_nonce_with_retry(), digest_auth_check_all_inner(), get_nonce_timestamp(), is_slot_available(), and queue_auth_required_response3_inner().

◆ REUSE_TIMEOUT

#define REUSE_TIMEOUT   30

Allow re-use of the nonce-nc map array slot after REUSE_TIMEOUT seconds, if this slot is needed for the new nonce, while the old nonce was not used even one time by the client. Typically clients immediately use generated nonce for new request.

Definition at line 59 of file digestauth.c.

Referenced by check_nonce_nc(), and is_slot_available().

◆ TIMESTAMP_BIN_SIZE

#define TIMESTAMP_BIN_SIZE   (48 / 8)

48 bit value in bytes

Definition at line 71 of file digestauth.c.

Referenced by calculate_nonce().

◆ TIMESTAMP_CHARS_LEN

#define TIMESTAMP_CHARS_LEN   (TIMESTAMP_BIN_SIZE * 2)

The printed timestamp size in chars

Definition at line 84 of file digestauth.c.

Referenced by get_nonce_timestamp().

◆ TRIM_TO_TIMESTAMP

#define TRIM_TO_TIMESTAMP ( value)
Value:
((value) & ((UINT64_C (1) << (TIMESTAMP_BIN_SIZE * 8)) - 1))
#define TIMESTAMP_BIN_SIZE
Definition digestauth.c:71

Trim value to the TIMESTAMP_BIN_SIZE size

Definition at line 77 of file digestauth.c.

Referenced by check_nonce_nc(), digest_auth_check_all_inner(), and is_slot_available().

◆ VLA_ARRAY_LEN_DIGEST

#define VLA_ARRAY_LEN_DIGEST ( n)
Value:
(MAX_DIGEST)

Macro to avoid using VLAs if the compiler does not support them. Return #MAX_DIGEST.

Parameters
nlength of the digest to be used for a VLA

Definition at line 137 of file digestauth.c.

◆ VLA_CHECK_LEN_DIGEST

#define VLA_CHECK_LEN_DIGEST ( n)
Value:
do { if ((n) > MAX_DIGEST) MHD_PANIC (_ ("VLA too big.\n")); } while (0)
#define MHD_PANIC(msg)
Definition internal.h:69
#define _(String)
Definition mhd_options.h:42

Check that n is below #MAX_DIGEST

Definition at line 151 of file digestauth.c.

Enumeration Type Documentation

◆ _MHD_GetUnqResult

The result of parameter unquoting

Enumerator
_MHD_UNQ_OK 

Got unquoted string

_MHD_UNQ_TOO_LARGE 

The string is too large to unquote

_MHD_UNQ_OUT_OF_MEM 

Out of memory error

Definition at line 2356 of file digestauth.c.

◆ MHD_CheckNonceNC_

The result of nonce-nc map array check.

Enumerator
MHD_CHECK_NONCENC_OK 

The nonce and NC are OK (valid and NC was not used before).

MHD_CHECK_NONCENC_STALE 

The 'nonce' was overwritten with newer 'nonce' in the same slot or NC was already used. The validity of the 'nonce' was not be checked.

MHD_CHECK_NONCENC_WRONG 

The 'nonce' is wrong, it was not generated before.

Definition at line 183 of file digestauth.c.

◆ MHD_GetRqNCResult

Result of request's Digest Authorization 'nc' value extraction

Enumerator
MHD_GET_RQ_NC_NONE 

No 'nc' value

MHD_GET_RQ_NC_VALID 

Readable 'nc' value

MHD_GET_RQ_NC_TOO_LONG 

The 'nc' value is too long

MHD_GET_RQ_NC_TOO_LARGE 

The 'nc' value is too big to fit uint32_t

MHD_GET_RQ_NC_BROKEN 

The 'nc' value is not a number

Definition at line 1187 of file digestauth.c.

Function Documentation

◆ calc_userdigest()

MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ _MHD_static_inline void calc_userdigest ( struct DigestAlgorithm * da,
const char * username,
const size_t username_len,
const char * realm,
const size_t realm_len,
const char * password,
uint8_t * ha1_bin )

Calculate userdigest, return it as binary data.

It is equal to H(A1) for non-session algorithms.

MHD internal version.

Parameters
dathe digest algorithm
usernamethe username to use
username_lenthe length of the username
realmthe realm to use
realm_lenthe length of the realm
passwordthe password, must be zero-terminated
[out]ha1_binthe output buffer, must have at least #digest_get_size(da) bytes available

Definition at line 1887 of file digestauth.c.

References digest_calc_hash(), digest_update(), digest_update_str(), digest_update_with_colon(), and mhd_assert.

Referenced by digest_auth_check_all_inner(), and MHD_digest_auth_calc_userdigest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_userhash()

_MHD_static_inline void calc_userhash ( struct DigestAlgorithm * da,
const char * username,
const size_t username_len,
const char * realm,
const size_t realm_len,
uint8_t * digest_bin )

Calculate userhash, return it as binary data.

MHD internal version.

Parameters
dathe digest algorithm
usernamethe username to use
username_lenthe length of the username
realmthe realm to use
realm_lenthe length of the realm
[out]digest_binthe output buffer, must have at least #MHD_digest_get_hash_size(algo3) bytes available

Definition at line 1987 of file digestauth.c.

References digest_calc_hash(), digest_update(), digest_update_with_colon(), mhd_assert, and NULL.

Referenced by digest_auth_check_all_inner(), and MHD_digest_auth_calc_userhash().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_add_nonce()

static bool calculate_add_nonce ( struct MHD_Connection *const connection,
uint64_t timestamp,
const char * realm,
size_t realm_len,
struct DigestAlgorithm * da,
char * nonce )
static

Calculate the server nonce so that it mitigates replay attacks and add the new nonce to the nonce-nc map array.

Parameters
connectionthe MHD connection structure
timestampthe current timestamp
realmthe string of characters that describes the realm of auth
realm_lenthe length of the realm
dathe digest algorithm to use
[out]noncethe pointer to a character array for the nonce to put in, must provide NONCE_STD_LEN(digest_get_size(da)) bytes, result is NOT zero-terminated
Returns
true if the new nonce has been added to the nonce-nc map array, false otherwise.

Definition at line 1697 of file digestauth.c.

References MHD_Connection::addr, MHD_Connection::addr_len, calculate_nonce(), MHD_Connection::daemon, digest_ext_error, digest_get_size(), get_nonce_nc_idx(), MHD_Request::headers_received, MHD_Request::http_mthd, is_slot_available(), MAX_DIGEST_NONCE_LENGTH, MHD_Request::method, mhd_assert, MHD_get_master(), MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_NonceNc::nc, MHD_NonceNc::nmask, MHD_NonceNc::nonce, NONCE_STD_LEN, MHD_Connection::rq, MHD_Request::url, and MHD_Request::url_len.

Referenced by calculate_add_nonce_with_retry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_add_nonce_with_retry()

static MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ bool calculate_add_nonce_with_retry ( struct MHD_Connection *const connection,
const char * realm,
struct DigestAlgorithm * da,
char * nonce )
static

Calculate the server nonce so that it mitigates replay attacks and add the new nonce to the nonce-nc map array.

Parameters
connectionthe MHD connection structure
realmA string of characters that describes the realm of auth.
dadigest algorithm to use
[out]noncethe pointer to a character array for the nonce to put in, must provide NONCE_STD_LEN(digest_get_size(da)) bytes, result is NOT zero-terminated

Definition at line 1777 of file digestauth.c.

References _, _MHD_ROTL32(), _MHD_ROTR32(), calculate_add_nonce(), MHD_Connection::daemon, DAUTH_JUMPBACK_MAX, digest_ext_error, digest_get_size(), digest_reset(), mhd_assert, MHD_get_master(), MHD_monotonic_msec_counter(), MHD_NonceNc::nonce, and NONCE_STD_LEN.

Referenced by queue_auth_required_response3_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_nonce()

static void calculate_nonce ( uint64_t nonce_time,
enum MHD_HTTP_Method mthd_e,
const char * method,
const char * rnd,
size_t rnd_size,
const struct sockaddr_storage * saddr,
size_t saddr_size,
const char * uri,
size_t uri_len,
const struct MHD_HTTP_Req_Header * first_header,
const char * realm,
size_t realm_len,
unsigned int bind_options,
struct DigestAlgorithm * da,
char * nonce )
static

Calculate the server nonce so that it mitigates replay attacks The current format of the nonce is ... H(timestamp:random data:various parameters) + Hex(timestamp)

Parameters
nonce_timeThe amount of time in seconds for a nonce to be invalid
mthd_eHTTP method as enum value
methodHTTP method as a string
rndthe pointer to a character array for the random seed
rnd_sizeThe size of the random seed array rnd
saddrthe pointer to the socket address structure
saddr_sizethe size of the socket address structure saddr
urithe HTTP URI (in MHD, without the arguments ("?k=v")
uri_lenthe length of the uri
first_headerthe pointer to the first request's header
realmA string of characters that describes the realm of auth.
realm_lenthe length of the realm.
bind_optionsthe nonce bind options (MHD_DAuthBindNonce values).
dadigest algorithm to use
[out]noncethe pointer to a character array for the nonce to put in, must provide NONCE_STD_LEN(digest_get_size(da)) bytes, result is NOT zero-terminated

Definition at line 1485 of file digestauth.c.

References digest_calc_hash(), digest_get_size(), digest_update(), digest_update_str(), digest_update_with_colon(), MHD_HTTP_Req_Header::header, MHD_HTTP_Req_Header::header_size, MHD_HTTP_Req_Header::kind, mhd_assert, MHD_bin_to_hex(), MHD_DAUTH_BIND_NONCE_CLIENT_IP, MHD_DAUTH_BIND_NONCE_NONE, MHD_DAUTH_BIND_NONCE_REALM, MHD_DAUTH_BIND_NONCE_URI, MHD_DAUTH_BIND_NONCE_URI_PARAMS, MHD_GET_ARGUMENT_KIND, MHD_HTTP_MTHD_GET, MHD_HTTP_MTHD_HEAD, MHD_HTTP_MTHD_OTHER, MHD_HTTP_Req_Header::next, NULL, TIMESTAMP_BIN_SIZE, MHD_HTTP_Req_Header::value, and MHD_HTTP_Req_Header::value_size.

Referenced by calculate_add_nonce(), and digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_argument_match()

static bool check_argument_match ( struct MHD_Connection * connection,
char * args )
static

Check that the arguments given by the client as part of the authentication header match the arguments we got as part of the HTTP request URI.

Parameters
connectionconnections with headers to compare against
argsthe copy of argument URI string (after "?" in URI), will be modified by this function
Returns
boolean true if the arguments match, boolean false if not

Definition at line 2219 of file digestauth.c.

References MHD_Request::headers_received, MHD_HTTP_Req_Header::kind, MHD_GET_ARGUMENT_KIND, MHD_NO, MHD_parse_arguments_(), MHD_HTTP_Req_Header::next, NULL, MHD_Connection::rq, and test_header().

Referenced by check_uri_match().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_nonce_nc()

static enum MHD_CheckNonceNC_ check_nonce_nc ( struct MHD_Connection * connection,
const char * nonce,
size_t noncelen,
uint64_t nonce_time,
uint64_t nc )
static

Check nonce-nc map array with the new nonce counter.

Parameters
connectionThe MHD connection structure
noncethe pointer that referenced hex nonce, does not need to be zero-terminated
noncelenthe length of nonce, in characters
ncThe nonce counter
Returns
#MHD_DAUTH_NONCENC_OK if successful, #MHD_DAUTH_NONCENC_STALE if nonce is stale (or no nonce-nc array is available), #MHD_DAUTH_NONCENC_WRONG if nonce was not recodered in nonce-nc map array, while it should.

< The timestamp in the slot

Definition at line 832 of file digestauth.c.

References MHD_Connection::daemon, get_nonce_nc_idx(), get_nonce_timestamp(), MAX_DIGEST_NONCE_LENGTH, mhd_assert, MHD_CHECK_NONCENC_OK, MHD_CHECK_NONCENC_STALE, MHD_CHECK_NONCENC_WRONG, MHD_get_master(), MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_NonceNc::nc, MHD_NonceNc::nmask, MHD_NonceNc::nonce, REUSE_TIMEOUT, TRIM_TO_TIMESTAMP, UINT32_MAX, and UINT64_MAX.

Referenced by digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_uri_match()

static bool check_uri_match ( struct MHD_Connection * connection,
char * uri,
size_t uri_len )
static

Check that the URI provided by the client as part of the authentication header match the real HTTP request URI.

Parameters
connectionconnections with headers to compare against
urithe copy of URI in the authentication header, should point to modifiable buffer at least uri_len + 1 characters long, will be modified by this function, not valid upon return
uri_lenthe length of the uri string in characters
Returns
boolean true if the URIs match, boolean false if not

Definition at line 2266 of file digestauth.c.

References _, check_argument_match(), MHD_Connection::daemon, NULL, MHD_Connection::rq, MHD_Daemon::unescape_callback, MHD_Daemon::unescape_callback_cls, MHD_Request::url, and MHD_Request::url_len.

Referenced by digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest_calc_hash()

_MHD_static_inline void digest_calc_hash ( struct DigestAlgorithm * da,
uint8_t * digest )

Finally calculate hash (the digest).

Parameters
dathe digest calculation
[out]digestthe pointer to the buffer to put calculated digest, must be at least digest_get_size(da) bytes large

Definition at line 576 of file digestauth.c.

References mhd_assert, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_MD5_finish(), MHD_MD5_finish_reset, MHD_SHA256_finish(), MHD_SHA256_finish_reset, and MHD_SHA512_256_finish().

Referenced by calc_userdigest(), calc_userhash(), calculate_nonce(), and digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest_get_hash_size()

_MHD_static_inline size_t digest_get_hash_size ( enum MHD_DigestAuthAlgo3 algo3)

Get digest size for specified algorithm.

Internal inline version.

Parameters
algo3the algorithm to check
Returns
the size of the digest or zero if the input value is not supported/valid

Definition at line 232 of file digestauth.c.

References MD5_DIGEST_SIZE, mhd_assert, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_MD5_DIGEST_SIZE, MHD_SHA256_DIGEST_SIZE, MHD_SHA512_256_DIGEST_SIZE, SHA256_DIGEST_SIZE, and SHA512_256_DIGEST_SIZE.

Referenced by MHD_digest_auth_calc_userhash_hex(), MHD_digest_auth_check_digest3(), and MHD_digest_get_hash_size().

Here is the caller graph for this function:

◆ digest_get_size()

_MHD_static_inline unsigned int digest_get_size ( struct DigestAlgorithm * da)

Return the size of the digest.

Parameters
dathe digest calculation structure to identify
Returns
the size of the digest.

Definition at line 351 of file digestauth.c.

References MD5_DIGEST_SIZE, mhd_assert, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, SHA256_DIGEST_SIZE, and SHA512_256_DIGEST_SIZE.

Referenced by calculate_add_nonce(), calculate_add_nonce_with_retry(), calculate_nonce(), digest_auth_check_all_inner(), MHD_digest_auth_calc_userdigest(), MHD_digest_auth_calc_userhash(), and queue_auth_required_response3_inner().

Here is the caller graph for this function:

◆ digest_init_one_time()

_MHD_static_inline bool digest_init_one_time ( struct DigestAlgorithm * da,
enum MHD_DigestBaseAlgo algo )

Set-up the digest calculation structure and initialise with initial values.

If da was successfully initialised, digest_deinit() must be called after finishing using of the da.

This function must not be called more than once for any da.

Parameters
dathe structure to set-up
algothe algorithm to use for digest calculation
Returns
boolean 'true' if successfully set-up, false otherwise.

Definition at line 448 of file digestauth.c.

References MHD_DIGEST_BASE_ALGO_INVALID, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_MD5_init_one_time, MHD_SHA256_init_one_time, and MHD_SHA512_256_init().

Referenced by digest_auth_check_all_inner(), MHD_digest_auth_calc_userdigest(), MHD_digest_auth_calc_userhash(), and queue_auth_required_response3_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest_reset()

_MHD_static_inline void digest_reset ( struct DigestAlgorithm * da)

Reset the digest calculation structure.

Parameters
dathe structure to reset

Definition at line 638 of file digestauth.c.

References mhd_assert, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_MD5_reset, MHD_SHA256_reset, and MHD_SHA512_256_init().

Referenced by calculate_add_nonce_with_retry(), and digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest_update()

_MHD_static_inline void digest_update ( struct DigestAlgorithm * da,
const void * data,
size_t length )

Feed digest calculation with more data.

Parameters
dathe digest calculation
datathe data to process
lengththe size of the data in bytes

Definition at line 512 of file digestauth.c.

References data, mhd_assert, MHD_DIGEST_BASE_ALGO_MD5, MHD_DIGEST_BASE_ALGO_SHA256, MHD_DIGEST_BASE_ALGO_SHA512_256, MHD_MD5_update(), MHD_SHA256_update(), and MHD_SHA512_256_update().

Referenced by calc_userdigest(), calc_userhash(), calculate_nonce(), digest_auth_check_all_inner(), digest_update_str(), and digest_update_with_colon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest_update_str()

_MHD_static_inline void digest_update_str ( struct DigestAlgorithm * da,
const char * str )

Feed digest calculation with more data from string.

Parameters
dathe digest calculation
strthe zero-terminated string to process

Definition at line 548 of file digestauth.c.

References digest_update().

Referenced by calc_userdigest(), calculate_nonce(), and digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digest_update_with_colon()

_MHD_static_inline void digest_update_with_colon ( struct DigestAlgorithm * da)

Feed digest calculation with single colon ':' character.

Parameters
dathe digest calculation
strthe zero-terminated string to process

Definition at line 562 of file digestauth.c.

References digest_update().

Referenced by calc_userdigest(), calc_userhash(), calculate_nonce(), and digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fast_simple_hash()

static MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ uint32_t fast_simple_hash ( const uint8_t * data,
size_t data_size )
static

Super-fast xor-based "hash" function

Parameters
datathe data to calculate hash for
data_sizethe size of the data in bytes
Returns
the "hash"

Definition at line 777 of file digestauth.c.

References _MHD_ROTL32(), and data.

Referenced by get_nonce_nc_idx().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_base_digest_algo()

_MHD_static_inline enum MHD_DigestBaseAlgo get_base_digest_algo ( enum MHD_DigestAuthAlgo3 algo3)

Get base hash calculation algorithm from MHD_DigestAuthAlgo3 value.

Parameters
algo3the MHD_DigestAuthAlgo3 value
Returns
the base hash calculation algorithm

Definition at line 210 of file digestauth.c.

References MHD_DIGEST_AUTH_ALGO3_NON_SESSION.

Referenced by digest_auth_check_all_inner(), MHD_digest_auth_calc_userdigest(), MHD_digest_auth_calc_userhash(), and queue_auth_required_response3_inner().

Here is the caller graph for this function:

◆ get_buffer_for_size()

static char * get_buffer_for_size ( char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE],
char ** ptmp2,
size_t * ptmp2_size,
size_t required_size )
static

Get the pointer to buffer with required size

Parameters
tmp1the first buffer with fixed size
ptmp2the pointer to pointer to malloc'ed buffer
ptmp2_sizethe pointer to the size of the buffer pointed by ptmp2
required_sizethe required size in buffer
Returns
the pointer to the buffer or NULL if failed to allocate buffer with requested size

Definition at line 2324 of file digestauth.c.

References _MHD_AUTH_DIGEST_MAX_PARAM_SIZE, _MHD_STATIC_UNQ_BUFFER_SIZE, mhd_assert, and NULL.

Referenced by digest_auth_check_all_inner(), get_unquoted_param(), and get_unquoted_param_copy().

Here is the caller graph for this function:

◆ get_nonce_nc_idx()

static MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ size_t get_nonce_nc_idx ( size_t arr_size,
const char * nonce,
size_t noncelen )
static

Get index of the nonce in the nonce-nc map array.

Parameters
arr_sizethe size of nonce_nc array
noncethe pointer that referenced a zero-terminated array of nonce
noncelenthe length of nonce, in characters
Returns
MHD_YES if successful, MHD_NO if invalid (or we have no NC array)

Definition at line 807 of file digestauth.c.

References fast_simple_hash(), and mhd_assert.

Referenced by calculate_add_nonce(), and check_nonce_nc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_nonce_timestamp()

static bool get_nonce_timestamp ( const char *const nonce,
size_t noncelen,
uint64_t *const ptimestamp )
static

Extract timestamp from the given nonce.

Parameters
noncethe nonce to check
noncelenthe length of the nonce, zero for autodetect
[out]ptimestampthe pointer to store extracted timestamp
Returns
true if timestamp was extracted, false if nonce does not have valid timestamp.

Definition at line 741 of file digestauth.c.

References MD5_DIGEST_SIZE, MHD_strx_to_uint64_n_(), NONCE_STD_LEN, and TIMESTAMP_CHARS_LEN.

Referenced by check_nonce_nc(), digest_auth_check_all_inner(), and is_slot_available().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_rq_extended_uname_copy_z()

static ssize_t get_rq_extended_uname_copy_z ( const char * uname_ext,
size_t uname_ext_len,
char * buf,
size_t buf_size )
static

Get decoded version of username from extended notation. This function automatically zero-teminate the result.

Parameters
uname_extthe string of client's 'username*' parameter value
uname_ext_lenthe length of uname_ext in chars
[out]bufthe output buffer to put decoded username value
buf_sizethe size of buf
Returns
the number of characters copied to the output buffer or -1 if wrong extended notation is used.

Definition at line 1052 of file digestauth.c.

References mhd_assert, MHD_DAUTH_EXT_PARAM_MIN_LEN, MHD_DAUTH_EXT_PARAM_PREFIX, MHD_STATICSTR_LEN_, MHD_str_equal_caseless_bin_n_(), MHD_str_pct_decode_strict_n_(), and SSIZE_MAX.

Referenced by digest_auth_check_all_inner(), and get_rq_uname().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_rq_nc()

static enum MHD_GetRqNCResult get_rq_nc ( const struct MHD_RqDAuth * params,
uint32_t * nc )
static

Get 'nc' value from request's Authorization header

Parameters
paramsthe request digest authentication
[out]ncthe pointer to put nc value to
Returns
enum value indicating the result

Definition at line 1204 of file digestauth.c.

References MHD_GET_RQ_NC_BROKEN, MHD_GET_RQ_NC_NONE, MHD_GET_RQ_NC_TOO_LARGE, MHD_GET_RQ_NC_TOO_LONG, MHD_GET_RQ_NC_VALID, MHD_strx_to_uint64_n_(), NULL, and UINT32_MAX.

Referenced by MHD_digest_auth_get_request_info3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_rq_param_unquoted_copy_z()

static size_t get_rq_param_unquoted_copy_z ( const struct MHD_RqDAuthParam * param,
char * buf )
static

Get unquoted version of Digest Authorization parameter. This function automatically zero-teminate the result.

Parameters
paramthe parameter to extract
[out]bufthe output buffer, must be enough size to hold the result, the recommended size is 'param->value.len + 1'
Returns
the size of the result, not including the terminating zero

Definition at line 1022 of file digestauth.c.

References mhd_assert, and NULL.

Referenced by get_rq_uname(), and MHD_digest_auth_get_request_info3().

Here is the caller graph for this function:

◆ get_rq_uname()

static size_t get_rq_uname ( const struct MHD_RqDAuth * params,
enum MHD_DigestAuthUsernameType uname_type,
struct MHD_DigestAuthUsernameInfo * uname_info,
uint8_t * buf,
size_t buf_size )
static

Get copy of username used by the client.

Parameters
paramsthe Digest Authorization parameters
uname_typethe type of username
[out]uname_infothe pointer to the structure to be filled
bufthe buffer to be used for usernames
buf_sizethe size of the buf
Returns
the size of the buf used by pointers in unames structure

Definition at line 1102 of file digestauth.c.

References get_rq_extended_uname_copy_z(), get_rq_param_unquoted_copy_z(), get_rq_uname_type(), mhd_assert, MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, MHD_DIGEST_AUTH_UNAME_TYPE_INVALID, MHD_DIGEST_AUTH_UNAME_TYPE_MISSING, MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD, MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH, MHD_hex_to_bin(), NULL, MHD_DigestAuthUsernameInfo::uname_type, MHD_DigestAuthUsernameInfo::userhash_bin, MHD_DigestAuthUsernameInfo::userhash_hex, MHD_DigestAuthUsernameInfo::userhash_hex_len, MHD_DigestAuthUsernameInfo::username, and MHD_DigestAuthUsernameInfo::username_len.

Referenced by MHD_digest_auth_get_request_info3(), MHD_digest_auth_get_username(), and MHD_digest_auth_get_username3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_rq_uname_type()

_MHD_static_inline enum MHD_DigestAuthUsernameType get_rq_uname_type ( const struct MHD_RqDAuth * params)

Get username type used by the client. This function does not check whether userhash can be decoded or extended notation (if used) is valid.

Parameters
paramsthe Digest Authorization parameters
Returns
the type of username

Definition at line 960 of file digestauth.c.

References MHD_DAUTH_EXT_PARAM_MIN_LEN, MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, MHD_DIGEST_AUTH_UNAME_TYPE_INVALID, MHD_DIGEST_AUTH_UNAME_TYPE_MISSING, MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD, MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH, and NULL.

Referenced by get_rq_uname(), get_rq_unames_size(), MHD_digest_auth_get_request_info3(), MHD_digest_auth_get_username(), and MHD_digest_auth_get_username3().

Here is the caller graph for this function:

◆ get_rq_unames_size()

_MHD_static_inline size_t get_rq_unames_size ( const struct MHD_RqDAuth * params,
enum MHD_DigestAuthUsernameType uname_type )

Get total size required for 'username' and 'userhash_bin'

Parameters
paramsthe Digest Authorization parameters
uname_typethe type of username
Returns
the total size required for 'username' and 'userhash_bin' is userhash is used

Definition at line 992 of file digestauth.c.

References get_rq_uname_type(), mhd_assert, MHD_DAUTH_EXT_PARAM_MIN_LEN, MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD, and MHD_DIGEST_AUTH_UNAME_TYPE_USERHASH.

Referenced by MHD_digest_auth_get_request_info3(), MHD_digest_auth_get_username(), and MHD_digest_auth_get_username3().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unquoted_param()

static enum _MHD_GetUnqResult get_unquoted_param ( const struct MHD_RqDAuthParam * param,
char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE],
char ** ptmp2,
size_t * ptmp2_size,
struct _MHD_str_w_len * unquoted )
static

Get Digest authorisation parameter as unquoted string.

Parameters
paramthe parameter to process
tmp1the small buffer in stack
ptmp2the pointer to pointer to malloc'ed buffer
ptmp2_sizethe pointer to the size of the buffer pointed by ptmp2
[out]unquotedthe pointer to store the result, NOT zero terminated
Returns
enum code indicating result of the process

Definition at line 2373 of file digestauth.c.

References _MHD_AUTH_DIGEST_MAX_PARAM_SIZE, _MHD_STATIC_UNQ_BUFFER_SIZE, _MHD_UNQ_OK, _MHD_UNQ_OUT_OF_MEM, _MHD_UNQ_TOO_LARGE, get_buffer_for_size(), _MHD_str_w_len::len, mhd_assert, NULL, and _MHD_str_w_len::str.

Referenced by digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_unquoted_param_copy()

static enum _MHD_GetUnqResult get_unquoted_param_copy ( const struct MHD_RqDAuthParam * param,
char tmp1[_MHD_STATIC_UNQ_BUFFER_SIZE],
char ** ptmp2,
size_t * ptmp2_size,
struct _MHD_mstr_w_len * unquoted )
static

Get copy of Digest authorisation parameter as unquoted string.

Parameters
paramthe parameter to process
tmp1the small buffer in stack
ptmp2the pointer to pointer to malloc'ed buffer
ptmp2_sizethe pointer to the size of the buffer pointed by ptmp2
[out]unquotedthe pointer to store the result, NOT zero terminated, but with enough space to zero-terminate
Returns
enum code indicating result of the process

Definition at line 2416 of file digestauth.c.

References _MHD_AUTH_DIGEST_MAX_PARAM_SIZE, _MHD_STATIC_UNQ_BUFFER_SIZE, _MHD_UNQ_OK, _MHD_UNQ_OUT_OF_MEM, _MHD_UNQ_TOO_LARGE, get_buffer_for_size(), _MHD_mstr_w_len::len, mhd_assert, NULL, and _MHD_mstr_w_len::str.

Referenced by digest_auth_check_all_inner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_param_equal()

_MHD_static_inline bool is_param_equal ( const struct MHD_RqDAuthParam * param,
const char *const str,
const size_t str_len )

Check whether Digest Auth request parameter is equal to given string

Parameters
paramthe parameter to check
strthe string to compare with, does not need to be zero-terminated
str_lenthe length of the str
Returns
true is parameter is equal to the given string, false otherwise

Definition at line 2458 of file digestauth.c.

References mhd_assert, and NULL.

Referenced by digest_auth_check_all_inner().

Here is the caller graph for this function:

◆ is_param_equal_caseless()

_MHD_static_inline bool is_param_equal_caseless ( const struct MHD_RqDAuthParam * param,
const char *const str,
const size_t str_len )

Check whether Digest Auth request parameter is caseless equal to given string

Parameters
paramthe parameter to check
strthe string to compare with, does not need to be zero-terminated
str_lenthe length of the str
Returns
true is parameter is caseless equal to the given string, false otherwise

Definition at line 2482 of file digestauth.c.

References mhd_assert, and NULL.

Referenced by digest_auth_check_all_inner().

Here is the caller graph for this function:

◆ is_slot_available()

static bool is_slot_available ( const struct MHD_NonceNc *const nn,
const uint64_t now,
const char *const new_nonce,
size_t new_nonce_len )
static

Check whether it is possible to use slot in nonce-nc map array.

Should be called with mutex held to avoid external modification of the slot data.

Parameters
nnthe pointer to the nonce-nc slot
nowthe current time
new_noncethe new nonce supposed to be stored in this slot, zero-terminated
new_nonce_lenthe length of the new_nonce in chars, not including the terminating zero.
Returns
true if the slot can be used to store the new nonce, false otherwise.

Definition at line 1641 of file digestauth.c.

References get_nonce_timestamp(), MAX_DIGEST_NONCE_LENGTH, mhd_assert, MHD_NonceNc::nc, MHD_NonceNc::nonce, NONCE_STD_LEN, REUSE_TIMEOUT, and TRIM_TO_TIMESTAMP.

Referenced by calculate_add_nonce().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_header()

static enum MHD_Result test_header ( void * cls,
const char * key,
size_t key_size,
const char * value,
size_t value_size,
enum MHD_ValueKind kind )
static

Test if the given key-value pair is in the headers for the given connection.

Parameters
clsthe test context
keythe key
key_sizenumber of bytes in key
valuethe value, can be NULL
value_sizenumber of bytes in value
kindtype of the header
Returns
MHD_YES if the key-value pair is in the headers, MHD_NO if not

Definition at line 2158 of file digestauth.c.

References MHD_HTTP_Req_Header::header, MHD_HTTP_Req_Header::header_size, MHD_Request::headers_received, MHD_HTTP_Req_Header::kind, mhd_assert, MHD_NO, MHD_YES, MHD_HTTP_Req_Header::next, NULL, MHD_Connection::rq, MHD_HTTP_Req_Header::value, and MHD_HTTP_Req_Header::value_size.

Referenced by check_argument_match().

Here is the caller graph for this function: