Skip to content

Commit

Permalink
use hw aes and ecp
Browse files Browse the repository at this point in the history
  • Loading branch information
shchen-Lab committed May 8, 2023
1 parent 842beb2 commit 2908946
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/platform/bouffalolab/BL702L/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ static_library("BL702L") {
import("${bouffalolab_iot_sdk_build_root}/bl702l/bl_iot_sdk.gni")
public_deps += [
"${bouffalolab_iot_sdk_build_root}/bl702l:bl_iot_sdk",
"${bouffalolab_iot_sdk_build_root}/bl702l:mbedtls",
]

sources += [
Expand Down
2 changes: 1 addition & 1 deletion src/platform/bouffalolab/BL702L/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ chip_device_platform = "bl702l"

riscv_platform_config = "${bouffalolab_iot_sdk_build_root}/common/rsicv.gni"

mbedtls_target = "${bouffalolab_iot_sdk_build_root}/bl702l:mbedtls"
mbedtls_target = "${bouffalolab_iot_sdk_build_root}/bl702l:bl_iot_sdk"

chip_inet_config_enable_ipv4 = false
chip_inet_config_enable_tcp_endpoint = false
Expand Down
4 changes: 4 additions & 0 deletions src/platform/bouffalolab/BL702L/bl702l-chip-mbedtls-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
#include MBEDTLS_USER_CONFIG_FILE
#endif

#define MBEDTLS_AES_ALT 1
#define MBEDTLS_ECP_ALT 1
#define MBEDTLS_USE_HW 1

#include "mbedtls/check_config.h"

#endif /* MBEDTLS_CONFIG_H */
9 changes: 0 additions & 9 deletions third_party/bouffalolab/bl702l/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ declare_args() {

assert(bl_iot_sdk_target != "", "bl_iot_sdk_target must be specified")

config("bl702l_mbedtls_config") {
defines = [ "MBEDTLS_CONFIG_FILE=\"bl702l-chip-mbedtls-config.h\"" ]
}

mbedtls_target("mbedtls") {
public_configs = [ ":bl702l_mbedtls_config" ]
include_dirs = [ "${chip_root}/src/platform/bouffalolab/BL702L" ]
}

group("bl_iot_sdk") {
public_deps = [ bl_iot_sdk_target ]
}
82 changes: 81 additions & 1 deletion third_party/bouffalolab/bl702l/bl_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,91 @@ template("bl_iot_sdk") {
]

public_deps = [
"${bouffalolab_iot_sdk_build_root}/bl702l:mbedtls",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
"${openthread_root}/src/core:libopenthread_core_headers",
]
}
config("${sdk_target_name}_config_mbedtls") {
include_dirs = [
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/include",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port",
"${chip_root}/src/platform/bouffalolab/BL702L",
]

defines = [ "MBEDTLS_CONFIG_FILE=\"bl702l-chip-mbedtls-config.h\"" ]
}

source_set("${sdk_target_name}_mbedtls") {
include_dirs =
[ "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library" ]

sources = [
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/aes_alt.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/bignum_hw.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/ecp_alt.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/ecp_curves_alt.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/hw_common.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/hw_common.h",
#"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/sha1_alt.c",
#"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/sha256_alt.c",
]

sources += [
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/bignum_ext.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_entropy_poll.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/mbedtls_port_mem.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/net_sockets.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/pkparse.c",
]

sources += [
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/aes.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/asn1parse.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/asn1write.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/base64.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/bignum.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ccm.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/cipher.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/cipher_wrap.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/cmac.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/constant_time.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ctr_drbg.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecdh.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecdsa.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecp.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecp_curves.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/entropy.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/hkdf.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/hmac_drbg.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/md.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/oid.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pem.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pk.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pk_wrap.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pkcs5.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pkwrite.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/platform.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/platform_util.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/sha256.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/sha512.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509_create.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509write_csr.c",
]

cflags_c = [
"-Wno-sign-compare",
"-Wno-implicit-function-declaration",
]
configs += [
":${sdk_target_name}_config_BSP_Driver",
":${sdk_target_name}_config_hosal",
":${sdk_target_name}_config_bl702l_rom_a0",
]
public_configs = [
":${sdk_target_name}_config",
":${sdk_target_name}_config_mbedtls",
]
}

group(sdk_target_name) {
public_deps = [
Expand All @@ -592,6 +671,7 @@ template("bl_iot_sdk") {
":${sdk_target_name}_sys",
":${sdk_target_name}_utils",
":${sdk_target_name}_ble",
":${sdk_target_name}_mbedtls",
]
public_configs = [
":${sdk_target_name}_config_BSP_Driver",
Expand Down

0 comments on commit 2908946

Please sign in to comment.