NCBI C++ ToolKit
Classes | Macros | Typedefs | Functions
platform.h File Reference

This file contains the definitions and functions of the Mbed TLS platform abstraction layer. More...

#include "mbedtls/private_access.h"
#include "mbedtls/build_info.h"
#include <stdio.h>
#include <stdlib.h>
+ Include dependency graph for platform.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Go to the SVN repository for this file.

Classes

struct  mbedtls_platform_context
 The platform context structure. More...
 

Macros

#define mbedtls_free   free
 
#define mbedtls_calloc   calloc
 
#define mbedtls_fprintf   fprintf
 
#define mbedtls_printf   printf
 
#define mbedtls_snprintf   MBEDTLS_PLATFORM_STD_SNPRINTF
 
#define mbedtls_vsnprintf   vsnprintf
 
#define mbedtls_setbuf   setbuf
 
#define mbedtls_exit   exit
 
#define MBEDTLS_EXIT_SUCCESS   MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
 
#define MBEDTLS_EXIT_FAILURE   MBEDTLS_PLATFORM_STD_EXIT_FAILURE
 
SECTION: Module settings

The configuration options you can set for this module are in this section.

Either change them in mbedtls_config.h or define them on the compiler command line.

#define MBEDTLS_PLATFORM_STD_SNPRINTF   snprintf
 The default snprintf function to use. More...
 
#define MBEDTLS_PLATFORM_STD_VSNPRINTF   vsnprintf
 The default vsnprintf function to use. More...
 
#define MBEDTLS_PLATFORM_STD_PRINTF   printf
 The default printf function to use. More...
 
#define MBEDTLS_PLATFORM_STD_FPRINTF   fprintf
 The default fprintf function to use. More...
 
#define MBEDTLS_PLATFORM_STD_CALLOC   calloc
 Default allocator to use, can be undefined. More...
 
#define MBEDTLS_PLATFORM_STD_FREE   free
 Default free to use, can be undefined. More...
 
#define MBEDTLS_PLATFORM_STD_SETBUF   setbuf
 The default setbuf function to use. More...
 
#define MBEDTLS_PLATFORM_STD_EXIT   exit
 The default exit function to use. More...
 
#define MBEDTLS_PLATFORM_STD_TIME   time
 The default time function to use. More...
 
#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS   EXIT_SUCCESS
 The default exit value to use. More...
 
#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE   EXIT_FAILURE
 The default exit value to use. More...
 

Typedefs

typedef struct mbedtls_platform_context mbedtls_platform_context
 The platform context structure. More...
 

Functions

int mbedtls_platform_setup (mbedtls_platform_context *ctx)
 This function performs any platform-specific initialization operations. More...
 
void mbedtls_platform_teardown (mbedtls_platform_context *ctx)
 This function performs any platform teardown operations. More...
 

Detailed Description

This file contains the definitions and functions of the Mbed TLS platform abstraction layer.

The platform abstraction layer removes the need for the library to directly link to standard C library functions or operating system services, making the library easier to port and embed. Application developers and users of the library can provide their own implementations of these functions, or implementations specific to their platform, which can be statically linked to the library or dynamically configured at runtime.

When all compilation options related to platform abstraction are disabled, this header just defines `mbedtls_xxx` function names as aliases to the standard `xxx` function.

Most modules in the library and example programs are expected to include this header.

Definition in file platform.h.

Macro Definition Documentation

◆ mbedtls_calloc

#define mbedtls_calloc   calloc

Definition at line 167 of file platform.h.

◆ mbedtls_exit

#define mbedtls_exit   exit

Definition at line 370 of file platform.h.

◆ MBEDTLS_EXIT_FAILURE

#define MBEDTLS_EXIT_FAILURE   MBEDTLS_PLATFORM_STD_EXIT_FAILURE

Definition at line 383 of file platform.h.

◆ MBEDTLS_EXIT_SUCCESS

#define MBEDTLS_EXIT_SUCCESS   MBEDTLS_PLATFORM_STD_EXIT_SUCCESS

Definition at line 378 of file platform.h.

◆ mbedtls_fprintf

#define mbedtls_fprintf   fprintf

Definition at line 194 of file platform.h.

◆ mbedtls_free

#define mbedtls_free   free

