Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file version.h |
| 3 | * |
Paul Bakker | f3b86c1 | 2011-01-27 15:24:17 +0000 | [diff] [blame] | 4 | * \brief Run-time version information |
Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 5 | */ |
| 6 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 7 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 16799db | 2023-11-02 19:47:20 +0000 | [diff] [blame] | 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Paul Bakker | f3b86c1 | 2011-01-27 15:24:17 +0000 | [diff] [blame] | 9 | */ |
| 10 | /* |
Bence Szépkúti | 04982f7 | 2021-06-21 14:40:51 +0200 | [diff] [blame] | 11 | * This set of run-time variables can be used to determine the version number of |
Bence Szépkúti | 1b2a883 | 2021-06-28 10:26:11 +0100 | [diff] [blame] | 12 | * the Mbed TLS library used. Compile-time version defines for the same can be |
Bence Szépkúti | 04982f7 | 2021-06-21 14:40:51 +0200 | [diff] [blame] | 13 | * found in build_info.h |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 14 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 15 | #ifndef MBEDTLS_VERSION_H |
| 16 | #define MBEDTLS_VERSION_H |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 17 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 18 | #include "mbedtls/build_info.h" |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 19 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 20 | #if defined(MBEDTLS_VERSION_C) |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 21 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 26 | /** |
| 27 | * Get the version number. |
| 28 | * |
Paul Bakker | 0f5f72e | 2011-01-18 14:58:55 +0000 | [diff] [blame] | 29 | * \return The constructed version number in the format |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 30 | * MMNNPP00 (Major, Minor, Patch). |
| 31 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 32 | unsigned int mbedtls_version_get_number(void); |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Get the version string ("x.y.z"). |
| 36 | * |
Paul Bakker | 0f5f72e | 2011-01-18 14:58:55 +0000 | [diff] [blame] | 37 | * \param string The string that will receive the value. |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 38 | * (Should be at least 9 bytes in size) |
| 39 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 40 | void mbedtls_version_get_string(char *string); |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 41 | |
| 42 | /** |
Gilles Peskine | e820c0a | 2023-08-03 17:45:20 +0200 | [diff] [blame] | 43 | * Get the full version string ("Mbed TLS x.y.z"). |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 44 | * |
Gilles Peskine | e820c0a | 2023-08-03 17:45:20 +0200 | [diff] [blame] | 45 | * \param string The string that will receive the value. The Mbed TLS version |
Paul Bakker | 8394684 | 2014-04-30 10:21:23 +0200 | [diff] [blame] | 46 | * string will use 18 bytes AT MOST including a terminating |
| 47 | * null byte. |
| 48 | * (So the buffer should be at least 18 bytes to receive this |
| 49 | * version string). |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 50 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 51 | void mbedtls_version_get_string_full(char *string); |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 52 | |
Paul Bakker | 0f90d7d | 2014-04-30 11:49:44 +0200 | [diff] [blame] | 53 | /** |
| 54 | * \brief Check if support for a feature was compiled into this |
Gilles Peskine | e820c0a | 2023-08-03 17:45:20 +0200 | [diff] [blame] | 55 | * Mbed TLS binary. This allows you to see at runtime if the |
Paul Bakker | 0f90d7d | 2014-04-30 11:49:44 +0200 | [diff] [blame] | 56 | * library was for instance compiled with or without |
| 57 | * Multi-threading support. |
| 58 | * |
Manuel Pégourié-Gonnard | 3eb50fa | 2015-06-02 10:28:09 +0100 | [diff] [blame] | 59 | * \note only checks against defines in the sections "System |
Gilles Peskine | e820c0a | 2023-08-03 17:45:20 +0200 | [diff] [blame] | 60 | * support", "Mbed TLS modules" and "Mbed TLS feature |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 61 | * support" in mbedtls_config.h |
Paul Bakker | 0f90d7d | 2014-04-30 11:49:44 +0200 | [diff] [blame] | 62 | * |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 63 | * \param feature The string for the define to check (e.g. "MBEDTLS_AES_C") |
Paul Bakker | 0f90d7d | 2014-04-30 11:49:44 +0200 | [diff] [blame] | 64 | * |
Manuel Pégourié-Gonnard | 3eb50fa | 2015-06-02 10:28:09 +0100 | [diff] [blame] | 65 | * \return 0 if the feature is present, |
| 66 | * -1 if the feature is not present and |
| 67 | * -2 if support for feature checking as a whole was not |
| 68 | * compiled in. |
Paul Bakker | 0f90d7d | 2014-04-30 11:49:44 +0200 | [diff] [blame] | 69 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 70 | int mbedtls_version_check_feature(const char *feature); |
Paul Bakker | 0f90d7d | 2014-04-30 11:49:44 +0200 | [diff] [blame] | 71 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 72 | #ifdef __cplusplus |
| 73 | } |
| 74 | #endif |
| 75 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 76 | #endif /* MBEDTLS_VERSION_C */ |
Paul Bakker | 3ac1b2d | 2010-06-18 22:47:29 +0000 | [diff] [blame] | 77 | |
| 78 | #endif /* version.h */ |