Skip to content

Commit a1ea814

Browse files
Ron EldorRon Eldor
authored andcommitted
Minor style fixes
Fix styls issues and rename ARM to Arm. Address additional minor comments from review.
1 parent c5ea8d7 commit a1ea814

File tree

18 files changed

+34
-28
lines changed

18 files changed

+34
-28
lines changed

features/mbedtls/targets/TARGET_CRYPTOCELL310/Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ To port your CC 310 driver to Mbed OS on your specific target, do the following:
1212

1313
1. In `targets.json` add the following to your target:
1414
* `MBEDTLS_CONFIG_HW_SUPPORT` to `macros_add` key. This instructs Mbed TLS to look for an alternative cryptographic implementation.
15-
* `CRYPTOCELL` to `device_has_add` key. Use this in your common code that you need to remove from compilation in case CC exists in your board. Use `#if !defined(DEVICE_CRYPTOCELL)` or `#if DEVICE_CRYPTOCELL`.
15+
* `CRYPTOCELL` to `device_has_add` key. Use this in your common code that you need to remove from compilation in case CC exists in your board. Use `#if !defined(DEVICE_CRYPTOCELL)` and `#if defined(DEVICE_CRYPTOCELL)`.
1616
* `CRYPTOCELL310` to `extra_labels_add` key. The build system uses this to look for the CC 310 code and binaries.
1717
1. In `objects.h`, include `objects_cryptocell.h`. You can use the `DEVICE_CRYPTOCELL` precompilation check as defined above.
1818
1. In `features/mbedtls/targets/TARGET_CRYPTOCELL310/TARGET_<target name>`, add your platform-specific libraries for all toolchains in `TOOLCHAIN_ARM`, `TOOLCHAIN_GCC_ARM` and `TOOLCHAIN_IAR` respectively.
1919
1. Add your CC setup code:
20-
* Implement `cc_platform_setup()` and `cc_platform_terminate()` to enable CC on your platform, in case you have board-specific setup functionality, required for CC setup. You can implement these functions as empty functions.
20+
* Implement `cc_platform_setup()` and `cc_platform_terminate()` to enable CC on your platform, in case you have board-specific setup functionality, required for CC setup.These functions can be empty.
2121
* Define `cc_platform_ctx` in `cc_platform.h` in a way that suits your implementation.
2222

features/mbedtls/targets/TARGET_CRYPTOCELL310/TARGET_NRF52840_DK/cc_platform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* cc_platform.h
33
*
4-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
4+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may

features/mbedtls/targets/TARGET_CRYPTOCELL310/TARGET_NRF52840_DK/cc_platform_nrf52840.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* cc_platform_nrf52840.c
33
*
4-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
4+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may

