PolarSSL is now part of ARM Official announcement and rebranded as mbed TLS.

API Documentation (Doxygen generated)

These pages are generated with doxygen directly from the source code!

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: 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  * This file is part of Mbed TLS (https://tls.mbed.org)
24  */
25 #ifndef MBEDTLS_PLATFORM_UTIL_H
26 #define MBEDTLS_PLATFORM_UTIL_H
27 
28 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include "config.h"
30 #else
31 #include MBEDTLS_CONFIG_FILE
32 #endif
33 
34 #include <stddef.h>
35 #if defined(MBEDTLS_HAVE_TIME_DATE)
36 #include "platform_time.h"
37 #include <time.h>
38 #endif /* MBEDTLS_HAVE_TIME_DATE */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #if defined(MBEDTLS_CHECK_PARAMS)
45 
46 #if defined(MBEDTLS_PARAM_FAILED)
47 
52 #define MBEDTLS_PARAM_FAILED_ALT
53 #else /* MBEDTLS_PARAM_FAILED */
54 #define MBEDTLS_PARAM_FAILED( cond ) \
55  mbedtls_param_failed( #cond, __FILE__, __LINE__ )
56 
72 void mbedtls_param_failed( const char *failure_condition,
73  const char *file,
74  int line );
75 #endif /* MBEDTLS_PARAM_FAILED */
76 
77 /* Internal macro meant to be called only from within the library. */
78 #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) \
79  do { \
80  if( !(cond) ) \
81  { \
82  MBEDTLS_PARAM_FAILED( cond ); \
83  return( ret ); \
84  } \
85  } while( 0 )
86 
87 /* Internal macro meant to be called only from within the library. */
88 #define MBEDTLS_INTERNAL_VALIDATE( cond ) \
89  do { \
90  if( !(cond) ) \
91  { \
92  MBEDTLS_PARAM_FAILED( cond ); \
93  return; \
94  } \
95  } while( 0 )
96 
97 #else /* MBEDTLS_CHECK_PARAMS */
98 
99 /* Internal macros meant to be called only from within the library. */
100 #define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 )
101 #define MBEDTLS_INTERNAL_VALIDATE( cond ) do { } while( 0 )
102 
103 #endif /* MBEDTLS_CHECK_PARAMS */
104 
105 /* Internal helper macros for deprecating API constants. */
106 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
107 #if defined(MBEDTLS_DEPRECATED_WARNING)
108 /* Deliberately don't (yet) export MBEDTLS_DEPRECATED here
109  * to avoid conflict with other headers which define and use
110  * it, too. We might want to move all these definitions here at
111  * some point for uniformity. */
112 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
113 MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t;
114 #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \
115  ( (mbedtls_deprecated_string_constant_t) ( VAL ) )
116 MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t;
117 #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \
118  ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) )
119 #undef MBEDTLS_DEPRECATED
120 #else /* MBEDTLS_DEPRECATED_WARNING */
121 #define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL
122 #define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL
123 #endif /* MBEDTLS_DEPRECATED_WARNING */
124 #endif /* MBEDTLS_DEPRECATED_REMOVED */
125 
148 void mbedtls_platform_zeroize( void *buf, size_t len );
149 
150 #if defined(MBEDTLS_HAVE_TIME_DATE)
151 
177 struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
178  struct tm *tm_buf );
179 #endif /* MBEDTLS_HAVE_TIME_DATE */
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif /* MBEDTLS_PLATFORM_UTIL_H */
#define MBEDTLS_DEPRECATED
Definition: aes.h:625
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:53
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