blob: d3217a1910ab4f25d9229e4ac87735d4602e4347 [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
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000024#include "mbedtls/version.h"
Paul Bakker0f90d7d2014-04-30 11:49:44 +020025
26#include <string.h>
27
Máté Vargac5de4622019-06-12 12:26:37 +020028static const char * const features[] = {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020029#if defined(MBEDTLS_VERSION_FEATURES)
David Horstmann8b6068b2023-01-05 15:42:32 +000030 FEATURE_DEFINES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020031#endif /* MBEDTLS_VERSION_FEATURES */
Paul Bakker0f90d7d2014-04-30 11:49:44 +020032 NULL
33};
34
David Horstmann8b6068b2023-01-05 15:42:32 +000035int mbedtls_version_check_feature(const char *feature)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020036{
Máté Vargac5de4622019-06-12 12:26:37 +020037 const char * const *idx = features;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020038
David Horstmann8b6068b2023-01-05 15:42:32 +000039 if (*idx == NULL) {
40 return -2;
41 }
Paul Bakker790e3952014-04-30 16:48:32 +020042
David Horstmann8b6068b2023-01-05 15:42:32 +000043 if (feature == NULL) {
44 return -1;
45 }
Paul Bakker0f90d7d2014-04-30 11:49:44 +020046
David Horstmann8b6068b2023-01-05 15:42:32 +000047 while (*idx != NULL) {
48 if (!strcmp(*idx, feature)) {
49 return 0;
50 }
Paul Bakker0f90d7d2014-04-30 11:49:44 +020051 idx++;
52 }
David Horstmann8b6068b2023-01-05 15:42:32 +000053 return -1;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020054}
55
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020056#endif /* MBEDTLS_VERSION_C */