libssh  0.10.90
The SSH library
Loading...
Searching...
No Matches
mbedcrypto-compat.h
1#ifndef MBEDCRYPTO_COMPAT_H
2#define MBEDCRYPTO_COMPAT_H
3
4/* mbedtls/version.h should be available for both v2 and v3
5 * v3 defines the version inside build_info.h so if it isn't defined
6 * in version.h we should have v3
7 */
8#include <mbedtls/version.h>
9#include <mbedtls/cipher.h>
10#ifdef MBEDTLS_VERSION_MAJOR
11#if MBEDTLS_VERSION_MAJOR < 3
12
13static inline size_t mbedtls_cipher_info_get_key_bitlen(
14 const mbedtls_cipher_info_t *info)
15{
16 if (info == NULL) {
17 return 0;
18 }
19 return info->key_bitlen;
20}
21
22static inline size_t mbedtls_cipher_info_get_iv_size(
23 const mbedtls_cipher_info_t *info)
24{
25 if (info == NULL) {
26 return 0;
27 }
28 return (size_t)info->iv_size;
29}
30
31#define MBEDTLS_PRIVATE(X) X
32#endif /* MBEDTLS_VERSION_MAJOR < 3 */
33#else /* MBEDTLS_VERSION_MAJOR */
34#include <mbedtls/build_info.h>
35#if MBEDTLS_VERSION_MAJOR < 3
36#define MBEDTLS_PRIVATE(X) X
37#endif /* MBEDTLS_VERSION_MAJOR < 3 */
38#endif /* MBEDTLS_VERSION_MAJOR */
39#endif /* MBEDCRYPTO_COMPAT_H */