SigV4
v1.0.0
SigV4 Library for AWS Authentication
|
|
Go to the documentation of this file.
28 #ifndef SIGV4_INTERNAL_H_
29 #define SIGV4_INTERNAL_H_
41 #ifndef SIGV4_DO_NOT_USE_CUSTOM_CONFIG
42 #include "sigv4_config.h"
50 #define YEAR_MIN 1900L
51 #define MONTH_ASCII_LEN 3U
56 #define MONTH_NAMES { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
61 #define MONTH_DAYS { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
63 #define FORMAT_RFC_3339 "%4Y-%2M-%2DT%2h:%2m:%2sZ"
64 #define FORMAT_RFC_3339_LEN sizeof( FORMAT_RFC_3339 ) - 1U
66 #define FORMAT_RFC_5322 "%3*, %2D %3M %4Y %2h:%2m:%2s GMT"
67 #define FORMAT_RFC_5322_LEN sizeof( FORMAT_RFC_5322 ) - 1U
69 #define ISO_YEAR_LEN 4U
70 #define ISO_NON_YEAR_LEN 2U
72 #define ISO_DATE_SCOPE_LEN 8U
79 #define CREDENTIAL_SCOPE_SEPARATOR '/'
80 #define CREDENTIAL_SCOPE_SEPARATOR_LEN 1U
85 #define CREDENTIAL_SCOPE_TERMINATOR "aws4_request"
86 #define CREDENTIAL_SCOPE_TERMINATOR_LEN ( sizeof( CREDENTIAL_SCOPE_TERMINATOR ) - 1U )
91 #define HTTP_EMPTY_PATH "/"
92 #define HTTP_EMPTY_PATH_LEN ( sizeof( HTTP_EMPTY_PATH ) - 1U )
94 #define URI_ENCODED_SPECIAL_CHAR_SIZE 3U
95 #define URI_DOUBLE_ENCODED_EQUALS_CHAR_SIZE 5U
97 #define LINEFEED_CHAR '\n'
98 #define LINEFEED_CHAR_LEN 1U
100 #define HTTP_REQUEST_LINE_ENDING "\r\n"
101 #define HTTP_REQUEST_LINE_ENDING_LEN ( sizeof( HTTP_REQUEST_LINE_ENDING ) - 1U )
103 #define SPACE_CHAR ' '
104 #define SPACE_CHAR_LEN 1U
106 #define S3_SERVICE_NAME "s3"
107 #define S3_SERVICE_NAME_LEN ( sizeof( S3_SERVICE_NAME ) - 1U )
109 #define SIGV4_HMAC_SIGNING_KEY_PREFIX "AWS4"
110 #define SIGV4_HMAC_SIGNING_KEY_PREFIX_LEN ( sizeof( SIGV4_HMAC_SIGNING_KEY_PREFIX ) - 1U )
112 #define AUTH_CREDENTIAL_PREFIX "Credential="
113 #define AUTH_CREDENTIAL_PREFIX_LEN ( sizeof( AUTH_CREDENTIAL_PREFIX ) - 1U )
114 #define AUTH_SEPARATOR ", "
115 #define AUTH_SEPARATOR_LEN ( sizeof( AUTH_SEPARATOR ) - 1U )
116 #define AUTH_SIGNED_HEADERS_PREFIX "SignedHeaders="
117 #define AUTH_SIGNED_HEADERS_PREFIX_LEN ( sizeof( AUTH_SIGNED_HEADERS_PREFIX ) - 1U )
118 #define AUTH_SIGNATURE_PREFIX "Signature="
119 #define AUTH_SIGNATURE_PREFIX_LEN ( sizeof( AUTH_SIGNATURE_PREFIX ) - 1U )
121 #define HMAC_INNER_PAD_BYTE ( 0x36U )
122 #define HMAC_OUTER_PAD_BYTE ( 0x5CU )
127 #define LOG_INSUFFICIENT_MEMORY_ERROR( purposeOfWrite, bytesExceeded ) \
129 LogError( ( "Unable to " purposeOfWrite ": Insufficient memory configured in \"SIGV4_PROCESSING_BUFFER_LENGTH\" macro. BytesExceeded=%lu", \
130 ( unsigned long ) ( bytesExceeded ) ) ); \
136 #define FLAG_IS_SET( bits, flag ) ( ( ( bits ) & ( flag ) ) == ( flag ) )
146 #define isWhitespace( c ) ( ( ( c ) == ' ' ) || ( ( c ) == '\t' ) )
153 typedef struct SigV4DateTime
168 typedef struct SigV4String
179 typedef struct SigV4ConstString
190 typedef struct SigV4KeyValuePair
200 typedef struct CanonicalContext
214 typedef struct HmacContext
const SigV4CryptoInterface_t * pCryptoInterface
The cryptography interface.
Definition: sigv4_internal.h:219
int32_t tm_mday
Definition: sigv4_internal.h:157
#define SIGV4_PROCESSING_BUFFER_LENGTH
Macro defining the size of the internal buffer used for incremental canonicalization and hashing.
Definition: sigv4_config_defaults.h:76
An aggregator to maintain the internal state of HMAC calculations.
Definition: sigv4_internal.h:215
const char * pData
Definition: sigv4_internal.h:181
#define SIGV4_HASH_MAX_BLOCK_LENGTH
Macro indicating the largest block size of any hashing algorithm used for SigV4 authentication i....
Definition: sigv4_config_defaults.h:130
The cryptography interface used to supply the user-defined hash implementation.
Definition: sigv4.h:211
#define SIGV4_MAX_QUERY_PAIR_COUNT
Macro defining the maximum number of query key/value pairs, used to assist the library in sorting que...
Definition: sigv4_config_defaults.h:104
int32_t tm_mon
Definition: sigv4_internal.h:156
A library structure holding the string and length values of parameters to be sorted and standardized....
Definition: sigv4_internal.h:180
The default values for configuration macros used by the SigV4 Utility Library.
char * pData
Definition: sigv4_internal.h:170
A key-value pair data structure that allows for sorting of SigV4 string values using internal compari...
Definition: sigv4_internal.h:191
int32_t tm_min
Definition: sigv4_internal.h:159
size_t dataLen
Definition: sigv4_internal.h:182
SigV4ConstString_t value
Definition: sigv4_internal.h:193
char * pBufCur
Definition: sigv4_internal.h:206
A library structure holding the string and length values of parameters to be sorted and standardized....
Definition: sigv4_internal.h:169
SigV4ConstString_t key
Definition: sigv4_internal.h:192
int32_t tm_year
Definition: sigv4_internal.h:155
size_t keyLen
The length of the accumulated key data.
Definition: sigv4_internal.h:229
An aggregator representing the individually parsed elements of the user-provided date parameter....
Definition: sigv4_internal.h:154
size_t dataLen
Definition: sigv4_internal.h:171
int32_t tm_sec
Definition: sigv4_internal.h:160
size_t bufRemaining
Definition: sigv4_internal.h:207
An aggregator to maintain the internal state of canonicalization during intermediate calculations.
Definition: sigv4_internal.h:201
int32_t tm_hour
Definition: sigv4_internal.h:158
#define SIGV4_MAX_HTTP_HEADER_COUNT
Macro defining the maximum number of headers in the request, used to assist the library in sorting he...
Definition: sigv4_config_defaults.h:90