mirror of https://github.com/ARMmbed/mbed-os.git
Rename the platform context varaiable
Rename the generic name `ctx` of `mbedtls_platform_context` in `platform_alt.c` to a specific name `plat_ctx`, to avoid conflicts when used as external in crypto modules.pull/9452/head
parent
4ea68829c5
commit
cad40e1633
|
@ -24,7 +24,7 @@
|
|||
#include "trng_api.h"
|
||||
#include "mbedtls/platform.h"
|
||||
|
||||
extern mbedtls_platform_context ctx;
|
||||
extern mbedtls_platform_context plat_ctx;
|
||||
static CRYS_RND_WorkBuff_t rndWorkBuff = { { 0 } };
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
|
@ -49,7 +49,7 @@ CRYSError_t LLF_RND_GetTrngSource(
|
|||
|
||||
void trng_init(trng_t *obj)
|
||||
{
|
||||
RNG_PLAT_SetUserRngParameters(&ctx.platform_impl_ctx.rndState, obj);
|
||||
RNG_PLAT_SetUserRngParameters(&plat_ctx.platform_impl_ctx.rndState, obj);
|
||||
}
|
||||
|
||||
void trng_free(trng_t *obj)
|
||||
|
@ -67,7 +67,7 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *outputLe
|
|||
uint32_t actualLength;
|
||||
|
||||
ret = LLF_RND_GetTrngSource(
|
||||
&ctx.platform_impl_ctx.rndState , /*in/out*/
|
||||
&plat_ctx.platform_impl_ctx.rndState , /*in/out*/
|
||||
obj, /*in/out*/
|
||||
0, /*in*/
|
||||
&entropySizeBits, /*in/out*/
|
||||
|
|
|
@ -22,30 +22,30 @@
|
|||
#if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
|
||||
#include "mbed_critical.h"
|
||||
|
||||
mbedtls_platform_context ctx = { { 0 } };
|
||||
mbedtls_platform_context plat_ctx = { { 0 } };
|
||||
|
||||
int mbedtls_platform_setup( mbedtls_platform_context *unused_ctx )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
core_util_atomic_incr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 );
|
||||
core_util_atomic_incr_u32( ( volatile uint32_t * )&plat_ctx.reference_count, 1 );
|
||||
|
||||
if( ctx.reference_count == 1 )
|
||||
if( plat_ctx.reference_count == 1 )
|
||||
{
|
||||
/* call platform specific code to setup crypto driver */
|
||||
ret = crypto_platform_setup( &ctx.platform_impl_ctx );
|
||||
ret = crypto_platform_setup( &plat_ctx.platform_impl_ctx );
|
||||
}
|
||||
return ( ret );
|
||||
}
|
||||
|
||||
void mbedtls_platform_teardown( mbedtls_platform_context *unused_ctx )
|
||||
{
|
||||
core_util_atomic_decr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 );
|
||||
if( ctx.reference_count < 1 )
|
||||
core_util_atomic_decr_u32( ( volatile uint32_t * )&plat_ctx.reference_count, 1 );
|
||||
if( plat_ctx.reference_count < 1 )
|
||||
{
|
||||
/* call platform specific code to terminate crypto driver */
|
||||
crypto_platform_terminate( &ctx.platform_impl_ctx );
|
||||
ctx.reference_count = 0;
|
||||
crypto_platform_terminate( &plat_ctx.platform_impl_ctx );
|
||||
plat_ctx.reference_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue