blob: cac6ac76f060848d3e4e52c5de7676fa8117e597 [file] [log] [blame]
Paul Bakker0f90d7d2014-04-30 11:49:44 +02001/*
2 * Version feature information
3 *
Bence Szépkúti1e148272020-08-07 13:07:28 +02004 * Copyright The Mbed TLS Contributors
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02005 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
Paul Bakker0f90d7d2014-04-30 11:49:44 +020018 */
19
Gilles Peskinedb09ef62020-06-03 01:43:33 +020020#include "common.h"
Paul Bakker0f90d7d2014-04-30 11:49:44 +020021
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#if defined(MBEDTLS_VERSION_C)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020023
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020024# include "mbedtls/version.h"
Paul Bakker0f90d7d2014-04-30 11:49:44 +020025
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020026# include <string.h>
Paul Bakker0f90d7d2014-04-30 11:49:44 +020027
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020028static const char *const features[] = {
29# if defined(MBEDTLS_VERSION_FEATURES)
30 FEATURE_DEFINES
31# endif /* MBEDTLS_VERSION_FEATURES */
32 NULL
Paul Bakker0f90d7d2014-04-30 11:49:44 +020033};
34
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020035int mbedtls_version_check_feature(const char *feature)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020036{
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020037 const char *const *idx = features;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020038
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020039 if (*idx == NULL)
40 return -2;
Paul Bakker790e3952014-04-30 16:48:32 +020041
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020042 if (feature == NULL)
43 return -1;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020044
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020045 while (*idx != NULL) {
46 if (!strcmp(*idx, feature))
47 return 0;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020048 idx++;
49 }
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020050 return -1;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020051}
52
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020053#endif /* MBEDTLS_VERSION_C */