1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: In mbedtls lib, adaption for polarssl. 15 */ 16 #ifndef HW_MBEDTLS_CONFIG_H 17 #define HW_MBEDTLS_CONFIG_H 18 19 /***************************************************************************** 20 * \brief 配置使能 21 * 22 ******************************************************************************/ 23 #define HW_MBEDTLS_CONFIG_DISABLE (0) 24 25 /***************************************************************************** 26 * \brief 配置不使能 27 * 28 ******************************************************************************/ 29 #define HW_MBEDTLS_CONFIG_ENABLE (1) 30 31 /***************************************************************************** 32 * \brief 定制修改,用于动态调整mbedtls库的功能。 33 * 34 ******************************************************************************/ 35 typedef enum HW_MBEDTLS_CONFIG_TYPES_en { 36 HW_MBEDTLS_CONFIG_NONE = 0, /* 无效值 */ 37 HW_MBEDTLS_CHECK_CERT_DATE = 1, /* SSL协议栈校验证书有效期,mbedtls库默认校验 */ 38 HW_MBEDTLS_CHECK_CERT_ISSUE_NAME = 2, /* X.509证书校验发生者名字,mbedtls库默认校验 */ 39 HW_MBEDTLS_DISABLE_MD2 = 3, /* 禁用MD2,默认为1,不使用MD2 */ 40 HW_MBEDTLS_DISABLE_MD4 = 4, /* 禁用MD4,默认为1,不使用MD4 */ 41 HW_MBEDTLS_CONFIG_BUTT 42 } HW_MBEDTLS_CONFIG_TYPES; 43 44 /***************************************************************************** 45 * \brief 配置mbedtls动态开关。 46 * 47 * \param type 需要修改的特性名。 48 * \param value 0表示关闭此特性,非0表示打开此特性。 49 * \return int 0表示设置成功,非0表示设置失败。 50 ******************************************************************************/ 51 int hw_mbedtls_set_config(HW_MBEDTLS_CONFIG_TYPES type, int value); 52 53 /***************************************************************************** 54 * \brief 获取mbedtls定制特性的动态值。 55 * 56 * \param type 需要查询的特性名。 57 * \return int 返回此特性的值:0表示没有开启;1表示开启;-1表示处理错误,未知状态。 58 ******************************************************************************/ 59 int hw_mbedtls_get_config(HW_MBEDTLS_CONFIG_TYPES type); 60 61 #endif 62