diff --git a/test/pkcs11_mbedtls_utest/core_pkcs11_mbedtls_utest.c b/test/pkcs11_mbedtls_utest/core_pkcs11_mbedtls_utest.c index 32494a27..941fb800 100644 --- a/test/pkcs11_mbedtls_utest/core_pkcs11_mbedtls_utest.c +++ b/test/pkcs11_mbedtls_utest/core_pkcs11_mbedtls_utest.c @@ -3212,10 +3212,13 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) CK_BYTE pulBuf[ sizeof( pulKnownBuf ) ] = { 0 }; CK_BYTE ulPoint[ pkcs11EC_POINT_LENGTH ] = { 0 }; CK_BYTE ulKnownPoint = 0x04; + CK_BYTE_PTR ulKnownPointLoc = &( ulKnownPoint ); CK_BBOOL xIsPrivate = CK_FALSE; CK_OBJECT_CLASS xPrivateKeyClass = { 0 }; CK_OBJECT_CLASS xKnownPrivateKeyClass = CKO_PRIVATE_KEY; CK_ATTRIBUTE xTemplate = { CKA_EC_PARAMS, pulBuf, sizeof( pulBuf ) }; + mbedtls_ecp_keypair xEcpKeyPair = { 0 }; + mbedtls_pk_context xKeyContext = { NULL, &xEcpKeyPair }; prvCommonInitStubs( &xSession ); @@ -3229,7 +3232,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) /* EC Params Case */ - mbedtls_pk_init_CMockIgnore(); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); mbedtls_x509_crt_init_CMockIgnore(); mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); PKCS11_PAL_GetObjectValueCleanup_CMockIgnore(); @@ -3245,6 +3249,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) xTemplate.pValue = NULL; xTemplate.ulValueLen = 0; + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_OK, xResult ); TEST_ASSERT_EQUAL( pkcs11EC_POINT_LENGTH, xTemplate.ulValueLen ); @@ -3252,6 +3258,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) xTemplate.pValue = &ulPoint; xTemplate.ulValueLen = sizeof( ulPoint ); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_OK, xResult ); TEST_ASSERT_EQUAL( ulKnownPoint, ulPoint[ 0 ] ); @@ -3260,6 +3268,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) xTemplate.ulValueLen = sizeof( ulPoint ); mbedtls_ecp_tls_write_point_IgnoreAndReturn( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_BUFFER_TOO_SMALL, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplate.ulValueLen ); @@ -3268,6 +3278,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) xTemplate.pValue = &ulPoint; xTemplate.ulValueLen = sizeof( ulPoint ); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_FUNCTION_FAILED, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplate.ulValueLen ); @@ -3277,6 +3289,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) /* Unknown attribute. */ xTemplate.type = CKA_SUBPRIME; + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_ATTRIBUTE_TYPE_INVALID, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplate.ulValueLen ); @@ -3287,6 +3301,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) xTemplate.ulValueLen = 0; mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_OK, xResult ); TEST_ASSERT_EQUAL( NULL, xTemplate.pValue ); @@ -3294,6 +3310,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) xTemplate.pValue = &xPrivateKeyClass; + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_OK, xResult ); TEST_ASSERT_EQUAL( sizeof( xPrivateKeyClass ), xTemplate.ulValueLen ); @@ -3307,6 +3325,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) PKCS11_PAL_GetObjectValue_ExpectAnyArgsAndReturn( CKR_OK ); PKCS11_PAL_GetObjectValue_ReturnThruPtr_pIsPrivate( &xIsPrivate ); PKCS11_PAL_GetObjectValue_ReturnThruPtr_pulDataSize( &ulLength ); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); mbedtls_pk_parse_key_IgnoreAndReturn( 1 ); mbedtls_pk_parse_public_key_ExpectAnyArgsAndReturn( 0 ); xResult = C_GetAttributeValue( xSession, xObjectPub, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); @@ -3321,6 +3341,8 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) PKCS11_PAL_GetObjectValue_ReturnThruPtr_pIsPrivate( &xIsPrivate ); PKCS11_PAL_GetObjectValue_ReturnThruPtr_pulDataSize( &ulLength ); mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObjectPub, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_BUFFER_TOO_SMALL, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplate.ulValueLen ); @@ -3331,6 +3353,9 @@ void test_pkcs11_C_GetAttributeValueAttParsing( void ) PKCS11_PAL_GetObjectValue_ExpectAnyArgsAndReturn( CKR_OK ); PKCS11_PAL_GetObjectValue_ReturnThruPtr_pIsPrivate( &xIsPrivate ); + PKCS11_PAL_GetObjectValue_ReturnThruPtr_ppucData( &ulKnownPointLoc ); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObjectPub, ( CK_ATTRIBUTE_PTR ) &xTemplate, ulCount ); TEST_ASSERT_EQUAL( CKR_OK, xResult ); TEST_ASSERT_EQUAL( 1, xTemplate.ulValueLen ); @@ -3373,6 +3398,8 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) CK_ULONG ulCount = 2; CK_BYTE ulPoint[ pkcs11EC_POINT_LENGTH ] = { 0 }; CK_ATTRIBUTE xTemplates[ 2 ] = { 0 }; + mbedtls_ecp_keypair xEcpKeyPair = { 0 }; + mbedtls_pk_context xKeyContext = { NULL, &xEcpKeyPair }; prvCommonInitStubs( &xSession ); @@ -3381,7 +3408,8 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xResult = prvCreateEcPriv( &xSession, &xObject ); TEST_ASSERT_EQUAL( CKR_OK, xResult ); - mbedtls_pk_init_CMockIgnore(); + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); mbedtls_x509_crt_init_CMockIgnore(); PKCS11_PAL_GetObjectValueCleanup_CMockIgnore(); mbedtls_pk_free_CMockIgnore(); @@ -3414,6 +3442,9 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 1 ].type = CKA_EC_POINT; xTemplates[ 1 ].pValue = NULL; xTemplates[ 1 ].ulValueLen = 0; + + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); /* CKR_ATTRIBUTE_TYPE_INVALID should be returned. */ @@ -3432,6 +3463,8 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 1 ].ulValueLen = 0; /* CKR_BUFFER_TOO_SMALL should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_BUFFER_TOO_SMALL, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 0 ].ulValueLen ); @@ -3449,13 +3482,14 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 1 ].ulValueLen = 0; /* CKR_BUFFER_TOO_SMALL should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_BUFFER_TOO_SMALL, xResult ); TEST_ASSERT_EQUAL( pkcs11EC_POINT_LENGTH, xTemplates[ 0 ].ulValueLen ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 1 ].ulValueLen ); /* CKR_ATTRIBUTE_SENSITIVE should be returned when getting CKA_VALUE type. */ - mbedtls_pk_parse_key_ExpectAnyArgsAndReturn( 0 ); xTemplates[ 0 ].type = CKA_VALUE; xTemplates[ 0 ].pValue = NULL; xTemplates[ 0 ].ulValueLen = 0; @@ -3466,6 +3500,9 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 1 ].ulValueLen = 0; /* CKA_PRIVATE_EXPONENT should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); + mbedtls_pk_parse_key_ExpectAnyArgsAndReturn( 0 ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_ATTRIBUTE_SENSITIVE, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 0 ].ulValueLen ); @@ -3477,20 +3514,20 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 0 ].ulValueLen = 0; /* CKR_ATTRIBUTE_SENSITIVE should be returned when getting CKA_VALUE type. */ - mbedtls_pk_parse_key_ExpectAnyArgsAndReturn( 0 ); xTemplates[ 1 ].type = CKA_VALUE; xTemplates[ 1 ].pValue = NULL; xTemplates[ 1 ].ulValueLen = 0; /* CKA_PRIVATE_EXPONENT should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); + mbedtls_pk_parse_key_ExpectAnyArgsAndReturn( 0 ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_ATTRIBUTE_SENSITIVE, xResult ); TEST_ASSERT_EQUAL( pkcs11EC_POINT_LENGTH, xTemplates[ 0 ].ulValueLen ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 1 ].ulValueLen ); /* CKR_FUNCTION_FAILED should be returned when mbedtls_ecp_tls_write_point returns -1. */ - mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); - mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xTemplates[ 0 ].type = CKA_EC_POINT; xTemplates[ 0 ].pValue = &ulPoint; xTemplates[ 0 ].ulValueLen = sizeof( ulPoint ); @@ -3501,6 +3538,10 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 1 ].ulValueLen = 0; /* CKR_FUNCTION_FAILED should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); + mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); + mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_FUNCTION_FAILED, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 0 ].ulValueLen ); @@ -3513,13 +3554,15 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 0 ].ulValueLen = 0; /* CKR_FUNCTION_FAILED should be returned when mbedtls_ecp_tls_write_point returns -1. */ - mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); - mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xTemplates[ 1 ].type = CKA_EC_POINT; xTemplates[ 1 ].pValue = &ulPoint; xTemplates[ 1 ].ulValueLen = sizeof( ulPoint ); /* CKR_FUNCTION_FAILED should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); + mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); + mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_FUNCTION_FAILED, xResult ); TEST_ASSERT_EQUAL( pkcs11EC_POINT_LENGTH, xTemplates[ 0 ].ulValueLen ); @@ -3531,21 +3574,21 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 0 ].ulValueLen = 0; /* CKR_FUNCTION_FAILED should be returned when mbedtls_ecp_tls_write_point returns -1. */ - mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); - mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xTemplates[ 1 ].type = CKA_EC_POINT; xTemplates[ 1 ].pValue = &ulPoint; xTemplates[ 1 ].ulValueLen = sizeof( ulPoint ); /* CKR_FUNCTION_FAILED should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); + mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); + mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_FUNCTION_FAILED, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 0 ].ulValueLen ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 1 ].ulValueLen ); /* CKR_FUNCTION_FAILED should be returned when mbedtls_ecp_tls_write_point returns -1. */ - mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); - mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xTemplates[ 0 ].type = CKA_EC_POINT; xTemplates[ 0 ].pValue = &ulPoint; xTemplates[ 0 ].ulValueLen = sizeof( ulPoint ); @@ -3556,6 +3599,10 @@ void test_pkcs11_C_GetAttributeValueMultipleAttParsing( void ) xTemplates[ 1 ].ulValueLen = 0; /* CKR_FUNCTION_FAILED should be returned. */ + mbedtls_pk_init_ExpectAnyArgs(); + mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); + mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); + mbedtls_ecp_tls_write_point_IgnoreAndReturn( -1 ); xResult = C_GetAttributeValue( xSession, xObject, ( CK_ATTRIBUTE_PTR ) &xTemplates, ulCount ); TEST_ASSERT_EQUAL( CKR_FUNCTION_FAILED, xResult ); TEST_ASSERT_EQUAL( CK_UNAVAILABLE_INFORMATION, xTemplates[ 0 ].ulValueLen ); @@ -3579,18 +3626,21 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) CK_OBJECT_HANDLE xObject = 0; CK_ULONG ulCount = 1; CK_ATTRIBUTE xTemplates[ 1 ] = { 0 }; - mbedtls_pk_context xKeyContext = { NULL, &xResult }; - CK_BYTE ulPoint[ pkcs11EC_POINT_LENGTH ] = { 0 }; + mbedtls_rsa_context xRsaContext = { 0 }; + mbedtls_pk_context xKeyContext = { NULL, &xRsaContext }; + mbedtls_mpi xMpi; prvCommonInitStubs( &xSession ); if( TEST_PROTECT() ) { - xResult = prvCreateEcPriv( &xSession, &xObject ); + xResult = prvCreateRsaPriv( &xSession, &xObject ); TEST_ASSERT_EQUAL( CKR_OK, xResult ); mbedtls_mpi_init_Ignore(); mbedtls_x509_crt_init_CMockIgnore(); + mbedtls_pk_parse_key_IgnoreAndReturn( 0 ); + PKCS11_PAL_GetObjectValue_IgnoreAndReturn( CKR_OK ); PKCS11_PAL_GetObjectValueCleanup_CMockIgnore(); mbedtls_pk_free_CMockIgnore(); mbedtls_x509_crt_free_CMockIgnore(); @@ -3598,8 +3648,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_MODULUS case */ /* Failure path */ xTemplates[ 0 ].type = CKA_MODULUS; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3611,8 +3661,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_MODULUS case */ /* Success path */ xTemplates[ 0 ].type = CKA_MODULUS; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3627,8 +3677,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PUBLIC_EXPONENT case */ /* Failure path */ xTemplates[ 0 ].type = CKA_PUBLIC_EXPONENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3640,8 +3690,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PUBLIC_EXPONENT case */ /* Success path */ xTemplates[ 0 ].type = CKA_PUBLIC_EXPONENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3656,8 +3706,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIME_1 case */ /* Failure path */ xTemplates[ 0 ].type = CKA_PRIME_1; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3669,8 +3719,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIME_1 case */ /* Success path */ xTemplates[ 0 ].type = CKA_PRIME_1; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3685,8 +3735,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIME_2 case */ /* Failure path */ xTemplates[ 0 ].type = CKA_PRIME_2; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3698,8 +3748,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIME_2 case */ /* Success path */ xTemplates[ 0 ].type = CKA_PRIME_2; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3714,8 +3764,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIVATE_EXPONENT case */ /* Failure path */ xTemplates[ 0 ].type = CKA_PRIVATE_EXPONENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3727,8 +3777,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIVATE_EXPONENT case */ /* Success path */ xTemplates[ 0 ].type = CKA_PRIVATE_EXPONENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3743,8 +3793,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIVATE_EXPONENT case */ /* Failure path */ xTemplates[ 0 ].type = CKA_PRIVATE_EXPONENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3756,8 +3806,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_PRIVATE_EXPONENT case */ /* Success path */ xTemplates[ 0 ].type = CKA_PRIVATE_EXPONENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3772,8 +3822,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_EXPONENT_1 case */ /* Failure path */ xTemplates[ 0 ].type = CKA_EXPONENT_1; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3785,8 +3835,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_EXPONENT_1 case */ /* Success path */ xTemplates[ 0 ].type = CKA_EXPONENT_1; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3801,8 +3851,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_EXPONENT_2 case */ /* Failure path */ xTemplates[ 0 ].type = CKA_EXPONENT_2; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3814,8 +3864,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_EXPONENT_2 case */ /* Success path */ xTemplates[ 0 ].type = CKA_EXPONENT_2; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3830,8 +3880,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_COEFFICIENT case */ /* Failure path */ xTemplates[ 0 ].type = CKA_COEFFICIENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3843,8 +3893,8 @@ void test_pkcs11_C_GetAttributeValueValidRsaContext( void ) /* CKA_COEFFICIENT case */ /* Success path */ xTemplates[ 0 ].type = CKA_COEFFICIENT; - xTemplates[ 0 ].pValue = &ulPoint; - xTemplates[ 0 ].ulValueLen = ( sizeof( mbedtls_mpi ) ); + xTemplates[ 0 ].pValue = &( xMpi ); + xTemplates[ 0 ].ulValueLen = sizeof( mbedtls_mpi ); mbedtls_pk_init_ExpectAnyArgs(); mbedtls_pk_init_ReturnThruPtr_ctx( &xKeyContext ); @@ -3920,7 +3970,6 @@ void test_pkcs11_C_GetAttributeValueModulusBadPath( void ) CK_OBJECT_HANDLE xObject = 0; CK_ULONG ulCount = 1; CK_ATTRIBUTE xTemplates[ 1 ] = { 0 }; - mbedtls_pk_context xKeyContext = { NULL, NULL }; CK_BYTE ulPoint[ pkcs11EC_POINT_LENGTH ] = { 0 }; prvCommonInitStubs( &xSession );