From 00c5336f2c766ef58bd62998667cad24cf10ce1e Mon Sep 17 00:00:00 2001 From: wanghaixiang Date: Mon, 19 Jul 2021 14:59:53 +0800 Subject: [PATCH 1/2] small devices support ED25519 to X25519 Signed-off-by: wanghaixiang --- frameworks/huks_standard/main/common/include/hks_config.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/frameworks/huks_standard/main/common/include/hks_config.h b/frameworks/huks_standard/main/common/include/hks_config.h index 13c76480..6fc79c43 100644 --- a/frameworks/huks_standard/main/common/include/hks_config.h +++ b/frameworks/huks_standard/main/common/include/hks_config.h @@ -65,9 +65,7 @@ #define HKS_SUPPORT_X25519_AGREE_KEY #define HKS_SUPPORT_X25519_GET_PUBLIC_KEY -#ifdef L2_STANDARD #define HKS_SUPPORT_ED25519_TO_X25519 -#endif #if defined(CHIP_VER_Hi3861) #undef HKS_SUPPORT_RSA_C From 5157309517f0eb603782e05b665ec468a94ae9fa Mon Sep 17 00:00:00 2001 From: wanghaixiang Date: Mon, 19 Jul 2021 16:18:15 +0800 Subject: [PATCH 2/2] --amend Signed-off-by: wanghaixiang --- .../main/common/include/hks_config.h | 9 +- .../main/common/include/hks_config_lite.h | 103 ++++++++++++++++++ 2 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 frameworks/huks_standard/main/common/include/hks_config_lite.h diff --git a/frameworks/huks_standard/main/common/include/hks_config.h b/frameworks/huks_standard/main/common/include/hks_config.h index 6fc79c43..d1e94a43 100644 --- a/frameworks/huks_standard/main/common/include/hks_config.h +++ b/frameworks/huks_standard/main/common/include/hks_config.h @@ -16,6 +16,8 @@ #ifndef HKS_CONFIG_H #define HKS_CONFIG_H +#define HKS_SUPPORT_POSIX + /* AES */ #define HKS_SUPPORT_AES_C #define HKS_SUPPORT_AES_GENERATE_KEY @@ -23,8 +25,6 @@ #define HKS_SUPPORT_AES_CBC_PKCS7 #define HKS_SUPPORT_AES_GCM -#define HKS_SUPPORT_POSIX - /* BN */ #define HKS_SUPPORT_BN_C @@ -67,11 +67,6 @@ #define HKS_SUPPORT_ED25519_TO_X25519 -#if defined(CHIP_VER_Hi3861) -#undef HKS_SUPPORT_RSA_C -#undef HKS_SUPPORT_ECC_C -#endif - #if defined(HKS_SUPPORT_AES_GENERATE_KEY) || defined(HKS_SUPPORT_ECC_GENERATE_KEY) || \ defined(HKS_SUPPORT_ED25519_GENERATE_KEY) || defined(HKS_SUPPORT_RSA_GENERATE_KEY) || \ defined(HKS_SUPPORT_X25519_GENERATE_KEY) diff --git a/frameworks/huks_standard/main/common/include/hks_config_lite.h b/frameworks/huks_standard/main/common/include/hks_config_lite.h new file mode 100644 index 00000000..daa11b38 --- /dev/null +++ b/frameworks/huks_standard/main/common/include/hks_config_lite.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021-2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HKS_CONFIG_H +#define HKS_CONFIG_H + +#define HKS_SUPPORT_POSIX + +/* AES */ +#define HKS_SUPPORT_AES_C +#define HKS_SUPPORT_AES_GENERATE_KEY +#define HKS_SUPPORT_AES_CBC_NOPADDING +#define HKS_SUPPORT_AES_CBC_PKCS7 +#define HKS_SUPPORT_AES_GCM + +/* BN */ +#define HKS_SUPPORT_BN_C + +/* HASH */ +#define HKS_SUPPORT_HASH_C + +/* HMAC */ +#define HKS_SUPPORT_HMAC_C + +/* KDF */ +#define HKS_SUPPORT_KDF_C +#define HKS_SUPPORT_KDF_PBKDF2 +#define HKS_SUPPORT_KDF_HKDF + +/* X25519 */ +#define HKS_SUPPORT_X25519_C +#define HKS_SUPPORT_X25519_GENERATE_KEY +#define HKS_SUPPORT_X25519_AGREE_KEY +#define HKS_SUPPORT_X25519_GET_PUBLIC_KEY + +#if defined(HKS_SUPPORT_AES_GENERATE_KEY) || defined(HKS_SUPPORT_ECC_GENERATE_KEY) || \ + defined(HKS_SUPPORT_ED25519_GENERATE_KEY) || defined(HKS_SUPPORT_RSA_GENERATE_KEY) || \ + defined(HKS_SUPPORT_X25519_GENERATE_KEY) +#define HKS_SUPPORT_API_GENERATE_KEY +#define HKS_SUPPORT_API_DELETE_KEY +#define HKS_SUPPORT_API_GET_KEY_PARAM_SET +#define HKS_SUPPORT_API_KEY_EXIST +#endif + +#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || \ + defined(HKS_SUPPORT_ED25519_C) || defined(HKS_SUPPORT_X25519_C) || \ + defined(HKS_SUPPORT_AES_C) +#define HKS_SUPPORT_API_IMPORT +#endif + +#if defined(HKS_SUPPORT_ECC_C) || defined(HKS_SUPPORT_RSA_C) || \ + defined(HKS_SUPPORT_ED25519_C) || defined(HKS_SUPPORT_X25519_C) +#define HKS_SUPPORT_API_EXPORT +#endif + +#define HKS_SUPPORT_API_GENERATE_RANDOM + +#if defined(HKS_SUPPORT_ECDSA_C) || defined(HKS_SUPPORT_ED25519_SIGN_VERIFY) || \ + defined(HKS_SUPPORT_RSA_SIGN_VERIFY) +#define HKS_SUPPORT_API_SIGN_VERIFY +#endif + +#if defined(HKS_SUPPORT_AES_C) || defined(HKS_SUPPORT_RSA_CRYPT) +#define HKS_SUPPORT_API_CIPHER +#endif + +#if defined(HKS_SUPPORT_X25519_AGREE_KEY) || defined(HKS_SUPPORT_ECDH_C) +#define HKS_SUPPORT_API_AGREE_KEY +#endif + +#ifdef HKS_SUPPORT_KDF_C +#define HKS_SUPPORT_API_DERIVE_KEY +#endif + +#ifdef HKS_SUPPORT_HMAC_C +#define HKS_SUPPORT_API_MAC +#endif + +#ifdef HKS_SUPPORT_HASH_C +#define HKS_SUPPORT_API_HASH +#endif + +#ifdef HKS_SUPPORT_BN_C +#define HKS_SUPPORT_API_BN_EXP_MOD +#endif + +#ifndef HKS_SUPPORT_LITE_HEAP +#define HKS_SUPPORT_API_GET_KEY_INFO_LIST +#endif + +#endif /* HKS_CONFIG_H */