Skip to content

Commit cad40e1

Browse files
Ron EldorRon Eldor
Ron Eldor
authored and
Ron Eldor
committed
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.
1 parent 4ea6882 commit cad40e1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

features/cryptocell/FEATURE_CRYPTOCELL310/trng.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "trng_api.h"
2525
#include "mbedtls/platform.h"
2626

27-
extern mbedtls_platform_context ctx;
27+
extern mbedtls_platform_context plat_ctx;
2828
static CRYS_RND_WorkBuff_t rndWorkBuff = { { 0 } };
2929

3030
/* Implementation that should never be optimized out by the compiler */
@@ -49,7 +49,7 @@ CRYSError_t LLF_RND_GetTrngSource(
4949

5050
void trng_init(trng_t *obj)
5151
{
52-
RNG_PLAT_SetUserRngParameters(&ctx.platform_impl_ctx.rndState, obj);
52+
RNG_PLAT_SetUserRngParameters(&plat_ctx.platform_impl_ctx.rndState, obj);
5353
}
5454

5555
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
6767
uint32_t actualLength;
6868

6969
ret = LLF_RND_GetTrngSource(
70-
&ctx.platform_impl_ctx.rndState , /*in/out*/
70+
&plat_ctx.platform_impl_ctx.rndState , /*in/out*/
7171
obj, /*in/out*/
7272
0, /*in*/
7373
&entropySizeBits, /*in/out*/

features/mbedtls/platform/src/platform_alt.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@
2222
#if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
2323
#include "mbed_critical.h"
2424

25-
mbedtls_platform_context ctx = { { 0 } };
25+
mbedtls_platform_context plat_ctx = { { 0 } };
2626

2727
int mbedtls_platform_setup( mbedtls_platform_context *unused_ctx )
2828
{
2929
int ret = 0;
3030

31-
core_util_atomic_incr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 );
31+
core_util_atomic_incr_u32( ( volatile uint32_t * )&plat_ctx.reference_count, 1 );
3232

33-
if( ctx.reference_count == 1 )
33+
if( plat_ctx.reference_count == 1 )
3434
{
3535
/* call platform specific code to setup crypto driver */
36-
ret = crypto_platform_setup( &ctx.platform_impl_ctx );
36+
ret = crypto_platform_setup( &plat_ctx.platform_impl_ctx );
3737
}
3838
return ( ret );
3939
}
4040

4141
void mbedtls_platform_teardown( mbedtls_platform_context *unused_ctx )
4242
{
43-
core_util_atomic_decr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 );
44-
if( ctx.reference_count < 1 )
43+
core_util_atomic_decr_u32( ( volatile uint32_t * )&plat_ctx.reference_count, 1 );
44+
if( plat_ctx.reference_count < 1 )
4545
{
4646
/* call platform specific code to terminate crypto driver */
47-
crypto_platform_terminate( &ctx.platform_impl_ctx );
48-
ctx.reference_count = 0;
47+
crypto_platform_terminate( &plat_ctx.platform_impl_ctx );
48+
plat_ctx.reference_count = 0;
4949
}
5050
}
5151

0 commit comments

Comments
 (0)