blob: 767eda1c74698b4c49514b5ac9a23bec900b5513 [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
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000023#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020024#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020025#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020026#endif
Paul Bakker0f90d7d2014-04-30 11:49:44 +020027
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020028#if defined(MBEDTLS_VERSION_C)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020029
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000030#include "mbedtls/version.h"
Paul Bakker0f90d7d2014-04-30 11:49:44 +020031
32#include <string.h>
33
Manuel Pégourié-Gonnard385069f2015-03-05 15:47:55 +000034static const char *features[] = {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020035#if defined(MBEDTLS_VERSION_FEATURES)
Paul Bakker0f90d7d2014-04-30 11:49:44 +020036FEATURE_DEFINES
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020037#endif /* MBEDTLS_VERSION_FEATURES */
Paul Bakker0f90d7d2014-04-30 11:49:44 +020038 NULL
39};
40
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020041int mbedtls_version_check_feature( const char *feature )
Paul Bakker0f90d7d2014-04-30 11:49:44 +020042{
43 const char **idx = features;
44
Paul Bakker790e3952014-04-30 16:48:32 +020045 if( *idx == NULL )
46 return( -2 );
47
Paul Bakker0f90d7d2014-04-30 11:49:44 +020048 if( feature == NULL )
49 return( -1 );
50
51 while( *idx != NULL )
52 {
Manuel Pégourié-Gonnardcb46fd82015-05-28 17:06:07 +020053 if( !strcmp( *idx, feature ) )
Paul Bakker0f90d7d2014-04-30 11:49:44 +020054 return( 0 );
55 idx++;
56 }
57 return( -1 );
58}
59
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020060#endif /* MBEDTLS_VERSION_C */