From 187fbb1334303c334c3a483622a2e889d7973756 Mon Sep 17 00:00:00 2001 From: Jarno Lamsa Date: Thu, 25 Apr 2019 09:03:19 +0300 Subject: [PATCH] Use mbedtls_platform_zeroize in uecc code ecc_dh.c used memset and gcc-specific asm-commands, changed those to use mbedtls_platform_zeroize to allow compilation with different compilers. --- tinycrypt/ecc_dh.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tinycrypt/ecc_dh.c b/tinycrypt/ecc_dh.c index 15d9ba34d..48d0da9de 100644 --- a/tinycrypt/ecc_dh.c +++ b/tinycrypt/ecc_dh.c @@ -1,6 +1,6 @@ /* ec_dh.c - TinyCrypt implementation of EC-DH */ -/* +/* * Copyright (c) 2014, Kenneth MacKay * All rights reserved. * @@ -57,6 +57,7 @@ #include #include #include +#include "mbedtls/platform_util.h" #if default_RNG_defined static uECC_RNG_Function g_rng_function = &default_CSPRNG; @@ -188,12 +189,9 @@ int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key, clear_and_out: /* erasing temporary buffer used to store secret: */ - memset(p2, 0, sizeof(p2)); - __asm__ __volatile__("" :: "g"(p2) : "memory"); - memset(tmp, 0, sizeof(tmp)); - __asm__ __volatile__("" :: "g"(tmp) : "memory"); - memset(_private, 0, sizeof(_private)); - __asm__ __volatile__("" :: "g"(_private) : "memory"); + mbedtls_platform_zeroize(p2, sizeof(p2)); + mbedtls_platform_zeroize(tmp, sizeof(tmp)); + mbedtls_platform_zeroize(_private, sizeof(_private)); return r; }