blob: e572c5ef19335880edb08315059d1f39009a2e78 [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)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020030FEATURE_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
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020035int 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
Paul Bakker790e3952014-04-30 16:48:32 +020039 if( *idx == NULL )
Mateusz Starzyke36f5b12021-07-22 16:43:35 +020040 return -2 ;
Paul Bakker790e3952014-04-30 16:48:32 +020041
Paul Bakker0f90d7d2014-04-30 11:49:44 +020042 if( feature == NULL )
Mateusz Starzyke36f5b12021-07-22 16:43:35 +020043 return -1 ;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020044
45 while( *idx != NULL )
46 {
Manuel Pégourié-Gonnardcb46fd82015-05-28 17:06:07 +020047 if( !strcmp( *idx, feature ) )
Mateusz Starzyke36f5b12021-07-22 16:43:35 +020048 return 0 ;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020049 idx++;
50 }
Mateusz Starzyke36f5b12021-07-22 16:43:35 +020051 return -1 ;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020052}
53
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020054#endif /* MBEDTLS_VERSION_C */