]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - common/mbedtls/platform_util_arm.c
2 * Common and shared functions used by multiple modules in the Mbed TLS
5 * Copyright (C) 2018, Arm Limited, All Rights Reserved
6 * SPDX-License-Identifier: GPL-2.0
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * This file is part of Mbed TLS (https://tls.mbed.org)
25 #if !defined(MBEDTLS_CONFIG_FILE)
26 #include "mbedtls/config.h"
28 #include MBEDTLS_CONFIG_FILE
31 #include "mbedtls/platform_util.h"
36 #if !defined(MBEDTLS_PLATFORM_ZEROIZE_ALT)
38 * This implementation should never be optimized out by the compiler
40 * This implementation for mbedtls_platform_zeroize() was inspired from Colin
41 * Percival's blog article at:
43 * http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html
45 * It uses a volatile function pointer to the standard memset(). Because the
46 * pointer is volatile the compiler expects it to change at
47 * any time and will not optimize out the call that could potentially perform
48 * other operations on the input buffer instead of just setting it to 0.
49 * Nevertheless, as pointed out by davidtgoldblatt on Hacker News
50 * (refer to http://www.daemonology.net/blog/2014-09-05-erratum.html for
51 * details), optimizations of the following form are still possible:
53 * if( memset_func != memset )
54 * memset_func( buf, 0, len );
56 * Note that it is extremely difficult to guarantee that
57 * mbedtls_platform_zeroize() will not be optimized out by aggressive compilers
58 * in a portable way. For this reason, Mbed TLS also provides the configuration
59 * option MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure
60 * mbedtls_platform_zeroize() to use a suitable implementation for their
64 void mbedtls_platform_zeroize( void *buf
, size_t len
)
66 memset( buf
, 0, len
);
68 #endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */