SigV4
v1.0.0
SigV4 Library for AWS Authentication
|
|
Go to the documentation of this file.
45 #ifndef SIGV4_DO_NOT_USE_CUSTOM_CONFIG
46 #include "sigv4_config.h"
58 #define SIGV4_AWS4_HMAC_SHA256 "AWS4-HMAC-SHA256"
59 #define SIGV4_AWS4_HMAC_SHA256_LENGTH ( sizeof( SIGV4_AWS4_HMAC_SHA256 ) - 1U )
60 #define SIGV4_HTTP_X_AMZ_DATE_HEADER "x-amz-date"
61 #define SIGV4_HTTP_X_AMZ_SECURITY_TOKEN_HEADER "x-amz-security-token"
63 #define SIGV4_STREAMING_AWS4_HMAC_SHA256_PAYLOAD "STREAMING-AWS4-HMAC-SHA256-PAYLOAD"
64 #define SIGV4_HTTP_X_AMZ_CONTENT_SHA256_HEADER "x-amz-content-sha256"
65 #define SIGV4_HTTP_X_AMZ_STORAGE_CLASS_HEADER "x-amz-storage-class"
67 #define SIGV4_ACCESS_KEY_ID_LENGTH 20U
68 #define SIGV4_SECRET_ACCESS_KEY_LENGTH 40U
70 #define SIGV4_ISO_STRING_LEN 16U
71 #define SIGV4_EXPECTED_LEN_RFC_3339 20U
72 #define SIGV4_EXPECTED_LEN_RFC_5322 29U
93 #define SIGV4_HTTP_PATH_IS_CANONICAL_FLAG 0x1U
102 #define SIGV4_HTTP_QUERY_IS_CANONICAL_FLAG 0x2U
111 #define SIGV4_HTTP_HEADERS_ARE_CANONICAL_FLAG 0x4U
120 #define SIGV4_HTTP_ALL_ARE_CANONICAL_FLAG 0x7U
126 typedef enum SigV4Status
210 typedef struct SigV4CryptoInterface
220 int32_t ( * hashInit )(
void * pHashContext );
232 int32_t ( * hashUpdate )(
void * pHashContext,
233 const uint8_t * pInput,
249 int32_t ( * hashFinal )(
void * pHashContext,
274 typedef struct SigV4HttpParameters
343 typedef struct SigV4Credentials
368 typedef struct SigV4Parameters
480 size_t * signatureLen );
550 size_t dateISO8601Len );
@ SigV4InvalidParameter
The SigV4 Utility library function received an invalid input parameter.
Definition: sigv4.h:145
@ SigV4MaxQueryPairCountExceeded
The maximum number of query parameters was exceeded while parsing the query string passed to the libr...
Definition: sigv4.h:186
size_t payloadLen
Length of pPayload.
Definition: sigv4.h:335
size_t algorithmLen
Length of pAlgorithm.
Definition: sigv4.h:388
size_t accessKeyIdLen
Length of pAccessKeyId.
Definition: sigv4.h:350
const char * pPayload
The HTTP response body, if one exists (ex. PUT request). If this body is chunked, then this field sho...
Definition: sigv4.h:334
The cryptography interface used to supply the user-defined hash implementation.
Definition: sigv4.h:211
@ SigV4HashError
An error occurred while performing a hash operation.
Definition: sigv4.h:194
Configurations for the AWS credentials used to generate the Signing Key.
Definition: sigv4.h:344
size_t regionLen
Length of pRegion.
Definition: sigv4.h:396
void * pHashContext
Context for the hashInit, hashUpdate, and hashFinal interfaces.
Definition: sigv4.h:256
The default values for configuration macros used by the SigV4 Utility Library.
@ SigV4Success
The SigV4 Utility library function completed successfully.
Definition: sigv4.h:135
size_t queryLen
Length of pQuery.
Definition: sigv4.h:315
size_t pathLen
Length of pPath.
Definition: sigv4.h:303
const char * pAlgorithm
The algorithm used for SigV4 authentication. If set to NULL, this will automatically be set to "AWS4-...
Definition: sigv4.h:386
const char * pQuery
The HTTP request query from the URL, if it exists. This contains all characters following the questio...
Definition: sigv4.h:314
Configurations of the HTTP request used to create the Canonical Request.
Definition: sigv4.h:275
const char * pAccessKeyId
The pAccessKeyId MUST be at least 16 characters long but not more than 128 characters long.
Definition: sigv4.h:349
SigV4Status_t SigV4_GenerateHTTPAuthorization(const SigV4Parameters_t *pParams, char *pAuthBuf, size_t *authBufLen, char **pSignature, size_t *signatureLen)
Generates the HTTP Authorization header value.
Definition: sigv4.c:3000
const char * pRegion
The target AWS region for the request. Please see https://docs.aws.amazon.com/general/latest/gr/rande...
Definition: sigv4.h:395
size_t hashBlockLen
The block length of the hash function.
Definition: sigv4.h:261
const char * pSecretAccessKey
The pSecretAccessKey MUST be at least 40 characters long.
Definition: sigv4.h:355
size_t hashDigestLen
The digest length of the hash function.
Definition: sigv4.h:266
@ SigV4ISOFormattingError
An error occurred while formatting the provided date header.
Definition: sigv4.h:162
size_t serviceLen
Length of pService.
Definition: sigv4.h:406
size_t httpMethodLen
Length of pHttpMethod.
Definition: sigv4.h:277
const char * pHeaders
The headers from the HTTP request that we want to sign. This should be the raw headers in HTTP reques...
Definition: sigv4.h:326
SigV4HttpParameters_t * pHttpParameters
HTTP specific SigV4 parameters for canonical request calculation.
Definition: sigv4.h:416
const char * pHttpMethod
The HTTP method: GET, POST, PUT, etc.
Definition: sigv4.h:276
Complete configurations required for generating "String to Sign" and "Signing Key" values.
Definition: sigv4.h:369
@ SigV4MaxHeaderPairCountExceeded
The maximum number of header parameters was exceeded while parsing the http header string passed to t...
Definition: sigv4.h:174
uint32_t flags
These flags are used to indicate if the path, query, or headers are already in the canonical form....
Definition: sigv4.h:290
SigV4Status_t SigV4_AwsIotDateToIso8601(const char *pDate, size_t dateLen, char *pDateISO8601, size_t dateISO8601Len)
Parse the date header value from the AWS IoT response, and generate the formatted ISO 8601 date requi...
Definition: sigv4.c:2924
SigV4Credentials_t * pCredentials
The AccessKeyId, SecretAccessKey, and SecurityToken used to generate the Authorization header.
Definition: sigv4.h:374
size_t secretAccessKeyLen
Length of pSecretAccessKey.
Definition: sigv4.h:356
const char * pDateIso8601
The date in ISO 8601 format, e.g. "20150830T123600Z". This is always 16 characters long.
Definition: sigv4.h:380
@ SigV4InsufficientMemory
The application buffer was not large enough for the specified hash function.
Definition: sigv4.h:154
SigV4CryptoInterface_t * pCryptoInterface
The cryptography interface.
Definition: sigv4.h:411
const char * pPath
The path in the HTTP request. This is the absolute request URI, which contains everything in the URI ...
Definition: sigv4.h:302
size_t headersLen
Length of pHeaders.
Definition: sigv4.h:327
@ SigV4InvalidHttpHeaders
HTTP headers parsed to the library are invalid.
Definition: sigv4.h:202
SigV4Status_t
Return status of the SigV4 Utility Library.
Definition: sigv4.h:127
const char * pService
The target AWS service for the request. The service name can be found as the first segment of the ser...
Definition: sigv4.h:405