From 55427964b1073e566acfa36786bc4ab3ad901b9c Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Mon, 29 Apr 2019 10:25:23 +0300 Subject: [PATCH] Guard tinycrypt files with MBEDTLS_USE_UECC --- include/tinycrypt/ecc.h | 2 ++ include/tinycrypt/ecc_dh.h | 2 ++ include/tinycrypt/ecc_dsa.h | 2 ++ tinycrypt/ecc.c | 3 ++- tinycrypt/ecc_dh.c | 2 ++ tinycrypt/ecc_dsa.c | 2 ++ 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/tinycrypt/ecc.h b/include/tinycrypt/ecc.h index 8abc949cc..ede754448 100644 --- a/include/tinycrypt/ecc.h +++ b/include/tinycrypt/ecc.h @@ -68,6 +68,7 @@ * */ +#if defined(MBEDTLS_USE_UECC) #ifndef __TC_UECC_H__ #define __TC_UECC_H__ @@ -543,3 +544,4 @@ void uECC_vli_bytesToNative(unsigned int *native, const uint8_t *bytes, #endif #endif /* __TC_UECC_H__ */ +#endif /* MBEDTLS_USE_UECC */ diff --git a/include/tinycrypt/ecc_dh.h b/include/tinycrypt/ecc_dh.h index b828e195d..18a4fd269 100644 --- a/include/tinycrypt/ecc_dh.h +++ b/include/tinycrypt/ecc_dh.h @@ -66,6 +66,7 @@ * Security: The curve NIST p-256 provides approximately 128 bits of security. */ +#if defined(MBEDTLS_USE_UECC) #ifndef __TC_ECC_DH_H__ #define __TC_ECC_DH_H__ @@ -129,3 +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 */ diff --git a/include/tinycrypt/ecc_dsa.h b/include/tinycrypt/ecc_dsa.h index aca00bc95..806534001 100644 --- a/include/tinycrypt/ecc_dsa.h +++ b/include/tinycrypt/ecc_dsa.h @@ -75,6 +75,7 @@ * the signer's public key and the signature values (r and s). */ +#if defined(MBEDTLS_USE_UECC) #ifndef __TC_ECC_DSA_H__ #define __TC_ECC_DSA_H__ @@ -137,3 +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 */ diff --git a/tinycrypt/ecc.c b/tinycrypt/ecc.c index b398c94b2..c4a677070 100644 --- a/tinycrypt/ecc.c +++ b/tinycrypt/ecc.c @@ -52,6 +52,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#if defined(MBEDTLS_USE_UECC) #include #include @@ -937,5 +938,5 @@ int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key, return 1; } - +#endif /* MBEDTLS_USE_UECC */ diff --git a/tinycrypt/ecc_dh.c b/tinycrypt/ecc_dh.c index 48d0da9de..7277879be 100644 --- a/tinycrypt/ecc_dh.c +++ b/tinycrypt/ecc_dh.c @@ -54,6 +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) #include #include #include @@ -195,3 +196,4 @@ clear_and_out: return r; } +#endif /* MBEDTLS_USE_UECC */ diff --git a/tinycrypt/ecc_dsa.c b/tinycrypt/ecc_dsa.c index 9a4c0a550..d3e72a57d 100644 --- a/tinycrypt/ecc_dsa.c +++ b/tinycrypt/ecc_dsa.c @@ -53,6 +53,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#if defined(MBEDTLS_USE_UECC) #include #include @@ -292,3 +293,4 @@ int uECC_verify(const uint8_t *public_key, const uint8_t *message_hash, return (int)(uECC_vli_equal(rx, r, num_words) == 0); } +#endif /* MBEDTLS_USE_UECC */