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)
72 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
103 authParams = &context->authParams;
105 #if (HTTP_CLIENT_BASIC_AUTH_SUPPORT == ENABLED)
120 p = context->buffer + context->bufferLen - 2;
149 context->bufferLen = context->bufferLen +
n + 2;
153 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
164 context->buffer[context->bufferLen] =
'\0';
189 if(context->randCallback == NULL)
194 error = context->randCallback((uint8_t *) authParams->
cnonce,
211 osStrlen(context->method), uri, uriLen, response);
226 p = context->buffer + context->bufferLen - 2;
258 if(authParams->
opaque[0] !=
'\0')
268 context->bufferLen = context->bufferLen +
n + 2;
309 if(param.
value == NULL && (*
p ==
' ' || *
p ==
'\t'))
314 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED && HTTP_CLIENT_MD5_SUPPORT == ENABLED)
349 if(param.
value != NULL)
359 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
422 #if (HTTP_CLIENT_BASIC_AUTH_SUPPORT == ENABLED)
429 context->authParams.mode = authHeader.
mode;
433 context->authParams.realm[authHeader.
realmLen] =
'\0';
437 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
448 context->authParams.mode = authHeader.
mode;
450 context->authParams.qop = authHeader.
qop;
452 context->authParams.algorithm = authHeader.
algorithm;
456 context->authParams.realm[authHeader.
realmLen] =
'\0';
460 context->authParams.nonce[authHeader.
nonceLen] =
'\0';
464 context->authParams.opaque[authHeader.
opaqueLen] =
'\0';
467 context->authParams.stale = authHeader.
stale;
497 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
506 for(i = 0; i < param->
valueLen; i += (
n + 1))
545 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
546 #if (HTTP_CLIENT_MD5_SUPPORT == ENABLED)
555 #if (HTTP_CLIENT_SHA256_SUPPORT == ENABLED)
564 #if (HTTP_CLIENT_SHA512_256_SUPPORT == ENABLED)
595 const char_t *method,
size_t methodLen,
const char_t *uri,
596 size_t uriLen,
char_t *response)
598 #if (HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED)
613 hash->
init(&hashContext);
615 hash->
update(&hashContext,
":", 1);
617 hash->
update(&hashContext,
":", 1);
619 hash->
final(&hashContext, ha1);
622 hash->
init(&hashContext);
623 hash->
update(&hashContext, method, methodLen);
624 hash->
update(&hashContext,
":", 1);
625 hash->
update(&hashContext, uri, uriLen);
626 hash->
final(&hashContext, ha2);
629 hash->
init(&hashContext);
637 hash->
update(&hashContext, buffer, 2);
641 hash->
update(&hashContext,
":", 1);
643 hash->
update(&hashContext,
":", 1);
653 hash->
update(&hashContext, buffer, 8);
654 hash->
update(&hashContext,
":", 1);
656 hash->
update(&hashContext,
":", 1);
657 hash->
update(&hashContext,
"auth", 4);
658 hash->
update(&hashContext,
":", 1);
667 hash->
update(&hashContext, buffer, 2);
671 hash->
final(&hashContext, (uint8_t *) response);
Generic hash algorithm context.
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.
@ 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.
HttpAuthMode mode
HTTP authentication mode.
void httpClientParseAlgorithmParam(const HttpParam *param, HttpWwwAuthenticateHeader *authHeader)
Parse algorithm parameter.