blob: 79d220ebc8330065ac4b3008aa2c786b6df709e8 [file] [log] [blame]
Paul Bakker0f90d7d2014-04-30 11:49:44 +02001/*
2 * Version feature information
3 *
Manuel Pégourié-Gonnard7381ff02015-08-04 11:12:49 +02004 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
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 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000019 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020020 */
21
Gilles Peskinedb09ef62020-06-03 01:43:33 +020022#include "common.h"
Paul Bakker0f90d7d2014-04-30 11:49:44 +020023
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020024#if defined(MBEDTLS_VERSION_C)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020025
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000026#include "mbedtls/version.h"
Paul Bakker0f90d7d2014-04-30 11:49:44 +020027
28#include <string.h>
29
Máté Vargac5de4622019-06-12 12:26:37 +020030static const char * const features[] = {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020031#if defined(MBEDTLS_VERSION_FEATURES)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020032FEATURE_DEFINES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020033#endif /* MBEDTLS_VERSION_FEATURES */
Paul Bakker0f90d7d2014-04-30 11:49:44 +020034 NULL
35};
36
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020037int mbedtls_version_check_feature( const char *feature )
Paul Bakker0f90d7d2014-04-30 11:49:44 +020038{
Máté Vargac5de4622019-06-12 12:26:37 +020039 const char * const *idx = features;
Paul Bakker0f90d7d2014-04-30 11:49:44 +020040
Paul Bakker790e3952014-04-30 16:48:32 +020041 if( *idx == NULL )
42 return( -2 );
43
Paul Bakker0f90d7d2014-04-30 11:49:44 +020044 if( feature == NULL )
45 return( -1 );
46
47 while( *idx != NULL )
48 {
Manuel Pégourié-Gonnardcb46fd82015-05-28 17:06:07 +020049 if( !strcmp( *idx, feature ) )
Paul Bakker0f90d7d2014-04-30 11:49:44 +020050 return( 0 );
51 idx++;
52 }
53 return( -1 );
54}
55
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020056#endif /* MBEDTLS_VERSION_C */