SigV4 v1.2.0
SigV4 Library for AWS Authentication
SigV4_GenerateHTTPAuthorization

Generates the HTTP Authorization header value.

char * pAuthBuf,
size_t * authBufLen,
char ** pSignature,
size_t * signatureLen );
SigV4Status_t
Return status of the SigV4 Library.
Definition: sigv4.h:142
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:3186
Complete configurations required for generating "String to Sign" and "Signing Key" values.
Definition: sigv4.h:384
Note
The API does not support HTTP headers containing empty HTTP header keys or values.
Parameters
[in]pParamsParameters for generating the SigV4 signature.
[out]pAuthBufBuffer to hold the generated Authorization header value.
[in,out]authBufLenInput: the length of pAuthBuf, output: the length of the authorization value written to the buffer.
[out]pSignatureLocation of the signature in the authorization string.
[out]signatureLenThe length of pSignature.
Returns
SigV4Success if successful, error code otherwise.

Example

// The following example shows how to use the SigV4_GenerateHTTPAuthorization
// function to generate the HTTP Authorization header value for HTTP requests
// to AWS services requiring SigV4 authentication.
// Buffer to hold the authorization header.
char pSigv4Auth[ 2048U ];
size_t sigv4AuthLen = sizeof( pSigv4Auth );
// Pointer to signature in the Authorization header that will be populated in
// pSigv4Auth by the SigV4_GenerateHTTPAuthorization API function.
char * signature = NULL;
size_t signatureLen = 0;
SigV4Parameters_t sigv4Params =
{
// Parsed temporary credentials obtained from AWS IoT Credential Provider.
.pCredentials = &sigv4Creds,
// Date in ISO8601 format.
.pDateIso8601 = pDateISO8601,
// The AWS region for the request.
.pRegion = AWS_REGION,
.regionLen = strlen( AWS_REGION ),
// The AWS service for the request.
.pService = AWS_SERVICE_NAME,
.serviceLen = strlen( AWS_SERVICE_NAME ),
// SigV4 crypto interface. See SigV4CryptoInterface_t interface documentation.
.pCryptoInterface = &cryptoInterface,
// HTTP parameters for the HTTP request to generate a SigV4 authorization header for.
.pHttpParameters = &sigv4HttpParams
};
status = SigV4_GenerateHTTPAuthorization( &sigv4Params, pSigv4Auth, &sigv4AuthLen, &signature, &signatureLen );
if( status != SigV4Success )
{
// Failed to generate authorization header.
}
@ SigV4Success
The SigV4 library function completed successfully.
Definition: sigv4.h:150
SigV4Credentials_t * pCredentials
The AccessKeyId, SecretAccessKey, and SecurityToken used to generate the Authorization header.
Definition: sigv4.h:389