Minor style fixes

Fix styls issues and rename ARM to Arm.
Address additional minor comments from review.
pull/6794/head
Ron Eldor 2018-05-16 13:58:46 +03:00
parent c5ea8d71bb
commit a1ea814f06
18 changed files with 34 additions and 28 deletions

View File

@ -12,11 +12,11 @@ To port your CC 310 driver to Mbed OS on your specific target, do the following:
1. In `targets.json` add the following to your target:
* `MBEDTLS_CONFIG_HW_SUPPORT` to `macros_add` key. This instructs Mbed TLS to look for an alternative cryptographic implementation.
* `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`.
* `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)`.
* `CRYPTOCELL310` to `extra_labels_add` key. The build system uses this to look for the CC 310 code and binaries.
1. In `objects.h`, include `objects_cryptocell.h`. You can use the `DEVICE_CRYPTOCELL` precompilation check as defined above.
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.
1. Add your CC setup code:
* 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.
* 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.
* Define `cc_platform_ctx` in `cc_platform.h` in a way that suits your implementation.

View File

@ -1,7 +1,7 @@
/*
* cc_platform.h
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* cc_platform_nrf52840.c
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -4,7 +4,7 @@
* Internal utility functions and definitions,
* used for converting mbedtls types to CC types, and vice versa
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* 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
int convert_CrysError_to_mbedtls_err( CRYSError_t Crys_err )
{
switch(Crys_err)
switch( Crys_err )
{
case CRYS_OK:
return ( 0 );

View File

@ -4,7 +4,7 @@
* Internal utility functions and definitions,
* used for converting mbedtls types to CC types, and vice versa
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* ccm_alt.c
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -54,7 +54,7 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx,
return ( MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE );
}
memcpy( ctx->cipher_key , key, keybits/8 );
memcpy( ctx->cipher_key , key, keybits / 8 );
ctx->keySize_ID = CRYS_AES_Key128BitSize;
return ( 0 );
@ -85,8 +85,10 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
if( iv_len < 7 || iv_len > 13 )
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
#if defined(MBEDTLS_HAVE_INT64)
if( length > 0xFFFFFFFF || add_len > 0xFFFFFFFF )
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
#endif
CrysRet = CRYS_AESCCM( SASI_AES_ENCRYPT, ctx->cipher_key, ctx->keySize_ID,(uint8_t*)iv, iv_len,
(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,
if( iv_len < 7 || iv_len > 13 )
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
#if defined(MBEDTLS_HAVE_INT64)
if( length > 0xFFFFFFFF || add_len > 0xFFFFFFFF )
return ( MBEDTLS_ERR_CCM_BAD_INPUT );
#endif
CrysRet = CRYS_AESCCM( SASI_AES_DECRYPT, ctx->cipher_key, ctx->keySize_ID,(uint8_t*)iv, iv_len,
(uint8_t*)add, add_len, (uint8_t*)input, length, output, tag_len, (uint8_t*)tag );

View File

@ -1,7 +1,7 @@
/*
* ccm_alt.h
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* ecdh_alt.c
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* 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
if ( pDomain )
{
uint8_t temp_buf[ 2 * MAX_KEY_SIZE_IN_BYTES + 1 ] = {0};
cc_ecc_ws_keygen_params_t* kgParams = mbedtls_calloc( 1, sizeof(cc_ecc_ws_keygen_params_t) );
cc_ecc_ws_keygen_params_t* kgParams = mbedtls_calloc( 1, sizeof( cc_ecc_ws_keygen_params_t ) );
if ( kgParams == NULL )
return ( MBEDTLS_ERR_ECP_ALLOC_FAILED );
pHeap = kgParams;
heapSize = sizeof(cc_ecc_ws_keygen_params_t);
heapSize = sizeof( cc_ecc_ws_keygen_params_t );
ret = convert_CrysError_to_mbedtls_err( CRYS_ECPKI_GenKeyPair( &cc_rand, convert_mbedtls_to_cc_rand,
pDomain, &kgParams->privKey,
@ -92,7 +92,7 @@ int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp
mbedtls_zeroize( temp_buf, sizeof( temp_buf ) );
}
/* if CRYS_ECPKI_GetEcDomain returns NULL, than the given curve is wither Montgomery 25519
/* if CRYS_ECPKI_GetEcDomain returns NULL, then the given curve is either Montgomery 25519
* or another curve which is not supported by CC310*/
else if ( grp->id == MBEDTLS_ECP_DP_CURVE25519 )
{

View File

@ -1,7 +1,7 @@
/*
* ecdsa_alt.c
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* 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,
mbedtls_rand_func_container cc_rand = { f_rng, p_rng };
const CRYS_ECPKI_Domain_t* pDomain = CRYS_ECPKI_GetEcDomain ( convert_mbedtls_grp_id_to_crys_domain_id( grp->id ) );
#if defined(MBEDTLS_HAVE_INT64)
if( blen > 0xFFFFFFFF )
{
ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
goto cleanup;
return ( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
}
#endif
if ( pDomain != NULL )
{
@ -175,11 +176,12 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
uint32_t signature_size = ( ( grp->nbits + 7 ) / 8 ) * 2;
const CRYS_ECPKI_Domain_t* pDomain = CRYS_ECPKI_GetEcDomain ( convert_mbedtls_grp_id_to_crys_domain_id( grp->id ) );
#if defined(MBEDTLS_HAVE_INT64)
if( blen > 0xFFFFFFFF )
{
ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
goto cleanup;
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
}
#endif
if ( pDomain )
{

View File

@ -1,7 +1,7 @@
/*
* mbedtls_device.h
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* platform_alt.c
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* platform_alt.h
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* sha1_alt.c
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* sha1_alt.h
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* sha256_alt.c
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* sha256_alt.h
*
* Copyright (C) 2018, ARM Limited, All Rights Reserved
* Copyright (C) 2018, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* objects_cryptocell.h
*
* Copyright (C) 2017, ARM Limited, All Rights Reserved
* Copyright (C) 2017, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,7 +1,7 @@
/*
* trng.c
*
* Copyright (C) 2017, ARM Limited, All Rights Reserved
* Copyright (C) 2017, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may