Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 1 | /** |
| 2 | * \file platform_util.h |
| 3 | * |
| 4 | * \brief Common and shared functions used by multiple modules in the Mbed TLS |
| 5 | * library. |
| 6 | */ |
| 7 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 8 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 7ff7965 | 2023-11-03 12:04:52 +0000 | [diff] [blame^] | 9 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 10 | */ |
| 11 | #ifndef MBEDTLS_PLATFORM_UTIL_H |
| 12 | #define MBEDTLS_PLATFORM_UTIL_H |
| 13 | |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 14 | #if !defined(MBEDTLS_CONFIG_FILE) |
Jaeden Amero | c49fbbf | 2019-07-04 20:01:14 +0100 | [diff] [blame] | 15 | #include "mbedtls/config.h" |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 16 | #else |
| 17 | #include MBEDTLS_CONFIG_FILE |
| 18 | #endif |
| 19 | |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 20 | #include <stddef.h> |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 21 | #if defined(MBEDTLS_HAVE_TIME_DATE) |
Jaeden Amero | c49fbbf | 2019-07-04 20:01:14 +0100 | [diff] [blame] | 22 | #include "mbedtls/platform_time.h" |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 23 | #include <time.h> |
| 24 | #endif /* MBEDTLS_HAVE_TIME_DATE */ |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 25 | |
| 26 | #ifdef __cplusplus |
| 27 | extern "C" { |
| 28 | #endif |
| 29 | |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 30 | #if defined(MBEDTLS_CHECK_PARAMS) |
| 31 | |
Gilles Peskine | c7ad122 | 2019-06-13 16:44:19 +0200 | [diff] [blame] | 32 | #if defined(MBEDTLS_CHECK_PARAMS_ASSERT) |
| 33 | /* Allow the user to define MBEDTLS_PARAM_FAILED to something like assert |
| 34 | * (which is what our config.h suggests). */ |
| 35 | #include <assert.h> |
| 36 | #endif /* MBEDTLS_CHECK_PARAMS_ASSERT */ |
| 37 | |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 38 | #if defined(MBEDTLS_PARAM_FAILED) |
| 39 | /** An alternative definition of MBEDTLS_PARAM_FAILED has been set in config.h. |
| 40 | * |
| 41 | * This flag can be used to check whether it is safe to assume that |
| 42 | * MBEDTLS_PARAM_FAILED() will expand to a call to mbedtls_param_failed(). |
| 43 | */ |
| 44 | #define MBEDTLS_PARAM_FAILED_ALT |
Gilles Peskine | c7ad122 | 2019-06-13 16:44:19 +0200 | [diff] [blame] | 45 | |
| 46 | #elif defined(MBEDTLS_CHECK_PARAMS_ASSERT) |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 47 | #define MBEDTLS_PARAM_FAILED(cond) assert(cond) |
Gilles Peskine | c7ad122 | 2019-06-13 16:44:19 +0200 | [diff] [blame] | 48 | #define MBEDTLS_PARAM_FAILED_ALT |
| 49 | |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 50 | #else /* MBEDTLS_PARAM_FAILED */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 51 | #define MBEDTLS_PARAM_FAILED(cond) \ |
| 52 | mbedtls_param_failed( #cond, __FILE__, __LINE__) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * \brief User supplied callback function for parameter validation failure. |
| 56 | * See #MBEDTLS_CHECK_PARAMS for context. |
| 57 | * |
bootstrap-prime | 7ef96ea | 2022-05-18 14:08:33 -0400 | [diff] [blame] | 58 | * This function will be called unless an alternative treatment |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 59 | * is defined through the #MBEDTLS_PARAM_FAILED macro. |
| 60 | * |
| 61 | * This function can return, and the operation will be aborted, or |
| 62 | * alternatively, through use of setjmp()/longjmp() can resume |
| 63 | * execution in the application code. |
| 64 | * |
| 65 | * \param failure_condition The assertion that didn't hold. |
| 66 | * \param file The file where the assertion failed. |
| 67 | * \param line The line in the file where the assertion failed. |
| 68 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 69 | void mbedtls_param_failed(const char *failure_condition, |
| 70 | const char *file, |
| 71 | int line); |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 72 | #endif /* MBEDTLS_PARAM_FAILED */ |
| 73 | |
| 74 | /* Internal macro meant to be called only from within the library. */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 75 | #define MBEDTLS_INTERNAL_VALIDATE_RET(cond, ret) \ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 76 | do { \ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 77 | if (!(cond)) \ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 78 | { \ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 79 | MBEDTLS_PARAM_FAILED(cond); \ |
| 80 | return ret; \ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 81 | } \ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 82 | } while (0) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 83 | |
| 84 | /* Internal macro meant to be called only from within the library. */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 85 | #define MBEDTLS_INTERNAL_VALIDATE(cond) \ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 86 | do { \ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 87 | if (!(cond)) \ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 88 | { \ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 89 | MBEDTLS_PARAM_FAILED(cond); \ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 90 | return; \ |
| 91 | } \ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 92 | } while (0) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 93 | |
| 94 | #else /* MBEDTLS_CHECK_PARAMS */ |
| 95 | |
| 96 | /* Internal macros meant to be called only from within the library. */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 97 | #define MBEDTLS_INTERNAL_VALIDATE_RET(cond, ret) do { } while (0) |
| 98 | #define MBEDTLS_INTERNAL_VALIDATE(cond) do { } while (0) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 99 | |
| 100 | #endif /* MBEDTLS_CHECK_PARAMS */ |
| 101 | |
| 102 | /* Internal helper macros for deprecating API constants. */ |
| 103 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) |
| 104 | #if defined(MBEDTLS_DEPRECATED_WARNING) |
| 105 | /* Deliberately don't (yet) export MBEDTLS_DEPRECATED here |
| 106 | * to avoid conflict with other headers which define and use |
| 107 | * it, too. We might want to move all these definitions here at |
| 108 | * some point for uniformity. */ |
| 109 | #define MBEDTLS_DEPRECATED __attribute__((deprecated)) |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 110 | MBEDTLS_DEPRECATED typedef char const *mbedtls_deprecated_string_constant_t; |
| 111 | #define MBEDTLS_DEPRECATED_STRING_CONSTANT(VAL) \ |
| 112 | ((mbedtls_deprecated_string_constant_t) (VAL)) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 113 | MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 114 | #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(VAL) \ |
| 115 | ((mbedtls_deprecated_numeric_constant_t) (VAL)) |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 116 | #undef MBEDTLS_DEPRECATED |
| 117 | #else /* MBEDTLS_DEPRECATED_WARNING */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 118 | #define MBEDTLS_DEPRECATED_STRING_CONSTANT(VAL) VAL |
| 119 | #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT(VAL) VAL |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 120 | #endif /* MBEDTLS_DEPRECATED_WARNING */ |
| 121 | #endif /* MBEDTLS_DEPRECATED_REMOVED */ |
| 122 | |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 123 | /* Implementation of the check-return facility. |
| 124 | * See the user documentation in config.h. |
Gilles Peskine | 7b8571f | 2021-07-07 21:02:36 +0200 | [diff] [blame] | 125 | * |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 126 | * Do not use this macro directly to annotate function: instead, |
| 127 | * use one of MBEDTLS_CHECK_RETURN_CRITICAL or MBEDTLS_CHECK_RETURN_TYPICAL |
| 128 | * depending on how important it is to check the return value. |
Gilles Peskine | 7b8571f | 2021-07-07 21:02:36 +0200 | [diff] [blame] | 129 | */ |
| 130 | #if !defined(MBEDTLS_CHECK_RETURN) |
| 131 | #if defined(__GNUC__) |
Gilles Peskine | e568eba | 2021-09-23 17:46:12 +0200 | [diff] [blame] | 132 | #define MBEDTLS_CHECK_RETURN __attribute__((__warn_unused_result__)) |
Gilles Peskine | 7b8571f | 2021-07-07 21:02:36 +0200 | [diff] [blame] | 133 | #elif defined(_MSC_VER) && _MSC_VER >= 1700 |
| 134 | #include <sal.h> |
| 135 | #define MBEDTLS_CHECK_RETURN _Check_return_ |
| 136 | #else |
| 137 | #define MBEDTLS_CHECK_RETURN |
| 138 | #endif |
| 139 | #endif |
| 140 | |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 141 | /** Critical-failure function |
| 142 | * |
| 143 | * This macro appearing at the beginning of the declaration of a function |
| 144 | * indicates that its return value should be checked in all applications. |
| 145 | * Omitting the check is very likely to indicate a bug in the application |
| 146 | * and will result in a compile-time warning if #MBEDTLS_CHECK_RETURN |
| 147 | * is implemented for the compiler in use. |
| 148 | * |
| 149 | * \note The use of this macro is a work in progress. |
| 150 | * This macro may be added to more functions in the future. |
| 151 | * Such an extension is not considered an API break, provided that |
| 152 | * there are near-unavoidable circumstances under which the function |
| 153 | * can fail. For example, signature/MAC/AEAD verification functions, |
| 154 | * and functions that require a random generator, are considered |
| 155 | * return-check-critical. |
| 156 | */ |
| 157 | #define MBEDTLS_CHECK_RETURN_CRITICAL MBEDTLS_CHECK_RETURN |
| 158 | |
| 159 | /** Ordinary-failure function |
| 160 | * |
| 161 | * This macro appearing at the beginning of the declaration of a function |
| 162 | * indicates that its return value should be generally be checked in portable |
| 163 | * applications. Omitting the check will result in a compile-time warning if |
Gilles Peskine | 8472a10 | 2021-09-23 18:07:36 +0200 | [diff] [blame] | 164 | * #MBEDTLS_CHECK_RETURN is implemented for the compiler in use and |
| 165 | * #MBEDTLS_CHECK_RETURN_WARNING is enabled in the compile-time configuration. |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 166 | * |
Gilles Peskine | c277932 | 2021-09-30 18:56:17 +0200 | [diff] [blame] | 167 | * You can use #MBEDTLS_IGNORE_RETURN to explicitly ignore the return value |
| 168 | * of a function that is annotated with #MBEDTLS_CHECK_RETURN. |
| 169 | * |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 170 | * \note The use of this macro is a work in progress. |
| 171 | * This macro will be added to more functions in the future. |
| 172 | * Eventually this should appear before most functions returning |
| 173 | * an error code (as \c int in the \c mbedtls_xxx API or |
| 174 | * as ::psa_status_t in the \c psa_xxx API). |
| 175 | */ |
Gilles Peskine | 8472a10 | 2021-09-23 18:07:36 +0200 | [diff] [blame] | 176 | #if defined(MBEDTLS_CHECK_RETURN_WARNING) |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 177 | #define MBEDTLS_CHECK_RETURN_TYPICAL MBEDTLS_CHECK_RETURN |
Gilles Peskine | 8472a10 | 2021-09-23 18:07:36 +0200 | [diff] [blame] | 178 | #else |
| 179 | #define MBEDTLS_CHECK_RETURN_TYPICAL |
| 180 | #endif |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 181 | |
| 182 | /** Benign-failure function |
| 183 | * |
| 184 | * This macro appearing at the beginning of the declaration of a function |
| 185 | * indicates that it is rarely useful to check its return value. |
| 186 | * |
| 187 | * This macro has an empty expansion. It exists for documentation purposes: |
| 188 | * a #MBEDTLS_CHECK_RETURN_OPTIONAL annotation indicates that the function |
Tom Cosgrove | 2b15075 | 2022-05-26 11:55:43 +0100 | [diff] [blame] | 189 | * has been analyzed for return-check usefulness, whereas the lack of |
Gilles Peskine | ee0a443 | 2021-09-23 17:28:59 +0200 | [diff] [blame] | 190 | * an annotation indicates that the function has not been analyzed and its |
| 191 | * return-check usefulness is unknown. |
| 192 | */ |
| 193 | #define MBEDTLS_CHECK_RETURN_OPTIONAL |
| 194 | |
Mateusz Starzyk | 15a7420 | 2021-08-05 13:56:48 +0200 | [diff] [blame] | 195 | /** \def MBEDTLS_IGNORE_RETURN |
| 196 | * |
Gilles Peskine | c277932 | 2021-09-30 18:56:17 +0200 | [diff] [blame] | 197 | * Call this macro with one argument, a function call, to suppress a warning |
| 198 | * from #MBEDTLS_CHECK_RETURN due to that function call. |
| 199 | */ |
| 200 | #if !defined(MBEDTLS_IGNORE_RETURN) |
Gilles Peskine | 327cb72 | 2021-09-30 18:54:51 +0200 | [diff] [blame] | 201 | /* GCC doesn't silence the warning with just (void)(result). |
Gilles Peskine | c79e4ab | 2021-09-30 20:34:29 +0200 | [diff] [blame] | 202 | * (void)!(result) is known to work up at least up to GCC 10, as well |
Gilles Peskine | 327cb72 | 2021-09-30 18:54:51 +0200 | [diff] [blame] | 203 | * as with Clang and MSVC. |
| 204 | * |
| 205 | * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Non_002dbugs.html |
| 206 | * https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result |
| 207 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34 |
Mateusz Starzyk | 15a7420 | 2021-08-05 13:56:48 +0200 | [diff] [blame] | 208 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 209 | #define MBEDTLS_IGNORE_RETURN(result) ((void) !(result)) |
Gilles Peskine | c277932 | 2021-09-30 18:56:17 +0200 | [diff] [blame] | 210 | #endif |
Mateusz Starzyk | 15a7420 | 2021-08-05 13:56:48 +0200 | [diff] [blame] | 211 | |
Tom Cosgrove | 95b5d79 | 2023-09-01 14:34:37 +0100 | [diff] [blame] | 212 | /* If the following macro is defined, the library is being built by the test |
| 213 | * framework, and the framework is going to provide a replacement |
| 214 | * mbedtls_platform_zeroize() using a preprocessor macro, so the function |
| 215 | * declaration should be omitted. */ |
| 216 | #if !defined(MBEDTLS_TEST_DEFINES_ZEROIZE) //no-check-names |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 217 | /** |
| 218 | * \brief Securely zeroize a buffer |
| 219 | * |
Andres Amaya Garcia | 56e06db | 2018-04-24 08:37:52 -0500 | [diff] [blame] | 220 | * The function is meant to wipe the data contained in a buffer so |
| 221 | * that it can no longer be recovered even if the program memory |
| 222 | * is later compromised. Call this function on sensitive data |
| 223 | * stored on the stack before returning from a function, and on |
| 224 | * sensitive data stored on the heap before freeing the heap |
| 225 | * object. |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 226 | * |
Andres Amaya Garcia | 56e06db | 2018-04-24 08:37:52 -0500 | [diff] [blame] | 227 | * It is extremely difficult to guarantee that calls to |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 228 | * mbedtls_platform_zeroize() are not removed by aggressive |
| 229 | * compiler optimizations in a portable way. For this reason, Mbed |
| 230 | * TLS provides the configuration option |
| 231 | * MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure |
| 232 | * mbedtls_platform_zeroize() to use a suitable implementation for |
| 233 | * their platform and needs |
Andres Amaya Garcia | 56e06db | 2018-04-24 08:37:52 -0500 | [diff] [blame] | 234 | * |
| 235 | * \param buf Buffer to be zeroized |
| 236 | * \param len Length of the buffer in bytes |
| 237 | * |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 238 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 239 | void mbedtls_platform_zeroize(void *buf, size_t len); |
Tom Cosgrove | 43210b5 | 2023-09-01 09:53:42 +0100 | [diff] [blame] | 240 | #endif |
| 241 | |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 242 | #if defined(MBEDTLS_HAVE_TIME_DATE) |
| 243 | /** |
Hanno Becker | c52ef40 | 2018-09-05 16:28:59 +0100 | [diff] [blame] | 244 | * \brief Platform-specific implementation of gmtime_r() |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 245 | * |
Hanno Becker | c52ef40 | 2018-09-05 16:28:59 +0100 | [diff] [blame] | 246 | * The function is a thread-safe abstraction that behaves |
Hanno Becker | 03b2bd4 | 2018-09-06 09:08:55 +0100 | [diff] [blame] | 247 | * similarly to the gmtime_r() function from Unix/POSIX. |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 248 | * |
Hanno Becker | 6a73978 | 2018-09-05 15:06:19 +0100 | [diff] [blame] | 249 | * Mbed TLS will try to identify the underlying platform and |
Hanno Becker | c52ef40 | 2018-09-05 16:28:59 +0100 | [diff] [blame] | 250 | * make use of an appropriate underlying implementation (e.g. |
Hanno Becker | 6a73978 | 2018-09-05 15:06:19 +0100 | [diff] [blame] | 251 | * gmtime_r() for POSIX and gmtime_s() for Windows). If this is |
| 252 | * not possible, then gmtime() will be used. In this case, calls |
| 253 | * from the library to gmtime() will be guarded by the mutex |
| 254 | * mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is |
| 255 | * enabled. It is recommended that calls from outside the library |
| 256 | * are also guarded by this mutex. |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 257 | * |
Hanno Becker | 6a73978 | 2018-09-05 15:06:19 +0100 | [diff] [blame] | 258 | * If MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, then Mbed TLS will |
| 259 | * unconditionally use the alternative implementation for |
| 260 | * mbedtls_platform_gmtime_r() supplied by the user at compile time. |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 261 | * |
Hanno Becker | 272675f | 2018-09-05 14:03:02 +0100 | [diff] [blame] | 262 | * \param tt Pointer to an object containing time (in seconds) since the |
Hanno Becker | 48a816f | 2018-09-05 15:22:22 +0100 | [diff] [blame] | 263 | * epoch to be converted |
Hanno Becker | 272675f | 2018-09-05 14:03:02 +0100 | [diff] [blame] | 264 | * \param tm_buf Pointer to an object where the results will be stored |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 265 | * |
| 266 | * \return Pointer to an object of type struct tm on success, otherwise |
| 267 | * NULL |
| 268 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 269 | struct tm *mbedtls_platform_gmtime_r(const mbedtls_time_t *tt, |
| 270 | struct tm *tm_buf); |
Andres Amaya Garcia | 1abb368 | 2018-08-16 21:42:09 +0100 | [diff] [blame] | 271 | #endif /* MBEDTLS_HAVE_TIME_DATE */ |
| 272 | |
Andres Amaya Garcia | 904e1ef | 2018-04-17 09:16:30 -0500 | [diff] [blame] | 273 | #ifdef __cplusplus |
| 274 | } |
| 275 | #endif |
| 276 | |
| 277 | #endif /* MBEDTLS_PLATFORM_UTIL_H */ |