blob: 66998bf560f1a29810ac082acfd32c4ab914ff93 [file] [log] [blame]
Paul Bakker3ac1b2d2010-06-18 22:47:29 +00001/**
2 * \file version.h
3 *
Paul Bakkerf3b86c12011-01-27 15:24:17 +00004 * \brief Run-time version information
Darryl Greena40a1012018-01-05 15:33:17 +00005 */
6/*
Bence Szépkúti1e148272020-08-07 13:07:28 +02007 * Copyright The Mbed TLS Contributors
Dave Rodgman0f2971a2023-11-03 12:04:52 +00008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Paul Bakkerf3b86c12011-01-27 15:24:17 +00009 */
10/*
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000011 * This set of compile-time defines and run-time variables can be used to
Gilles Peskinef08ca832023-09-12 19:21:54 +020012 * determine the version number of the Mbed TLS library used.
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000013 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020014#ifndef MBEDTLS_VERSION_H
15#define MBEDTLS_VERSION_H
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000016
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020017#if !defined(MBEDTLS_CONFIG_FILE)
Jaeden Amero6609aef2019-07-04 20:01:14 +010018#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020019#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020020#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020021#endif
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000022
23/**
24 * The version number x.y.z is split into three parts.
25 * Major, Minor, Patchlevel
26 */
Jaeden Amero3f8d7842019-03-19 16:11:28 +000027#define MBEDTLS_VERSION_MAJOR 2
Dave Rodgmand41dab32021-12-15 11:55:31 +000028#define MBEDTLS_VERSION_MINOR 28
Manuel Pégourié-Gonnard9f7cc4c2024-08-26 12:44:41 +020029#define MBEDTLS_VERSION_PATCH 9
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000030
31/**
32 * The single version number has the following structure:
33 * MMNNPP00
34 * Major version | Minor version | Patch version
35 */
Manuel Pégourié-Gonnard9f7cc4c2024-08-26 12:44:41 +020036#define MBEDTLS_VERSION_NUMBER 0x021C0900
37#define MBEDTLS_VERSION_STRING "2.28.9"
38#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 2.28.9"
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000039
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020040#if defined(MBEDTLS_VERSION_C)
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000041
Paul Bakker407a0da2013-06-27 14:29:21 +020042#ifdef __cplusplus
43extern "C" {
44#endif
45
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000046/**
47 * Get the version number.
48 *
Paul Bakker0f5f72e2011-01-18 14:58:55 +000049 * \return The constructed version number in the format
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000050 * MMNNPP00 (Major, Minor, Patch).
51 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010052unsigned int mbedtls_version_get_number(void);
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000053
54/**
55 * Get the version string ("x.y.z").
56 *
Paul Bakker0f5f72e2011-01-18 14:58:55 +000057 * \param string The string that will receive the value.
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000058 * (Should be at least 9 bytes in size)
59 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010060void mbedtls_version_get_string(char *string);
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000061
62/**
Gilles Peskinef08ca832023-09-12 19:21:54 +020063 * Get the full version string ("Mbed TLS x.y.z").
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000064 *
Gilles Peskinef08ca832023-09-12 19:21:54 +020065 * \param string The string that will receive the value. The Mbed TLS version
Paul Bakker83946842014-04-30 10:21:23 +020066 * string will use 18 bytes AT MOST including a terminating
67 * null byte.
68 * (So the buffer should be at least 18 bytes to receive this
69 * version string).
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000070 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010071void mbedtls_version_get_string_full(char *string);
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000072
Paul Bakker0f90d7d2014-04-30 11:49:44 +020073/**
74 * \brief Check if support for a feature was compiled into this
Gilles Peskinef08ca832023-09-12 19:21:54 +020075 * Mbed TLS binary. This allows you to see at runtime if the
Paul Bakker0f90d7d2014-04-30 11:49:44 +020076 * library was for instance compiled with or without
77 * Multi-threading support.
78 *
Manuel Pégourié-Gonnard3eb50fa2015-06-02 10:28:09 +010079 * \note only checks against defines in the sections "System
Gilles Peskinef08ca832023-09-12 19:21:54 +020080 * support", "Mbed TLS modules" and "Mbed TLS feature
Manuel Pégourié-Gonnard3eb50fa2015-06-02 10:28:09 +010081 * support" in config.h
Paul Bakker0f90d7d2014-04-30 11:49:44 +020082 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020083 * \param feature The string for the define to check (e.g. "MBEDTLS_AES_C")
Paul Bakker0f90d7d2014-04-30 11:49:44 +020084 *
Manuel Pégourié-Gonnard3eb50fa2015-06-02 10:28:09 +010085 * \return 0 if the feature is present,
86 * -1 if the feature is not present and
87 * -2 if support for feature checking as a whole was not
88 * compiled in.
Paul Bakker0f90d7d2014-04-30 11:49:44 +020089 */
Gilles Peskine1b6c09a2023-01-11 14:52:35 +010090int mbedtls_version_check_feature(const char *feature);
Paul Bakker0f90d7d2014-04-30 11:49:44 +020091
Paul Bakker407a0da2013-06-27 14:29:21 +020092#ifdef __cplusplus
93}
94#endif
95
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020096#endif /* MBEDTLS_VERSION_C */
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000097
98#endif /* version.h */