Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
platform_util.h
00001 /** 00002 * \file platform_util.h 00003 * 00004 * \brief Common and shared functions used by multiple modules in the Mbed TLS 00005 * library. 00006 */ 00007 /* 00008 * Copyright (C) 2018, Arm Limited, All Rights Reserved 00009 * SPDX-License-Identifier: Apache-2.0 00010 * 00011 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00012 * not use this file except in compliance with the License. 00013 * You may obtain a copy of the License at 00014 * 00015 * http://www.apache.org/licenses/LICENSE-2.0 00016 * 00017 * Unless required by applicable law or agreed to in writing, software 00018 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00019 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 * See the License for the specific language governing permissions and 00021 * limitations under the License. 00022 * 00023 * This file is part of Mbed TLS (https://tls.mbed.org) 00024 */ 00025 #ifndef MBEDTLS_PLATFORM_UTIL_H 00026 #define MBEDTLS_PLATFORM_UTIL_H 00027 00028 #if !defined(MBEDTLS_CONFIG_FILE) 00029 #include "mbedtls/config.h" 00030 #else 00031 #include MBEDTLS_CONFIG_FILE 00032 #endif 00033 00034 #include <stddef.h> 00035 #if defined(MBEDTLS_HAVE_TIME_DATE) 00036 #include "mbedtls/platform_time.h" 00037 #include <time.h> 00038 #endif /* MBEDTLS_HAVE_TIME_DATE */ 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /** 00045 * \brief Securely zeroize a buffer 00046 * 00047 * The function is meant to wipe the data contained in a buffer so 00048 * that it can no longer be recovered even if the program memory 00049 * is later compromised. Call this function on sensitive data 00050 * stored on the stack before returning from a function, and on 00051 * sensitive data stored on the heap before freeing the heap 00052 * object. 00053 * 00054 * It is extremely difficult to guarantee that calls to 00055 * mbedtls_platform_zeroize() are not removed by aggressive 00056 * compiler optimizations in a portable way. For this reason, Mbed 00057 * TLS provides the configuration option 00058 * MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure 00059 * mbedtls_platform_zeroize() to use a suitable implementation for 00060 * their platform and needs 00061 * 00062 * \param buf Buffer to be zeroized 00063 * \param len Length of the buffer in bytes 00064 * 00065 */ 00066 void mbedtls_platform_zeroize( void *buf, size_t len ); 00067 00068 #if defined(MBEDTLS_HAVE_TIME_DATE) 00069 /** 00070 * \brief Platform-specific implementation of gmtime_r() 00071 * 00072 * The function is a thread-safe abstraction that behaves 00073 * similarly to the gmtime_r() function from Unix/POSIX. 00074 * 00075 * Mbed TLS will try to identify the underlying platform and 00076 * make use of an appropriate underlying implementation (e.g. 00077 * gmtime_r() for POSIX and gmtime_s() for Windows). If this is 00078 * not possible, then gmtime() will be used. In this case, calls 00079 * from the library to gmtime() will be guarded by the mutex 00080 * mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is 00081 * enabled. It is recommended that calls from outside the library 00082 * are also guarded by this mutex. 00083 * 00084 * If MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, then Mbed TLS will 00085 * unconditionally use the alternative implementation for 00086 * mbedtls_platform_gmtime_r() supplied by the user at compile time. 00087 * 00088 * \param tt Pointer to an object containing time (in seconds) since the 00089 * epoch to be converted 00090 * \param tm_buf Pointer to an object where the results will be stored 00091 * 00092 * \return Pointer to an object of type struct tm on success, otherwise 00093 * NULL 00094 */ 00095 struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt, 00096 struct tm *tm_buf ); 00097 #endif /* MBEDTLS_HAVE_TIME_DATE */ 00098 00099 #ifdef __cplusplus 00100 } 00101 #endif 00102 00103 #endif /* MBEDTLS_PLATFORM_UTIL_H */
Generated on Tue Aug 9 2022 00:37:17 by