Definition at line 166 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_CALLOC

#define MBEDTLS_PLATFORM_STD_CALLOC   calloc

Default allocator to use, can be undefined.

The default calloc function to use.

It must initialize the allocated buffer memory to zeroes. The size of the buffer is the product of the two parameters. The calloc function returns either a null pointer or a pointer to the allocated space. If the product is 0, the function may either return NULL or a valid pointer to an array of size 0 which is a valid input to the deallocation function. An uninitialized MBEDTLS_PLATFORM_STD_CALLOC always fails, returning a null pointer. See the description of #MBEDTLS_PLATFORM_MEMORY for more details. The corresponding deallocation function is MBEDTLS_PLATFORM_STD_FREE.

Definition at line 84 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_EXIT

#define MBEDTLS_PLATFORM_STD_EXIT   exit

The default exit function to use.

Definition at line 93 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_EXIT_FAILURE

#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE   EXIT_FAILURE

The default exit value to use.

Definition at line 102 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_EXIT_SUCCESS

#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS   EXIT_SUCCESS

The default exit value to use.

Definition at line 99 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_FPRINTF

#define MBEDTLS_PLATFORM_STD_FPRINTF   fprintf

The default fprintf function to use.

Definition at line 81 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_FREE

#define MBEDTLS_PLATFORM_STD_FREE   free

Default free to use, can be undefined.

The default free function to use.

NULL is a valid parameter, and the function must do nothing. A non-null parameter will always be a pointer previously returned by MBEDTLS_PLATFORM_STD_CALLOC and not yet freed. An uninitialized MBEDTLS_PLATFORM_STD_FREE does not do anything. See the description of #MBEDTLS_PLATFORM_MEMORY for more details (same principles as for MBEDTLS_PLATFORM_STD_CALLOC apply).

Definition at line 87 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_PRINTF

#define MBEDTLS_PLATFORM_STD_PRINTF   printf

The default printf function to use.

Definition at line 78 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_SETBUF

#define MBEDTLS_PLATFORM_STD_SETBUF   setbuf

The default setbuf function to use.

Definition at line 90 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_SNPRINTF

#define MBEDTLS_PLATFORM_STD_SNPRINTF   snprintf

The default snprintf function to use.

Definition at line 67 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_TIME

#define MBEDTLS_PLATFORM_STD_TIME   time

The default time function to use.

Definition at line 96 of file platform.h.

◆ MBEDTLS_PLATFORM_STD_VSNPRINTF

#define MBEDTLS_PLATFORM_STD_VSNPRINTF   vsnprintf

The default vsnprintf function to use.

Definition at line 74 of file platform.h.

◆ mbedtls_printf

#define mbedtls_printf   printf

Definition at line 219 of file platform.h.

◆ mbedtls_setbuf

#define mbedtls_setbuf   setbuf

Definition at line 345 of file platform.h.

◆ mbedtls_snprintf

#define mbedtls_snprintf   MBEDTLS_PLATFORM_STD_SNPRINTF

Definition at line 255 of file platform.h.

◆ mbedtls_vsnprintf

#define mbedtls_vsnprintf   vsnprintf

Definition at line 292 of file platform.h.

Typedef Documentation

◆ mbedtls_platform_context

The platform context structure.

Note
This structure may be used to assist platform-specific setup or teardown operations.

Function Documentation

◆ mbedtls_platform_setup()

int mbedtls_platform_setup ( mbedtls_platform_context ctx)

This function performs any platform-specific initialization operations.

Note
This function should be called before any other library functions.

Its implementation is platform-specific, and unless platform-specific code is provided, it does nothing.

Note
The usage and necessity of this function is dependent on the platform.
Parameters
ctxThe platform context.
Returns
0 on success.

◆ mbedtls_platform_teardown()

void mbedtls_platform_teardown ( mbedtls_platform_context ctx)

This function performs any platform teardown operations.

Note
This function should be called after every other Mbed TLS module has been correctly freed using the appropriate free function.

Its implementation is platform-specific, and unless platform-specific code is provided, it does nothing.

Note
The usage and necessity of this function is dependent on the platform.
Parameters
ctxThe platform context.
Modified on Mon May 27 04:35:37 2024 by modify_doxy.py rev. 669887