1/* 2 * Version feature information 3 * 4 * Copyright The Mbed TLS Contributors 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 6 */ 7 8#include "common.h" 9 10#if defined(MBEDTLS_VERSION_C) 11 12#include "mbedtls/version.h" 13 14#include <string.h> 15 16static const char * const features[] = { 17#if defined(MBEDTLS_VERSION_FEATURES) 18 FEATURE_DEFINES 19#endif /* MBEDTLS_VERSION_FEATURES */ 20 NULL 21}; 22 23int mbedtls_version_check_feature(const char *feature) 24{ 25 const char * const *idx = features; 26 27 if (*idx == NULL) { 28 return -2; 29 } 30 31 if (feature == NULL) { 32 return -1; 33 } 34 35 if (strncmp(feature, "MBEDTLS_", 8)) { 36 return -1; 37 } 38 39 feature += 8; 40 41 while (*idx != NULL) { 42 if (!strcmp(*idx, feature)) { 43 return 0; 44 } 45 idx++; 46 } 47 return -1; 48} 49 50#endif /* MBEDTLS_VERSION_C */ 51