blob: 637f9d38bf6df3ef5c45ca61f4c7a2c7e4d86675 [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 Rodgman16799db2023-11-02 19:47:20 +00008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Paul Bakkerf3b86c12011-01-27 15:24:17 +00009 */
10/*
Bence Szépkúti04982f72021-06-21 14:40:51 +020011 * This set of run-time variables can be used to determine the version number of
Bence Szépkúti1b2a8832021-06-28 10:26:11 +010012 * the Mbed TLS library used. Compile-time version defines for the same can be
Bence Szépkúti04982f72021-06-21 14:40:51 +020013 * found in build_info.h
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000014 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020015#ifndef MBEDTLS_VERSION_H
16#define MBEDTLS_VERSION_H
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000017
Bence Szépkútic662b362021-05-27 11:25:03 +020018#include "mbedtls/build_info.h"
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000019
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020020#if defined(MBEDTLS_VERSION_C)
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000021
Paul Bakker407a0da2013-06-27 14:29:21 +020022#ifdef __cplusplus
23extern "C" {
24#endif
25
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000026/**
27 * Get the version number.
28 *
Paul Bakker0f5f72e2011-01-18 14:58:55 +000029 * \return The constructed version number in the format
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000030 * MMNNPP00 (Major, Minor, Patch).
31 */
Gilles Peskine449bd832023-01-11 14:50:10 +010032unsigned int mbedtls_version_get_number(void);
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000033
34/**
35 * Get the version string ("x.y.z").
36 *
Paul Bakker0f5f72e2011-01-18 14:58:55 +000037 * \param string The string that will receive the value.
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000038 * (Should be at least 9 bytes in size)
39 */
Gilles Peskine449bd832023-01-11 14:50:10 +010040void mbedtls_version_get_string(char *string);
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000041
42/**
Gilles Peskinee820c0a2023-08-03 17:45:20 +020043 * Get the full version string ("Mbed TLS x.y.z").
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000044 *
Gilles Peskinee820c0a2023-08-03 17:45:20 +020045 * \param string The string that will receive the value. The Mbed TLS version
Paul Bakker83946842014-04-30 10:21:23 +020046 * 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 Bakker3ac1b2d2010-06-18 22:47:29 +000050 */
Gilles Peskine449bd832023-01-11 14:50:10 +010051void mbedtls_version_get_string_full(char *string);
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000052
Paul Bakker0f90d7d2014-04-30 11:49:44 +020053/**
54 * \brief Check if support for a feature was compiled into this
Gilles Peskinee820c0a2023-08-03 17:45:20 +020055 * Mbed TLS binary. This allows you to see at runtime if the
Paul Bakker0f90d7d2014-04-30 11:49:44 +020056 * library was for instance compiled with or without
57 * Multi-threading support.
58 *
Manuel Pégourié-Gonnard3eb50fa2015-06-02 10:28:09 +010059 * \note only checks against defines in the sections "System
Gilles Peskinee820c0a2023-08-03 17:45:20 +020060 * support", "Mbed TLS modules" and "Mbed TLS feature
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +020061 * support" in mbedtls_config.h
Paul Bakker0f90d7d2014-04-30 11:49:44 +020062 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020063 * \param feature The string for the define to check (e.g. "MBEDTLS_AES_C")
Paul Bakker0f90d7d2014-04-30 11:49:44 +020064 *
Manuel Pégourié-Gonnard3eb50fa2015-06-02 10:28:09 +010065 * \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 Bakker0f90d7d2014-04-30 11:49:44 +020069 */
Gilles Peskine449bd832023-01-11 14:50:10 +010070int mbedtls_version_check_feature(const char *feature);
Paul Bakker0f90d7d2014-04-30 11:49:44 +020071
Paul Bakker407a0da2013-06-27 14:29:21 +020072#ifdef __cplusplus
73}
74#endif
75
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020076#endif /* MBEDTLS_VERSION_C */
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000077
78#endif /* version.h */