mbed TLS v2.16.3: platform.h File Reference

mbed TLS v2.16.3

Data Structures | Macros
platform.h File Reference

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

`#include "config.h"`
`#include "platform_time.h"`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <time.h>`
Include dependency graph for platform.h:

Go to the source code of this file.

## Data Structures
struct | mbedtls_platform_context
| The platform context structure. More...

## Macros
#define | MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070
#define | MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072

## SECTION: Module settings
The configuration options you can set for this module are in this section. Either change them in config.h or define them on the compiler command line.
#define | MBEDTLS_PLATFORM_STD_SNPRINTF snprintf
#define | MBEDTLS_PLATFORM_STD_PRINTF printf
#define | MBEDTLS_PLATFORM_STD_FPRINTF fprintf
#define | MBEDTLS_PLATFORM_STD_CALLOC calloc
#define | MBEDTLS_PLATFORM_STD_FREE free
#define | MBEDTLS_PLATFORM_STD_EXIT exit
#define | MBEDTLS_PLATFORM_STD_TIME time
#define | MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS
#define | MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE
#define | MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read
#define | MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write
#define | MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile"
#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_exit exit
#define | MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
#define | MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE
typedef struct mbedtls_platform_context | mbedtls_platform_context
| The platform context structure. More...
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.

Definition in file platform.h.

## Macro Definition Documentation

## ◆ mbedtls_calloc

#define mbedtls_calloc calloc

Definition at line 144 of file platform.h.

## ◆ MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED

#define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072

The requested feature is not supported by the platform

Definition at line 47 of file platform.h.

## ◆ MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED

#define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070

Hardware accelerator failed

Definition at line 46 of file platform.h.

## ◆ mbedtls_exit

#define mbedtls_exit exit

Definition at line 253 of file platform.h.

## ◆ MBEDTLS_EXIT_FAILURE

#define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE

Definition at line 266 of file platform.h.

## ◆ MBEDTLS_EXIT_SUCCESS

#define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS

Definition at line 261 of file platform.h.

## ◆ mbedtls_fprintf

#define mbedtls_fprintf fprintf

Definition at line 170 of file platform.h.

## ◆ mbedtls_free

#define mbedtls_free free

Definition at line 143 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_CALLOC

#define MBEDTLS_PLATFORM_STD_CALLOC calloc

The default `calloc` function to use.

Definition at line 79 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_EXIT

#define MBEDTLS_PLATFORM_STD_EXIT exit

The default `exit` function to use.

Definition at line 85 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 94 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 91 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_FPRINTF

#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf

The default `fprintf` function to use.

Definition at line 76 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_FREE

#define MBEDTLS_PLATFORM_STD_FREE free

The default `free` function to use.

Definition at line 82 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_NV_SEED_FILE

#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile"

Definition at line 104 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_NV_SEED_READ

#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read

Definition at line 98 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_NV_SEED_WRITE

#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write

Definition at line 101 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_PRINTF

#define MBEDTLS_PLATFORM_STD_PRINTF printf

The default `printf` function to use.

Definition at line 73 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_SNPRINTF

#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf

The default `snprintf` function to use.

Definition at line 69 of file platform.h.

## ◆ MBEDTLS_PLATFORM_STD_TIME

#define MBEDTLS_PLATFORM_STD_TIME time

The default `time` function to use.

Definition at line 88 of file platform.h.

## ◆ mbedtls_printf

#define mbedtls_printf printf

Definition at line 194 of file platform.h.

## ◆ mbedtls_snprintf

#define mbedtls_snprintf MBEDTLS_PLATFORM_STD_SNPRINTF

Definition at line 229 of file platform.h.

## Typedef Documentation

## ◆ mbedtls_platform_context

typedef struct mbedtls_platform_context 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.

  The usage and necessity of this function is dependent on the platform.

Parameters

  ctx | The 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

  ctx | The platform context.