33 #ifndef MBEDTLS_COMPAT_H_
34 #define MBEDTLS_COMPAT_H_
40 #include <mbedtls/cipher.h>
41 #include <mbedtls/ctr_drbg.h>
42 #include <mbedtls/dhm.h>
43 #include <mbedtls/md.h>
44 #include <mbedtls/pem.h>
45 #include <mbedtls/pk.h>
46 #include <mbedtls/ssl.h>
47 #include <mbedtls/version.h>
48 #include <mbedtls/x509_crt.h>
50 #if HAVE_MBEDTLS_PSA_CRYPTO_H
51 #include <psa/crypto.h>
57 #if HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C)
58 if (psa_crypto_init() != PSA_SUCCESS)
60 msg(
M_FATAL,
"mbedtls: psa_crypto_init() failed");
77 const unsigned char *additional,
80 #if MBEDTLS_VERSION_NUMBER > 0x03000000
81 return mbedtls_ctr_drbg_update(ctx, additional, add_len);
82 #elif HAVE_MBEDTLS_CTR_DRBG_UPDATE_RET
83 return mbedtls_ctr_drbg_update_ret(ctx, additional, add_len);
85 mbedtls_ctr_drbg_update(ctx, additional, add_len);
92 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng)
94 #if MBEDTLS_VERSION_NUMBER < 0x03020100
95 return mbedtls_pk_check_pair(pub, prv);
97 return mbedtls_pk_check_pair(pub, prv, f_rng, p_rng);
103 const unsigned char *
key,
size_t keylen,
104 const unsigned char *pwd,
size_t pwdlen,
105 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng)
107 #if MBEDTLS_VERSION_NUMBER < 0x03020100
108 return mbedtls_pk_parse_key(ctx,
key, keylen, pwd, pwdlen);
110 return mbedtls_pk_parse_key(ctx,
key, keylen, pwd, pwdlen, f_rng, p_rng);
116 const char *path,
const char *password,
117 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng)
119 #if MBEDTLS_VERSION_NUMBER < 0x03020100
120 return mbedtls_pk_parse_keyfile(ctx, path, password);
122 return mbedtls_pk_parse_keyfile(ctx, path, password, f_rng, p_rng);
126 #if MBEDTLS_VERSION_NUMBER < 0x03020100
130 return (
size_t)cipher->block_size;
136 return (
size_t)cipher->iv_size;
142 return (
size_t)cipher->key_bitlen;
145 static inline mbedtls_cipher_mode_t
151 static inline const char *
157 static inline mbedtls_cipher_type_t
169 static inline const mbedtls_md_info_t *
175 static inline const unsigned char *
178 *buf_size = ctx->buflen;
185 return ctx->ext_types & ext_type;