ReactOS  0.4.15-dev-3428-g0609db5
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 OR GPL-2.0-or-later
10  *
11  * This file is provided under the Apache License 2.0, or the
12  * GNU General Public License v2.0 or later.
13  *
14  * **********
15  * Apache License 2.0:
16  *
17  * Licensed under the Apache License, Version 2.0 (the "License"); you may
18  * not use this file except in compliance with the License.
19  * You may obtain a copy of the License at
20  *
21  * http://www.apache.org/licenses/LICENSE-2.0
22  *
23  * Unless required by applicable law or agreed to in writing, software
24  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
25  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26  * See the License for the specific language governing permissions and
27  * limitations under the License.
28  *
29  * **********
30  *
31  * **********
32  * GNU General Public License v2.0 or later:
33  *
34  * This program is free software; you can redistribute it and/or modify
35  * it under the terms of the GNU General Public License as published by
36  * the Free Software Foundation; either version 2 of the License, or
37  * (at your option) any later version.
38  *
39  * This program is distributed in the hope that it will be useful,
40  * but WITHOUT ANY WARRANTY; without even the implied warranty of
41  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42  * GNU General Public License for more details.
43  *
44  * You should have received a copy of the GNU General Public License along
45  * with this program; if not, write to the Free Software Foundation, Inc.,
46  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
47  *
48  * **********
49  */
50 #ifndef MBEDTLS_PLATFORM_UTIL_H
51 #define MBEDTLS_PLATFORM_UTIL_H
52 
53 #if !defined(MBEDTLS_CONFIG_FILE)
54 #include "config.h"
55 #else
56 #include MBEDTLS_CONFIG_FILE
57 #endif
58 
59 #include <stddef.h>
60 #if defined(MBEDTLS_HAVE_TIME_DATE)
61 #include "platform_time.h"
62 #include <time.h>
63 #endif /* MBEDTLS_HAVE_TIME_DATE */
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 #if defined(MBEDTLS_CHECK_PARAMS)
70 
71 #if defined(MBEDTLS_CHECK_PARAMS_ASSERT)
72 /* Allow the user to define MBEDTLS_PARAM_FAILED to something like assert
73  * (which is what our config.h suggests). */
74 #include <assert.h>
75 #endif /* MBEDTLS_CHECK_PARAMS_ASSERT */
76 
77 #if defined(MBEDTLS_PARAM_FAILED)
78 
83 #define MBEDTLS_PARAM_FAILED_ALT
84 
85 #elif defined(MBEDTLS_CHECK_PARAMS_ASSERT)
86 #define MBEDTLS_PARAM_FAILED( cond ) assert( cond )
87 #define MBEDTLS_PARAM_FAILED_ALT
88 
89 #else /* MBEDTLS_PARAM_FAILED */
90 #define MBEDTLS_PARAM_FAILED( cond ) \
91  mbedtls_param_failed( #cond, __FILE__, __LINE__ )
92 
108 void mbedtls_param_failed( const char *failure_condition,
109  const char *file,
110  int line );
111 #endif /* MBEDTLS_PARAM_FAILED */
112 
113 /* Internal macro meant to be called only from within the library. */
114 #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) \
115  do { \
116  if( !(cond) ) \
117  { \
118  MBEDTLS_PARAM_FAILED( cond ); \
119  return( ret ); \
120  } \
121  } while( 0 )
122 
123 /* Internal macro meant to be called only from within the library. */
124 #define MBEDTLS_INTERNAL_VALIDATE( cond ) \
125  do { \
126  if( !(cond) ) \
127  { \
128  MBEDTLS_PARAM_FAILED( cond ); \
129  return; \
130  } \
131  } while( 0 )
132 
133 #else /* MBEDTLS_CHECK_PARAMS */
134 
135 /* Internal macros meant to be called only from within the library. */
136 #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 )
137 #define MBEDTLS_INTERNAL_VALIDATE( cond ) do { } while( 0 )
138 
139 #endif /* MBEDTLS_CHECK_PARAMS */
140 
141 /* Internal helper macros for deprecating API constants. */
142 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
143 #if defined(MBEDTLS_DEPRECATED_WARNING)
144 /* Deliberately don't (yet) export MBEDTLS_DEPRECATED here
145  * to avoid conflict with other headers which define and use
146  * it, too. We might want to move all these definitions here at
147  * some point for uniformity. */
148 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
149 MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t;
150 #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \
151  ( (mbedtls_deprecated_string_constant_t) ( VAL ) )
152 MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t;
153 #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \
154  ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) )
155 #undef MBEDTLS_DEPRECATED
156 #else /* MBEDTLS_DEPRECATED_WARNING */
157 #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL
158 #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL
159 #endif /* MBEDTLS_DEPRECATED_WARNING */
160 #endif /* MBEDTLS_DEPRECATED_REMOVED */
161 
184 void mbedtls_platform_zeroize( void *buf, size_t len );
185 
186 #if defined(MBEDTLS_HAVE_TIME_DATE)
187 
213 struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
214  struct tm *tm_buf );
215 #endif /* MBEDTLS_HAVE_TIME_DATE */
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* MBEDTLS_PLATFORM_UTIL_H */
#define MBEDTLS_DEPRECATED
Definition: aes.h:651
void mbedtls_platform_zeroize(void *buf, size_t len)
Securely zeroize a buffer.
Definition: platform_util.c:98
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
time_t mbedtls_time_t
Definition: platform_time.h:78
Definition: parser.c:48
GLenum GLsizei len
Definition: glext.h:6722
Definition: time.h:68
mbed TLS Platform time abstraction
Definition: fci.c:126