Go to the documentation of this file.
47 #define TRACE_LEVEL HTTP_TRACE_LEVEL
56 #if (HTTP_CLIENT_SUPPORT == ENABLED && HTTP_CLIENT_AUTH_SUPPORT == ENABLED)
80 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
111 authParams = &context->authParams;
113 #if (HTTP_CLIENT_BASIC_AUTH_SUPPORT == ENABLED)
129 p = context->buffer + context->bufferLen - 2;
158 context->bufferLen = context->bufferLen +
n + 2;
162 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
174 context->buffer[context->bufferLen] =
'\0';
199 if(context->randCallback == NULL)
204 error = context->randCallback((uint8_t *) authParams->
cnonce,
221 osStrlen(context->method), uri, uriLen, response);
236 p = context->buffer + context->bufferLen - 2;
268 if(authParams->
opaque[0] !=
'\0')
278 context->bufferLen = context->bufferLen +
n + 2;
319 if(param.
value == NULL && (*
p ==
' ' || *
p ==
'\t'))
324 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED && HTTP_CLIENT_MD5_SUPPORT == ENABLED)
359 if(param.
value != NULL)
369 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
432 #if (HTTP_CLIENT_BASIC_AUTH_SUPPORT == ENABLED)
442 context->authParams.selectedMode = authHeader.
mode;
448 context->authParams.realm[authHeader.
realmLen] =
'\0';
453 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
467 context->authParams.selectedMode = authHeader.
mode;
469 context->authParams.qop = authHeader.
qop;
471 context->authParams.algorithm = authHeader.
algorithm;
477 context->authParams.realm[authHeader.
realmLen] =
'\0';
483 context->authParams.nonce[authHeader.
nonceLen] =
'\0';
489 context->authParams.opaque[authHeader.
opaqueLen] =
'\0';
492 context->authParams.stale = authHeader.
stale;
523 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
532 for(i = 0; i < param->
valueLen; i += (
n + 1))
571 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
572 #if (HTTP_CLIENT_MD5_SUPPORT == ENABLED)
581 #if (HTTP_CLIENT_SHA256_SUPPORT == ENABLED)
590 #if (HTTP_CLIENT_SHA512_256_SUPPORT == ENABLED)
621 const char_t *method,
size_t methodLen,
const char_t *uri,
622 size_t uriLen,
char_t *response)
624 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
639 hash->
init(&hashContext);
641 hash->
update(&hashContext,
":", 1);
643 hash->
update(&hashContext,
":", 1);
645 hash->
final(&hashContext, ha1);
648 hash->
init(&hashContext);
649 hash->
update(&hashContext, method, methodLen);
650 hash->
update(&hashContext,
":", 1);
651 hash->
update(&hashContext, uri, uriLen);
652 hash->
final(&hashContext, ha2);
655 hash->
init(&hashContext);
663 hash->
update(&hashContext, buffer, 2);
667 hash->
update(&hashContext,
":", 1);
669 hash->
update(&hashContext,
":", 1);
679 hash->
update(&hashContext, buffer, 8);
680 hash->
update(&hashContext,
":", 1);
682 hash->
update(&hashContext,
":", 1);
683 hash->
update(&hashContext,
"auth", 4);
684 hash->
update(&hashContext,
":", 1);
693 hash->
update(&hashContext, buffer, 2);
697 hash->
final(&hashContext, (uint8_t *) response);
Generic hash algorithm context.
HttpAuthMode selectedMode
Selected HTTP authentication mode.
error_t httpClientComputeDigest(HttpClientAuthParams *authParams, const char_t *method, size_t methodLen, const char_t *uri, size_t uriLen, char_t *response)
Digest operation.
void base64Encode(const void *input, size_t inputLen, char_t *output, size_t *outputLen)
Base64 encoding algorithm.
void httpEncodeHexString(const uint8_t *input, size_t inputLen, char_t *output)
Convert byte array to hex string.
bool_t httpCompareParamName(const HttpParam *param, const char_t *name)
Compare parameter name with the supplied string.
bool_t httpCompareParamValue(const HttpParam *param, const char_t *value)
Compare parameter name with the supplied string.
#define osStrncasecmp(s1, s2, length)
char_t cnonce[HTTP_CLIENT_CNONCE_SIZE *2+1]
Cnonce value.
#define HttpClientContext
#define HTTP_CLIENT_MAX_OPAQUE_LEN
char_t password[HTTP_CLIENT_MAX_PASSWORD_LEN+1]
Password.
#define osSprintf(dest,...)
char_t username[HTTP_CLIENT_MAX_USERNAME_LEN+1]
User name.
uint_t allowedModes
Allowed HTTP authentication modes.
@ ERROR_FAILURE
Generic error code.
#define HTTP_CLIENT_MAX_NONCE_LEN
#define HTTP_CLIENT_MAX_REALM_LEN
char_t realm[HTTP_CLIENT_MAX_REALM_LEN+1]
Realm.
char_t nonce[HTTP_CLIENT_MAX_NONCE_LEN+1]
Nonce value.
HTTP client (HyperText Transfer Protocol)
error_t httpClientParseWwwAuthenticateField(HttpClientContext *context, const char_t *value)
Parse WWW-Authenticate header field.
HttpAuthQop qop
Quality of protection.
const HashAlgo * algorithm
Digest algorithm.
void httpClientParseQopParam(const HttpParam *param, HttpWwwAuthenticateHeader *authHeader)
Parse qop parameter.
HTTP authentication parameters.
#define HTTP_CLIENT_CNONCE_SIZE
#define osStrncpy(s1, s2, length)
void httpClientInitAuthParams(HttpClientAuthParams *authParams)
Initialize HTTP authentication parameters.
#define SHA512_256_HASH_ALGO
#define HTTP_CLIENT_BUFFER_SIZE
Common interface for hash algorithms.
#define HTTP_CLIENT_MAX_RESPONSE_LEN
#define HTTP_CLIENT_MAX_HASH_DIGEST_SIZE
error_t httpClientFormatAuthorizationField(HttpClientContext *context)
Format Authorization header field.
#define osMemset(p, value, length)
char_t opaque[HTTP_CLIENT_MAX_OPAQUE_LEN+1]
Opaque parameter.
error_t httpParseParam(const char_t **pos, HttpParam *param)
Parse a list of parameters.
void httpClientParseAlgorithmParam(const HttpParam *param, HttpWwwAuthenticateHeader *authHeader)
Parse algorithm parameter.