mbed TLS v2.16.1
platform_util.h
Go to the documentation of this file.
1 
7 /*
8  * Copyright (C) 2018, Arm Limited, All Rights Reserved
9  * SPDX-License-Identifier: GPL-2.0
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * This file is part of Mbed TLS (https://tls.mbed.org)
26  */
27 #ifndef MBEDTLS_PLATFORM_UTIL_H
28 #define MBEDTLS_PLATFORM_UTIL_H
29 
30 #if !defined(MBEDTLS_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include MBEDTLS_CONFIG_FILE
34 #endif
35 
36 #include <stddef.h>
37 #if defined(MBEDTLS_HAVE_TIME_DATE)
38 #include "platform_time.h"
39 #include <time.h>
40 #endif /* MBEDTLS_HAVE_TIME_DATE */
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #if defined(MBEDTLS_CHECK_PARAMS)
47 
48 #if defined(MBEDTLS_PARAM_FAILED)
49 
54 #define MBEDTLS_PARAM_FAILED_ALT
55 #else /* MBEDTLS_PARAM_FAILED */
56 #define MBEDTLS_PARAM_FAILED( cond ) \
57  mbedtls_param_failed( #cond, __FILE__, __LINE__ )
58 
74 void mbedtls_param_failed( const char *failure_condition,
75  const char *file,
76  int line );
77 #endif /* MBEDTLS_PARAM_FAILED */
78 
79 /* Internal macro meant to be called only from within the library. */
80 #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) \
81  do { \
82  if( !(cond) ) \
83  { \
84  MBEDTLS_PARAM_FAILED( cond ); \
85  return( ret ); \
86  } \
87  } while( 0 )
88 
89 /* Internal macro meant to be called only from within the library. */
90 #define MBEDTLS_INTERNAL_VALIDATE( cond ) \
91  do { \
92  if( !(cond) ) \
93  { \
94  MBEDTLS_PARAM_FAILED( cond ); \
95  return; \
96  } \
97  } while( 0 )
98 
99 #else /* MBEDTLS_CHECK_PARAMS */
100 
101 /* Internal macros meant to be called only from within the library. */
102 #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 )
103 #define MBEDTLS_INTERNAL_VALIDATE( cond ) do { } while( 0 )
104 
105 #endif /* MBEDTLS_CHECK_PARAMS */
106 
107 /* Internal helper macros for deprecating API constants. */
108 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
109 #if defined(MBEDTLS_DEPRECATED_WARNING)
110 /* Deliberately don't (yet) export MBEDTLS_DEPRECATED here
111  * to avoid conflict with other headers which define and use
112  * it, too. We might want to move all these definitions here at
113  * some point for uniformity. */
114 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
115 MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t;
116 #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \
117  ( (mbedtls_deprecated_string_constant_t) ( VAL ) )
118 MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t;
119 #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \
120  ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) )
121 #undef MBEDTLS_DEPRECATED
122 #else /* MBEDTLS_DEPRECATED_WARNING */
123 #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL
124 #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL
125 #endif /* MBEDTLS_DEPRECATED_WARNING */
126 #endif /* MBEDTLS_DEPRECATED_REMOVED */
127 
150 void mbedtls_platform_zeroize( void *buf, size_t len );
151 
152 #if defined(MBEDTLS_HAVE_TIME_DATE)
153 
179 struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
180  struct tm *tm_buf );
181 #endif /* MBEDTLS_HAVE_TIME_DATE */
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* MBEDTLS_PLATFORM_UTIL_H */
#define MBEDTLS_DEPRECATED
Definition: aes.h:627
Configuration options (set of defines)
void mbedtls_platform_zeroize(void *buf, size_t len)
Securely zeroize a buffer.
time_t mbedtls_time_t
Definition: platform_time.h:55
struct tm * mbedtls_platform_gmtime_r(const mbedtls_time_t *tt, struct tm *tm_buf)
Platform-specific implementation of gmtime_r()
mbed TLS Platform time abstraction