OpenVPN
Data Structures | Macros | Typedefs | Functions
crypto_mbedtls.h File Reference

Data Channel Cryptography backend interface using the TF-PSA-Crypto library part of Mbed TLS 4. More...

#include <psa/crypto.h>
#include "integer.h"
Include dependency graph for crypto_mbedtls.h:

Go to the source code of this file.

Data Structures

struct  cipher_info
 
union  psa_cipher_or_aead_operation
 
struct  cipher_ctx
 
struct  md_info
 
struct  md_ctx
 
struct  hmac_ctx
 

Macros

#define OPENVPN_MAX_IV_LENGTH   16
 Maximum length of an IV.
 
#define OPENVPN_MODE_CBC   PSA_ALG_CBC_PKCS7
 Cipher is in CBC mode.
 
#define OPENVPN_MODE_OFB   PSA_ALG_OFB
 Cipher is in OFB mode.
 
#define OPENVPN_MODE_CFB   PSA_ALG_CFB
 Cipher is in CFB mode.
 
#define OPENVPN_MODE_GCM   PSA_ALG_GCM
 Cipher is in GCM mode.
 
#define OPENVPN_OP_ENCRYPT   0
 Cipher should encrypt.
 
#define OPENVPN_OP_DECRYPT   1
 Cipher should decrypt.
 
#define MD4_DIGEST_LENGTH   16
 
#define MD5_DIGEST_LENGTH   16
 
#define SHA_DIGEST_LENGTH   20
 
#define SHA256_DIGEST_LENGTH   32
 
#define mbed_ok(errval)   mbed_log_func_line_lite(D_CRYPT_ERRORS, errval, __func__, __LINE__)
 Check errval and log on error.
 

Typedefs

typedef int crypto_operation_t
 
typedef void provider_t
 
typedef struct cipher_info cipher_info_t
 
typedef union psa_cipher_or_aead_operation cipher_operation_t
 
typedef struct cipher_ctx cipher_ctx_t
 
typedef struct md_info md_info_t
 
typedef struct md_ctx md_ctx_t
 
typedef struct hmac_ctx hmac_ctx_t
 

Functions

bool mbed_log_err (unsigned int flags, int errval, const char *prefix)
 Log the supplied mbed TLS error, prefixed by supplied prefix.
 
bool mbed_log_func_line (unsigned int flags, int errval, const char *func, int line)
 Log the supplied mbed TLS error, prefixed by function name and line number.
 
static bool mbed_log_func_line_lite (unsigned int flags, int errval, const char *func, int line)
 Wraps mbed_log_func_line() to prevent function calls for non-errors.
 

Detailed Description

Data Channel Cryptography backend interface using the TF-PSA-Crypto library part of Mbed TLS 4.

Definition in file crypto_mbedtls.h.

Macro Definition Documentation

◆ mbed_ok

#define mbed_ok (   errval)    mbed_log_func_line_lite(D_CRYPT_ERRORS, errval, __func__, __LINE__)

Check errval and log on error.

Convenience wrapper to put around mbed TLS library calls, e.g. if (!mbed_ok (mbedtls_ssl_func())) return 0; or ASSERT (mbed_ok (mbedtls_ssl_func()));

Parameters
errvalmbed TLS error code to convert to error message.
Returns
true if no errors are detected, false otherwise. TODO: The log function has been removed, do something about it?

Definition at line 161 of file crypto_mbedtls.h.

◆ MD4_DIGEST_LENGTH

#define MD4_DIGEST_LENGTH   16

Definition at line 61 of file crypto_mbedtls.h.

◆ MD5_DIGEST_LENGTH

#define MD5_DIGEST_LENGTH   16

Definition at line 62 of file crypto_mbedtls.h.

◆ OPENVPN_MAX_IV_LENGTH

#define OPENVPN_MAX_IV_LENGTH   16

Maximum length of an IV.

Definition at line 39 of file crypto_mbedtls.h.

◆ OPENVPN_MODE_CBC

#define OPENVPN_MODE_CBC   PSA_ALG_CBC_PKCS7

Cipher is in CBC mode.

Definition at line 42 of file crypto_mbedtls.h.

◆ OPENVPN_MODE_CFB

#define OPENVPN_MODE_CFB   PSA_ALG_CFB

Cipher is in CFB mode.

Definition at line 48 of file crypto_mbedtls.h.

◆ OPENVPN_MODE_GCM

#define OPENVPN_MODE_GCM   PSA_ALG_GCM

Cipher is in GCM mode.

Definition at line 51 of file crypto_mbedtls.h.

◆ OPENVPN_MODE_OFB

#define OPENVPN_MODE_OFB   PSA_ALG_OFB

Cipher is in OFB mode.

Definition at line 45 of file crypto_mbedtls.h.

◆ OPENVPN_OP_DECRYPT

#define OPENVPN_OP_DECRYPT   1

Cipher should decrypt.

Definition at line 59 of file crypto_mbedtls.h.

◆ OPENVPN_OP_ENCRYPT

#define OPENVPN_OP_ENCRYPT   0

Cipher should encrypt.

Definition at line 56 of file crypto_mbedtls.h.

◆ SHA256_DIGEST_LENGTH

#define SHA256_DIGEST_LENGTH   32

Definition at line 64 of file crypto_mbedtls.h.

◆ SHA_DIGEST_LENGTH

#define SHA_DIGEST_LENGTH   20

Definition at line 63 of file crypto_mbedtls.h.

Typedef Documentation

◆ cipher_ctx_t

typedef struct cipher_ctx cipher_ctx_t

◆ cipher_info_t

typedef struct cipher_info cipher_info_t

◆ cipher_operation_t

◆ crypto_operation_t

typedef int crypto_operation_t

Definition at line 53 of file crypto_mbedtls.h.

◆ hmac_ctx_t

typedef struct hmac_ctx hmac_ctx_t

◆ md_ctx_t

typedef struct md_ctx md_ctx_t

◆ md_info_t

typedef struct md_info md_info_t

◆ provider_t

typedef void provider_t

Definition at line 66 of file crypto_mbedtls.h.

Function Documentation

◆ mbed_log_err()

bool mbed_log_err ( unsigned int  flags,
int  errval,
const char *  prefix 
)

Log the supplied mbed TLS error, prefixed by supplied prefix.

Parameters
flagsFlags to indicate error type and priority.
errvalmbed TLS error code.
prefixPrefix to mbed TLS error message.
Returns
true if no errors are detected, false otherwise.

◆ mbed_log_func_line()

bool mbed_log_func_line ( unsigned int  flags,
int  errval,
const char *  func,
int  line 
)

Log the supplied mbed TLS error, prefixed by function name and line number.

Parameters
flagsFlags to indicate error type and priority.
errvalmbed TLS error code.
funcFunction name where error was reported.
lineLine number where error was reported.
Returns
true if no errors are detected, false otherwise.

Referenced by mbed_log_func_line_lite().

◆ mbed_log_func_line_lite()

static bool mbed_log_func_line_lite ( unsigned int  flags,
int  errval,
const char *  func,
int  line 
)
inlinestatic

Wraps mbed_log_func_line() to prevent function calls for non-errors.

Definition at line 139 of file crypto_mbedtls.h.

References mbed_log_func_line().