Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aggarw13 committed Aug 10, 2021
1 parent dea0cc9 commit 60ede09
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions test/unit-test/sigv4_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#define DATE "20150830T123600Z"
#define REGION "us-east-1"
#define SERVICE "iam"
#define HEADERS "Host: iam.amazonaws.com\r\nContent-Type: application/x-www-form-urlencoded; charset=utf-8\r\nX-Amz-Date: 20150830T123600Z\r\n\r\n"
#define HEADERS "Host: iam.amazonaws.com\r\nContent-Type: application/x-www-form-urlencoded; charset=utf-8\r\nX-Amz-Date: "DATE "\r\n\r\n"
#define PRECANON_HEADER "content-type:application/json;host:iam.amazonaws.com"
#define HEADERS_LENGTH ( sizeof( HEADERS ) - 1U )
#define SECURITY_TOKEN "security-token"
Expand All @@ -65,7 +65,7 @@
#define EXPIRATION_LENGTH ( sizeof( EXPIRATION ) - 1U )

/* Insufficient memory parameters for SIGV4_PROCESSING_BUFFER_LENGTH=350. In the comments below,
* + means concatenation. */
* + means concatenation, OOM means "Out of Memory", LF means newline character */

/* HTTP method + URI-encoded variant of this string must be greater than SIGV4_PROCESSING_BUFFER_LENGTH. */
#define PATH_FIRST_ENCODE_OOM \
Expand Down Expand Up @@ -167,7 +167,9 @@ void formatAndVerifyInputDate( const char * pInputDate,
tearDown();
}

static int32_t sha256_init( void * pHashContext )
/*==================== OpenSSL Based implementation of Crypto Interface ===================== */

static int32_t valid_sha256_init( void * pHashContext )
{
if( SHA256_Init( ( SHA256_CTX * ) pHashContext ) == 1 )
{
Expand All @@ -177,9 +179,9 @@ static int32_t sha256_init( void * pHashContext )
return -1;
}

static int32_t sha256_update( void * pHashContext,
const char * pInput,
size_t inputLen )
static int32_t valid_sha256_update( void * pHashContext,
const char * pInput,
size_t inputLen )
{
if( SHA256_Update( ( SHA256_CTX * ) pHashContext, pInput, inputLen ) )
{
Expand All @@ -189,9 +191,9 @@ static int32_t sha256_update( void * pHashContext,
return -1;
}

static int32_t sha256_final( void * pHashContext,
char * pOutput,
size_t outputLen )
static int32_t valid_sha256_final( void * pHashContext,
char * pOutput,
size_t outputLen )
{
if( SHA256_Final( pOutput, ( SHA256_CTX * ) pHashContext ) )
{
Expand All @@ -201,6 +203,8 @@ static int32_t sha256_final( void * pHashContext,
return -1;
}

/*==================== Echo Implementation of Crypto Interface ===================== */

static hashEchoBuffer[ SIGV4_HASH_MAX_BLOCK_LENGTH ];
static size_t hashInputLen;

Expand All @@ -227,6 +231,8 @@ static int32_t echo_hash_final( void * pHashContext,
( void ) memcpy( pOutput, hashEchoBuffer, hashInputLen );
}

/*==================== Failable Implementation of Crypto Interface ===================== */

/*
#define FAIL_HASH_INIT 1U,
#define FAIL_HASH_UPDATE 2U
Expand Down Expand Up @@ -280,6 +286,8 @@ static int32_t hash_final_failable( void * pHashContext,
return ret;
}

/*============================ Test Helpers ========================== */

static void resetFailableHashParams()
{
initHashCalledCount = 0U;
Expand Down Expand Up @@ -334,11 +342,11 @@ static void resetInputParams()
params.pService = SERVICE;
params.serviceLen = sizeof( SERVICE ) - 1U;
cryptoInterface.pHashContext = &sha256;
cryptoInterface.hashInit = sha256_init;
cryptoInterface.hashUpdate = sha256_update;
cryptoInterface.hashFinal = sha256_final;
cryptoInterface.hashBlockLen = SIGV4_SHA256_BLOCK_LENGTH;
cryptoInterface.hashDigestLen = SIGV4_SHA256_DIGEST_LENGTH;
cryptoInterface.hashInit = valid_sha256_init;
cryptoInterface.hashUpdate = valid_sha256_update;
cryptoInterface.hashFinal = valid_sha256_final;
cryptoInterface.hashBlockLen = SIGV4_HASH_MAX_BLOCK_LENGTH;
cryptoInterface.hashDigestLen = SIGV4_HASH_MAX_DIGEST_LENGTH;
params.pCryptoInterface = &cryptoInterface;
}

Expand Down Expand Up @@ -494,6 +502,8 @@ void test_SigV4_AwsIotDateToIso8601_Formatting_Error()
}
}

/* ======================= Testing SigV4_GenerateHTTPAuthorization =========================== */
/* TODO - Verify the generated signatures. */
void test_SigV4_GenerateHTTPAuthorization_Happy_Paths()
{
SigV4Status_t returnStatus;
Expand Down

0 comments on commit 60ede09

Please sign in to comment.