features/mbedtls/targets/TARGET_CRYPTOCELL310/cc_internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Internal utility functions and definitions,
55
* used for converting mbedtls types to CC types, and vice versa
66
*
7-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
7+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
88
* SPDX-License-Identifier: Apache-2.0
99
*
1010
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -92,7 +92,7 @@ uint32_t convert_mbedtls_to_cc_rand( void* mbedtls_rnd_ctx, uint16_t outSizeByte
9292

9393
int convert_CrysError_to_mbedtls_err( CRYSError_t Crys_err )
9494
{
95-
switch(Crys_err)
95+
switch( Crys_err )
9696
{
9797
case CRYS_OK:
9898
return ( 0 );

features/mbedtls/targets/TARGET_CRYPTOCELL310/cc_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Internal utility functions and definitions,
55
* used for converting mbedtls types to CC types, and vice versa
66
*
7-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
7+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
88
* SPDX-License-Identifier: Apache-2.0
99
*
1010
* Licensed under the Apache License, Version 2.0 (the "License"); you may

features/mbedtls/targets/TARGET_CRYPTOCELL310/ccm_alt.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* ccm_alt.c
33
*
4-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
4+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -54,7 +54,7 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx,
5454
return ( MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE );
5555
}
5656

57-
memcpy( ctx->cipher_key , key, keybits/8 );
57+
memcpy( ctx->cipher_key , key, keybits / 8 );
5858
ctx->keySize_ID = CRYS_AES_Key128BitSize;
5959

6060
return ( 0 );
@@ -85,8 +85,10 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
8585
if( iv_len < 7 || iv_len > 13 )
8686
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
8787

88+
#if defined(MBEDTLS_HAVE_INT64)
8889
if( length > 0xFFFFFFFF || add_len > 0xFFFFFFFF )
8990
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
91+
#endif
9092

9193
CrysRet = CRYS_AESCCM( SASI_AES_ENCRYPT, ctx->cipher_key, ctx->keySize_ID,(uint8_t*)iv, iv_len,
9294
(uint8_t*)add, add_len, (uint8_t*)input, length, output, tag_len, tag );
@@ -120,8 +122,10 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
120122
if( iv_len < 7 || iv_len > 13 )
121123
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
122124

125+
#if defined(MBEDTLS_HAVE_INT64)
123126
if( length > 0xFFFFFFFF || add_len > 0xFFFFFFFF )
124127
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
128+
#endif
125129

126130
CrysRet = CRYS_AESCCM( SASI_AES_DECRYPT, ctx->cipher_key, ctx->keySize_ID,(uint8_t*)iv, iv_len,
127131
(uint8_t*)add, add_len, (uint8_t*)input, length, output, tag_len, (uint8_t*)tag );

features/mbedtls/targets/TARGET_CRYPTOCELL310/ccm_alt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* ccm_alt.h
33
*
4-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
4+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may

features/mbedtls/targets/TARGET_CRYPTOCELL310/ecdh_alt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* ecdh_alt.c
33
*
4-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
4+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -52,12 +52,12 @@ int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp
5252
if ( pDomain )
5353
{
5454
uint8_t temp_buf[ 2 * MAX_KEY_SIZE_IN_BYTES + 1 ] = {0};
55-
cc_ecc_ws_keygen_params_t* kgParams = mbedtls_calloc( 1, sizeof(cc_ecc_ws_keygen_params_t) );
55+
cc_ecc_ws_keygen_params_t* kgParams = mbedtls_calloc( 1, sizeof( cc_ecc_ws_keygen_params_t ) );
5656

5757
if ( kgParams == NULL )
5858
return ( MBEDTLS_ERR_ECP_ALLOC_FAILED );
5959
pHeap = kgParams;
60-
heapSize = sizeof(cc_ecc_ws_keygen_params_t);
60+
heapSize = sizeof( cc_ecc_ws_keygen_params_t );
6161

6262
ret = convert_CrysError_to_mbedtls_err( CRYS_ECPKI_GenKeyPair( &cc_rand, convert_mbedtls_to_cc_rand,
6363
pDomain, &kgParams->privKey,
@@ -92,7 +92,7 @@ int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp
9292
mbedtls_zeroize( temp_buf, sizeof( temp_buf ) );
9393
}
9494

95-
/* if CRYS_ECPKI_GetEcDomain returns NULL, than the given curve is wither Montgomery 25519
95+
/* if CRYS_ECPKI_GetEcDomain returns NULL, then the given curve is either Montgomery 25519
9696
* or another curve which is not supported by CC310*/
9797
else if ( grp->id == MBEDTLS_ECP_DP_CURVE25519 )
9898
{

features/mbedtls/targets/TARGET_CRYPTOCELL310/ecdsa_alt.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* ecdsa_alt.c
33
*
4-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
4+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -78,11 +78,12 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
7878
mbedtls_rand_func_container cc_rand = { f_rng, p_rng };
7979
const CRYS_ECPKI_Domain_t* pDomain = CRYS_ECPKI_GetEcDomain ( convert_mbedtls_grp_id_to_crys_domain_id( grp->id ) );
8080

81+
#if defined(MBEDTLS_HAVE_INT64)
8182
if( blen > 0xFFFFFFFF )
8283
{
83-
ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
84-
goto cleanup;
84+
return ( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
8585
}
86+
#endif
8687

8788
if ( pDomain != NULL )
8889
{
@@ -175,11 +176,12 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
175176
uint32_t signature_size = ( ( grp->nbits + 7 ) / 8 ) * 2;
176177
const CRYS_ECPKI_Domain_t* pDomain = CRYS_ECPKI_GetEcDomain ( convert_mbedtls_grp_id_to_crys_domain_id( grp->id ) );
177178

179+
#if defined(MBEDTLS_HAVE_INT64)
178180
if( blen > 0xFFFFFFFF )
179181
{
180-
ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
181-
goto cleanup;
182+
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
182183
}
184+
#endif
183185

184186
if ( pDomain )
185187
{

features/mbedtls/targets/TARGET_CRYPTOCELL310/mbedtls_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* mbedtls_device.h
33
*
4-
* Copyright (C) 2018, ARM Limited, All Rights Reserved
4+
* Copyright (C) 2018, Arm Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License"); you may

0 commit comments

Comments
 (0)