Merge remote-tracking branch 'origin/pr/565' into baremetal

This commit is contained in:
Simon Butcher 2019-05-24 15:06:56 +01:00
commit 0edb924e16
12 changed files with 42 additions and 40 deletions

View File

@ -87,8 +87,8 @@
#error "MBEDTLS_CMAC_C defined, but not all prerequisites"
#endif
#if defined(MBEDTLS_USE_UECC) && defined(MBEDTLS_NO_64BIT_MULTIPLICATION)
#error "MBEDTLS_USE_UECC defined, but it cannot be defined with MBEDTLS_NO_64BIT_MULTIPLICATION"
#if defined(MBEDTLS_USE_TINYCRYPT) && defined(MBEDTLS_NO_64BIT_MULTIPLICATION)
#error "MBEDTLS_USE_TINYCRYPT defined, but it cannot be defined with MBEDTLS_NO_64BIT_MULTIPLICATION"
#endif
#if defined(MBEDTLS_NIST_KW_C) && \

View File

@ -2279,18 +2279,20 @@
#define MBEDTLS_ECP_C
/**
* \def MBEDTLS_USE_UECC
* \def MBEDTLS_USE_TINYCRYPT
*
* Enable the tinycrypt ECC library.
* Enable the TinyCrypt ECC library. This module provides alternative ECC
* handling functions replacing the native Mbed TLS ECP module.
*
* TinyCrypt is a project independent from Mbed TLS, licensed under 3-clause
* BSD, and can be found at https://github.com/intel/tinycrypt - this option
* only enables the ECC modules from TinyCrypt.
*
* Module: tinycrypt/ecc.c
* tinycrypt/ecc_dh.c
* tinycrypt/ecc_dsa.c
*
* This module provides alternative ECC handling functions replacing
* native MBEDTLS ECP module.
*/
//#define MBEDTLS_USE_UECC
//#define MBEDTLS_USE_TINYCRYPT
/**
* \def MBEDTLS_ENTROPY_C

View File

@ -68,7 +68,7 @@
*
*/
#if defined(MBEDTLS_USE_UECC)
#if defined(MBEDTLS_USE_TINYCRYPT)
#ifndef __TC_UECC_H__
#define __TC_UECC_H__
@ -544,4 +544,4 @@ void uECC_vli_bytesToNative(unsigned int *native, const uint8_t *bytes,
#endif
#endif /* __TC_UECC_H__ */
#endif /* MBEDTLS_USE_UECC */
#endif /* MBEDTLS_USE_TINYCRYPT */

View File

@ -66,7 +66,7 @@
* Security: The curve NIST p-256 provides approximately 128 bits of security.
*/
#if defined(MBEDTLS_USE_UECC)
#if defined(MBEDTLS_USE_TINYCRYPT)
#ifndef __TC_ECC_DH_H__
#define __TC_ECC_DH_H__
@ -130,4 +130,4 @@ int uECC_shared_secret(const uint8_t *p_public_key, const uint8_t *p_private_key
#endif
#endif /* __TC_ECC_DH_H__ */
#endif /* MBEDTLS_USE_UECC */
#endif /* MBEDTLS_USE_TINYCRYPT */

View File

@ -75,7 +75,7 @@
* the signer's public key and the signature values (r and s).
*/
#if defined(MBEDTLS_USE_UECC)
#if defined(MBEDTLS_USE_TINYCRYPT)
#ifndef __TC_ECC_DSA_H__
#define __TC_ECC_DSA_H__
@ -138,4 +138,4 @@ int uECC_verify(const uint8_t *p_public_key, const uint8_t *p_message_hash,
#endif
#endif /* __TC_ECC_DSA_H__ */
#endif /* MBEDTLS_USE_UECC */
#endif /* MBEDTLS_USE_TINYCRYPT */

View File

@ -615,9 +615,9 @@ static const char *features[] = {
#if defined(MBEDTLS_ECP_C)
"MBEDTLS_ECP_C",
#endif /* MBEDTLS_ECP_C */
#if defined(MBEDTLS_USE_UECC)
"MBEDTLS_USE_UECC",
#endif /* MBEDTLS_USE_UECC */
#if defined(MBEDTLS_USE_TINYCRYPT)
"MBEDTLS_USE_TINYCRYPT",
#endif /* MBEDTLS_USE_TINYCRYPT */
#if defined(MBEDTLS_ENTROPY_C)
"MBEDTLS_ENTROPY_C",
#endif /* MBEDTLS_ENTROPY_C */

View File

@ -1682,13 +1682,13 @@ int query_config( const char *config )
}
#endif /* MBEDTLS_ECP_C */
#if defined(MBEDTLS_USE_UECC)
if( strcmp( "MBEDTLS_USE_UECC", config ) == 0 )
#if defined(MBEDTLS_USE_TINYCRYPT)
if( strcmp( "MBEDTLS_USE_TINYCRYPT", config ) == 0 )
{
MACRO_EXPANSION_TO_STR( MBEDTLS_USE_UECC );
MACRO_EXPANSION_TO_STR( MBEDTLS_USE_TINYCRYPT );
return( 0 );
}
#endif /* MBEDTLS_USE_UECC */
#endif /* MBEDTLS_USE_TINYCRYPT */
#if defined(MBEDTLS_ENTROPY_C)
if( strcmp( "MBEDTLS_ENTROPY_C", config ) == 0 )

View File

@ -98,7 +98,7 @@ MBEDTLS_ZLIB_SUPPORT
MBEDTLS_PKCS11_C
MBEDTLS_NO_UDBL_DIVISION
MBEDTLS_NO_64BIT_MULTIPLICATION
MBEDTLS_USE_UECC
MBEDTLS_USE_TINYCRYPT
_ALT\s*$
);

View File

@ -1047,16 +1047,16 @@ component_test_no_64bit_multiplication () {
make test
}
component_build_uecc_cmake () {
msg "build: uecc native, cmake"
scripts/config.pl set MBEDTLS_USE_UECC
component_build_tinycrypt_cmake () {
msg "build: tinycrypt native, cmake"
scripts/config.pl set MBEDTLS_USE_TINYCRYPT
CC=gcc cmake .
make
}
component_build_uecc_make () {
msg "build: uecc native, make"
scripts/config.pl set MBEDTLS_USE_UECC
component_build_tinycrypt_make () {
msg "build: tinycrypt native, make"
scripts/config.pl set MBEDTLS_USE_TINYCRYPT
make CC=gcc CFLAGS='-Werror -O1'
}
@ -1155,10 +1155,10 @@ component_build_armcc () {
armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
}
component_build_armcc_uecc_baremetal () {
msg "build: ARM Compiler 5, make with uecc and baremetal"
component_build_armcc_tinycrypt_baremetal () {
msg "build: ARM Compiler 5, make with tinycrypt and baremetal"
scripts/config.pl baremetal
scripts/config.pl set MBEDTLS_USE_UECC
scripts/config.pl set MBEDTLS_USE_TINYCRYPT
make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
make clean

View File

@ -52,7 +52,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(MBEDTLS_USE_UECC)
#if defined(MBEDTLS_USE_TINYCRYPT)
#include <tinycrypt/ecc.h>
#include <string.h>
@ -938,6 +938,6 @@ int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key,
return 1;
}
#else
typedef int mbedtls_dummy_uecc_def;
#endif /* MBEDTLS_USE_UECC */
typedef int mbedtls_dummy_tinycrypt_def;
#endif /* MBEDTLS_USE_TINYCRYPT */

View File

@ -54,7 +54,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(MBEDTLS_USE_UECC)
#if defined(MBEDTLS_USE_TINYCRYPT)
#include <tinycrypt/ecc.h>
#include <tinycrypt/ecc_dh.h>
#include <string.h>
@ -197,5 +197,5 @@ clear_and_out:
return r;
}
#else
typedef int mbedtls_dummy_uecc_def;
#endif /* MBEDTLS_USE_UECC */
typedef int mbedtls_dummy_tinycrypt_def;
#endif /* MBEDTLS_USE_TINYCRYPT */

View File

@ -53,7 +53,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(MBEDTLS_USE_UECC)
#if defined(MBEDTLS_USE_TINYCRYPT)
#include <tinycrypt/ecc.h>
#include <tinycrypt/ecc_dsa.h>
@ -293,5 +293,5 @@ int uECC_verify(const uint8_t *public_key, const uint8_t *message_hash,
return (int)(uECC_vli_equal(rx, r, num_words) == 0);
}
#else
typedef int mbedtls_dummy_uecc_def;
#endif /* MBEDTLS_USE_UECC */
typedef int mbedtls_dummy_tinycrypt_def;
#endif /* MBEDTLS_USE_TINYCRYPT */