mbed TLS v3.3.0
Loading...
Searching...
No Matches
platform_util.h
Go to the documentation of this file.
1
7/*
8 * Copyright The Mbed TLS Contributors
9 * SPDX-License-Identifier: Apache-2.0
10 *
11 * Licensed under the Apache License, Version 2.0 (the "License"); you may
12 * not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
19 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 */
23#ifndef MBEDTLS_PLATFORM_UTIL_H
24#define MBEDTLS_PLATFORM_UTIL_H
25
26#include "mbedtls/build_info.h"
27
28#include <stddef.h>
29#if defined(MBEDTLS_HAVE_TIME_DATE)
31#include <time.h>
32#endif /* MBEDTLS_HAVE_TIME_DATE */
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/* Internal macros meant to be called only from within the library. */
39#define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 )
40#define MBEDTLS_INTERNAL_VALIDATE( cond ) do { } while( 0 )
41
42/* Internal helper macros for deprecating API constants. */
43#if !defined(MBEDTLS_DEPRECATED_REMOVED)
44#if defined(MBEDTLS_DEPRECATED_WARNING)
45#define MBEDTLS_DEPRECATED __attribute__((deprecated))
46MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t;
47#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \
48 ( (mbedtls_deprecated_string_constant_t) ( VAL ) )
49MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t;
50#define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \
51 ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) )
52#else /* MBEDTLS_DEPRECATED_WARNING */
53#define MBEDTLS_DEPRECATED
54#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL
55#define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL
56#endif /* MBEDTLS_DEPRECATED_WARNING */
57#endif /* MBEDTLS_DEPRECATED_REMOVED */
58
59/* Implementation of the check-return facility.
60 * See the user documentation in mbedtls_config.h.
61 *
62 * Do not use this macro directly to annotate function: instead,
63 * use one of MBEDTLS_CHECK_RETURN_CRITICAL or MBEDTLS_CHECK_RETURN_TYPICAL
64 * depending on how important it is to check the return value.
65 */
66#if !defined(MBEDTLS_CHECK_RETURN)
67#if defined(__GNUC__)
68#define MBEDTLS_CHECK_RETURN __attribute__((__warn_unused_result__))
69#elif defined(_MSC_VER) && _MSC_VER >= 1700
70#include <sal.h>
71#define MBEDTLS_CHECK_RETURN _Check_return_
72#else
73#define MBEDTLS_CHECK_RETURN
74#endif
75#endif
76
93#define MBEDTLS_CHECK_RETURN_CRITICAL MBEDTLS_CHECK_RETURN
94
112#if defined(MBEDTLS_CHECK_RETURN_WARNING)
113#define MBEDTLS_CHECK_RETURN_TYPICAL MBEDTLS_CHECK_RETURN
114#else
115#define MBEDTLS_CHECK_RETURN_TYPICAL
116#endif
117
129#define MBEDTLS_CHECK_RETURN_OPTIONAL
130
136#if !defined(MBEDTLS_IGNORE_RETURN)
137/* GCC doesn't silence the warning with just (void)(result).
138 * (void)!(result) is known to work up at least up to GCC 10, as well
139 * as with Clang and MSVC.
140 *
141 * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Non_002dbugs.html
142 * https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result
143 * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34
144 */
145#define MBEDTLS_IGNORE_RETURN(result) ( (void) !( result ) )
146#endif
147
170void mbedtls_platform_zeroize( void *buf, size_t len );
171
172#if defined(MBEDTLS_HAVE_TIME_DATE)
200 struct tm *tm_buf );
201#endif /* MBEDTLS_HAVE_TIME_DATE */
202
203#ifdef __cplusplus
204}
205#endif
206
207#endif /* MBEDTLS_PLATFORM_UTIL_H */
Build-time configuration info.
mbed TLS Platform time abstraction
time_t mbedtls_time_t
Definition: platform_time.h:39
void mbedtls_platform_zeroize(void *buf, size_t len)
Securely zeroize a buffer.
#define MBEDTLS_DEPRECATED
Definition: platform_util.h:53
struct tm * mbedtls_platform_gmtime_r(const mbedtls_time_t *tt, struct tm *tm_buf)
Platform-specific implementation of gmtime_r()