blob: 648db7ed62584fbe8583aaaeb49649fa71732218 [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
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02008 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
11 * not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
Paul Bakkerf3b86c12011-01-27 15:24:17 +000021 */
22/*
Bence Szépkúti04982f72021-06-21 14:40:51 +020023 * This set of run-time variables can be used to determine the version number of
24 * the mbed TLS library used. Compile-time version defines for the same can be
25 * found in build_info.h
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000026 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020027#ifndef MBEDTLS_VERSION_H
28#define MBEDTLS_VERSION_H
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000029
Bence Szépkútic662b362021-05-27 11:25:03 +020030#include "mbedtls/build_info.h"
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000031
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020032#if defined(MBEDTLS_VERSION_C)
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000033
Paul Bakker407a0da2013-06-27 14:29:21 +020034#ifdef __cplusplus
35extern "C" {
36#endif
37
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000038/**
39 * Get the version number.
40 *
Paul Bakker0f5f72e2011-01-18 14:58:55 +000041 * \return The constructed version number in the format
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000042 * MMNNPP00 (Major, Minor, Patch).
43 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020044unsigned int mbedtls_version_get_number( void );
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000045
46/**
47 * Get the version string ("x.y.z").
48 *
Paul Bakker0f5f72e2011-01-18 14:58:55 +000049 * \param string The string that will receive the value.
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000050 * (Should be at least 9 bytes in size)
51 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020052void mbedtls_version_get_string( char *string );
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000053
54/**
Manuel Pégourié-Gonnardb4fe3cb2015-01-22 16:11:05 +000055 * Get the full version string ("mbed TLS x.y.z").
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000056 *
Manuel Pégourié-Gonnardb4fe3cb2015-01-22 16:11:05 +000057 * \param string The string that will receive the value. The mbed TLS version
Paul Bakker83946842014-04-30 10:21:23 +020058 * string will use 18 bytes AT MOST including a terminating
59 * null byte.
60 * (So the buffer should be at least 18 bytes to receive this
61 * version string).
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000062 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020063void mbedtls_version_get_string_full( char *string );
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000064
Paul Bakker0f90d7d2014-04-30 11:49:44 +020065/**
66 * \brief Check if support for a feature was compiled into this
Manuel Pégourié-Gonnardb4fe3cb2015-01-22 16:11:05 +000067 * mbed TLS binary. This allows you to see at runtime if the
Paul Bakker0f90d7d2014-04-30 11:49:44 +020068 * library was for instance compiled with or without
69 * Multi-threading support.
70 *
Manuel Pégourié-Gonnard3eb50fa2015-06-02 10:28:09 +010071 * \note only checks against defines in the sections "System
72 * support", "mbed TLS modules" and "mbed TLS feature
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +020073 * support" in mbedtls_config.h
Paul Bakker0f90d7d2014-04-30 11:49:44 +020074 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020075 * \param feature The string for the define to check (e.g. "MBEDTLS_AES_C")
Paul Bakker0f90d7d2014-04-30 11:49:44 +020076 *
Manuel Pégourié-Gonnard3eb50fa2015-06-02 10:28:09 +010077 * \return 0 if the feature is present,
78 * -1 if the feature is not present and
79 * -2 if support for feature checking as a whole was not
80 * compiled in.
Paul Bakker0f90d7d2014-04-30 11:49:44 +020081 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020082int mbedtls_version_check_feature( const char *feature );
Paul Bakker0f90d7d2014-04-30 11:49:44 +020083
Paul Bakker407a0da2013-06-27 14:29:21 +020084#ifdef __cplusplus
85}
86#endif
87
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020088#endif /* MBEDTLS_VERSION_C */
Paul Bakker3ac1b2d2010-06-18 22:47:29 +000089
90#endif /* version.h */