├── docs ├── arm_cc312_rt_sdm_101122_0104_02_en.zip └── cc312_r1_oss_rt_sw-r1p4-00rel0_ReleaseNote.pdf ├── utils └── src │ ├── cc3x_boot_cert │ ├── examples │ │ ├── content_cert │ │ │ ├── images_table.tbl │ │ │ ├── images_table_enc_0.tbl │ │ │ ├── images_table_verify_flash.tbl │ │ │ └── images_table_verify_mem.tbl │ │ └── developer_cert │ │ │ ├── sb_developer_dbg_cert.cfg │ │ │ └── sb_developer_dbg_cert_no_pwd.cfg │ ├── common_utils │ │ ├── global_defines_prim_hash.py │ │ ├── hash_basic_utility.py │ │ └── global_defines_rsa_format.py │ ├── cert_lib │ │ └── Makefile │ └── Makefile │ ├── Makefile.openssl │ ├── dmpu_asset_pkg_util │ ├── Makefile │ ├── icv_key_response │ │ ├── examples │ │ │ └── dmpu_icv_key_response.cfg │ │ ├── Makefile │ │ └── lib │ │ │ └── Makefile │ ├── oem_key_request │ │ ├── examples │ │ │ └── dmpu_oem_key_request.cfg │ │ ├── lib │ │ │ └── Makefile │ │ └── Makefile │ └── oem_asset_package │ │ ├── examples │ │ ├── asset_oem_ce.cfg │ │ └── asset_oem_cp.cfg │ │ ├── Makefile │ │ └── lib │ │ └── Makefile │ ├── proj.cfg │ ├── cc3x_asset_prov_rt │ ├── examples │ │ └── asset_prov_se_512.cfg │ ├── Makefile │ └── lib │ │ └── Makefile │ ├── cmpu_asset_pkg_util │ ├── examples │ │ ├── asset_icv_cp.cfg │ │ └── asset_icv_ce.cfg │ ├── lib │ │ └── Makefile │ └── Makefile │ └── common │ └── common_crypto_encode.h ├── README.md ├── host ├── src │ ├── cc3x_sbromlib │ │ └── Makefile │ ├── pal │ │ ├── linux │ │ │ ├── Makefile │ │ │ ├── cc_pal_abort_plat.c │ │ │ ├── cc_pal_apbc.c │ │ │ ├── cc_pal_pm.c │ │ │ ├── cc_pal_log.c │ │ │ ├── cc_pal_barrier.c │ │ │ ├── cc_pal_fips.c │ │ │ └── cc_pal_buff_attr.c │ │ ├── no_os │ │ │ ├── Makefile │ │ │ ├── cc_pal_barrier.c │ │ │ ├── cc_pal_abort_plat.c │ │ │ ├── cc_pal_apbc.c │ │ │ ├── cc_pal_pm.c │ │ │ ├── cc_pal_log.c │ │ │ ├── cc_pal.c │ │ │ ├── cc_pal_fips.c │ │ │ └── cc_pal_buff_attr.c │ │ ├── Makefile │ │ ├── freertos │ │ │ ├── Makefile │ │ │ ├── cc_pal_barrier.c │ │ │ ├── cc_pal_abort_plat.c │ │ │ ├── cc_pal_log.c │ │ │ ├── cc_pal_apbc.c │ │ │ ├── cc_pal_pm.c │ │ │ └── cc_pal_fips.c │ │ └── project_pal.mk │ ├── cc3x_productionlib │ │ ├── cmpu │ │ │ ├── Makefile │ │ │ ├── cmpu_derivation.h │ │ │ └── cmpu_llf_rnd.h │ │ ├── dmpu │ │ │ └── Makefile │ │ ├── Makefile │ │ └── common │ │ │ └── prod_util.h │ ├── tests │ │ ├── TestAL │ │ │ ├── configs │ │ │ │ ├── proj-testal_linux_x86.cfg │ │ │ │ ├── proj-testal_freertos_cm33.cfg │ │ │ │ ├── proj-testal_no_os_cm3.cfg │ │ │ │ ├── proj-testal_mbedos_cm33.cfg │ │ │ │ ├── proj-testal_linux_ca9.cfg │ │ │ │ ├── proj-testal_linux_ca72.ca53.cfg │ │ │ │ └── proj-testal_freertos_cm3.cfg │ │ │ ├── ReadMe.txt │ │ │ └── pal │ │ │ │ ├── no_os │ │ │ │ ├── board_addrs.c │ │ │ │ ├── test_pal_file.c │ │ │ │ ├── test_pal_cli.c │ │ │ │ └── test_pal_time.c │ │ │ │ ├── freertos │ │ │ │ ├── test_pal_file.c │ │ │ │ └── test_pal_time.c │ │ │ │ ├── mbedos │ │ │ │ └── test_pal_time.c │ │ │ │ └── linux │ │ │ │ ├── test_pal_cli.c │ │ │ │ └── test_pal_time.c │ │ ├── common │ │ │ ├── tst_common_init.h │ │ │ ├── linux64 │ │ │ │ └── load_pal_driver.sh │ │ │ ├── multi2_soft.h │ │ │ └── tst_common_init.c │ │ ├── integration_cc3x │ │ │ ├── cmpu_integration_test │ │ │ │ ├── Makefile │ │ │ │ └── cmpu_integration_test.h │ │ │ ├── dmpu_integration_test │ │ │ │ ├── Makefile │ │ │ │ └── dmpu_integration_test.h │ │ │ ├── runtime_integration_test │ │ │ │ ├── Makefile │ │ │ │ ├── pal │ │ │ │ │ └── include │ │ │ │ │ │ ├── run_integration_pal_reg.h │ │ │ │ │ │ └── run_integration_pal_otp.h │ │ │ │ ├── tests │ │ │ │ │ └── run_integration_test_api.h │ │ │ │ ├── run_integration_test.h │ │ │ │ └── README.txt │ │ │ └── proj_integration_tests.cfg │ │ └── proj │ │ │ ├── cc3x │ │ │ ├── test_proj.c │ │ │ └── cc312_r1 │ │ │ │ └── test_proj_cclib.h │ │ │ └── test_proj_common.h │ └── cc3x_lib │ │ ├── cc_util_int_defs.h │ │ ├── cc_rng_params.h │ │ ├── cc_fips_defs.h │ │ └── cc_plat.h ├── Makefile.guards └── Makefile.freertos ├── shared ├── include │ ├── pal │ │ ├── linux │ │ │ ├── cc_pal_perf_plat.h │ │ │ ├── cc_pal_abort_plat.h │ │ │ ├── cc_pal_log_plat.h │ │ │ ├── cc_pal_mutex_plat.h │ │ │ ├── cc_pal_interrupt_ctrl_plat.h │ │ │ ├── cc_pal_types_plat.h │ │ │ └── cc_pal_dma_plat.h │ │ ├── no_os │ │ │ ├── cc_pal_abort_plat.h │ │ │ ├── cc_pal_log_plat.h │ │ │ ├── cc_pal_perf_plat.h │ │ │ ├── cc_pal_mutex_plat.h │ │ │ ├── cc_pal_interrupt_ctrl_plat.h │ │ │ ├── cc_pal_dma_plat.h │ │ │ └── cc_pal_types_plat.h │ │ ├── mbedos │ │ │ ├── cc_pal_abort_plat.h │ │ │ ├── cc_pal_perf_plat.h │ │ │ ├── cc_pal_log_plat.h │ │ │ ├── cc_pal_types_plat.h │ │ │ ├── cc_pal_mutex_plat.h │ │ │ ├── cc_pal_interrupt_ctrl_plat.h │ │ │ └── cc_pal_dma_plat.h │ │ ├── freertos │ │ │ ├── cc_pal_abort_plat.h │ │ │ ├── cc_pal_perf_plat.h │ │ │ ├── cc_pal_log_plat.h │ │ │ ├── cc_pal_types_plat.h │ │ │ ├── cc_pal_mutex_plat.h │ │ │ └── cc_pal_dma_plat.h │ │ ├── cc_pal_abort.h │ │ ├── cc_pal_barrier.h │ │ ├── cc_log_mask.h │ │ ├── cc_pal_apbc.h │ │ ├── cc_pal_init.h │ │ └── cc_pal_dma_defs.h │ ├── trng │ │ └── cc_config_trng90b.h │ ├── sbrom │ │ ├── cc_crypto_x509_common_defs.h │ │ └── cc_asset_prov.h │ ├── crypto_api │ │ └── cc3x │ │ │ ├── cc_hash_defs_proj.h │ │ │ ├── cc_aes_defs_proj.h │ │ │ └── cc_ecpki_domain.h │ ├── proj │ │ └── cc3x │ │ │ ├── cc_address_defs.h │ │ │ ├── cc_util_apbc.h │ │ │ ├── cc_util_pm.h │ │ │ ├── cc_sec_defs.h │ │ │ ├── cc_ecpki_domains_defs.h │ │ │ ├── cc_int_general_defs.h │ │ │ └── cc_sram_map.h │ ├── mbedtls │ │ ├── cmac_alt.h │ │ ├── chachapoly_alt.h │ │ ├── sha1_alt.h │ │ ├── sha256_alt.h │ │ ├── ccm_alt.h │ │ └── gcm_alt.h │ ├── cc_sym_error.h │ ├── cc_lli_defs.h │ └── cc_util │ │ └── cc_util_asset_prov_int.h ├── hw │ └── include │ │ ├── musca_b1 │ │ └── dx_reg_base_host.h │ │ ├── dx_reg_common.h │ │ ├── zynq │ │ └── dx_reg_base_host.h │ │ ├── dx_reg_base_host.h │ │ ├── mps2.cm33 │ │ └── dx_reg_base_host.h │ │ └── mps2 │ │ └── dx_reg_base_host.h └── src │ └── proj │ └── cc3x │ └── cc_hash_info.c ├── codesafe └── src │ ├── crypto_api │ ├── pki │ │ ├── common │ │ │ ├── pki_modular_arithmetic.h │ │ │ └── pka_point_compress_regs_def.h │ │ ├── ec_wrst │ │ │ ├── pka_ec_wrst_glob_regs.h │ │ │ ├── pka_ec_wrst_dsa_sign_regs.h │ │ │ └── pka_ec_wrst_dsa_verify_regs.h │ │ ├── rsa │ │ │ ├── rsa_public.h │ │ │ └── rsa_private.h │ │ ├── ec_mont │ │ │ └── pka_ec_mont_glob_regs_def.h │ │ └── srp │ │ │ └── srp.h │ ├── cc3x_sym │ │ ├── driver │ │ │ ├── hash_driver_ext_dma.h │ │ │ ├── chacha_driver_ext_dma.h │ │ │ ├── aes_driver_ext_dma.h │ │ │ ├── hmac_driver.h │ │ │ └── bypass_driver.h │ │ └── api │ │ │ └── mbedtls_cc_poly.c │ └── ec_wrst │ │ ├── ecc_domains │ │ ├── cc_ecpki_domain_secp192k1.h │ │ ├── cc_ecpki_domain_secp192r1.h │ │ ├── cc_ecpki_domain_secp224k1.h │ │ ├── cc_ecpki_domain_secp224r1.h │ │ ├── cc_ecpki_domain_secp256k1.h │ │ ├── cc_ecpki_domain_secp256r1.h │ │ ├── cc_ecpki_domain_secp521r1.h │ │ └── cc_ecpki_domain_secp384r1.h │ │ └── cc_ecpki_domain.c │ ├── mbedtls_api │ ├── mbedtls_common.c │ ├── mbedtls_common.h │ ├── mbedtls_hash_common.h │ ├── mbedtls_ccm_common.h │ └── ecp_common.h │ └── secure_boot_debug │ ├── secure_boot_gen │ ├── secureboot_basetypes.h │ └── secureboot_general_hwdefs.h │ ├── crypto_driver │ └── reg │ │ └── crypto_driver.h │ ├── platform │ └── pal │ │ ├── cc3x │ │ └── cc_pal_sb_plat.h │ │ └── cc_pal_x509_verify.c │ ├── util │ └── util_base64.h │ └── x509_cert_parser │ └── sb_x509_error.h ├── proj.ext.cfg └── Arm-proprietary-license.txt /docs/arm_cc312_rt_sdm_101122_0104_02_en.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/cryptocell-312-runtime/HEAD/docs/arm_cc312_rt_sdm_101122_0104_02_en.zip -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/examples/content_cert/images_table.tbl: -------------------------------------------------------------------------------- 1 | image3.bin 0x30008000 0x0000cef0 0x00004000 0x0 2 | image2.bin 0x30006000 0x00003458 0x00003000 0x0 3 | -------------------------------------------------------------------------------- /docs/cc312_r1_oss_rt_sw-r1p4-00rel0_ReleaseNote.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ARM-software/cryptocell-312-runtime/HEAD/docs/cc312_r1_oss_rt_sw-r1p4-00rel0_ReleaseNote.pdf -------------------------------------------------------------------------------- /utils/src/Makefile.openssl: -------------------------------------------------------------------------------- 1 | OPENSSL_ROOT_DIR := $(UTILS_ROOT)/src/openssl 2 | OPENSSL_INC_DIR := $(OPENSSL_ROOT_DIR)/include 3 | OPENSSL_LIB_DIR := $(OPENSSL_ROOT_DIR) 4 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/examples/content_cert/images_table_enc_0.tbl: -------------------------------------------------------------------------------- 1 | image3.bin 0x30008000 0x0000cef0 0x00004000 0x1 2 | image2.bin 0x30006000 0x00003458 0x00003000 0x1 3 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/examples/content_cert/images_table_verify_flash.tbl: -------------------------------------------------------------------------------- 1 | image3.bin 0xffffffff 0x0000cef0 0x00004000 0x0 2 | image2.bin 0xffffffff 0x00003458 0x00003000 0x0 3 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/examples/content_cert/images_table_verify_mem.tbl: -------------------------------------------------------------------------------- 1 | image3.bin 0x30008000 0xffffffff 0x00004000 0x0 2 | image2.bin 0x30006000 0xffffffff 0x00003000 0x0 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cryptocell-312-runtime 2 | 3 | Refer to docs/cc312_r1_oss_rt_sw-*_ReleaseNote.pdf for additional information ( contents, build commands and more). 4 | 5 | Refer to docs/arm_cc312_rt_sdm_101122_*.zip for APIs documentation. 6 | -------------------------------------------------------------------------------- /host/src/cc3x_sbromlib/Makefile: -------------------------------------------------------------------------------- 1 | HOST_PROJ_ROOT ?= $(shell pwd)/../.. 2 | include $(HOST_PROJ_ROOT)/Makefile.defs 3 | 4 | CFLAGS_EXTRA += -DCC_TEE -DCC_SB_SUPPORT_IOT 5 | OS =no_os 6 | include project_sbromlib.mk 7 | 8 | include $(HOST_PROJ_ROOT)/Makefile.rules 9 | 10 | -------------------------------------------------------------------------------- /host/src/pal/linux/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for pal for linux 2 | 3 | HOST_PROJ_ROOT ?= $(shell pwd)/../../.. 4 | include $(HOST_PROJ_ROOT)/Makefile.defs 5 | TARGET_LIBS = pal_linux 6 | PLAT_OS=linux 7 | include ../project_pal.mk 8 | 9 | include $(HOST_PROJ_ROOT)/Makefile.rules 10 | 11 | -------------------------------------------------------------------------------- /host/src/pal/no_os/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for pal for linux 2 | 3 | HOST_PROJ_ROOT ?= $(shell pwd)/../../.. 4 | include $(HOST_PROJ_ROOT)/Makefile.defs 5 | TARGET_LIBS = pal_no_os 6 | PLAT_OS=no_os 7 | include ../project_pal.mk 8 | 9 | include $(HOST_PROJ_ROOT)/Makefile.rules 10 | 11 | -------------------------------------------------------------------------------- /host/src/pal/Makefile: -------------------------------------------------------------------------------- 1 | SUB_DIRS = $(TEE_OS) 2 | 3 | all: $(foreach sub_dir,$(SUB_DIRS),do_$(sub_dir)) 4 | 5 | clean: $(foreach sub_dir,$(SUB_DIRS),clean_$(sub_dir)) 6 | 7 | clean_%: 8 | @make -C $* clean 9 | 10 | do_%: 11 | @make -C $* 12 | 13 | .PHONY: all clean clean_% do_% 14 | 15 | -------------------------------------------------------------------------------- /host/src/cc3x_productionlib/cmpu/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for cmpu utility 2 | HOST_PROJ_ROOT ?= $(shell pwd)/../../.. 3 | include $(HOST_PROJ_ROOT)/Makefile.defs 4 | #overwriting the OS defined in the config 5 | OS = no_os 6 | export 7 | 8 | include project_cmpu.mk 9 | 10 | include $(HOST_PROJ_ROOT)/Makefile.rules 11 | 12 | -------------------------------------------------------------------------------- /host/src/cc3x_productionlib/dmpu/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for cmpu utility 2 | HOST_PROJ_ROOT ?= $(shell pwd)/../../.. 3 | include $(HOST_PROJ_ROOT)/Makefile.defs 4 | #overwriting the OS defined in the config 5 | OS = no_os 6 | export 7 | 8 | include project_dmpu.mk 9 | 10 | include $(HOST_PROJ_ROOT)/Makefile.rules 11 | 12 | -------------------------------------------------------------------------------- /host/src/cc3x_productionlib/Makefile: -------------------------------------------------------------------------------- 1 | SUB_DIRS = cmpu dmpu 2 | OS = no_os 3 | 4 | all: $(foreach sub_dir,$(SUB_DIRS),do_$(sub_dir)) 5 | 6 | clean: $(foreach sub_dir,$(SUB_DIRS),clean_$(sub_dir)) 7 | 8 | clean_%: 9 | @make -C $* clean 10 | 11 | do_%: 12 | @make -C $* 13 | 14 | .PHONY: all clean clean_% do_% 15 | 16 | 17 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/Makefile: -------------------------------------------------------------------------------- 1 | SUB_DIRS = oem_key_request icv_key_response oem_asset_package 2 | 3 | all: $(foreach sub_dir,$(SUB_DIRS),do_$(sub_dir)) 4 | 5 | clean: $(foreach sub_dir,$(SUB_DIRS),clean_$(sub_dir)) 6 | 7 | clean_%: 8 | @make -C $* clean 9 | 10 | do_%: 11 | @make -C $* 12 | 13 | .PHONY: all clean clean_% do_% 14 | 15 | -------------------------------------------------------------------------------- /host/src/pal/freertos/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for PAL for freertos 2 | 3 | HOST_PROJ_ROOT ?= $(shell pwd)/../../.. 4 | include $(HOST_PROJ_ROOT)/Makefile.defs 5 | TARGET_LIBS = pal_freertos 6 | PLAT_OS = freertos 7 | 8 | include ../project_pal.mk 9 | include $(HOST_PROJ_ROOT)/Makefile.freertos 10 | 11 | include $(HOST_PROJ_ROOT)/Makefile.rules 12 | 13 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal_barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | void CC_PalWmb(void) 9 | { 10 | return; 11 | } 12 | 13 | void CC_PalRmb(void) 14 | { 15 | return; 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /host/src/pal/freertos/cc_pal_barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | void CC_PalWmb(void) 9 | { 10 | return; 11 | } 12 | 13 | void CC_PalRmb(void) 14 | { 15 | return; 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /shared/include/pal/linux/cc_pal_perf_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_PERF_PLAT_H__ 8 | #define _CC_PAL_PERF_PLAT_H__ 9 | 10 | typedef uint32_t CCPalPerfData_t; 11 | #endif /*_CC_PAL_PERF_PLAT_H__*/ 12 | -------------------------------------------------------------------------------- /shared/include/pal/no_os/cc_pal_abort_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_ABORT_PLAT_H 8 | #define _CC_PAL_ABORT_PLAT_H 9 | 10 | #include "cc_pal_log.h" 11 | #include 12 | 13 | void _CC_PalAbort(const char * exp); 14 | #endif 15 | -------------------------------------------------------------------------------- /shared/include/pal/mbedos/cc_pal_abort_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_ABORT_PLAT_H 9 | #define _CC_PAL_ABORT_PLAT_H 10 | 11 | #include "cc_pal_log.h" 12 | #include 13 | 14 | void CC_PalAbort(const char * exp); 15 | #endif 16 | -------------------------------------------------------------------------------- /shared/include/pal/freertos/cc_pal_abort_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_ABORT_PLAT_H 9 | #define _CC_PAL_ABORT_PLAT_H 10 | 11 | #include "cc_pal_log.h" 12 | #include 13 | 14 | void CC_PalAbort(const char * exp); 15 | #endif 16 | -------------------------------------------------------------------------------- /shared/include/pal/linux/cc_pal_abort_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_ABORT_PLAT_H 8 | #define _CC_PAL_ABORT_PLAT_H 9 | 10 | #include "cc_pal_log.h" 11 | #include "cc_pal_compiler.h" 12 | #include "stdlib.h" 13 | 14 | void _CC_PalAbort(const char * exp); 15 | #endif 16 | -------------------------------------------------------------------------------- /shared/include/pal/mbedos/cc_pal_perf_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_PERF_PLAT_H__ 9 | #define _CC_PAL_PERF_PLAT_H__ 10 | 11 | #include "stdlib.h" 12 | #include "stdint.h" 13 | 14 | typedef unsigned int CCPalPerfData_t; 15 | 16 | #endif /*_CC_PAL_PERF_PLAT_H__*/ 17 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/configs/proj-testal_linux_x86.cfg: -------------------------------------------------------------------------------- 1 | # Configuration: linux_x86 2 | # Supported Toolchains: native 3 | 4 | OS=linux 5 | 6 | DEVICE=host 7 | BOARD= 8 | 9 | CORTEX=x86 10 | CORTEX_SHORT=x86 11 | 12 | # TZM indicates whether the configuration supports TrustZone-M or not. 13 | # By default, TZM equals to 0. 14 | TZM=0 15 | 16 | # M_ARCH specifies a target architecture. If empty, target is 17 | # determined by CORTEX 18 | M_ARCH= 19 | -------------------------------------------------------------------------------- /shared/include/pal/freertos/cc_pal_perf_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_PERF_PLAT_H__ 9 | #define _CC_PAL_PERF_PLAT_H__ 10 | 11 | #include "stdlib.h" 12 | #include "stdint.h" 13 | 14 | typedef unsigned int CCPalPerfData_t; 15 | 16 | #endif /*_CC_PAL_PERF_PLAT_H__*/ 17 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/configs/proj-testal_freertos_cm33.cfg: -------------------------------------------------------------------------------- 1 | # Configuration: freertos_cm33 2 | # Supported Toolchains: arm-none-eabi arm-compiler-6 3 | 4 | OS=freertos 5 | 6 | CC_TYPE=GCC 7 | 8 | DEVICE=target 9 | BOARD=MPS2+ 10 | 11 | CMSIS_DRIVER=SSE_200 12 | M_ARCH=armv8-m.main 13 | CORTEX=8-M.Main 14 | CORTEX_SHORT=CM33 15 | 16 | # TZM indicates whether the configuration supports TrustZone-M or not. 17 | # By default, TZM equals to 0. 18 | TZM=1 19 | -------------------------------------------------------------------------------- /shared/include/pal/linux/cc_pal_log_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_LOG_PLAT_H_ 8 | #define _CC_PAL_LOG_PLAT_H_ 9 | 10 | #include "cc_log_mask.h" 11 | #include 12 | 13 | void CC_PalLog(int level, const char * format, ...); 14 | 15 | #endif /*_CC_PAL_LOG_PLAT_H_*/ 16 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/configs/proj-testal_no_os_cm3.cfg: -------------------------------------------------------------------------------- 1 | # Configuration: no_os_cm3 2 | # Supported Toolchains: arm-compiler-5 3 | 4 | OS=no_os 5 | 6 | DEVICE=target 7 | BOARD=MPS2+ 8 | 9 | CORTEX=cortex-m3 10 | CORTEX_SHORT=CM3 11 | 12 | # TZM indicates whether the configuration supports TrustZone-M or not. 13 | # By default, TZM equals to 0. 14 | TZM=0 15 | 16 | # M_ARCH specifies a target architecture. If empty, target is 17 | # determined by CORTEX 18 | M_ARCH= -------------------------------------------------------------------------------- /host/src/tests/TestAL/configs/proj-testal_mbedos_cm33.cfg: -------------------------------------------------------------------------------- 1 | # Configuration: mbedos_cm33 2 | # Supported Toolchains: arm-none-eabi 3 | 4 | OS=mbedos 5 | 6 | DEVICE=target 7 | BOARD=MPS2+ 8 | 9 | CORTEX=cortex-m33 10 | CORTEX_SHORT=CM33 11 | 12 | # TZM indicates whether the configuration supports TrustZone-M or not. 13 | # By default, TZM equals to 0. 14 | TZM=0 15 | 16 | # M_ARCH specifies a target architecture. If empty, target is 17 | # determined by CORTEX 18 | M_ARCH= -------------------------------------------------------------------------------- /host/src/tests/TestAL/configs/proj-testal_linux_ca9.cfg: -------------------------------------------------------------------------------- 1 | # Configuration: linux_ca9 2 | # Supported Toolchains: arm-xilinx , arm-br-7.3 3 | 4 | OS=linux 5 | 6 | DEVICE=target 7 | BOARD=Zynq 8 | 9 | CORTEX=cortex-a9 10 | CORTEX_SHORT=CA9 11 | 12 | # TZM indicates whether the configuration supports TrustZone-M or not. 13 | # By default, TZM equals to 0. 14 | TZM=0 15 | 16 | # M_ARCH specifies a target architecture. If empty, target is 17 | # determined by CORTEX 18 | M_ARCH= -------------------------------------------------------------------------------- /shared/include/pal/no_os/cc_pal_log_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_LOG_PLAT_H_ 8 | #define _CC_PAL_LOG_PLAT_H_ 9 | 10 | #include "cc_log_mask.h" 11 | #include 12 | 13 | 14 | 15 | void CC_PalLog(int level, const char * format, ...); 16 | 17 | 18 | 19 | 20 | #endif /*_CC_PAL_LOG_PLAT_H_*/ 21 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal_abort_plat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #include "cc_pal_log.h" 7 | #include "stdlib.h" 8 | 9 | void CC_PalAbort(const char * exp) 10 | { 11 | CC_PAL_LOG_ERR("ASSERT:%s:%d: %s", __FILE__, __LINE__, exp); 12 | CC_UNUSED_PARAM(exp); /* to avoid compilation error in case DEBUG isn't defined*/ 13 | abort(); 14 | } 15 | -------------------------------------------------------------------------------- /host/src/pal/freertos/cc_pal_abort_plat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #include "cc_pal_log.h" 7 | #include "stdlib.h" 8 | 9 | 10 | void CC_PalAbort(const char *exp) 11 | { 12 | CC_PAL_LOG_ERR("ASSERT:%s:%d: %s", __FILE__, __LINE__, exp); 13 | CC_UNUSED_PARAM(exp); /* to avoid compilation error in case DEBUG isn't defined*/ 14 | abort(); 15 | } 16 | -------------------------------------------------------------------------------- /host/src/pal/linux/cc_pal_abort_plat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #include "cc_pal_log.h" 7 | #include "stdlib.h" 8 | 9 | 10 | void CC_PalAbort(const char * exp) 11 | { 12 | CC_PAL_LOG_ERR("ASSERT:%s:%d: %s", __FILE__, __LINE__, exp); 13 | CC_UNUSED_PARAM(exp); /* to avoid compilation error in case DEBUG isn't defined*/ 14 | abort(); 15 | } 16 | -------------------------------------------------------------------------------- /host/src/tests/common/tst_common_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef __TST_COMMON_INIT_H__ 7 | #define __TST_COMMON_INIT_H__ 8 | 9 | #include "test_pal_thread.h" 10 | #include "board_configs.h" 11 | 12 | 13 | int tests_CC_libInit_wrap(CCRndContext_t* rndContext_ptr, CCRndWorkBuff_t * rndWorkBuff_ptr); 14 | 15 | 16 | #endif /* __TST_COMMON_INIT_H__ */ 17 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/configs/proj-testal_linux_ca72.ca53.cfg: -------------------------------------------------------------------------------- 1 | # Configuration: linux_ca72.ca53 2 | # Supported Toolchains: aarch64-linaro-5.3 , aarch64-br-7.3 3 | 4 | OS=linux 5 | 6 | DEVICE=target 7 | BOARD=Juno 8 | 9 | CORTEX=cortex-a72.cortex-a53 10 | CORTEX_SHORT=CA72.CA53 11 | 12 | # TZM indicates whether the configuration supports TrustZone-M or not. 13 | # By default, TZM equals to 0. 14 | TZM=0 15 | 16 | # M_ARCH specifies a target architecture. If empty, target is 17 | # determined by CORTEX 18 | M_ARCH= 19 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal_apbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | 9 | void CC_PalApbcCntrInit(void) 10 | { 11 | return; 12 | } 13 | 14 | void CC_PalApbcCntrValue(void) 15 | { 16 | return; 17 | } 18 | 19 | CCError_t CC_PalApbcModeSelect(CCBool isApbcInc) 20 | { 21 | CC_UNUSED_PARAM(isApbcInc); 22 | 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/configs/proj-testal_freertos_cm3.cfg: -------------------------------------------------------------------------------- 1 | # Configuration: freertos_cm3 2 | # Supported Toolchains: arm-compiler-5, arm-compiler-6, arm-none-eabi 3 | 4 | OS=freertos 5 | 6 | DEVICE=target 7 | BOARD=MPS2+ 8 | 9 | # M_ARCH specifies a target architecture. If empty, target is 10 | # determined by CORTEX 11 | M_ARCH= 12 | 13 | CMSIS_DRIVER=ARMCM3 14 | CORTEX=cortex-m3 15 | CORTEX_SHORT=CM3 16 | 17 | # TZM indicates whether the configuration supports TrustZone-M or not. 18 | # By default, TZM equals to 0. 19 | TZM=0 -------------------------------------------------------------------------------- /utils/src/proj.cfg: -------------------------------------------------------------------------------- 1 | # Project configuration for cc312 utils 2 | PROJ_NAME = cc312 3 | # Default HW for ARM is the zc706 4 | PROJ_HW = zc706 5 | 6 | PROJ_PRD = cc3x 7 | TEE_OS = linux 8 | 9 | # List of targets to build for utils/src 10 | PROJ_TARGETS = cc3x_asset_prov_rt cc3x_boot_cert cmpu_asset_pkg_util dmpu_asset_pkg_util 11 | 12 | CERT_ENDIANITY = 0 13 | CERT_VERSION_MAJOR = 1 14 | CERT_VERSION_MINOR = 0 15 | 16 | # Specific project definitions 17 | SPECIAL_ADDITIONAL_DATA_USED = 0 18 | CONFIG_SB_SUPPORT_IOT = 1 19 | 20 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal_pm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | 9 | 10 | void CC_PalPowerSaveModeInit(void) 11 | { 12 | return; 13 | } 14 | 15 | void CC_PalPowerSaveModeStatus(void) 16 | { 17 | return; 18 | } 19 | 20 | CCError_t CC_PalPowerSaveModeSelect(CCBool isPowerSaveMode) 21 | { 22 | CC_UNUSED_PARAM(isPowerSaveMode); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/cmpu_integration_test/Makefile: -------------------------------------------------------------------------------- 1 | HOST_PROJ_ROOT ?= $(shell pwd)/../../../.. 2 | 3 | ifneq (,$(findstring gnu,$(CROSS_COMPILE))) 4 | TEE_OS = linux 5 | else 6 | TEE_OS = freertos 7 | endif 8 | 9 | ifneq ($(wildcard $(HOST_PROJ_ROOT)/../configs/proj-cc312-sbrom_integration_tests.cfg),) 10 | $(info Compiling for Internal ARM use) 11 | ARM_INTERNAL=1 12 | else 13 | ARM_INTERNAL=0 14 | endif 15 | 16 | include $(HOST_PROJ_ROOT)/Makefile.defs 17 | 18 | include cmpu_integration_test.mk 19 | 20 | include $(HOST_PROJ_ROOT)/Makefile.rules -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/dmpu_integration_test/Makefile: -------------------------------------------------------------------------------- 1 | HOST_PROJ_ROOT ?= $(shell pwd)/../../../.. 2 | 3 | ifneq (,$(findstring gnu,$(CROSS_COMPILE))) 4 | TEE_OS = linux 5 | else 6 | TEE_OS = freertos 7 | endif 8 | 9 | ifneq ($(wildcard $(HOST_PROJ_ROOT)/../configs/proj-cc312-sbrom_integration_tests.cfg),) 10 | $(info Compiling for Internal ARM use) 11 | ARM_INTERNAL=1 12 | else 13 | ARM_INTERNAL=0 14 | endif 15 | 16 | include $(HOST_PROJ_ROOT)/Makefile.defs 17 | 18 | include dmpu_integration_test.mk 19 | 20 | include $(HOST_PROJ_ROOT)/Makefile.rules -------------------------------------------------------------------------------- /host/src/cc3x_lib/cc_util_int_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_UTIL_INT_DEFS_H 8 | #define _CC_UTIL_INT_DEFS_H 9 | 10 | typedef enum { 11 | UTIL_USER_KEY = 0, 12 | UTIL_ROOT_KEY = 1, 13 | UTIL_KCP_KEY = 2, 14 | UTIL_KCE_KEY = 3, 15 | UTIL_KPICV_KEY = 4, 16 | UTIL_KCEICV_KEY = 5, 17 | UTIL_END_OF_KEY_TYPE = 0x7FFFFFFF 18 | }UtilKeyType_t; 19 | 20 | 21 | #endif /*_CC_UTIL_INT_DEFS_H*/ 22 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/runtime_integration_test/Makefile: -------------------------------------------------------------------------------- 1 | HOST_PROJ_ROOT ?= $(shell pwd)/../../../.. 2 | 3 | ifneq (,$(findstring gnu,$(CROSS_COMPILE))) 4 | TEE_OS = linux 5 | else 6 | TEE_OS = freertos 7 | endif 8 | 9 | ifneq ($(wildcard $(HOST_PROJ_ROOT)/../configs/proj-cc312_integration_tests.cfg),) 10 | $(info Compiling for Internal ARM use) 11 | ARM_INTERNAL=1 12 | else 13 | ARM_INTERNAL=0 14 | endif 15 | 16 | 17 | include $(HOST_PROJ_ROOT)/Makefile.defs 18 | 19 | include run_integration_test.mk 20 | 21 | 22 | include $(HOST_PROJ_ROOT)/Makefile.rules -------------------------------------------------------------------------------- /host/src/tests/common/linux64/load_pal_driver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LINUX64_DRIVER_NAME="cc_linux_drv" 3 | is_load=$1 4 | is_driver_loaded=`lsmod| grep $LINUX64_DRIVER_NAME| wc -l` 5 | #unload driver in any case 6 | if [[ $is_driver_loaded -ne 0 ]]; then 7 | echo Unloading driver $LINUX64_DRIVER_NAME 8 | modprobe -r $LINUX64_DRIVER_NAME 9 | echo lsmod 10 | lsmod 11 | fi 12 | 13 | if [[ $is_load == "load" ]]; then 14 | echo Loading driver $LINUX64_DRIVER_NAME 15 | modprobe $LINUX64_DRIVER_NAME 16 | echo lsmod 17 | lsmod 18 | fi 19 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/common/pki_modular_arithmetic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _PKI_MODULAR_ARITHMETIC_H 9 | #define _PKI_MODULAR_ARITHMETIC_H 10 | 11 | #include "cc_pal_types.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | 19 | 20 | int32_t PkiCalcJacobiSymbol(void); 21 | bool PkiCalcModSquareRoot(void); 22 | 23 | 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/cc3x_sym/driver/hash_driver_ext_dma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef _HASH_DRIVER_EXT_DMA_H 7 | #define _HASH_DRIVER_EXT_DMA_H 8 | 9 | #include "driver_defs.h" 10 | 11 | 12 | 13 | 14 | drvError_t FinishHashExtDma(hashMode_t mode, uint32_t * digest); 15 | drvError_t InitHashExtDma(hashMode_t mode, uint32_t dataSize); 16 | drvError_t terminateHashExtDma(void); 17 | 18 | 19 | 20 | 21 | #endif // #_HASH_DRIVER_EXT_DMA_H 22 | -------------------------------------------------------------------------------- /host/src/cc3x_lib/cc_rng_params.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_RNG_PARAMS_H 8 | #define CC_RNG_PARAMS_H 9 | 10 | 11 | /* Default RNG parameters are used when these parameters are set to 0 */ 12 | #define CC_RNG_NUM_OF_ROSCS_ALLOWED_FLAG 0x0 13 | #define CC_RNG_SAMPL_RATIO_ON_SWEE_MODE 0 14 | 15 | 16 | /* Default, increment and mininimal values, for Sampling Ratio */ 17 | #define CC_RNG_DEFAULT_ROSCS_ALLOWED_FLAG 0xF 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /codesafe/src/mbedtls_api/mbedtls_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #include "cc_pal_types.h" 9 | #include "cc_pal_log.h" 10 | 11 | /* Implementation that should never be optimized out by the compiler */ 12 | 13 | void mbedtls_zeroize_internal( void *v, size_t n ) 14 | { 15 | volatile unsigned char *p = NULL; 16 | if( NULL == v ) 17 | { 18 | CC_PAL_LOG_ERR( "input is NULL\n" ); 19 | return; 20 | } 21 | p = (unsigned char*)v; while( n-- ) *p++ = 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /codesafe/src/mbedtls_api/mbedtls_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef MBEDTLS_COMMON_H 7 | #define MBEDTLS_COMMON_H 8 | #ifdef __cplusplus 9 | extern "C" 10 | { 11 | #endif 12 | 13 | /** 14 | * \brief Implementation of memset to zero 15 | * 16 | * \param v adrress to set 17 | * \param n size 18 | */ 19 | void mbedtls_zeroize_internal( void *v, size_t n ); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif /* MBEDTLS_COMMON_H */ 26 | -------------------------------------------------------------------------------- /shared/include/pal/freertos/cc_pal_log_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_LOG_PLAT_H_ 9 | #define _CC_PAL_LOG_PLAT_H_ 10 | 11 | #include "cc_log_mask.h" 12 | #include 13 | 14 | /************** PRINTF rules ******************/ 15 | #if defined(DEBUG) 16 | 17 | void CC_PalLog(int level, const char * format, ...); 18 | 19 | #else /* Disable all prints */ 20 | 21 | #define CC_PalLog(...) do {} while (0) 22 | 23 | #endif 24 | 25 | 26 | #endif /*_CC_PAL_LOG_PLAT_H_*/ 27 | -------------------------------------------------------------------------------- /shared/include/pal/mbedos/cc_pal_log_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_LOG_PLAT_H_ 9 | #define _CC_PAL_LOG_PLAT_H_ 10 | 11 | #include "cc_log_mask.h" 12 | #include 13 | 14 | /************** PRINTF rules ******************/ 15 | #if defined(DEBUG) 16 | 17 | void CC_PalLog(int level, const char * format, ...); 18 | 19 | #else /* Disable all prints */ 20 | 21 | #define CC_PalLog(...) do {} while (0) 22 | 23 | #endif 24 | 25 | 26 | #endif /*_CC_PAL_LOG_PLAT_H_*/ 27 | -------------------------------------------------------------------------------- /shared/hw/include/musca_b1/dx_reg_base_host.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | */ 6 | 7 | #ifndef __DX_REG_BASE_HOST_H__ 8 | #define __DX_REG_BASE_HOST_H__ 9 | 10 | /* Identify platform: ARM MUSCA_B1 */ 11 | #define DX_PLAT_MUSCA_B1 1 12 | 13 | #define DX_BASE_CC 0x50088000 14 | #define DX_BASE_CODE 0x50030000 //# not used 15 | 16 | #define DX_BASE_ENV_REGS 0x500A0000 //TODO need confirm 17 | 18 | #define DX_BASE_HOST_RGF 0x0UL 19 | #define DX_BASE_CRY_KERNEL 0x0UL 20 | 21 | #define DX_BASE_RNG 0x0000UL 22 | #endif /*__DX_REG_BASE_HOST_H__*/ 23 | -------------------------------------------------------------------------------- /shared/include/pal/no_os/cc_pal_perf_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_PERF_PLAT_H__ 8 | #define _CC_PAL_PERF_PLAT_H__ 9 | 10 | typedef unsigned int CCPalPerfData_t; 11 | 12 | /** 13 | * @brief DSM environment bug - sometimes very long write operation. 14 | * to overcome this bug we added while to make sure write opeartion is completed 15 | * 16 | * @param[in] 17 | * * 18 | * @return None 19 | */ 20 | void CC_PalDsmWorkarround(); 21 | 22 | 23 | #endif /*_CC_PAL_PERF_PLAT_H__*/ 24 | -------------------------------------------------------------------------------- /shared/include/trng/cc_config_trng90b.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_CONFIG_TRNG90B_H 8 | #define _CC_CONFIG_TRNG90B_H 9 | 10 | /* 11 | This file should be updated according to the characterization process. 12 | */ 13 | 14 | /*** For Startup Tests ***/ 15 | // amount of bytes for the startup test = 528 (at least 4096 bits (NIST SP 800-90B (2nd Draft) 4.3.12) = 22 EHRs = 4224 bits) 16 | #define CC_CONFIG_TRNG90B_AMOUNT_OF_BYTES_STARTUP 528 17 | 18 | 19 | 20 | #endif // _CC_CONFIG_TRNG90B_H 21 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/cc3x_sym/driver/chacha_driver_ext_dma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef _CHACHA_DRIVER_EXT_DMA_H 7 | #define _CHACHA_DRIVER_EXT_DMA_H 8 | 9 | #include "driver_defs.h" 10 | 11 | 12 | 13 | 14 | drvError_t FinishChachaExtDma(hashMode_t mode, uint32_t * digest); 15 | drvError_t InitChachaExtDma(uint32_t *nonceBuf, chachaNonceSize_t nonceSizeFlag, uint32_t *keyBuf, uint32_t initialCounter, uint32_t dataLen); 16 | drvError_t terminateChachaExtDma(void); 17 | 18 | 19 | 20 | 21 | #endif // #_CHACHA_DRIVER_EXT_DMA_H 22 | -------------------------------------------------------------------------------- /host/src/tests/proj/cc3x/test_proj.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include 8 | 9 | #include "test_proj_defs.h" 10 | #include "test_proj.h" 11 | #include "dx_env.h" 12 | 13 | uint32_t Test_ProjInit(void) 14 | { 15 | uint32_t error = 0; 16 | 17 | error = Test_ProjMap(); 18 | if (error != 0) { 19 | return error; 20 | } 21 | TEST_WRITE_TEE_ENV_REG(DX_ENV_APB_PPROT_OVERRIDE_REG_OFFSET, 0x9); 22 | 23 | return error; 24 | 25 | } 26 | 27 | void Test_ProjFree(void) 28 | { 29 | Test_ProjUnmap(); 30 | return; 31 | } 32 | -------------------------------------------------------------------------------- /codesafe/src/secure_boot_debug/secure_boot_gen/secureboot_basetypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_sb_basetypes 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains basic type definitions for the Secure Boot. 15 | */ 16 | 17 | #ifndef _SECUREBOOT_BASE_TYPES_H 18 | #define _SECUREBOOT_BASE_TYPES_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | #include "cc_pal_types.h" 26 | #include "cc_pal_types_plat.h" 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | /*! 33 | @} 34 | */ 35 | #endif 36 | -------------------------------------------------------------------------------- /proj.ext.cfg: -------------------------------------------------------------------------------- 1 | # External project configuration for cc312 2 | 3 | # definitions for TRNG 4 | # TRNG mode: 0 for FE TRNG, 1 for TRNG90B 5 | CC_CONFIG_TRNG_MODE = 0 6 | 7 | # indicates whether the project supports srp 8 | CC_CONFIG_SUPPORT_SRP = 1 9 | 10 | # indicates whether the project supports chacha\poly 11 | CC_CONFIG_CC_CHACHA_POLY_SUPPORT = 1 12 | 13 | #indicates whether to use X509 certificate format or proprietary 14 | CC_CONFIG_SB_X509_CERT_SUPPORTED = 0 15 | 16 | #indicates whether the project supports External DMA 17 | CC_CONFIG_SUPPORT_EXT_DMA = 0 18 | 19 | #indicates whether the project supports SB run time. 20 | CC_CONFIG_SUPPORT_SB_RT = 1 21 | 22 | #indicates that CryptoCell is working with mbedtls 23 | USE_MBEDTLS_CRYPTOCELL = 1 24 | -------------------------------------------------------------------------------- /host/src/cc3x_lib/cc_fips_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_FIPS_DEFS_H 8 | #define _CC_FIPS_DEFS_H 9 | 10 | //empty macro since FIPS not supported 11 | #define CHECK_AND_RETURN_ERR_UPON_FIPS_ERROR() 12 | #define CHECK_AND_RETURN_UPON_FIPS_ERROR() 13 | #define CHECK_AND_RETURN_UPON_FIPS_STATE() 14 | #define CHECK_FIPS_SUPPORTED(supported) {supported = false;} 15 | #define FIPS_RSA_VALIDATE(rndContext_ptr,pCcUserPrivKey,pCcUserPubKey,pFipsCtx) (CC_OK) 16 | #define FIPS_ECC_VALIDATE(pRndContext, pUserPrivKey, pUserPublKey, pFipsCtx) (CC_OK) 17 | #define CC_FIPS_SET_RND_CONT_ERR() 18 | 19 | #endif // _CC_FIPS_DEFS_H 20 | 21 | -------------------------------------------------------------------------------- /host/Makefile.guards: -------------------------------------------------------------------------------- 1 | all: check_var print_var 2 | 3 | check_var: \ 4 | guard-KERNEL_DIR \ 5 | guard-ARM_CPU \ 6 | guard-ARCH \ 7 | guard-COMPILER_TYPE \ 8 | guard-CROSS_COMPILE 9 | 10 | guard-%: 11 | @ if [ "${${*}}" = "" ]; then \ 12 | echo -e "\033[41m $* is undefined \033[0m"; \ 13 | exit 1; \ 14 | fi 15 | 16 | print_var: 17 | @echo -e "\033[42m*********************************************\033[0m" ;\ 18 | echo -e "\033[42m KERNEL_DIR[$(KERNEL_DIR)] \033[0m" ;\ 19 | echo -e "\033[42m ARM_CPU[$(ARM_CPU)] \033[0m" ;\ 20 | echo -e "\033[42m ARCH[$(ARCH)] \033[0m" ;\ 21 | echo -e "\033[42m COMPILER_TYPE[$(COMPILER_TYPE)] \033[0m" ;\ 22 | echo -e "\033[42m CROSS_COMPILE[$(CROSS_COMPILE)] \033[0m" ;\ 23 | echo -e "\033[42m*********************************************\033[0m" ; 24 | 25 | -------------------------------------------------------------------------------- /shared/include/pal/cc_pal_abort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_pal_abort 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file includes all PAL APIs. 15 | */ 16 | 17 | #ifndef _CC_PAL_ABORT_H 18 | #define _CC_PAL_ABORT_H 19 | 20 | 21 | #include "cc_pal_abort_plat.h" 22 | 23 | 24 | /*! 25 | @brief This function performs the "Abort" operation. 26 | 27 | Must be implemented according to platform and OS. 28 | */ 29 | void CC_PalAbort( 30 | /*! [in] An optional parameter for a string of chars to indicate the abort 31 | operation. */ 32 | const char * exp 33 | ); 34 | 35 | /*! 36 | @} 37 | */ 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/common_utils/global_defines_prim_hash.py: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 6 | # 7 | 8 | 9 | 10 | # Global Definitions # 11 | #--------------------# 12 | 13 | # Output size definitions 14 | #------------------------# 15 | 16 | OUTPUT_SIZE_SHA_256 = 0x1 17 | 18 | OUTPUT_SIZE_SHA_256_TRUNC = 0x2 19 | 20 | # File names definitions 21 | #-----------------------# 22 | 23 | # Prim key hash file name 24 | PRIM_KEY_HASH_FILE_NAME = "PrimKeyHASH.txt" 25 | 26 | # ECC file name 27 | ECC_FILE_NAME = "PrimKeyHASHECC.txt" 28 | 29 | ZEROS_NUM_FILES_NAME = "ZeroBitsInHASH.txt" 30 | 31 | # General definitions 32 | #-------------------- 33 | SIZE_OF_WORD_IN_BITS = 32 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/secure_boot_debug/secure_boot_gen/secureboot_general_hwdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef SECUREBOOT_GENERAL_HWDEFS_H 8 | #define SECUREBOOT_GENERAL_HWDEFS_H 9 | 10 | 11 | #include "cc_regs.h" 12 | #include "dx_host.h" 13 | #include "dx_crys_kernel.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | 21 | /************************ Defines ******************************/ 22 | #define SB_REG_ADDR(base, reg_name) (base + CC_REG_OFFSET(CRY_KERNEL, reg_name)) 23 | #define SB_REG_ADDR_UNIT(base, reg_name, unit) (base + CC_REG_OFFSET(unit, reg_name)) 24 | 25 | 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /host/src/cc3x_productionlib/cmpu/cmpu_derivation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CMPU_DERIVATION_H 8 | #define _CMPU_DERIVATION_H 9 | 10 | 11 | uint32_t CC_PROD_Derivation_Instantiate (uint32_t *pEntrSrc, 12 | uint32_t sourceSize, 13 | uint8_t *pKey, 14 | uint8_t *pIv); 15 | uint32_t CC_PROD_Derivation_Generate(uint8_t *pKey, 16 | uint8_t *pIv, 17 | uint32_t *pOutputBuff, 18 | uint32_t outDataSize); 19 | 20 | #endif //_CMPU_DERIVATION_H 21 | 22 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/ec_wrst/pka_ec_wrst_glob_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef PKA_ECC_GLOB_REGS_DEF_H 8 | #define PKA_ECC_GLOB_REGS_DEF_H 9 | 10 | /* Define global PKA registers pointers */ 11 | #define ECC_REG_N PKA_REG_N 12 | #define ECC_REG_N1 PKA_REG_N 13 | #define ECC_REG_NP PKA_REG_NP 14 | #define ECC_REG_T 2 15 | #define ECC_REG_T1 3 16 | #define ECC_REG_T2 4 17 | #define ECC_REG_T3 5 18 | #define ECC_REG_AQ 6 19 | #define ECC_REG_A_NM2 7 20 | #define ECC_REG_N4 8 21 | #define ECC_REG_N8 9 22 | #define ECC_REG_N12 10 23 | #define ECC_REG_EC_A 11 24 | #define ECC_REG_T4 12 25 | #define ECC_REG_AAA_Z 13 26 | #endif 27 | -------------------------------------------------------------------------------- /shared/include/sbrom/cc_crypto_x509_common_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_CRYPTO_X509_COMMON_DEFS_H 8 | #define _CC_CRYPTO_X509_COMMON_DEFS_H 9 | 10 | /*! 11 | @file 12 | @brief This file contains definitions used in the X509 certificates. 13 | */ 14 | 15 | /*! MAX size of issuer name string. */ 16 | #define X509_ISSUER_NAME_MAX_STRING_SIZE 64 17 | /*! MAX size of subject name string. */ 18 | #define X509_SUBJECT_NAME_MAX_STRING_SIZE 64 19 | /*! MAX size of validity period string. */ 20 | #define X509_VALIDITY_PERIOD_MAX_STRING_SIZE 16 21 | /*! MAX size of a single user's data buffer */ 22 | #define X509_USER_DATA_MAX_SIZE_BYTES 64 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp192k1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_ECPKI_DOMAIN_SECP192K1_H 8 | #define CC_ECPKI_DOMAIN_SECP192K1_H 9 | 10 | /* 11 | * All the includes that are needed for code using this module to 12 | * compile correctly should be #included here. 13 | */ 14 | #include "cc_pal_types.h" 15 | #include "cc_ecpki_types.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | /** 23 | @brief the function returns the domain pointer 24 | @return return domain pointer 25 | 26 | */ 27 | const CCEcpkiDomain_t *CC_EcpkiGetSecp192k1DomainP(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp192r1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_ECPKI_DOMAIN_SECP192R1_H 8 | #define CC_ECPKI_DOMAIN_SECP192R1_H 9 | 10 | /* 11 | * All the includes that are needed for code using this module to 12 | * compile correctly should be #included here. 13 | */ 14 | #include "cc_pal_types.h" 15 | #include "cc_ecpki_types.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | /** 23 | @brief the function returns the domain pointer 24 | @return return domain pointer 25 | 26 | */ 27 | const CCEcpkiDomain_t *CC_EcpkiGetSecp192r1DomainP(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp224k1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_ECPKI_DOMAIN_SECP224K1_H 8 | #define CC_ECPKI_DOMAIN_SECP224K1_H 9 | 10 | /* 11 | * All the includes that are needed for code using this module to 12 | * compile correctly should be #included here. 13 | */ 14 | #include "cc_pal_types.h" 15 | #include "cc_ecpki_types.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | /** 23 | @brief the function returns the domain pointer 24 | @return return domain pointer 25 | 26 | */ 27 | const CCEcpkiDomain_t *CC_EcpkiGetSecp224k1DomainP(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp224r1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_ECPKI_DOMAIN_SECP224R1_H 8 | #define CC_ECPKI_DOMAIN_SECP224R1_H 9 | 10 | /* 11 | * All the includes that are needed for code using this module to 12 | * compile correctly should be #included here. 13 | */ 14 | #include "cc_pal_types.h" 15 | #include "cc_ecpki_types.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | /** 23 | @brief the function returns the domain pointer 24 | @return return domain pointer 25 | 26 | */ 27 | const CCEcpkiDomain_t *CC_EcpkiGetSecp224r1DomainP(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp256k1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_ECPKI_DOMAIN_SECP256K1_H 8 | #define CC_ECPKI_DOMAIN_SECP256K1_H 9 | 10 | /* 11 | * All the includes that are needed for code using this module to 12 | * compile correctly should be #included here. 13 | */ 14 | #include "cc_pal_types.h" 15 | #include "cc_ecpki_types.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | /** 23 | @brief the function returns the domain pointer 24 | @return return domain pointer 25 | 26 | */ 27 | const CCEcpkiDomain_t *CC_EcpkiGetSecp256k1DomainP(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp256r1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_ECPKI_DOMAIN_SECP256R1_H 8 | #define CC_ECPKI_DOMAIN_SECP256R1_H 9 | 10 | /* 11 | * All the includes that are needed for code using this module to 12 | * compile correctly should be #included here. 13 | */ 14 | #include "cc_pal_types.h" 15 | #include "cc_ecpki_types.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | /** 23 | @brief the function returns the domain pointer 24 | @return return domain pointer 25 | 26 | */ 27 | const CCEcpkiDomain_t *CC_EcpkiGetSecp256r1DomainP(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp521r1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_ECPKI_DOMAIN_SECP521R1_H 8 | #define CC_ECPKI_DOMAIN_SECP521R1_H 9 | 10 | /* 11 | * All the includes that are needed for code using this module to 12 | * compile correctly should be #included here. 13 | */ 14 | #include "cc_pal_types.h" 15 | #include "cc_ecpki_types.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" 19 | { 20 | #endif 21 | 22 | /** 23 | @brief the function returns the domain pointer 24 | @return return domain pointer 25 | 26 | */ 27 | const CCEcpkiDomain_t *CC_EcpkiGetSecp521r1DomainP(void); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /host/Makefile.freertos: -------------------------------------------------------------------------------- 1 | ifeq ($(TEE_OS), freertos) 2 | INCDIRS_EXTRA += $(KERNEL_DIR)/OS/FreeRTOS/Source/include 3 | INCDIRS_EXTRA += $(KERNEL_DIR)/OS/FreeRTOS-Plus-CLI 4 | INCDIRS_EXTRA += $(KERNEL_DIR)/OS/FreeRTOS-Plus-TCP/include 5 | INCDIRS_EXTRA += $(KERNEL_DIR)/boards/MPS2+ 6 | INCDIRS_EXTRA += $(KERNEL_DIR)/lib/main 7 | INCDIRS_EXTRA += $(KERNEL_DIR)/InterruptCtrl 8 | 9 | COMPILER_TYPE_DIR = $(shell echo $(COMPILER_TYPE) | tr a-z A-Z) 10 | 11 | INCDIRS_EXTRA += $(KERNEL_DIR)/OS/FreeRTOS-Plus-TCP/portable/Compiler/$(COMPILER_TYPE_DIR) 12 | 13 | ifeq ($(ARM_CPU), cortex-m33) 14 | CFLAGS += -DSSE_200 15 | INCDIRS_EXTRA += $(KERNEL_DIR)/OS/FreeRTOS/Source/portable/$(COMPILER_TYPE_DIR)/ARM_CM33 16 | else 17 | CFLAGS += -DARMCM3 18 | INCDIRS_EXTRA += $(KERNEL_DIR)/OS/FreeRTOS/Source/portable/$(COMPILER_TYPE_DIR)/ARM_CM3 19 | endif 20 | 21 | endif 22 | 23 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/ecc_domains/cc_ecpki_domain_secp384r1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef CC_ECPKI_DOMAIN_SECP384R1_H 9 | #define CC_ECPKI_DOMAIN_SECP384R1_H 10 | 11 | /* 12 | * All the includes that are needed for code using this module to 13 | * compile correctly should be #included here. 14 | */ 15 | #include "cc_pal_types.h" 16 | #include "cc_ecpki_types.h" 17 | 18 | #ifdef __cplusplus 19 | extern "C" 20 | { 21 | #endif 22 | 23 | /** 24 | @brief the function returns the domain pointer 25 | @return return domain pointer 26 | 27 | */ 28 | const CCEcpkiDomain_t *CC_EcpkiGetSecp384r1DomainP(void); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /shared/include/pal/freertos/cc_pal_types_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | /*! @file 9 | @brief This file contains basic platform-dependent type definitions. 10 | */ 11 | #ifndef _CC_PAL_TYPES_PLAT_H 12 | #define _CC_PAL_TYPES_PLAT_H 13 | /* Host specific types for standard (ISO-C99) compilant platforms */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | typedef uintptr_t CCVirtAddr_t; 20 | typedef uint32_t CCBool_t; 21 | typedef uint32_t CCStatus; 22 | 23 | #define CCError_t CCStatus 24 | #define CC_INFINITE 0xFFFFFFFF 25 | 26 | #define CEXPORT_C 27 | #define CIMPORT_C 28 | 29 | #endif /*_CC_PAL_TYPES_PLAT_H*/ 30 | -------------------------------------------------------------------------------- /shared/include/pal/mbedos/cc_pal_types_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | /*! @file 9 | @brief This file contains basic platform-dependent type definitions. 10 | */ 11 | #ifndef _CC_PAL_TYPES_PLAT_H 12 | #define _CC_PAL_TYPES_PLAT_H 13 | /* Host specific types for standard (ISO-C99) compilant platforms */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | typedef uintptr_t CCVirtAddr_t; 20 | typedef uint32_t CCBool_t; 21 | typedef uint32_t CCStatus; 22 | 23 | #define CCError_t CCStatus 24 | #define CC_INFINITE 0xFFFFFFFF 25 | 26 | #define CEXPORT_C 27 | #define CIMPORT_C 28 | 29 | #endif /*_CC_PAL_TYPES_PLAT_H*/ 30 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal_log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include 8 | #include "cc_pal_types.h" 9 | #include "cc_pal_log.h" 10 | #include 11 | 12 | int CC_PAL_logLevel = CC_PAL_MAX_LOG_LEVEL; 13 | uint32_t CC_PAL_logMask = 0xFFFFFFFF; 14 | 15 | void CC_PalLogInit(void) 16 | { 17 | } 18 | 19 | void CC_PalLogLevelSet(int setLevel) 20 | { 21 | CC_PAL_logLevel = setLevel; 22 | } 23 | 24 | void CC_PalLogMaskSet(uint32_t setMask) 25 | { 26 | CC_PAL_logMask = setMask; 27 | } 28 | 29 | void CC_PalLog(int level, const char * format, ...) 30 | { 31 | va_list args; 32 | CC_UNUSED_PARAM(level); 33 | va_start( args, format ); 34 | vprintf(format, args); 35 | va_end(args); 36 | } 37 | -------------------------------------------------------------------------------- /host/src/cc3x_productionlib/cmpu/cmpu_llf_rnd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CMPU_LLF_RND_DEFS_H 9 | #define _CMPU_LLF_RND_DEFS_H 10 | 11 | /************* Include Files ****************/ 12 | #include "prod_hw_defs.h" 13 | #include "cc_otp_defs.h" 14 | 15 | #define CC_PROD_RND_Fast 0 16 | #define CC_PROD_REQUIRED_ENTROPY_BITS 256 17 | 18 | uint32_t CC_PROD_LLF_RND_GetTrngSource(uint32_t **ppSourceOut, 19 | uint32_t *pSourceOutSize, 20 | uint32_t *pRndWorkBuff); 21 | 22 | uint32_t CC_PROD_LLF_RND_VerifyGeneration(uint8_t *pBuff); 23 | 24 | #endif //_CMPU_LLF_RND_DEFS_H 25 | -------------------------------------------------------------------------------- /shared/include/crypto_api/cc3x/cc_hash_defs_proj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_hash_defs_proj 9 | @{ 10 | */ 11 | 12 | 13 | /*! 14 | @file 15 | @brief This file contains the project-specific definitions of hash APIs. 16 | */ 17 | 18 | #ifndef _CC_HASH_DEFS_PROJ_H 19 | #define _CC_HASH_DEFS_PROJ_H 20 | 21 | #ifdef __cplusplus 22 | extern "C" 23 | { 24 | #endif 25 | 26 | 27 | /************************ Defines ******************************/ 28 | 29 | /*! The size of the context prototype of the user in words. 30 | See ::CCHashUserContext_t. */ 31 | #define CC_HASH_USER_CTX_SIZE_IN_WORDS 60 32 | 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | /*! 39 | @} 40 | */ 41 | #endif 42 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ********** Building Process ********** 2 | There are two ways to build the TestAL libraries: 3 | 4 | 1. USING build_config.sh 5 | 6 | 1. Export KERNEL_DIR in case of mbedOS or FreeRTOS. 7 | 2. Run the build_config.sh script, with or without a configuration number. 8 | 3. The static libraries will be located in the project directory. 9 | 10 | 2. BUILDING MANUALLY 11 | 1. Configure the toolchain. 12 | 2. Run "make distclean". 13 | 3. Run "make setconfig_testal__" 14 | 4. Run "make" 15 | 5. The static libraries will be located in the project directory. 16 | 17 | ********** Cleaning Process ********** 18 | For cleaning object files, config file and static libraries: 19 | 1. Run “make distclean". 20 | 21 | For cleaning object files: 22 | 1. Run “make clean". 23 | 24 | For cleaning the current config file: 25 | 1. Run "make clrconfig". 26 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/icv_key_response/examples/dmpu_icv_key_response.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for generating key request certificate by OEM 2 | # [DMPU-ICV-KEY-RES-CFG] Mandatory header. 3 | # oem-cert-pkg = OEM key request certificate package output file. Binary format. 4 | #key-filename = File holding the encrypted Krtl, in binary format. 5 | #keypwd-filename = Passphrase for the key file, in txt format. 6 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 7 | #icv-enc-oem-key = The file containing teh encrypted oem key, generated by dmpu_key_response_util.py. 8 | [DMPU-ICV-KEY-RES-CFG] 9 | oem-cert-pkg = oem_request_pkg.bin 10 | key-filename = rtl_enc_key.bin 11 | keypwd-filename = rtl_key_pwd.txt 12 | icv-enc-oem-key = icv_response_pkg.bin 13 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/no_os/board_addrs.c: -------------------------------------------------------------------------------- 1 | #include "board_addrs.h" 2 | 3 | /******************************************************************************/ 4 | unsigned long MPS2_GetDMAbaseAddr(void) 5 | { 6 | return (unsigned long)MPS2_PLUS_MEM_DMA_BASE_ADDR; 7 | } 8 | 9 | /******************************************************************************/ 10 | unsigned long MPS2_GetDMAAreaLen(void) 11 | { 12 | return (unsigned long)MPS2_PLUS_MEM_DMA_AREA_LEN; 13 | } 14 | 15 | /******************************************************************************/ 16 | unsigned long MPS2_GetUnmanagedbaseAddr(void) 17 | { 18 | return (unsigned long)MPS2_PLUS_MEM_UNMANAGED_BASE_ADDR; 19 | } 20 | 21 | /******************************************************************************/ 22 | unsigned long MPS2_GetUnmanagedAreaLen(void) 23 | { 24 | return (unsigned long)MPS2_PLUS_MEM_UNMANAGED_AREA_LEN; 25 | } 26 | -------------------------------------------------------------------------------- /shared/include/proj/cc3x/cc_address_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_general_defs 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains general definitions for CryptoCell APIs. 15 | */ 16 | 17 | 18 | 19 | #ifndef _CC_ADDRESS_DEFS_H 20 | #define _CC_ADDRESS_DEFS_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" 24 | { 25 | #endif 26 | 27 | 28 | /************************ Defines ******************************/ 29 | 30 | /* Address types within CryptoCell. */ 31 | /*! The SRAM address type. */ 32 | typedef uint32_t CCSramAddr_t; 33 | /*! The DMA address type. */ 34 | typedef uint32_t CCDmaAddr_t; 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | /*! 41 | @} 42 | */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /utils/src/cc3x_asset_prov_rt/examples/asset_prov_se_512.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for enabler debug certificate generation 2 | # [ASSET-PROV-CFG] Mandatory header. 3 | #key-filename = File holding the encrypted Kpicv, in binary format. 4 | #keypwd-filename = Passphrase for the key file, in txt format. 5 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 6 | #asset-id = The ICV asset ID in 32 bits hex format (e.g. 0x7000000f). 7 | #asset-filename = The asset to create the BLOB for 8 | #asset-pkg = The asset package, generated by asset_provisioning_util_rt.py. 9 | [ASSET-PROV-CFG] 10 | key-filename = icv_key_enc.bin 11 | keypwd-filename = icv_key_pwd.txt 12 | asset-id = 0x00112233 13 | asset-filename = asset512_bin.bin 14 | asset-pkg = asset_pkg_se_512.bin 15 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/cc3x_sym/driver/aes_driver_ext_dma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _AES_DRIVER_EXT_DMA_H 8 | #define _AES_DRIVER_EXT_DMA_H 9 | 10 | #include "driver_defs.h" 11 | #include "aes_driver.h" 12 | 13 | 14 | 15 | 16 | 17 | drvError_t finalizeAesExtDma(aesMode_t mode, uint32_t *pIv); 18 | drvError_t terminateAesExtDma(void); 19 | 20 | 21 | drvError_t AesExtDmaSetIv(aesMode_t mode, uint32_t *pIv); 22 | 23 | 24 | drvError_t AesExtDmaSetKey(aesMode_t mode, uint32_t *keyBuf, keySizeId_t keySizeId); 25 | 26 | 27 | void AesExtDmaSetDataSize(uint32_t dataSize); 28 | 29 | 30 | drvError_t AesExtDmaInit(cryptoDirection_t encryptDecryptFlag, 31 | aesMode_t operationMode, 32 | keySizeId_t keySizeId); 33 | 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Arm-proprietary-license.txt: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from Arm Limited (or its affiliates). * 5 | * Copyright (c) 2001-2020, Arm Limited and Contributors. * 6 | * All rights reserved. * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from Arm Limited (or its affiliates). * 11 | *****************************************************************************/ 12 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/common/pka_point_compress_regs_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef PKA_POINT_COMPRESS_REGS_DEF_H 7 | #define PKA_POINT_COMPRESS_REGS_DEF_H 8 | 9 | /*stack*/ 10 | #define PKA_REG_X 2 11 | #define PKA_REG_Y 3 12 | #define PKA_REG_EC_A 4 13 | #define PKA_REG_EC_B 5 14 | 15 | /*Square root*/ 16 | /*in*/ 17 | #define PKA_REG_Y1 PKA_REG_Y //zQ 18 | #define PKA_REG_Y2 PKA_REG_EC_A //zN 19 | /*stack*/ 20 | #define PKA_REG_T 6 //zT 21 | #define PKA_REG_Z 7 //zZ 22 | #define PKA_REG_EX 8 //zEx 23 | #define PKA_REG_YT 9 //zYt 24 | 25 | /* Jacobi symbol */ 26 | /*in*/ 27 | #define PKA_REG_A 10 //za 28 | #define PKA_REG_B 11 //zb 29 | /*stack*/ 30 | #define PKA_REG_C 12 //zc 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /host/src/pal/freertos/cc_pal_log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | /************* Include Files ****************/ 9 | #include 10 | #include 11 | #include "cc_pal_types.h" 12 | #include "cc_pal_log.h" 13 | 14 | int CC_PAL_logLevel = CC_PAL_MAX_LOG_LEVEL; 15 | uint32_t CC_PAL_logMask = 0xFFFFFFFF; 16 | 17 | void CC_PalLogInit(void) 18 | { 19 | } 20 | 21 | void CC_PalLogLevelSet(int setLevel) 22 | { 23 | CC_PAL_logLevel = setLevel; 24 | } 25 | 26 | void CC_PalLogMaskSet(uint32_t setMask) 27 | { 28 | CC_PAL_logMask = setMask; 29 | } 30 | 31 | void CC_PalLog(int level, const char * format, ...) 32 | { 33 | va_list args; 34 | CC_UNUSED_PARAM(level); 35 | va_start( args, format ); 36 | 37 | vprintf( format, args); 38 | va_end(args); 39 | } 40 | -------------------------------------------------------------------------------- /shared/include/mbedtls/cmac_alt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef MBEDTLS_CMAC_ALT_H 8 | #define MBEDTLS_CMAC_ALT_H 9 | 10 | #if defined(MBEDTLS_CONFIG_FILE) 11 | #include MBEDTLS_CONFIG_FILE 12 | #endif 13 | 14 | 15 | 16 | #include 17 | #include 18 | 19 | 20 | /* hide internal implementation of the struct. Allocate enough space for it.*/ 21 | #define MBEDTLS_CMAC_CONTEXT_SIZE_IN_WORDS 33 22 | 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * \brief CMAC cipher context structure 30 | */ 31 | struct mbedtls_cmac_context_t{ 32 | /*! Internal buffer */ 33 | uint32_t buf[MBEDTLS_CMAC_CONTEXT_SIZE_IN_WORDS]; 34 | }; 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* MBEDTLS_CMAC_ALT_H */ 41 | -------------------------------------------------------------------------------- /codesafe/src/secure_boot_debug/crypto_driver/reg/crypto_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | 9 | #ifndef _CRYPTO_DRIVER_H 10 | #define _CRYPTO_DRIVER_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | 17 | 18 | #include "secureboot_basetypes.h" 19 | #include "bsv_crypto_api.h" 20 | 21 | 22 | /*! 23 | * @brief This function gives the functionality of integrated hash 24 | * 25 | * @param[in] hwBaseAddress - CryptoCell base address 26 | * @param[out] hashResult - the HASH result. 27 | * 28 | */ 29 | #define SBROM_CryptoHash(wBaseAddress, inputDataAddr, dataSize, hashBuff) \ 30 | CC_BsvSHA256(hwBaseAddress, (uint8_t *)inputDataAddr, (size_t)dataSize, hashBuff); 31 | 32 | 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /codesafe/src/secure_boot_debug/platform/pal/cc3x/cc_pal_sb_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_pal_sb_plat 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains platform-dependent definitions used in the Boot Services code. 15 | */ 16 | 17 | #ifndef _CC_PAL_SB_PLAT_H 18 | #define _CC_PAL_SB_PLAT_H 19 | 20 | #include "cc_pal_types.h" 21 | 22 | 23 | #ifdef __cplusplus 24 | extern "C" 25 | { 26 | #endif 27 | 28 | /*! DMA address types: 32 bits or 64 bits, according to platform. */ 29 | typedef uint32_t CCDmaAddr_t; 30 | /*! CryptocCell address types: 32 bits or 64 bits, according to platform. */ 31 | typedef uint32_t CCAddr_t; 32 | 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | /*! 38 | @} 39 | */ 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/runtime_integration_test/pal/include/run_integration_pal_reg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _RUN_INTEGRATION_PAL_REG_H_ 8 | #define _RUN_INTEGRATION_PAL_REG_H_ 9 | 10 | /************************************************************ 11 | * 12 | * macros 13 | * 14 | ************************************************************/ 15 | /** Write to register at offset (in words)*/ 16 | #define RUNIT_READ_REG(offset) \ 17 | *(volatile uint32_t *)(processMap.processTeeHwRegBaseAddr + (offset)) 18 | 19 | /** Read from register at offset (in words) into val */ 20 | #define RUNIT_WRITE_REG(offset, val) { \ 21 | (*(volatile uint32_t *)(processMap.processTeeHwRegBaseAddr + (offset))) = (uint32_t)(val); \ 22 | } 23 | 24 | #endif //_RUN_INTEGRATION_PAL_REG_H_ 25 | -------------------------------------------------------------------------------- /shared/include/mbedtls/chachapoly_alt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _MBEDTLS_CHACHAPOLY_ALT_H 8 | #define _MBEDTLS_CHACHAPOLY_ALT_H 9 | 10 | #if defined(MBEDTLS_CONFIG_FILE) 11 | #include MBEDTLS_CONFIG_FILE 12 | #endif 13 | 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | 20 | /************************ Defines ******************************/ 21 | 22 | #if defined(MBEDTLS_CHACHAPOLY_ALT) 23 | 24 | 25 | #define MBEDTLS_CHACHAPOLY_KEY_SIZE_BYTES 32 26 | 27 | 28 | typedef struct mbedtls_chachapoly_context 29 | { 30 | unsigned char key[MBEDTLS_CHACHAPOLY_KEY_SIZE_BYTES]; 31 | } 32 | mbedtls_chachapoly_context; 33 | 34 | #endif 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | 45 | #endif /* chachapoly_alt.h */ 46 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/oem_key_request/examples/dmpu_oem_key_request.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for generating key request certificate by OEM 2 | # [DMPU-OEM-KEY-REQ-CFG] Mandatory header. 3 | # oem-main-keypair = File holding the RSA keypair for signing this certificate, in pem format. 4 | # oem-main-keypwd = Passphrase for the keypair file, in txt format. 5 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 6 | # oem-enc-pubkey = File holding the RSA public key for ICV to encrypt the requested key, in pem format. 7 | # oem-cert-pkg = OEM key request certificate package output file. Binary format created by dmpu_oem_key_request_util.py. 8 | [DMPU-OEM-KEY-REQ-CFG] 9 | oem-main-keypair = oem_main_key_pair.pem 10 | oem-main-keypwd = oem_main_key_pair_pwd.txt 11 | oem-enc-pubkey = oem_enc_pub_key.pem 12 | oem-cert-pkg = oem_request_pkg.bin 13 | -------------------------------------------------------------------------------- /shared/include/mbedtls/sha1_alt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef MBEDTLS_SHA1_ALT_H 8 | #define MBEDTLS_SHA1_ALT_H 9 | 10 | #include 11 | #include 12 | 13 | #include "cc_hash_defs_proj.h" 14 | #if defined (MBEDTLS_CONFIG_FILE) 15 | #include MBEDTLS_CONFIG_FILE 16 | #endif 17 | 18 | #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035 /**< SHA-1 hardware accelerator failed */ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * \brief SHA-1 context structure 26 | */ 27 | typedef struct mbedtls_sha1_context { 28 | /*! Internal buffer */ 29 | uint32_t buff[CC_HASH_USER_CTX_SIZE_IN_WORDS]; // defined in cc_hash_defs_proj.h 30 | } mbedtls_sha1_context; 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* MBEDTLS_SHA1_ALT_H */ 37 | -------------------------------------------------------------------------------- /host/src/pal/linux/cc_pal_apbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | 9 | int32_t g_apbcCntr; 10 | 11 | void CC_PalApbcCntrInit(void) 12 | { 13 | g_apbcCntr = 0; 14 | return; 15 | } 16 | 17 | int32_t CC_PalApbcCntrValue(void) 18 | { 19 | return g_apbcCntr; 20 | } 21 | 22 | CCError_t CC_PalApbcModeSelect(CCBool isApbcInc) 23 | { 24 | CCError_t rc = CC_OK; 25 | switch (isApbcInc){ 26 | case CC_FALSE: 27 | __atomic_fetch_sub(&g_apbcCntr, 1, __ATOMIC_SEQ_CST); 28 | break; 29 | case CC_TRUE: 30 | __atomic_fetch_add(&g_apbcCntr, 1, __ATOMIC_SEQ_CST); 31 | break; 32 | default: 33 | return -1; 34 | } 35 | 36 | if(g_apbcCntr < 0 ){ 37 | /* illegal state - exit with error */ 38 | return 1; 39 | } 40 | 41 | return rc; 42 | } 43 | -------------------------------------------------------------------------------- /shared/include/mbedtls/sha256_alt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef MBEDTLS_SHA256_ALT_H 8 | #define MBEDTLS_SHA256_ALT_H 9 | 10 | #include 11 | #include 12 | 13 | #include "cc_hash_defs_proj.h" 14 | #if defined (MBEDTLS_CONFIG_FILE) 15 | #include MBEDTLS_CONFIG_FILE 16 | #endif 17 | 18 | 19 | #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037 /**< SHA-256 hardware accelerator failed */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * \brief SHA-256 context structure 27 | */ 28 | typedef struct mbedtls_sha256_context { 29 | /*! Internal buffer */ 30 | uint32_t buff[CC_HASH_USER_CTX_SIZE_IN_WORDS]; // defined in cc_hash_defs.h 31 | } mbedtls_sha256_context; 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* MBEDTLS_SHA256_ALT_H */ 38 | -------------------------------------------------------------------------------- /codesafe/src/mbedtls_api/mbedtls_hash_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef MBEDTLS_HASH_COMMON_H 7 | #define MBEDTLS_HASH_COMMON_H 8 | #include "mbedtls_common.h" 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | 15 | uint32_t mbedtls_hashUpdate(void *pHashUserCtx, 16 | uint8_t *pDataIn, 17 | size_t dataInSize); 18 | 19 | void mbedtls_sha_init_internal( void *ctx ); 20 | 21 | int mbedtls_sha_process_internal( void *ctx, const unsigned char *data ); 22 | 23 | int mbedtls_sha_finish_internal( void *ctx ); 24 | 25 | int mbedtls_sha_update_internal( void *ctx, const unsigned char *input, size_t ilen ); 26 | 27 | int mbedtls_sha_starts_internal( void *ctx, hashMode_t mode); 28 | 29 | 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* MBEDTLS_HASH_COMMON_H */ 37 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/cc3x_sym/driver/hmac_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _HMAC_DRIVER_H 8 | #define _HMAC_DRIVER_H 9 | 10 | #include "driver_defs.h" 11 | 12 | /****************************************************************************** 13 | * TYPE DEFINITIONS 14 | ******************************************************************************/ 15 | 16 | /* The context data-base used by the Hmac functions on the low level */ 17 | typedef struct HmacContext { 18 | uint32_t valid_tag; 19 | /* Key XOR opad result */ 20 | uint8_t KeyXorOpadBuff[CC_HMAC_SHA2_1024BIT_KEY_SIZE_IN_BYTES]; 21 | /* The operation mode */ 22 | CCHashOperationMode_t mode; 23 | /* The user HASH context - required for operating the HASH described below */ 24 | CCHashUserContext_t HashUserContext; 25 | } HmacContext_t; 26 | 27 | 28 | #endif /* _HMAC_DRIVER_H */ 29 | 30 | -------------------------------------------------------------------------------- /shared/include/proj/cc3x/cc_util_apbc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_UTIL_APBC_H_ 9 | #define _CC_UTIL_APBC_H_ 10 | 11 | /*! 12 | @file 13 | @defgroup cc_apbc_defs CryptoCell APBC macros 14 | @brief This file contains APBC definitions. 15 | @{ 16 | @ingroup cryptocell_api 17 | 18 | */ 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | #include "cc_pal_apbc.h" 26 | 27 | /*! Get APBC Access counter. Return number of active APBC accesses operations */ 28 | #define CC_APBC_CNTR_GET CC_PalApbcCntrValue() 29 | 30 | /*! Increment APBC access counter. */ 31 | #define CC_APBC_ACCESS_INC CC_PalApbcModeSelect(CC_TRUE) 32 | 33 | /*! Decrement APBC access counter. */ 34 | #define CC_APBC_ACCESS_DEC CC_PalApbcModeSelect(CC_FALSE) 35 | 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | /** 41 | @} 42 | */ 43 | #endif /*_CC_UTIL_APBC_H_*/ 44 | -------------------------------------------------------------------------------- /shared/include/proj/cc3x/cc_util_pm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PM_DEFS_H_ 9 | #define _CC_PM_DEFS_H_ 10 | 11 | /*! 12 | @file 13 | @defgroup cc_pm_defs CryptoCell power management macroes 14 | @brief This file contains power management definitions. 15 | @{ 16 | @ingroup cryptocell_api 17 | 18 | */ 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | #include "cc_pal_pm.h" 26 | 27 | /*! Get ARM Cerberus status. Return number of active registered CC operations */ 28 | #define CC_STATUS_GET CC_PalPowerSaveModeStatus() 29 | 30 | /*! Notify ARM Cerberus is active. */ 31 | #define CC_IS_WAKE CC_PalPowerSaveModeSelect(CC_FALSE) 32 | 33 | /*! Notify ARM Cerberus is idle. */ 34 | #define CC_IS_IDLE CC_PalPowerSaveModeSelect(CC_TRUE) 35 | 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | /** 41 | @} 42 | */ 43 | #endif /*_CC_PM_DEFS_H_*/ 44 | -------------------------------------------------------------------------------- /shared/include/pal/no_os/cc_pal_mutex_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_MUTEX_PLAT_H 8 | #define _CC_PAL_MUTEX_PLAT_H 9 | 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | /** 16 | * @brief File Description: 17 | * This file contains functions for resource management (semaphor operations). 18 | * The functions implementations are generally just wrappers to different operating system calls. 19 | * None of the described functions will check the input parameters so the behavior 20 | * of the APIs in illegal parameters case is dependent on the operating system behavior. 21 | * 22 | */ 23 | 24 | typedef uint32_t CC_PalMutex; 25 | 26 | 27 | 28 | /*---------------------------- 29 | PUBLIC FUNCTIONS 30 | -----------------------------------*/ 31 | 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | 39 | 40 | -------------------------------------------------------------------------------- /shared/include/proj/cc3x/cc_sec_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_SEC_DEFS_H 9 | #define _CC_SEC_DEFS_H 10 | 11 | /*! 12 | @file 13 | @brief This file contains general hash definitions and types. 14 | */ 15 | 16 | #ifdef __cplusplus 17 | extern "C" 18 | { 19 | #endif 20 | 21 | /*! The hashblock size in words. */ 22 | #define HASH_BLOCK_SIZE_IN_WORDS 16 23 | 24 | /*! SHA256 result size in words. */ 25 | #define HASH_RESULT_SIZE_IN_WORDS 8 26 | /*! SHA256 result size in Bytes. */ 27 | #define HASH_RESULT_SIZE_IN_BYTES 32 28 | 29 | /*! Defines the hash result array. */ 30 | typedef uint32_t CCHashResult_t[HASH_RESULT_SIZE_IN_WORDS]; 31 | 32 | /*! Definition for converting pointer to address. */ 33 | #define CONVERT_TO_ADDR(ptr) (unsigned long)ptr 34 | 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/rsa/rsa_public.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef LLF_RSA_PUBLIC_H 9 | #define LLF_RSA_PUBLIC_H 10 | 11 | /* 12 | * All the includes that are needed for code using this module to 13 | * compile correctly should be #included here. 14 | */ 15 | 16 | #include "cc_error.h" 17 | #include "cc_rsa_types.h" 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | 26 | typedef struct { 27 | /* the Barrett mod tag NP for N-modulus - used in the modular multiplication and 28 | exponentiation, calculated in CC_RsaPrivKeyBuild function */ 29 | uint32_t NP[CC_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; 30 | }RsaPubKeyDb_t; 31 | 32 | CCError_t RsaExecPubKeyExp(CCRsaPubKey_t *pPubKey, 33 | CCRsaPrimeData_t *pPubData ); 34 | 35 | CCError_t RsaInitPubKeyDb(CCRsaPubKey_t *pPubKey); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /codesafe/src/secure_boot_debug/util/util_base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | 9 | #ifndef UTIL_BASE64_H 10 | #define UTIL_BASE64_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | 17 | /** 18 | * @brief This function converts pem base64 encoded string to char string 19 | * 20 | * 21 | * @param[in] pInStr - PEM base64 string 22 | * @param[in] inSize - size of given string 23 | * @param[out] pOutStr - output string decoded 24 | * @param[in/out] outSize - the output buffer size (in MAX size out actual size) 25 | * 26 | * @return CCError_t - On success the value CC_OK is returned, 27 | * on failure - a value from bootimagesverifierx509_error.h 28 | */ 29 | CCError_t UTIL_ConvertPemStrToCharStr(uint8_t *pInStr, uint32_t inSize, 30 | uint8_t *pOutStr, uint32_t *outSize); 31 | 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /host/src/tests/proj/cc3x/cc312_r1/test_proj_cclib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _TEST_PROJ_CCLIB_H_ 8 | #define _TEST_PROJ_CCLIB_H_ 9 | 10 | #include "cc_rnd_common.h" 11 | 12 | 13 | /****************************************************************************/ 14 | /* 15 | * @brief This function frees previously allocated resources 16 | * 17 | * @param[in/out] *pProcessMap - mapping regions 18 | * 19 | * @return rc - 0 for success, 1 for failure 20 | */ 21 | void Test_ProjFree(void); 22 | 23 | /****************************************************************************/ 24 | /* 25 | * @brief This function 26 | * 27 | * @param[in/out] 28 | * 29 | * @return rc - 30 | */ 31 | int Test_Proj_CC_LibInit_Wrap(void* p_rng, 32 | void* p_entropy, 33 | CCRndWorkBuff_t * rndWorkBuff_ptr); 34 | 35 | #endif //_TEST_PROJ_CCLIB_H_ 36 | 37 | -------------------------------------------------------------------------------- /shared/hw/include/dx_reg_common.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from Arm Limited (or its affiliates). * 5 | * (C) COPYRIGHT [2001-2018] Arm Limited (or its affiliates). * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from Arm Limited (or its affiliates). * 11 | *****************************************************************************/ 12 | 13 | #ifndef __DX_REG_COMMON_H__ 14 | #define __DX_REG_COMMON_H__ 15 | 16 | #define DX_DEV_SIGNATURE 0x10E00000UL 17 | 18 | #endif /*__DX_REG_COMMON_H__*/ 19 | 20 | -------------------------------------------------------------------------------- /shared/include/pal/mbedos/cc_pal_mutex_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_MUTEX_PLAT_H 9 | #define _CC_PAL_MUTEX_PLAT_H 10 | 11 | #include "cmsis_os2.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | /** 18 | * @brief File Description: 19 | * This file contains functions for resource management (semaphor operations). 20 | * The functions implementations are generally just wrappers to different operating system calls. 21 | * None of the described functions will check the input parameters so the behavior 22 | * of the APIs in illegal parameters case is dependent on the operating system behavior. 23 | * 24 | */ 25 | 26 | typedef osMutexId_t CC_PalMutex; 27 | 28 | 29 | 30 | /*---------------------------- 31 | PUBLIC FUNCTIONS 32 | -----------------------------------*/ 33 | 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | 41 | 42 | -------------------------------------------------------------------------------- /shared/include/pal/linux/cc_pal_mutex_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_MUTEX_PLAT_H 8 | #define _CC_PAL_MUTEX_PLAT_H 9 | 10 | 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | #include 17 | 18 | /** 19 | * @brief File Description: 20 | * This file contains functions for resource management (semaphor operations). 21 | * The functions implementations are generally just wrappers to different operating system calls. 22 | * None of the described functions will check the input parameters so the behavior 23 | * of the APIs in illegal parameters case is dependent on the operating system behavior. 24 | * 25 | */ 26 | 27 | typedef pthread_mutex_t CC_PalMutex; 28 | 29 | 30 | 31 | /*---------------------------- 32 | PUBLIC FUNCTIONS 33 | -----------------------------------*/ 34 | 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | 42 | 43 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/ec_wrst/pka_ec_wrst_dsa_sign_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef PKA_ECDSA_SIGN_REGS_DEF_H 7 | #define PKA_ECDSA_SIGN_REGS_DEF_H 8 | 9 | /* PkaScalarMultSca regs */ 10 | #define EC_SIGN_REG_X2 12 11 | #define EC_SIGN_REG_Y2 13 12 | #define EC_SIGN_REG_Z2 14 13 | #define EC_SIGN_REG_T2 15 14 | #define EC_SIGN_REG_X4 16 15 | #define EC_SIGN_REG_Y4 17 16 | #define EC_SIGN_REG_Z4 18 17 | #define EC_SIGN_REG_T4 19 18 | #define EC_SIGN_REG_XS 20 19 | #define EC_SIGN_REG_YS 21 20 | #define EC_SIGN_REG_ZS 22 21 | #define EC_SIGN_REG_TS 23 22 | #define EC_SIGN_REG_ZP 24 23 | #define EC_SIGN_REG_TP 25 24 | #define EC_SIGN_REG_ZR 26 25 | /* k, p[in/out] */ 26 | #define EC_SIGN_REG_ORD 26 /*=EC_SIGN_REG_ZR, used for EC order*/ 27 | #define EC_SIGN_REG_RK 27 /*scalar*/ 28 | #define EC_SIGN_REG_XP 28 /*in/out*/ 29 | #define EC_SIGN_REG_YP 29 /*in/out*/ 30 | #endif 31 | -------------------------------------------------------------------------------- /shared/include/pal/cc_pal_barrier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_pal_barrier 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains the definitions and APIs for memory-barrier 15 | implementation. 16 | 17 | This is a placeholder for platform-specific memory barrier implementation. 18 | The secure core driver should include a memory barrier, before and after 19 | the last word of the descriptor, to allow correct order between the words 20 | and different descriptors. 21 | */ 22 | 23 | 24 | #ifndef _CC_PAL_BARRIER_H 25 | #define _CC_PAL_BARRIER_H 26 | 27 | 28 | /*! 29 | This macro puts the memory barrier after the write operation. 30 | 31 | @return None 32 | */ 33 | 34 | void CC_PalWmb(void); 35 | 36 | /*! 37 | This macro puts the memory barrier before the read operation. 38 | 39 | @return None 40 | */ 41 | void CC_PalRmb(void); 42 | 43 | /*! 44 | @} 45 | */ 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /host/src/pal/linux/cc_pal_pm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | 9 | int32_t g_pmCntr; 10 | 11 | void CC_PalPowerSaveModeInit(void) 12 | { 13 | g_pmCntr = 0; 14 | return; 15 | } 16 | 17 | int32_t CC_PalPowerSaveModeStatus(void) 18 | { 19 | return g_pmCntr; 20 | } 21 | 22 | CCError_t CC_PalPowerSaveModeSelect(CCBool isPowerSaveMode) 23 | { 24 | CCError_t rc = CC_OK; 25 | switch (isPowerSaveMode){ 26 | case CC_FALSE: 27 | __atomic_fetch_add(&g_pmCntr, 1, __ATOMIC_SEQ_CST); 28 | break; 29 | case CC_TRUE: 30 | __atomic_fetch_sub(&g_pmCntr, 1, __ATOMIC_SEQ_CST); 31 | break; 32 | default: 33 | return -1; 34 | } 35 | 36 | if(g_pmCntr == 0){ 37 | /* once the counter is zero, 38 | * an external callback shall be called to notify the PMU that ARM Cerberus might be powered down. */ 39 | } 40 | 41 | if(g_pmCntr < 0 ){ 42 | /* illegal state - exit with error */ 43 | return 1; 44 | } 45 | 46 | return rc; 47 | } 48 | -------------------------------------------------------------------------------- /shared/include/pal/freertos/cc_pal_mutex_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_MUTEX_PLAT_H 9 | #define _CC_PAL_MUTEX_PLAT_H 10 | 11 | #include "FreeRTOS.h" 12 | #include "semphr.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" 16 | { 17 | #endif 18 | /** 19 | * @brief File Description: 20 | * This file contains functions for resource management (semaphor operations). 21 | * The functions implementations are generally just wrappers to different operating system calls. 22 | * None of the described functions will check the input parameters so the behavior 23 | * of the APIs in illegal parameters case is dependent on the operating system behavior. 24 | * 25 | */ 26 | 27 | typedef SemaphoreHandle_t CC_PalMutex; 28 | 29 | 30 | 31 | /*---------------------------- 32 | PUBLIC FUNCTIONS 33 | -----------------------------------*/ 34 | 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | 42 | 43 | -------------------------------------------------------------------------------- /host/src/pal/freertos/cc_pal_apbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | #include "FreeRTOS.h" 9 | #include "task.h" 10 | 11 | int32_t g_apbcCntr; 12 | 13 | void CC_PalApbcCntrInit(void) 14 | { 15 | g_apbcCntr = 0; 16 | return; 17 | } 18 | 19 | int32_t CC_PalApbcCntrValue(void) 20 | { 21 | return g_apbcCntr; 22 | } 23 | 24 | CCError_t CC_PalApbcModeSelect(CCBool isApbcInc) 25 | { 26 | CCError_t rc = CC_OK; 27 | 28 | switch (isApbcInc){ 29 | case CC_FALSE: 30 | taskENTER_CRITICAL(); 31 | g_apbcCntr--; 32 | taskEXIT_CRITICAL(); 33 | break; 34 | case CC_TRUE: 35 | taskENTER_CRITICAL(); 36 | g_apbcCntr++; 37 | taskEXIT_CRITICAL(); 38 | break; 39 | default: 40 | return CC_FAIL; 41 | } 42 | 43 | if(g_apbcCntr < 0 ){ 44 | /* illegal state - exit with error */ 45 | return 1; 46 | } 47 | 48 | return rc; 49 | } 50 | -------------------------------------------------------------------------------- /codesafe/src/mbedtls_api/mbedtls_ccm_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_aesccm_star_common 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains the common definitions of the CryptoCell AES-CCM star APIs. 15 | */ 16 | 17 | 18 | 19 | #ifndef _MBEDTLS_CCM_COMMON_H 20 | #define _MBEDTLS_CCM_COMMON_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" 24 | { 25 | #endif 26 | 27 | /*! The size of the AES CCM star nonce in bytes. */ 28 | #define MBEDTLS_AESCCM_STAR_NONCE_SIZE_BYTES 13 29 | /*! The size of source address of the AES CCM star in bytes. */ 30 | #define MBEDTLS_AESCCM_STAR_SOURCE_ADDRESS_SIZE_BYTES 8 31 | 32 | /*! AES CCM mode: CCM. */ 33 | #define MBEDTLS_AESCCM_MODE_CCM 0 34 | /*! AES CCM mode: CCM star. */ 35 | #define MBEDTLS_AESCCM_MODE_STAR 1 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | /*! 42 | @} 43 | */ 44 | #endif /* _MBEDTLS_CCM_COMMON_H */ 45 | 46 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/runtime_integration_test/pal/include/run_integration_pal_otp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _RUN_INTEGRATION_PAL_OTP_H_ 8 | #define _RUN_INTEGRATION_PAL_OTP_H_ 9 | 10 | /************************************************************ 11 | * 12 | * macros 13 | * 14 | ************************************************************/ 15 | /** Write OTP value */ 16 | #define RUNIT_WRITE_OTP(wordOffset, val) { \ 17 | volatile uint32_t ii1; \ 18 | (*(volatile uint32_t *)(processMap.processTeeHwEnvBaseAddr + RUNIT_ENV_OTP_START_OFFSET+ ((wordOffset)*sizeof(uint32_t)))) = (uint32_t)(val); \ 19 | for(ii1=0; ii1<500; ii1++);\ 20 | } 21 | 22 | /** Read OTP value */ 23 | #define RUNIT_READ_OTP(wordOffset) \ 24 | *(volatile uint32_t *)(processMap.processTeeHwEnvBaseAddr + RUNIT_ENV_OTP_START_OFFSET + ((wordOffset)*sizeof(uint32_t))) 25 | 26 | #endif //_RUN_INTEGRATION_PAL_OTP_H_ 27 | -------------------------------------------------------------------------------- /shared/include/pal/linux/cc_pal_interrupt_ctrl_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_INTERRUPTCTRL_PLAT_H 8 | #define _CC_PAL_INTERRUPTCTRL_PLAT_H 9 | 10 | 11 | 12 | /** 13 | * @brief This function removes the interrupt handler for 14 | * cryptocell interrupts. 15 | * 16 | */ 17 | void CC_PalFinishIrq(void); 18 | 19 | /* @brief 20 | * 21 | * @param[in] 22 | * 23 | * @param[out] 24 | * 25 | * @return - CC_SUCCESS for success, CC_FAIL for failure. 26 | */ 27 | CCError_t CC_PalInitIrq(void); 28 | 29 | /*! 30 | * Busy wait upon Interrupt Request Register (IRR) signals. 31 | * This function notifys for any ARM CryptoCell interrupt, it is the caller responsiblity 32 | * to verify and prompt the expected case interupt source. 33 | * 34 | * @param[in] data - input data for future use 35 | * \return CCError_t - CC_OK upon success 36 | */ 37 | CCError_t CC_PalWaitInterrupt( uint32_t data); 38 | 39 | 40 | #endif /* _CC_PAL_INTERRUPTCTRL_H */ 41 | 42 | -------------------------------------------------------------------------------- /shared/include/pal/no_os/cc_pal_interrupt_ctrl_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_INTERRUPTCTRL_PLAT_H 8 | #define _CC_PAL_INTERRUPTCTRL_PLAT_H 9 | 10 | 11 | 12 | /** 13 | * @brief This function removes the interrupt handler for 14 | * cryptocell interrupts. 15 | * 16 | */ 17 | void CC_PalFinishIrq(void); 18 | 19 | /* @brief 20 | * 21 | * @param[in] 22 | * 23 | * @param[out] 24 | * 25 | * @return - CC_SUCCESS for success, CC_FAIL for failure. 26 | */ 27 | CCError_t CC_PalInitIrq(void); 28 | 29 | /*! 30 | * Busy wait upon Interrupt Request Register (IRR) signals. 31 | * This function notifys for any ARM CryptoCell interrupt, it is the caller responsiblity 32 | * to verify and prompt the expected case interupt source. 33 | * 34 | * @param[in] data - input data for future use 35 | * \return CCError_t - CC_OK upon success 36 | */ 37 | CCError_t CC_PalWaitInterrupt( uint32_t data); 38 | 39 | 40 | #endif /* _CC_PAL_INTERRUPTCTRL_H */ 41 | 42 | -------------------------------------------------------------------------------- /shared/include/pal/mbedos/cc_pal_interrupt_ctrl_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_INTERRUPTCTRL_PLAT_H 8 | #define _CC_PAL_INTERRUPTCTRL_PLAT_H 9 | 10 | 11 | 12 | /** 13 | * @brief This function removes the interrupt handler for 14 | * cryptocell interrupts. 15 | * 16 | */ 17 | void CC_PalFinishIrq(void); 18 | 19 | /* @brief 20 | * 21 | * @param[in] 22 | * 23 | * @param[out] 24 | * 25 | * @return - CC_SUCCESS for success, CC_FAIL for failure. 26 | */ 27 | CCError_t CC_PalInitIrq(void); 28 | 29 | /*! 30 | * Busy wait upon Interrupt Request Register (IRR) signals. 31 | * This function notifys for any ARM CryptoCell interrupt, it is the caller responsiblity 32 | * to verify and prompt the expected case interupt source. 33 | * 34 | * @param[in] data - input data for future use 35 | * \return CCError_t - CC_OK upon success 36 | */ 37 | CCError_t CC_PalWaitInterrupt( uint32_t data); 38 | 39 | 40 | #endif /* _CC_PAL_INTERRUPTCTRL_H */ 41 | 42 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/ec_wrst/pka_ec_wrst_dsa_verify_regs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef PKA_ECDSA_VERIFY_REGS_DEF_H 8 | #define PKA_ECDSA_VERIFY_REGS_DEF_H 9 | 10 | /* Definition of ECDSA Verify specific registers */ 11 | #define EC_VERIFY_REG_R PKA_REG_N 12 | #define EC_VERIFY_REG_NR PKA_REG_NP 13 | #define EC_VERIFY_REG_F 2 14 | #define EC_VERIFY_REG_D 3 15 | #define EC_VERIFY_REG_H 4 16 | #define EC_VERIFY_REG_TMP 5 17 | #define EC_VERIFY_REG_XPQ 14 18 | #define EC_VERIFY_REG_YPQ 15 19 | #define EC_VERIFY_REG_ZR 16 20 | #define EC_VERIFY_REG_TR 17 21 | #define EC_VERIFY_REG_H1 18 22 | #define EC_VERIFY_REG_H2 19 23 | #define EC_VERIFY_REG_P_GX 20 24 | #define EC_VERIFY_REG_P_GY 21 25 | #define EC_VERIFY_REG_P_WX 22 26 | #define EC_VERIFY_REG_P_WY 23 27 | #define EC_VERIFY_REG_P_RX 24 28 | #define EC_VERIFY_REG_P_RY 25 29 | #define EC_VERIFY_REG_TMP_N 26 30 | #define EC_VERIFY_REG_TMP_NP 27 31 | #define EC_VERIFY_REG_C 28 32 | #endif 33 | -------------------------------------------------------------------------------- /shared/include/proj/cc3x/cc_ecpki_domains_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | /*! 9 | @addtogroup cc_ecpki_domains_defs 10 | 11 | @{ 12 | */ 13 | 14 | /*! 15 | @file 16 | @brief This file contains CryptoCell ECPKI domains supported by the project. 17 | */ 18 | 19 | #ifndef _CC_ECPKI_DOMAIN_DEFS_H 20 | #define _CC_ECPKI_DOMAIN_DEFS_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" 24 | { 25 | #endif 26 | 27 | #include "cc_ecpki_domain_secp192r1.h" 28 | #include "cc_ecpki_domain_secp224r1.h" 29 | #include "cc_ecpki_domain_secp256r1.h" 30 | #include "cc_ecpki_domain_secp521r1.h" 31 | #include "cc_ecpki_domain_secp192k1.h" 32 | #include "cc_ecpki_domain_secp224k1.h" 33 | #include "cc_ecpki_domain_secp256k1.h" 34 | #include "cc_ecpki_domain_secp384r1.h" 35 | 36 | /*! Definition of the domain-retrieval function. */ 37 | typedef const CCEcpkiDomain_t * (*getDomainFuncP)(void); 38 | 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | /*! 45 | @} 46 | */ 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /shared/include/proj/cc3x/cc_int_general_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_INT_GENERAL_DEFS_H 8 | #define _CC_INT_GENERAL_DEFS_H 9 | 10 | /*! 11 | @file 12 | @brief This file contains internal general definitions of the CryptoCell runtime SW APIs. 13 | @defgroup cc_general_defs CryptoCell general definitions 14 | @{ 15 | @ingroup cryptocell_api 16 | 17 | */ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | 25 | /************************ Macros ******************************/ 26 | 27 | /* check if fatal error bit is set to ON */ 28 | #define CC_IS_FATAL_ERR_ON(rc)\ 29 | do {\ 30 | uint32_t regVal = 0;\ 31 | regVal = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_AO_LOCK_BITS));\ 32 | rc = CC_REG_FLD_GET(0, HOST_AO_LOCK_BITS, HOST_FATAL_ERR, regVal);\ 33 | rc = (rc == 1)?CC_TRUE:CC_FALSE;\ 34 | }while(0) 35 | 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | /** 41 | @} 42 | */ 43 | #endif 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/runtime_integration_test/tests/run_integration_test_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _RUN_INTEGRATION_TEST_API_H_ 8 | #define _RUN_INTEGRATION_TEST_API_H_ 9 | 10 | #include "stdint.h" 11 | 12 | #include "run_integration_test.h" 13 | 14 | RunItError_t runIt_aesTest(void); 15 | RunItError_t runIt_rsaTest(void); 16 | RunItError_t runIt_ccmTest(void); 17 | RunItError_t runIt_gcmTest(void); 18 | RunItError_t runIt_shaTest(void); 19 | RunItError_t runIt_ecdsaTest(void); 20 | RunItError_t runIt_eciesTest(void); 21 | RunItError_t runIt_ecdhTest(void); 22 | RunItError_t runIt_ctrDrbgTest(void); 23 | RunItError_t runIt_keyDerivationTest(void); 24 | RunItError_t runIt_ChachaTest(void); 25 | RunItError_t runIt_srpTest(void); 26 | RunItError_t runIt_macTest(void); 27 | RunItError_t runIt_dhmTest(void); 28 | RunItError_t runIt_assetProvTest(void); 29 | RunItError_t runIt_extDmaTest(void); 30 | RunItError_t runIt_secureBootTest(void); 31 | #endif //_RUN_INTEGRATION_TEST_API_H_ 32 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/oem_asset_package/examples/asset_oem_ce.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for generating asset package for production phase application - DMPU 2 | # [DMPU-OEM-ASSET-CFG] Mandatory header. 3 | #asset-type = defines the asset type encryptin key or provisioning key 4 | #icv-enc-oem-key = The file containing the encrypted oem key, generated by dmpu_icv_key_response_util.py. 5 | # oem-enc-keypair = File holding the RSA keypair for decrypting " oem-enc-keypair", in pem format. 6 | # oem-enc-keypwd = Passphrase for the "oem-enc-keypair" file, in txt format. 7 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 8 | #asset-filename = The asset to create the package for 9 | #pkg-filename = The package file, generated by dmpu_asset_pkg_util.py. 10 | [DMPU-OEM-ASSET-CFG] 11 | asset-type = kce 12 | icv-enc-oem-key = icv_response_pkg.bin 13 | oem-enc-keypair = oem_enc_key_pair.pem 14 | oem-enc-keypwd = oem_enc_key_pair_pwd.txt 15 | asset-filename = oem_enc_asset.bin 16 | pkg-filename = oem_enc_asset_pkg.bin 17 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/oem_asset_package/examples/asset_oem_cp.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for generating asset package for production phase application - DMPU 2 | # [DMPU-OEM-ASSET-CFG] Mandatory header. 3 | #asset-type = defines the asset type encryptin key or provisioning key 4 | #icv-enc-oem-key = The file containing the encrypted oem key, generated by dmpu_icv_key_response_util.py. 5 | # oem-enc-keypair = File holding the RSA keypair for decrypting " oem-enc-keypair", in pem format. 6 | # oem-enc-keypwd = Passphrase for the "oem-enc-keypair" file, in txt format. 7 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 8 | #asset-filename = The asset to create the package for 9 | #pkg-filename = The package file, generated by dmpu_asset_pkg_util.py. 10 | [DMPU-OEM-ASSET-CFG] 11 | asset-type = kcp 12 | icv-enc-oem-key = icv_response_pkg.bin 13 | oem-enc-keypair = oem_enc_key_pair.pem 14 | oem-enc-keypwd = oem_enc_key_pair_pwd.txt 15 | asset-filename = oem_prov_asset.bin 16 | pkg-filename = oem_prov_asset_pkg.bin 17 | -------------------------------------------------------------------------------- /shared/include/pal/mbedos/cc_pal_dma_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_DMA_PLAT_H 9 | #define _CC_PAL_DMA_PLAT_H 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include "cc_address_defs.h" 19 | 20 | /** 21 | * @brief stub function, the function should initialize the DMA mapping of the platform (if needed) 22 | * 23 | * @param[in] buffSize - buffer size in Bytes 24 | * @param[in] physBuffAddr - physical start address of the memory to map 25 | * 26 | * @return Start address of contiguous memory 27 | */ 28 | extern uint32_t CC_PalDmaInit(uint32_t buffSize, /*!< [in] Buffer size in Bytes. */ 29 | CCDmaAddr_t physBuffAddr /*!< [in] Physical start address of the memory to map. */); 30 | 31 | /** 32 | * @brief free system resources created in PD_PAL_DmaInit() 33 | * 34 | * 35 | * @return void 36 | */ 37 | extern void CC_PalDmaTerminate(void); 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | 44 | 45 | -------------------------------------------------------------------------------- /shared/include/pal/no_os/cc_pal_dma_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_DMA_PLAT_H 8 | #define _CC_PAL_DMA_PLAT_H 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | 17 | #include "cc_address_defs.h" 18 | 19 | /** 20 | * @brief stub function, the function should initialize the DMA mapping of the platform (if needed) 21 | * 22 | * @param[in] buffSize - buffer size in Bytes 23 | * @param[in] physBuffAddr - physical start address of the memory to map 24 | * 25 | * @return Virtual start address of contiguous memory 26 | */ 27 | extern uint32_t CC_PalDmaInit(uint32_t buffSize, /*!< [in] Buffer size in Bytes. */ 28 | CCDmaAddr_t physBuffAddr /*!< [in] Physical start address of the memory to map. */); 29 | 30 | /** 31 | * @brief free system resources created in PD_PAL_DmaInit() 32 | * 33 | * 34 | * @return void 35 | */ 36 | extern void CC_PalDmaTerminate(void); 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | 43 | 44 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/ec_mont/pka_ec_mont_glob_regs_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef PKA_EC_MONT_GLOB_REGS_DEF_H 8 | #define PKA_EC_MONT_GLOB_REGS_DEF_H 9 | 10 | /*! Note: Don't change registers ID-s ! */ 11 | 12 | /*! Define global PKA registers ID-s used in EC Montgomry operations */ 13 | /* global regs. */ 14 | #define EC_MONT_REG_N PKA_REG_N /* EC mod. */ 15 | #define EC_MONT_REG_NP PKA_REG_NP /* EC Barr.tag */ 16 | #define EC_MONT_REG_T 2 17 | #define EC_MONT_REG_T1 3 18 | #define EC_MONT_REG_T2 4 19 | #define EC_MONT_REG_N4 5 /* 4*mod */ 20 | #define EC_MONT_REG_A24 6 /* ec parameter (A+2)/4 */ 21 | /*! scalarmult in/out and local regs. */ 22 | #define EC_MONT_REG_RES 7 /* result point */ 23 | #define EC_MONT_REG_X1 8 /* inputt point */ 24 | #define EC_MONT_REG_X2 9 25 | #define EC_MONT_REG_Z2 10 26 | #define EC_MONT_REG_X3 11 27 | #define EC_MONT_REG_Z3 12 28 | 29 | #define EC_MONT_PKA_REGS_USED 13 /* beside 2 PKA temp regs. */ 30 | #endif 31 | -------------------------------------------------------------------------------- /shared/include/pal/freertos/cc_pal_dma_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_PAL_DMA_PLAT_H 9 | #define _CC_PAL_DMA_PLAT_H 10 | 11 | #include 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #include "cc_address_defs.h" 19 | 20 | /** 21 | * @brief stub function, the function should initialize the DMA mapping of the platform (if needed) 22 | * 23 | * @param[in] buffSize - buffer size in Bytes 24 | * @param[in] physBuffAddr - physical start address of the memory to map 25 | * 26 | * @return Start address of contiguous memory 27 | */ 28 | extern uint32_t CC_PalDmaInit(uint32_t buffSize, /*!< [in] Buffer size in Bytes. */ 29 | CCDmaAddr_t physBuffAddr /*!< [in] Physical start address of the memory to map. */); 30 | 31 | /** 32 | * @brief free system resources created in PD_PAL_DmaInit() 33 | * 34 | * 35 | * @return void 36 | */ 37 | extern void CC_PalDmaTerminate(void); 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | 44 | 45 | -------------------------------------------------------------------------------- /host/src/pal/linux/cc_pal_log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include 8 | #include 9 | #include "cc_pal_types.h" 10 | #include "cc_pal_log.h" 11 | 12 | #ifdef DEBUG 13 | #define SYSLOG_OPTIONS (LOG_CONS | LOG_NDELAY | LOG_PID | LOG_PERROR) 14 | #else 15 | #define SYSLOG_OPTIONS (LOG_CONS | LOG_NDELAY | LOG_PID) 16 | #endif 17 | 18 | int CC_PAL_logLevel = CC_PAL_MAX_LOG_LEVEL; 19 | uint32_t CC_PAL_logMask = 0xFFFFFFFF; 20 | 21 | void CC_PalLogInit(void) 22 | { 23 | static int initOnce = 0; 24 | 25 | if (!initOnce) 26 | openlog("CC.Proc.", SYSLOG_OPTIONS, LOG_USER); 27 | initOnce = 1; 28 | } 29 | 30 | void CC_PalLogLevelSet(int setLevel) 31 | { 32 | CC_PAL_logLevel = setLevel; 33 | } 34 | 35 | void CC_PalLogMaskSet(uint32_t setMask) 36 | { 37 | CC_PAL_logMask = setMask; 38 | } 39 | 40 | void CC_PalLog(int level, const char * format, ...) 41 | { 42 | va_list args; 43 | va_start( args, format ); 44 | 45 | vsyslog(level + LOG_ERR, format, args); 46 | va_end(args); 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/cmpu_integration_test/cmpu_integration_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CMPU_INTEGRATION_TEST_H_ 8 | #define _CMPU_INTEGRATION_TEST_H_ 9 | 10 | /* system includes */ 11 | #include "stdio.h" 12 | #include "stdint.h" 13 | 14 | /************************************************************ 15 | * 16 | * type decelerations 17 | * 18 | ************************************************************/ 19 | /** 20 | * Error Codes 21 | */ 22 | typedef enum CmpuItError_t 23 | { 24 | CMPUIT_ERROR__OK = 0, 25 | CMPUIT_ERROR__FAIL = 0x0000FFFF, 26 | }CmpuItError_t; 27 | 28 | /************************************************************ 29 | * 30 | * externs 31 | * 32 | ************************************************************/ 33 | 34 | /************************************************************ 35 | * 36 | * function prototypes 37 | * 38 | ************************************************************/ 39 | CmpuItError_t cmpuIt_all(void); 40 | #endif //_CMPU_INTEGRATION_TEST_H_ 41 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/dmpu_integration_test/dmpu_integration_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _DMPU_INTEGRATION_TEST_H_ 8 | #define _DMPU_INTEGRATION_TEST_H_ 9 | 10 | /* system includes */ 11 | #include "stdio.h" 12 | #include "stdint.h" 13 | 14 | /************************************************************ 15 | * 16 | * type decelerations 17 | * 18 | ************************************************************/ 19 | /** 20 | * Error Codes 21 | */ 22 | typedef enum DmpuItError_t 23 | { 24 | DMPUIT_ERROR__OK = 0, 25 | DMPUIT_ERROR__FAIL = 0x0000FFFF, 26 | }DmpuItError_t; 27 | 28 | /************************************************************ 29 | * 30 | * externs 31 | * 32 | ************************************************************/ 33 | 34 | /************************************************************ 35 | * 36 | * function prototypes 37 | * 38 | ************************************************************/ 39 | DmpuItError_t dmpuIt_all(void); 40 | #endif //_DMPU_INTEGRATION_TEST_H_ 41 | -------------------------------------------------------------------------------- /shared/include/mbedtls/ccm_alt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef MBEDTLS_CCM_ALT_H 8 | #define MBEDTLS_CCM_ALT_H 9 | 10 | #if defined(MBEDTLS_CONFIG_FILE) 11 | #include MBEDTLS_CONFIG_FILE 12 | #endif 13 | 14 | #include 15 | #include 16 | #include "mbedtls/cipher.h" 17 | 18 | 19 | #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /**< Bad input parameters to function. */ 20 | #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F /**< Authenticated decryption failed. */ 21 | 22 | /* hide internal implementation of the struct. Allocate enough space for it.*/ 23 | #define MBEDTLS_CCM_CONTEXT_SIZE_IN_WORDS 264 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /** 30 | * \brief The CCM context-type definition. The CCM context is passed 31 | * to the APIs called. 32 | */ 33 | typedef struct { 34 | uint32_t buf[MBEDTLS_CCM_CONTEXT_SIZE_IN_WORDS]; 35 | } 36 | mbedtls_ccm_context; 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* MBEDTLS_CCM_ALT_H */ 43 | -------------------------------------------------------------------------------- /shared/include/pal/no_os/cc_pal_types_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! @file 8 | @brief This file contains basic platform-dependent type definitions. 9 | */ 10 | #ifndef _CC_PAL_TYPES_PLAT_H 11 | #define _CC_PAL_TYPES_PLAT_H 12 | /* Host specific types for standard (ISO-C99) compliant platforms */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | /*! Type definition for virtual address. */ 19 | typedef uintptr_t CCVirtAddr_t; 20 | /*! Type Definition for boolean variable. */ 21 | typedef uint32_t CCBool_t; 22 | /*! Type definition for return status. */ 23 | typedef uint32_t CCStatus; 24 | 25 | /*! Type definition for error return. */ 26 | #define CCError_t CCStatus 27 | /*! Defines inifinite value, used to define unlimited time frame. */ 28 | #define CC_INFINITE 0xFFFFFFFF 29 | 30 | /*! Type definition for C export. */ 31 | #define CEXPORT_C 32 | /*! Type definition for C import. */ 33 | #define CIMPORT_C 34 | 35 | #endif /*_CC_PAL_TYPES_PLAT_H*/ 36 | -------------------------------------------------------------------------------- /utils/src/cc3x_asset_prov_rt/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for managing build and installation 2 | 3 | # shared library to build 4 | UTIL_ROOT = $(shell pwd) 5 | UTILS_DIR_ROOT = $(UTIL_ROOT)/../.. 6 | HOST_DIR_ROOT = $(UTIL_ROOT)/../host 7 | UTILS_LIB_PATH = ./lib 8 | UTILS_LIB_NAME = libutil_crypto.so 9 | UTILS_SCRIPTS_DIRNAME = $(UTIL_ROOT) 10 | 11 | 12 | DEPENDENCY_ON_EXISTENCE_OF = $(filter-out $(wildcard $(1)), $(1)) 13 | 14 | INSTALL_LIST = install_lib install_scripts 15 | 16 | all: $(INSTALL_LIST) 17 | 18 | 19 | 20 | install_lib: build_lib $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/lib) 21 | @echo Installing util_crypto library 22 | @cp $(UTILS_LIB_PATH)/$(UTILS_LIB_NAME) $(UTILS_DIR_ROOT)/lib 23 | 24 | build_lib: 25 | @make -C $(UTILS_LIB_PATH) 26 | 27 | install_scripts: $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin) $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin/example) 28 | @echo Installing scripts 29 | @cp $(UTIL_ROOT)/*.py $(UTILS_DIR_ROOT)/bin/ 30 | 31 | $(UTILS_DIR_ROOT)/%: 32 | @echo Creating directory $@ 33 | @mkdir $@ 34 | 35 | 36 | clean: 37 | @make -C $(UTILS_LIB_PATH) clean 38 | 39 | .PHONY: install_lib install_sd_scripts clean 40 | 41 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/cc3x_sym/api/mbedtls_cc_poly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #define CC_PAL_LOG_CUR_COMPONENT CC_LOG_MASK_CC_API 8 | 9 | #include "mbedtls_cc_poly.h" 10 | #include "poly.h" 11 | #include "mbedtls_cc_poly_error.h" 12 | 13 | 14 | CIMPORT_C CCError_t mbedtls_poly( 15 | mbedtls_poly_key pKey, 16 | uint8_t *pDataIn, 17 | size_t dataInSize, 18 | mbedtls_poly_mac macRes) 19 | 20 | { 21 | CCError_t rc; 22 | 23 | // Verify inputs 24 | if (pKey == NULL) { 25 | return CC_POLY_KEY_INVALID_ERROR; 26 | } 27 | if ((macRes == NULL) || 28 | ((pDataIn == NULL) ^ (dataInSize == 0)) || 29 | (dataInSize > CC_MAX_UINT32_VAL)) { 30 | return CC_POLY_DATA_INVALID_ERROR; 31 | } 32 | 33 | // calculate teh MAC using PKA 34 | rc = PolyMacCalc(pKey, NULL, 0, pDataIn, dataInSize, macRes, false); 35 | if (rc != CC_OK) { 36 | return CC_POLY_RESOURCES_ERROR; 37 | } 38 | 39 | return CC_OK; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /host/src/pal/freertos/cc_pal_pm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | #include "FreeRTOS.h" 9 | #include "task.h" 10 | 11 | int32_t g_pmCntr; 12 | 13 | void CC_PalPowerSaveModeInit(void) 14 | { 15 | g_pmCntr = 0; 16 | return; 17 | } 18 | 19 | int32_t CC_PalPowerSaveModeStatus(void) 20 | { 21 | return g_pmCntr; 22 | } 23 | 24 | CCError_t CC_PalPowerSaveModeSelect(CCBool isPowerSaveMode) 25 | { 26 | CCError_t rc = CC_OK; 27 | 28 | switch (isPowerSaveMode){ 29 | case CC_FALSE: 30 | taskENTER_CRITICAL(); 31 | g_pmCntr++; 32 | taskEXIT_CRITICAL(); 33 | break; 34 | case CC_TRUE: 35 | taskENTER_CRITICAL(); 36 | g_pmCntr--; 37 | taskEXIT_CRITICAL(); 38 | break; 39 | default: 40 | return CC_FAIL; 41 | } 42 | 43 | if(g_pmCntr == 0){ 44 | /* once the counter is zero, 45 | * an external callback shall be called to notify the PMU that ARM Cerberus might be powered down. */ 46 | } 47 | 48 | if(g_pmCntr < 0 ){ 49 | /* illegal state - exit with error */ 50 | return CC_FAIL; 51 | } 52 | 53 | return rc; 54 | } 55 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/no_os/test_pal_file.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include 14 | #include 15 | 16 | /******************************************************************************/ 17 | size_t Test_PalFetchDataFromFile(const char *data_fname, uint8_t **data_pp) 18 | { 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /shared/include/crypto_api/cc3x/cc_aes_defs_proj.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_aes_defs_proj 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains project definitions that are used for CryptoCell 15 | AES APIs. 16 | */ 17 | 18 | #ifndef CC_AES_DEFS_PROJ_H 19 | #define CC_AES_DEFS_PROJ_H 20 | 21 | #include "cc_pal_types.h" 22 | 23 | 24 | #ifdef __cplusplus 25 | extern "C" 26 | { 27 | #endif 28 | 29 | /************************ Defines ******************************/ 30 | 31 | /*! The size of the context prototype of the user in words. 32 | See ::CCAesUserContext_t.*/ 33 | #define CC_AES_USER_CTX_SIZE_IN_WORDS (4+8+8+4) 34 | 35 | /*! The maximal size of the AES key in words. */ 36 | #define CC_AES_KEY_MAX_SIZE_IN_WORDS 8 37 | /*! The maximal size of the AES key in bytes. */ 38 | #define CC_AES_KEY_MAX_SIZE_IN_BYTES (CC_AES_KEY_MAX_SIZE_IN_WORDS * sizeof(uint32_t)) 39 | 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | 46 | /*! 47 | @} 48 | */ 49 | 50 | #endif /* #ifndef CC_AES_DEFS_PROJ_H */ 51 | 52 | -------------------------------------------------------------------------------- /utils/src/cmpu_asset_pkg_util/examples/asset_icv_cp.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for generating asset package for production phase applications - CMPU 2 | # [CMPU-ASSET-CFG] Mandatory header. 3 | #asset-type = defines the asset type encryptin key or provisioning key 4 | #unique-data = File holding the user unique data, in binary format. 5 | # It is recommanded to use HBK0 6 | # If ICV doesn't define HBK0 in the device it is recommanded to use 16 bytes random data 7 | #key-filename = File holding the encrypted Krtl, in binary format. 8 | #keypwd-filename = Passphrase for the key file, in txt format. 9 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 10 | #asset-filename = The asset to create the package for 11 | #pkg-filename = The package file, generated by cmpu_asset_pkg_util.py. 12 | [CMPU-ASSET-CFG] 13 | asset-type = kpicv 14 | unique-data = hbk0.bin 15 | key-filename = rtl_enc_key.bin 16 | keypwd-filename = rtl_key_pwd.txt 17 | asset-filename = icv_prov_asset.bin 18 | pkg-filename = icv_prov_asset_pkg.bin 19 | -------------------------------------------------------------------------------- /shared/include/proj/cc3x/cc_sram_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_sram_map 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains internal SRAM mapping definitions. 15 | */ 16 | 17 | #ifndef _CC_SRAM_MAP_H_ 18 | #define _CC_SRAM_MAP_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | /*! The base address of the PKA in the PKA SRAM. */ 26 | #define CC_SRAM_PKA_BASE_ADDRESS 0x0 27 | /*! The size of the PKA SRAM in KB. */ 28 | #define CC_PKA_SRAM_SIZE_IN_KBYTES 6 29 | 30 | /*! The SRAM address of the RND. */ 31 | #define CC_SRAM_RND_HW_DMA_ADDRESS 0x0 32 | /*! Addresses 0K-2KB in SRAM. Reserved for RND operations. */ 33 | #define CC_SRAM_RND_MAX_SIZE 0x800 34 | /*! The maximal size of SRAM. */ 35 | #define CC_SRAM_MAX_SIZE 0x1000 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | /*! 42 | @} 43 | */ 44 | #endif /*_CC_SRAM_MAP_H_*/ 45 | 46 | -------------------------------------------------------------------------------- /utils/src/cmpu_asset_pkg_util/examples/asset_icv_ce.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for generating asset package for production phase applications - CMPU 2 | # [CMPU-ASSET-CFG] Mandatory header. 3 | #asset-type = defines the asset type encryptin key or provisioning key 4 | #unique-data = File holding the user unique data, in binary format. 5 | # It is recommanded to use HBK0. 6 | # If ICV doesn't define HBK0 in the device it is recommanded to use 16 bytes random data 7 | #key-filename = File holding the encrypted Krtl, in binary format. 8 | #keypwd-filename = Passphrase for the key file, in txt format. 9 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 10 | #asset-filename = The asset to create the package for 11 | #pkg-filename = The package file, generated by cmpu_asset_pkg_util.py. 12 | [CMPU-ASSET-CFG] 13 | asset-type = kceicv 14 | unique-data = user_data.bin 15 | key-filename = rtl_enc_key.bin 16 | keypwd-filename = rtl_key_pwd.txt 17 | asset-filename = icv_enc_asset.bin 18 | pkg-filename = icv_enc_asset_pkg.bin 19 | -------------------------------------------------------------------------------- /shared/include/pal/cc_log_mask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_LOG_MASK_H_ 8 | #define _CC_LOG_MASK_H_ 9 | 10 | #define CC_LOG_MASK_CCLIB (1<<1) 11 | #define CC_LOG_MASK_SECURE_BOOT (1<<2) 12 | #define CC_LOG_MASK_CMPU (1<<3) 13 | #define CC_LOG_MASK_DMPU (1<<4) 14 | #define CC_LOG_MASK_CC_API (1<<5) 15 | #define CC_LOG_MASK_CC_SYM_DRIVER (1<<6) 16 | #define CC_LOG_MASK_MLLI (1<<7) 17 | #define CC_LOG_MASK_HW_QUEUE (1<<8) 18 | #define CC_LOG_MASK_COMPLETION (1<<9) 19 | #define CC_LOG_MASK_INFRA (1<<10) 20 | #define CC_LOG_MASK_LLF (1<<13) 21 | #define CC_LOG_MASK_ASYM_ECC (1<<14) 22 | #define CC_LOG_MASK_ASYM_RSA_DH (1<<15) 23 | #define CC_LOG_MASK_ASYM_KDF (1<<16) 24 | #define CC_LOG_MASK_ASYM_LLF (1<<17) 25 | #define CC_LOG_MASK_ASYM_RND (1<<18) 26 | #define CC_LOG_MASK_UTILS (1<<19) 27 | 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/freertos/test_pal_file.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include 14 | #include 15 | 16 | /******************************************************************************/ 17 | size_t Test_PalFetchDataFromFile(const char *data_fname, uint8_t **data_pp) 18 | { 19 | (void)data_fname; 20 | (void)data_pp; 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /shared/include/mbedtls/gcm_alt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef MBEDTLS_GCM_ALT_H 8 | #define MBEDTLS_GCM_ALT_H 9 | 10 | #if defined(MBEDTLS_CONFIG_FILE) 11 | #include MBEDTLS_CONFIG_FILE 12 | #endif 13 | 14 | #if defined(MBEDTLS_GCM_C) 15 | 16 | #include 17 | #include 18 | #include "mbedtls/cipher.h" 19 | 20 | #define MBEDTLS_GCM_ENCRYPT 1 21 | #define MBEDTLS_GCM_DECRYPT 0 22 | 23 | #define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012 /**< Authenticated decryption failed. */ 24 | #define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 /**< Bad input parameters to function. */ 25 | 26 | /* hide internal implementation of the struct. Allocate enough space for it.*/ 27 | #define MBEDTLS_GCM_CONTEXT_SIZE_IN_WORDS 40 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * \brief GCM context structure 35 | */ 36 | typedef struct { 37 | uint32_t buf[MBEDTLS_GCM_CONTEXT_SIZE_IN_WORDS]; 38 | } 39 | mbedtls_gcm_context; 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | 46 | 47 | #endif /* MBEDTLS_GCM_C */ 48 | #endif /* MBEDTLS_GCM_ALT_H */ 49 | -------------------------------------------------------------------------------- /host/src/tests/common/multi2_soft.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /* file multi2_soft.h 8 | * Soft implementatoion for Multi2 (missing in tomcrypt library). 9 | * Cipher mode valid: ecb, cbc. 10 | */ 11 | 12 | #ifndef __MULTI2_SOFT_H__ 13 | #define __MULTI2_SOFT_H__ 14 | 15 | #include "tomcrypt.h" 16 | 17 | int multi2_soft_ecb_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); 18 | 19 | int multi2_soft_ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_key *skey); 20 | 21 | int multi2_soft_ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_key *skey); 22 | 23 | int multi2_soft_cbc_setup(const unsigned char *iv, const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); 24 | 25 | int multi2_soft_cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_key *skey); 26 | 27 | int multi2_soft_cbc_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_key *skey); 28 | 29 | void multi2_soft_done(symmetric_key *skey); 30 | 31 | #endif // __MULTI2_SOFT_H__ 32 | 33 | 34 | -------------------------------------------------------------------------------- /shared/include/pal/linux/cc_pal_types_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_TYPES_PLAT_H 8 | #define _CC_PAL_TYPES_PLAT_H 9 | 10 | /*! @file 11 | @brief This file contains basic platform-dependent type definitions. 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | typedef uintptr_t CCVirtAddr_t; 19 | typedef uint32_t CCBool_t; 20 | typedef uint32_t CCStatus; 21 | 22 | #define CCError_t CCStatus 23 | #define CC_INFINITE 0xFFFFFFFF 24 | 25 | #define CEXPORT_C 26 | #define CIMPORT_C 27 | 28 | /* Define macros for host to SeP endianess conversion (for host wrappers) */ 29 | #include 30 | #include 31 | #if __BYTE_ORDER == __BIG_ENDIAN 32 | #define cpu_to_le16(x) bswap_16(x) 33 | #define le16_to_cpu(x) bswap_16(x) 34 | #define cpu_to_le32(x) bswap_32(x) 35 | #define le32_to_cpu(x) bswap_32(x) 36 | #else /*__LITTLE_ENDIAN*/ 37 | #define cpu_to_le16(x) x 38 | #define le16_to_cpu(x) x 39 | #define cpu_to_le32(x) x 40 | #define le32_to_cpu(x) x 41 | #endif /*__BYTE_ORDER*/ 42 | 43 | #endif /*_CC_PAL_TYPES_PLAT_H*/ 44 | -------------------------------------------------------------------------------- /shared/include/pal/linux/cc_pal_dma_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_PAL_DMA_PLAT_H 8 | #define _CC_PAL_DMA_PLAT_H 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | 17 | #include "cc_address_defs.h" 18 | 19 | /** 20 | * @brief Initializes contiguous memory pool required for CC_PalDmaContigBufferAllocate() and CC_PalDmaContigBufferFree(). Our 21 | * example implementation is to mmap 0x30000000 and call to bpool(), for use of bget() in CC_PalDmaContigBufferAllocate(), 22 | * and brel() in CC_PalDmaContigBufferFree(). 23 | * 24 | * @return A non-zero value in case of failure. 25 | */ 26 | extern uint32_t CC_PalDmaInit(uint32_t buffSize, /*!< [in] Buffer size in Bytes. */ 27 | CCDmaAddr_t physBuffAddr /*!< [in] Physical start address of the memory to map. */); 28 | 29 | /** 30 | * @brief free system resources created in CC_PalDmaInit() 31 | * 32 | * @param[in] buffSize - buffer size in Bytes 33 | * 34 | * @return void 35 | */ 36 | extern void CC_PalDmaTerminate(void); 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | 43 | 44 | -------------------------------------------------------------------------------- /host/src/tests/common/tst_common_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "tst_common.h" 8 | #include "tst_common_init.h" 9 | #include "test_log.h" 10 | 11 | int tests_CC_libInit_wrap(CCRndContext_t* rndContext_ptr, CCRndWorkBuff_t * rndWorkBuff_ptr){ 12 | uint32_t rc = 0; 13 | int threadRc; 14 | void *threadRet; 15 | ThreadHandle threadHandle; 16 | LibInitArgs params; 17 | params.rndContext_ptr=rndContext_ptr; 18 | params.rndWorkBuff_ptr=rndWorkBuff_ptr; 19 | 20 | threadHandle = Test_PalThreadCreate(THREAD_STACK_SIZE, (void *)Test_LibInit, ¶ms, NULL, 0, true); 21 | if (threadHandle == NULL) { 22 | TEST_PRINTF_ERROR("Test_PalThreadCreate failed\n"); 23 | return -1; 24 | } 25 | 26 | /* Wait till thread is complete before main continues */ 27 | threadRc = Test_PalThreadJoin(threadHandle, &threadRet); 28 | if (threadRc != 0) { 29 | TEST_PRINTF_ERROR("Test_PalThreadJoin failed\n"); 30 | return -1; 31 | } 32 | 33 | rc =*((uint32_t *)*&threadRet); 34 | 35 | threadRc = Test_PalThreadDestroy(threadHandle); 36 | if (threadRc != 0) { 37 | TEST_PRINTF_ERROR("pthread_attr_destroy failed\n"); 38 | } 39 | 40 | return rc; 41 | } 42 | -------------------------------------------------------------------------------- /host/src/pal/linux/cc_pal_barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_barrier.h" 8 | 9 | /* taken from arch/arm/include/asm/barrier.h */ 10 | 11 | 12 | 13 | #if defined(__arm64__) 14 | /* This is memmory barrier for ARM64*/ 15 | 16 | #define dsb(opt) asm volatile("dsb " #opt : : : "memory") 17 | 18 | #elif defined(__arm__) 19 | /* This is memmory barrier for ARM*/ 20 | 21 | #define dsb() __asm__ __volatile__ ("dsb" : : : "memory") 22 | 23 | #else 24 | #error This is a place holder for platform specific memory barrier implementation 25 | #define dsb() 26 | #endif 27 | /* This is a plac holder for L2 cache sync function*/ 28 | #define CC_PAL_L2_CACHE_SYNC() do { } while (0) 29 | 30 | #if defined(__arm64__) 31 | #define mb() dsb(sy) 32 | #define rmb() dsb(ld) 33 | #define wmb() dsb(st) 34 | #else 35 | #define mb() do { dsb(); CC_PAL_L2_CACHE_SYNC(); } while (0) 36 | #define rmb() dsb() 37 | #define wmb() mb() 38 | #endif 39 | 40 | 41 | 42 | void CC_PalWmb(void) 43 | { 44 | wmb(); 45 | } 46 | 47 | void CC_PalRmb(void) 48 | { 49 | rmb(); 50 | } 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/runtime_integration_test/run_integration_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _RUN_INTEGRATION_TEST_H_ 8 | #define _RUN_INTEGRATION_TEST_H_ 9 | 10 | /************************************************************ 11 | * 12 | * type decelerations 13 | * 14 | ************************************************************/ 15 | /** 16 | * Error Codes 17 | */ 18 | typedef enum RunItError_t 19 | { 20 | RUNIT_ERROR__OK = 0, 21 | RUNIT_ERROR__FAIL = 0x0000FFFF, 22 | }RunItError_t; 23 | 24 | /************************************************************ 25 | * 26 | * externs 27 | * 28 | ************************************************************/ 29 | 30 | /************************************************************ 31 | * 32 | * function prototypes 33 | * 34 | ************************************************************/ 35 | 36 | /** 37 | * @brief Call to perform all tests 38 | * Performs: 39 | * 40 | * @return RUNIT_ERROR__OK on success, RUNIT_ERROR__FAIL otherwise 41 | */ 42 | RunItError_t runIt_all(void); 43 | 44 | #endif //_RUN_INTEGRATION_TEST_H_ 45 | -------------------------------------------------------------------------------- /shared/include/crypto_api/cc3x/cc_ecpki_domain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef CC_ECPKI_DOMAIN_H 9 | #define CC_ECPKI_DOMAIN_H 10 | 11 | 12 | /*! 13 | @file 14 | @brief This file defines the ecpki build domain API. 15 | @defgroup cc_ecpki_domain CryptoCell ECC domain APIs 16 | @{ 17 | @ingroup cryptocell_ecpki 18 | 19 | */ 20 | 21 | 22 | #include "cc_error.h" 23 | #include "cc_ecpki_types.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif 29 | 30 | 31 | 32 | 33 | /********************************************************************************** 34 | * CC_EcpkiGetEcDomain function * 35 | **********************************************************************************/ 36 | 37 | /*! 38 | * @brief The function returns a pointer to an ECDSA saved domain (one of the supported domains). 39 | * 40 | * @return Domain pointer on success. 41 | * @return NULL on failure. 42 | */ 43 | 44 | const CCEcpkiDomain_t *CC_EcpkiGetEcDomain(CCEcpkiDomainID_t domainId /*!< [in] Index of one of the domain Id (must be one of the supported domains). */); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/examples/developer_cert/sb_developer_dbg_cert.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for developer debug certificate generation 2 | # [DEVELOPER-DBG-CFG] required header - do not change! 3 | #cert-keypair = File holding the RSA keypair for signing this certificate, in pem format. 4 | #cert-keypair-pwd = Passphrase for the keypair file, in txt format. 5 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 6 | #soc-id = Binary file holding the 16byte SOC_ID. 7 | #debug-mask[x-y] = The DCU mask allowed by the OEM. 128 bit mask in 4*32 bits hex format (e.g. 0x7000000f). 8 | # If bit 0 in debug-mask[0-31] is set, the HW keys reset in debug mode is not performed 9 | #enabler-cert-pkg = The enabler Debug certificate package. 10 | #cert-pkg = Final certificate package (Enabler+Developer) output file. Binary format. 11 | [DEVELOPER-DBG-CFG] 12 | cert-keypair = dev_keypair1.pem 13 | cert-keypair-pwd = pwd.txt 14 | soc-id = soc_id1.bin 15 | debug-mask[0-31] = 0x00112233 16 | debug-mask[32-63] = 0x44556677 17 | debug-mask[64-95] = 0x8899AABB 18 | debug-mask[96-127] = 0xCCDDEEFF 19 | enabler-cert-pkg = cert_enabler_pkg.bin 20 | cert-pkg = cert_developer_pkg.bin 21 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/examples/developer_cert/sb_developer_dbg_cert_no_pwd.cfg: -------------------------------------------------------------------------------- 1 | # This is configuration file example for developer debug certificate generation 2 | # [DEVELOPER-DBG-CFG] required header - do not change! 3 | #cert-keypair = File holding the RSA keypair for signing this certificate, in pem format. 4 | #cert-keypair-pwd = Passphrase for the keypair file, in txt format. 5 | # For enhanced security, this parameter can be omitted, and then the utility will prompt for direct TTY input. 6 | #soc-id = Binary file holding the 16byte SOC_ID. 7 | #debug-mask[x-y] = The DCU mask allowed by the OEM. 128 bit mask in 4*32 bits hex format (e.g. 0x7000000f). 8 | # If bit 0 in debug-mask[0-31] is set, the HW keys reset in debug mode is not performed 9 | #enabler-cert-pkg = The Enabler Debug certificate package. 10 | #cert-pkg = Final certificate package (Enabler+Developer) output file. Binary format. 11 | [DEVELOPER-DBG-CFG] 12 | cert-keypair = dev_keypair1.pem 13 | cert-keypair-pwd = 14 | soc-id = soc_id1.bin 15 | debug-mask[0-31] = 0x00112233 16 | debug-mask[32-63] = 0x44556677 17 | debug-mask[64-95] = 0x8899AABB 18 | debug-mask[96-127] = 0xCCDDEEFF 19 | enabler-cert-pkg = cert_enabler_pkg.bin 20 | cert-pkg = cert_developer_pkg.bin 21 | -------------------------------------------------------------------------------- /codesafe/src/secure_boot_debug/platform/pal/cc_pal_x509_verify.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | 9 | #define CC_PAL_LOG_CUR_COMPONENT CC_LOG_MASK_SECURE_BOOT 10 | 11 | /************* Include Files ****************/ 12 | 13 | #include "secureboot_basetypes.h" 14 | /*! 15 | @brief This function checks validity period and should be implemented by customer. 16 |
  • The function gets as input start and end validiy period.
  • 17 |
  • For each period the function gets indication flag.
  • 18 |
  • if the flag is not 1 the value of current period wasn't defined be user.
19 | 20 | @return CC_OK On success. 21 | @return a non-zero value from sbrom_bsv_error.h on failure. 22 | */ 23 | 24 | CCError_t CC_PalVerifyCertValidity(char *pNotBeforeStr,uint32_t notBeforeStrSize,uint8_t notBeforeStrFlag, 25 | char *pNotAfterStr,uint32_t notAfterStrSize,uint8_t notAfterStrFlag){ 26 | 27 | CC_UNUSED_PARAM(pNotBeforeStr); 28 | CC_UNUSED_PARAM(pNotAfterStr); 29 | CC_UNUSED_PARAM(notBeforeStrSize); 30 | CC_UNUSED_PARAM(notBeforeStrFlag); 31 | CC_UNUSED_PARAM(notAfterStrSize); 32 | CC_UNUSED_PARAM(notAfterStrFlag); 33 | 34 | return 0; 35 | } 36 | 37 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/common_utils/hash_basic_utility.py: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 6 | # 7 | 8 | 9 | import string 10 | from global_defines import * 11 | import hashlib 12 | 13 | #################################################################### 14 | # Filename - hashbasicutillity 15 | # Description - This file contains the main functionality of the 16 | # secure boot utility. The utility creates a certificate 17 | # that is used in the secure boot process 18 | #################################################################### 19 | 20 | 21 | ########### Basic Utilities ############################### 22 | 23 | # This function calculates HASH SHA256 on binary data and return the HASH result 24 | def HASH_SHA256(BinData, OutputRep): 25 | 26 | # Calculate SHA 256 on given binary data 27 | HashObj = hashlib.sha256() 28 | HashObj.update(BinData) 29 | 30 | if OutputRep == HASH_BINARY_REPRESENTATION: 31 | HashRes = HashObj.digest() 32 | else: 33 | HashRes = HashObj.hexdigest() 34 | 35 | return HashRes 36 | # End of HASH_SHA256 37 | 38 | 39 | ######################################## END OF FILE ######################################## 40 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/cert_lib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for building sbu_crypto library 3 | SH_LIB_NAME = libsbu_crypto.so 4 | 5 | LIB_SRC_O = main.o common_rsa_keypair.o common_rsa_keypair_util.o common_crypto_sym.o common_util_files.o common_sb_ops.o 6 | 7 | UTILS_ROOT = $(shell pwd)/../../.. 8 | SHARED_DIR = $(UTILS_ROOT)/../shared 9 | UTILS_LIB_PATH = $(UTILS_ROOT)/lib 10 | UTILS_INC_PATH = $(UTILS_ROOT)/include $(UTILS_ROOT)/src/common $(SHARED_DIR)/include/proj/$(PROJ_PRD) $(SHARED_DIR)/include 11 | UTILS_INC_PATH += $(CODESAFE_SRCDIR)/secure_boot_debug/secure_debug/cc3x $(SHARED_DIR)/include/pal $(SHARED_DIR)/include/pal/$(TEE_OS) 12 | 13 | include $(UTILS_ROOT)/src/Makefile.openssl 14 | 15 | UTILS_INC_PATH += $(OPENSSL_INC_DIR) 16 | 17 | CFLAGS += -fPIC $(foreach incdir,$(UTILS_INC_PATH),-I$(incdir)) -c 18 | 19 | CFLAGS += -DCC_SB_SUPPORT_IOT 20 | 21 | all: $(SH_LIB_NAME) 22 | 23 | # Compile and link the sbu_crypto library with hard-coded library run path to utils/lib 24 | # (to assure the private version of openssl libraries are used) 25 | $(SH_LIB_NAME): $(LIB_SRC_O) 26 | gcc -shared -o $(SH_LIB_NAME) $(LIB_SRC_O) -Wl,-rpath=$(OPENSSL_LIB_DIR) -L $(OPENSSL_LIB_DIR) -lcrypto -lssl 27 | 28 | vpath %.c $(UTILS_ROOT)/src/common 29 | 30 | %.o: %.c 31 | gcc $(CFLAGS) $< 32 | 33 | clean: 34 | rm -f $(SH_LIB_NAME) $(LIB_SRC_O) 35 | 36 | .PHONY: clean all 37 | 38 | -------------------------------------------------------------------------------- /utils/src/cmpu_asset_pkg_util/lib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for building sbu_crypto library 3 | SH_LIB_NAME = lib_cmpuutil_crypto.so 4 | 5 | LIB_SRC_O = main.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o 6 | 7 | UTILS_ROOT = $(shell pwd)/../../.. 8 | SHARED_DIR = $(UTILS_ROOT)/../shared 9 | HOSTSRC_DIR = $(UTILS_ROOT)/../host/src 10 | UTILS_LIB_PATH = $(UTILS_ROOT)/lib 11 | UTILS_INC_PATH = $(SHARED_DIR)/include $(SHARED_DIR)/include/proj/$(PROJ_PRD) $(UTILS_ROOT)/include 12 | UTILS_INC_PATH += $(UTILS_ROOT)/src/common $(HOSTSRC_DIR)/cc3x_productionlib/common $(SHARED_DIR)/include/pal $(SHARED_DIR)/include/pal/$(TEE_OS) 13 | 14 | include $(UTILS_ROOT)/src/Makefile.openssl 15 | 16 | UTILS_INC_PATH += $(OPENSSL_INC_DIR) 17 | 18 | CFLAGS += -fPIC $(foreach incdir,$(UTILS_INC_PATH),-I$(incdir)) -c 19 | 20 | all: $(SH_LIB_NAME) 21 | 22 | # Compile and link the sbu_crypto library with hard-coded library run path to utils/lib 23 | # (to assure the private version of openssl libraries are used) 24 | $(SH_LIB_NAME): $(LIB_SRC_O) 25 | gcc -shared -o $(SH_LIB_NAME) $(LIB_SRC_O) -Wl,-rpath=$(OPENSSL_LIB_DIR) -L $(OPENSSL_LIB_DIR) -lcrypto -lssl 26 | 27 | vpath %.c $(UTILS_ROOT)/src/common 28 | 29 | %.o: %.c 30 | gcc $(CFLAGS) $< 31 | 32 | clean: 33 | rm -f $(SH_LIB_NAME) $(LIB_SRC_O) 34 | 35 | .PHONY: clean all 36 | 37 | -------------------------------------------------------------------------------- /utils/src/cmpu_asset_pkg_util/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for managing build and installation 2 | 3 | # shared library to build 4 | UTIL_ROOT = $(shell pwd) 5 | UTILS_DIR_ROOT = $(UTIL_ROOT)/../.. 6 | HOST_DIR_ROOT = $(UTIL_ROOT)/../host 7 | UTILS_LIB_PATH = ./lib 8 | UTILS_LIB_NAME = lib_cmpuutil_crypto.so 9 | UTILS_SCRIPTS_DIRNAME = $(UTIL_ROOT) 10 | 11 | include $(UTILS_ROOT)/src/Makefile.openssl 12 | 13 | DEPENDENCY_ON_EXISTENCE_OF = $(filter-out $(wildcard $(1)), $(1)) 14 | 15 | INSTALL_LIST = install_lib install_scripts 16 | 17 | all: $(INSTALL_LIST) 18 | 19 | 20 | 21 | install_lib: build_lib $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/lib) 22 | @echo Installing produtil_crypto library 23 | @cp $(UTILS_LIB_PATH)/$(UTILS_LIB_NAME) $(UTILS_DIR_ROOT)/lib 24 | 25 | build_lib: 26 | @echo build_lib for cmpu_asset_pkg_util.py. 27 | @make -C $(UTILS_LIB_PATH) 28 | 29 | install_scripts: $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin) $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin/example) 30 | @echo Installing scripts for cmpu_asset_pkg_util.py. 31 | @cp $(UTIL_ROOT)/*.py $(UTILS_DIR_ROOT)/bin 32 | @cp $(UTIL_ROOT)/examples/*.cfg $(UTILS_DIR_ROOT)/bin/example 33 | 34 | $(UTILS_DIR_ROOT)/%: 35 | @echo Creating directory prod package 36 | @mkdir $@ 37 | 38 | 39 | clean: 40 | @make -C $(UTILS_LIB_PATH) clean 41 | 42 | .PHONY: install_lib install_sd_scripts clean 43 | 44 | -------------------------------------------------------------------------------- /codesafe/src/secure_boot_debug/x509_cert_parser/sb_x509_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _SB_X509_ERROR_H 8 | #define _SB_X509_ERROR_H 9 | 10 | #include "secureboot_error.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" 14 | { 15 | #endif 16 | 17 | 18 | #define CC_SB_X509_CERT_INV_PARAM CC_SB_X509_CERT_BASE_ERROR + 0x00000001 19 | #define CC_SB_X509_CERT_ILLEGAL_TOKEN CC_SB_X509_CERT_BASE_ERROR + 0x00000002 20 | #define CC_SB_X509_CERT_PARSE_ILLEGAL_VAL CC_SB_X509_CERT_BASE_ERROR + 0x00000003 21 | #define CC_SB_X509_CERT_ILLEGAL_SWVER_ID CC_SB_X509_CERT_BASE_ERROR + 0x00000005 22 | #define CC_SB_X509_CERT_ILLEGAL_VERSION CC_SB_X509_CERT_BASE_ERROR + 0x00000006 23 | #define CC_SB_X509_CERT_ILLEGAL_LCS CC_SB_X509_CERT_BASE_ERROR + 0x00000007 24 | #define CC_SB_X509_CERT_ILLEGAL_PKG_ADD CC_SB_X509_CERT_BASE_ERROR + 0x00000008 25 | #define CC_SB_X509_CERT_ILLEGAL_SOC_ID CC_SB_X509_CERT_BASE_ERROR + 0x00000009 26 | #define CC_SB_X509_CERT_ILLEGAL_CERT_TYPE CC_SB_X509_CERT_BASE_ERROR + 0x0000000A 27 | #define CC_SB_X509_CERT_SIG_ALIGN_INCORRECT CC_SB_X509_CERT_BASE_ERROR + 0x0000000C 28 | 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | 36 | 37 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/mbedos/test_pal_time.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include "cmsis_os2.h" 14 | #include "mbed_wait_api.h" 15 | #include "test_pal_time.h" 16 | 17 | /******************************************************************************/ 18 | void Test_PalDelay(const uint32_t usec) 19 | { 20 | wait_us((int)usec); 21 | } 22 | 23 | /******************************************************************************/ 24 | uint32_t Test_PalGetTimestamp(void) 25 | { 26 | return (us_ticker_read() / 1000); 27 | } 28 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/oem_asset_package/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for managing build and installation 2 | 3 | # shared library to build 4 | UTIL_ROOT = $(shell pwd) 5 | UTILS_DIR_ROOT = $(UTIL_ROOT)/../../.. 6 | HOST_DIR_ROOT = $(UTILS_DIR_ROOT)/../host 7 | UTILS_LIB_PATH = ./lib 8 | UTILS_LIB_NAME = lib_oem_asset_pkg.so 9 | UTILS_SCRIPTS_DIRNAME = $(UTIL_ROOT) 10 | 11 | 12 | DEPENDENCY_ON_EXISTENCE_OF = $(filter-out $(wildcard $(1)), $(1)) 13 | 14 | INSTALL_LIST = install_lib install_scripts 15 | 16 | all: $(INSTALL_LIST) 17 | 18 | install_lib: build_lib $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/lib) 19 | @echo Installing oem_asset_pkg library 20 | @cp $(UTILS_LIB_PATH)/$(UTILS_LIB_NAME) $(UTILS_DIR_ROOT)/lib 21 | 22 | build_lib: 23 | @echo build_lib for oem_asset_pkg.py. 24 | @make -C $(UTILS_LIB_PATH) 25 | 26 | install_scripts: $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin) $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin/example) 27 | @echo Installing scripts for oem_asset_pkg.py. 28 | @cp $(UTIL_ROOT)/../common/*.py $(UTILS_DIR_ROOT)/bin 29 | @cp $(UTIL_ROOT)/*.py $(UTILS_DIR_ROOT)/bin 30 | @cp $(UTIL_ROOT)/examples/*.cfg $(UTILS_DIR_ROOT)/bin/example 31 | 32 | $(UTILS_DIR_ROOT)/%: 33 | @echo Creating directory for dmpu package 34 | @mkdir $@ 35 | 36 | 37 | clean: 38 | @make -C $(UTILS_LIB_PATH) clean 39 | 40 | .PHONY: install_lib install_sd_scripts clean 41 | 42 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/oem_key_request/lib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for building sbu_crypto library 3 | SH_LIB_NAME = lib_oem_key_request.so 4 | 5 | LIB_SRC_O = main.o common_sb_ops.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o common_crypto_sym.o #common_crypto_asym.o 6 | 7 | UTILS_ROOT = $(shell pwd)/../../../.. 8 | SHARED_DIR = $(UTILS_ROOT)/../shared 9 | HOSTSRC_DIR = $(UTILS_ROOT)/../host/src 10 | UTILS_LIB_PATH = $(UTILS_ROOT)/lib 11 | UTILS_INC_PATH = $(SHARED_DIR)/include $(SHARED_DIR)/include/proj/$(PROJ_PRD) $(UTILS_ROOT)/include 12 | UTILS_INC_PATH += $(UTILS_ROOT)/src/common $(HOSTSRC_DIR)/cc3x_productionlib/common $(SHARED_DIR)/include/pal $(SHARED_DIR)/include/pal/$(TEE_OS) 13 | 14 | include $(UTILS_ROOT)/src/Makefile.openssl 15 | 16 | UTILS_INC_PATH += $(OPENSSL_INC_DIR) 17 | 18 | CFLAGS += -fPIC $(foreach incdir,$(UTILS_INC_PATH),-I$(incdir)) -c 19 | 20 | all: $(SH_LIB_NAME) 21 | 22 | # Compile and link the sbu_crypto library with hard-coded library run path to utils/lib 23 | # (to assure the private version of openssl libraries are used) 24 | $(SH_LIB_NAME): $(LIB_SRC_O) 25 | gcc -shared -o $(SH_LIB_NAME) $(LIB_SRC_O) -Wl,-rpath=$(OPENSSL_LIB_DIR) -L $(OPENSSL_LIB_DIR) -lcrypto -lssl 26 | 27 | vpath %.c $(UTILS_ROOT)/src/common 28 | 29 | %.o: %.c 30 | gcc $(CFLAGS) $< 31 | 32 | clean: 33 | rm -f $(SH_LIB_NAME) $(LIB_SRC_O) 34 | 35 | .PHONY: clean all 36 | 37 | -------------------------------------------------------------------------------- /shared/include/pal/cc_pal_apbc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_pal_apbc 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains the definitions and APIs for APB-C implementation. 15 | 16 | This is a placeholder for platform-specific APB-C implementation. 17 | */ 18 | 19 | #ifndef _CC_PAL_APBC_H 20 | #define _CC_PAL_APBC_H 21 | 22 | /*! 23 | @brief This function initiates an atomic counter. 24 | 25 | @return Void. 26 | */ 27 | void CC_PalApbcCntrInit(void); 28 | 29 | /*! 30 | @brief This function returns the number of APB-C access operations. 31 | 32 | @return The value of the atomic counter. 33 | */ 34 | int32_t CC_PalApbcCntrValue(void); 35 | 36 | /*! 37 | @brief This function updates the atomic counter on each call to APB-C access. 38 | 39 | On each call to APB-C access, the counter is increased. At the end of each 40 | operation, the counter is decreased. 41 | 42 | @return \c 0 on success. 43 | @return A non-zero value on failure. 44 | */ 45 | CCError_t CC_PalApbcModeSelect( 46 | /*! [in] Determines the APB-C mode: TRUE (APB-C start access). 47 | FALSE (APB-C finish access). */ 48 | CCBool isApbcInc 49 | ); 50 | 51 | 52 | /*! 53 | @} 54 | */ 55 | #endif 56 | -------------------------------------------------------------------------------- /shared/hw/include/zynq/dx_reg_base_host.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *****************************************************************************/ 12 | #ifndef __DX_REG_BASE_HOST_H__ 13 | #define __DX_REG_BASE_HOST_H__ 14 | 15 | /* Identify platform: Xilinx Zynq7000 ZC706 */ 16 | #define DX_PLAT_ZYNQ7000 1 17 | #define DX_PLAT_ZYNQ7000_ZC706 1 18 | 19 | #define DX_BASE_CC 0x60000000 20 | 21 | #define DX_BASE_ENV_REGS 0x40008000 22 | #define DX_BASE_ENV_CC_MEMORIES 0x40008000 23 | #define DX_BASE_ENV_PERF_RAM 0x40009000 24 | 25 | #define DX_BASE_HOST_RGF 0x0UL 26 | #define DX_BASE_CRY_KERNEL 0x0UL 27 | #define DX_BASE_ROM 0x40000000 28 | 29 | #define DX_BASE_RNG 0x0000UL 30 | #endif /*__DX_REG_BASE_HOST_H__*/ 31 | -------------------------------------------------------------------------------- /shared/hw/include/dx_reg_base_host.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *****************************************************************************/ 12 | 13 | #ifndef __DX_REG_BASE_HOST_H__ 14 | #define __DX_REG_BASE_HOST_H__ 15 | 16 | /* Identify platform: ARM MPS2 PLUS */ 17 | #define DX_PLAT_MPS2_PLUS 1 18 | 19 | #define DX_BASE_CC 0x50088000 20 | #define DX_BASE_CODE 0x1E000000 21 | 22 | #define DX_BASE_ENV_REGS 0x400A8000 23 | #define DX_BASE_ENV_NVM_LOW 0x400AA000 24 | #define DX_BASE_ENV_NVM_HI 0x400AB000 25 | #define DX_BASE_ENV_PERF_RAM 0x400A9000 26 | 27 | #define DX_BASE_HOST_RGF 0x0UL 28 | #define DX_BASE_CRY_KERNEL 0x0UL 29 | 30 | #define DX_BASE_RNG 0x0000UL 31 | 32 | #endif /*__DX_REG_BASE_HOST_H__*/ 33 | -------------------------------------------------------------------------------- /shared/include/sbrom/cc_asset_prov.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_ASSET_PROV_H 8 | #define _CC_ASSET_PROV_H 9 | 10 | /*! 11 | @file 12 | @brief This file contains the functions and definitions for the OEM Asset provisioning. 13 | */ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | #include "cc_bitops.h" 20 | 21 | #define ASSET_PROV_TOKEN 0x41736574UL 22 | #define ASSET_PROV_VERSION 0x10000UL 23 | 24 | #define KPICV_KEY_SIZE 16 25 | #define KPROV_KEY_SIZE 16 26 | #define KPROV_DATA_IN_SIZE 8 27 | #define ASSET_NONCE_SIZE 12 28 | #define ASSET_RESERVED_SIZE 8 29 | #define ASSET_RESERVED_WORD_SIZE (8/CC_32BIT_WORD_SIZE) 30 | #define ASSET_TAG_SIZE 16 31 | #define ASSET_BLOCK_SIZE 16 32 | #define MAX_ASSET_SIZE 512 33 | #define ASSET_ADATA_SIZE (3*CC_32BIT_WORD_SIZE+ASSET_RESERVED_SIZE) // token||version||assetId||reserved 34 | 35 | typedef struct { 36 | uint32_t token; 37 | uint32_t version; 38 | uint32_t assetSize; 39 | uint32_t reserved[ASSET_RESERVED_WORD_SIZE]; 40 | uint8_t nonce[ASSET_NONCE_SIZE]; 41 | uint8_t encAsset[MAX_ASSET_SIZE+ASSET_TAG_SIZE]; 42 | }CCBsvAssetProv_t; 43 | 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /*_CC_ASSET_PROV_H */ 50 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/srp/srp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #define CC_PAL_LOG_CUR_COMPONENT CC_LOG_MASK_CC_API 8 | 9 | #ifndef _SRP_H 10 | #define _SRP_H 11 | 12 | #include "mbedtls_cc_srp.h" 13 | 14 | 15 | 16 | uint32_t SrpPwdVerifierCalc(mbedtls_srp_digest xBuff, 17 | mbedtls_srp_modulus pwdVerifier, 18 | mbedtls_srp_context *pCtx); 19 | 20 | /* calculates S=(((A*v^u)^b)%N */ 21 | uint32_t SrpHostSharedSecretCalc(mbedtls_srp_modulus userPubKeyA, 22 | mbedtls_srp_modulus pwdVerifier, 23 | mbedtls_srp_digest uScramble, 24 | mbedtls_srp_modulus sessionKey, 25 | mbedtls_srp_context *pCtx); 26 | 27 | 28 | // Use PKA to calculate S=((B-g^x)^(a+u*x))%N 29 | uint32_t SrpUserSharedSecretCalc(mbedtls_srp_modulus hostPubKeyB, 30 | mbedtls_srp_digest xBuff, 31 | mbedtls_srp_digest uScramble, 32 | mbedtls_srp_modulus sessionKey, 33 | mbedtls_srp_context *pCtx); 34 | 35 | /* calculates B = (k*v+ g^b)%N */ 36 | uint32_t SrpHostPublicKeyCalc(mbedtls_srp_modulus pwdVerifier, // in 37 | mbedtls_srp_modulus hostPubKey, // out 38 | mbedtls_srp_context *pCtx); 39 | 40 | /* calculates A = (g^a)%N */ 41 | uint32_t SrpUserPublicKeyCalc(mbedtls_srp_modulus userPubKeyA, // out 42 | mbedtls_srp_context *pCtx); 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /host/src/pal/project_pal.mk: -------------------------------------------------------------------------------- 1 | 2 | CFLAGS_EXTRA += -DCC_IOT 3 | 4 | SOURCES_pal_$(PLAT_OS) += cc_pal.c 5 | SOURCES_pal_$(PLAT_OS) += cc_pal_mutex.c 6 | SOURCES_pal_$(PLAT_OS) += cc_pal_memmap.c 7 | SOURCES_pal_$(PLAT_OS) += cc_pal_dma.c 8 | SOURCES_pal_$(PLAT_OS) += cc_pal_pm.c 9 | SOURCES_pal_$(PLAT_OS) += cc_pal_interrupt_ctrl.c 10 | SOURCES_pal_$(PLAT_OS) += cc_pal_mem.c 11 | SOURCES_pal_$(PLAT_OS) += cc_pal_buff_attr.c 12 | SOURCES_pal_$(PLAT_OS) += cc_pal_abort_plat.c 13 | SOURCES_pal_$(PLAT_OS) += cc_pal_trng.c 14 | SOURCES_pal_$(PLAT_OS) += cc_pal_apbc.c 15 | 16 | INCDIRS_EXTRA += $(SHARED_INCDIR)/pal 17 | INCDIRS_EXTRA += $(SHARED_INCDIR)/pal/$(PLAT_OS) 18 | 19 | INCDIRS_EXTRA += $(SHARED_DIR)/hw/include # for dx_reg_base_host.h, included in cc_pal.c 20 | INCDIRS_EXTRA += $(HOST_SRCDIR)/hal # for cc_pal_interrupt_ctrl.c 21 | 22 | ifeq ($(ARCH),arm) 23 | ifeq ($(CROSS_COMPILE),arm-none-eabi-) 24 | ifeq ($(ARM_CPU), cortex-m33) 25 | CFLAGS += -DSSE_200 26 | endif 27 | endif 28 | endif 29 | 30 | ifeq ($(DEBUG),1) 31 | SOURCES_pal_$(PLAT_OS) += cc_pal_log.c 32 | CFLAGS += -DDEBUG 33 | endif 34 | 35 | $(info TRNG: CC_CONFIG_TRNG_MODE=$(CC_CONFIG_TRNG_MODE)) 36 | CFLAGS_EXTRA += -DCC_CONFIG_TRNG_MODE=$(CC_CONFIG_TRNG_MODE) 37 | 38 | ifeq ($(LIB_PERF),1) 39 | SOURCES_pal_$(PLAT_OS) += cc_pal_perf_plat.c 40 | CFLAGS += -DLIB_PERF 41 | endif 42 | 43 | VPATH += $(HOST_SRCDIR)/pal $(HOST_SRCDIR)/pal/$(PLAT_OS) 44 | 45 | -------------------------------------------------------------------------------- /shared/include/cc_sym_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef __CC_ERROR_H__ 8 | #define __CC_ERROR_H__ 9 | 10 | #ifdef __KERNEL__ 11 | #include 12 | #define INT32_MAX 0x7FFFFFFFL 13 | #else 14 | #include 15 | #endif 16 | 17 | 18 | typedef enum CCSymRetCode { 19 | CC_RET_OK = 0, /* No error */ 20 | CC_RET_UNSUPP_ALG, /* Unsupported algorithm */ 21 | CC_RET_UNSUPP_ALG_MODE, /* Unsupported algorithm mode */ 22 | CC_RET_UNSUPP_OPERATION, /* Unsupported operation */ 23 | CC_RET_UNSUPP_HWKEY, /* Unsupported hw key */ 24 | CC_RET_INV_HWKEY, /* invalid hw key */ 25 | CC_RET_INVARG, /* Invalid parameter */ 26 | CC_RET_INVARG_KEY_SIZE, /* Invalid key size */ 27 | CC_RET_INVARG_CTX_IDX, /* Invalid context index */ 28 | CC_RET_INVARG_CTX, /* Bad or corrupted context */ 29 | CC_RET_INVARG_BAD_ADDR, /* Bad address */ 30 | CC_RET_INVARG_INCONSIST_DMA_TYPE, /* DIN is inconsist with DOUT DMA type */ 31 | CC_RET_PERM, /* Operation not permitted */ 32 | CC_RET_NOEXEC, /* Execution format error */ 33 | CC_RET_BUSY, /* Resource busy */ 34 | CC_RET_NOMEM, /* Out of memory */ 35 | CC_RET_OSFAULT, /* Internal TEE_OS error */ 36 | CCSYMCRYPTO_RET_RESERVE32 = INT32_MAX /* assure this enum is 32b */ 37 | }CCSymRetCode_t; 38 | 39 | 40 | #endif /*__CC_ERROR_H__*/ 41 | -------------------------------------------------------------------------------- /shared/hw/include/mps2.cm33/dx_reg_base_host.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *****************************************************************************/ 12 | 13 | #ifndef __DX_REG_BASE_HOST_H__ 14 | #define __DX_REG_BASE_HOST_H__ 15 | 16 | /* Identify platform: ARM MPS2 PLUS */ 17 | #define DX_PLAT_MPS2_PLUS 1 18 | 19 | #define DX_BASE_CC 0x50088000 20 | #define DX_BASE_CODE 0x1E000000 21 | 22 | #define DX_BASE_ENV_REGS 0x400A8000 23 | #define DX_BASE_ENV_NVM_LOW 0x400AA000 24 | #define DX_BASE_ENV_NVM_HI 0x400AB000 25 | #define DX_BASE_ENV_PERF_RAM 0x400A9000 26 | 27 | #define DX_BASE_HOST_RGF 0x0UL 28 | #define DX_BASE_CRY_KERNEL 0x0UL 29 | 30 | #define DX_BASE_RNG 0x0000UL 31 | 32 | #endif /*__DX_REG_BASE_HOST_H__*/ 33 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/icv_key_response/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for managing build and installation 2 | 3 | # shared library to build 4 | UTIL_ROOT = $(shell pwd) 5 | UTILS_DIR_ROOT = $(UTIL_ROOT)/../../.. 6 | HOST_DIR_ROOT = $(UTILS_DIR_ROOT)/../host 7 | UTILS_LIB_PATH = ./lib 8 | UTILS_LIB_NAME = lib_icv_key_response.so 9 | UTILS_SCRIPTS_DIRNAME = $(UTIL_ROOT) 10 | 11 | 12 | DEPENDENCY_ON_EXISTENCE_OF = $(filter-out $(wildcard $(1)), $(1)) 13 | 14 | INSTALL_LIST = install_lib install_scripts 15 | 16 | all: $(INSTALL_LIST) 17 | 18 | install_lib: build_lib $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/lib) 19 | @echo Installing icv_key_response library 20 | @cp $(UTILS_LIB_PATH)/$(UTILS_LIB_NAME) $(UTILS_DIR_ROOT)/lib 21 | 22 | build_lib: 23 | @echo build_lib for dmpu_icv_key_response_util.py. 24 | @make -C $(UTILS_LIB_PATH) 25 | 26 | install_scripts: $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin) $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin/example) 27 | @echo Installing scripts for dmpu_icv_key_response_util.py. 28 | @cp $(UTIL_ROOT)/../common/*.py $(UTILS_DIR_ROOT)/bin 29 | @cp $(UTIL_ROOT)/*.py $(UTILS_DIR_ROOT)/bin 30 | @cp $(UTIL_ROOT)/examples/*.cfg $(UTILS_DIR_ROOT)/bin/example 31 | 32 | $(UTILS_DIR_ROOT)/%: 33 | @echo Creating directory for dmpu package 34 | @mkdir $@ 35 | 36 | 37 | clean: 38 | @make -C $(UTILS_LIB_PATH) clean 39 | 40 | .PHONY: install_lib install_sd_scripts clean 41 | 42 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/freertos/test_pal_time.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include "FreeRTOS.h" 14 | #include "task.h" 15 | #include "test_pal_time.h" 16 | 17 | /******************************************************************************/ 18 | void Test_PalDelay(const uint32_t usec) 19 | { 20 | vTaskDelay(usec / (1000 * portTICK_PERIOD_MS)); 21 | } 22 | 23 | /******************************************************************************/ 24 | uint32_t Test_PalGetTimestamp(void) 25 | { 26 | return (xTaskGetTickCount() * portTICK_PERIOD_MS); 27 | } 28 | -------------------------------------------------------------------------------- /utils/src/cc3x_asset_prov_rt/lib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for building sbu_crypto library 3 | SH_LIB_NAME = libutil_crypto.so 4 | 5 | LIB_SRC_O = main.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o 6 | 7 | UTILS_ROOT := $(shell pwd)/../../.. 8 | SHARED_DIR := $(UTILS_ROOT)/../shared 9 | HOST_DIR := $(UTILS_ROOT)/../host 10 | 11 | include $(UTILS_ROOT)/src/Makefile.openssl 12 | 13 | UTILS_INC_PATH = $(SHARED_DIR)/include 14 | UTILS_INC_PATH += $(SHARED_DIR)/include/cc_util 15 | UTILS_INC_PATH += $(SHARED_DIR)/include/proj/$(PROJ_PRD) 16 | UTILS_INC_PATH += $(SHARED_DIR)/include/pal 17 | UTILS_INC_PATH += $(SHARED_DIR)/include/pal/$(TEE_OS) 18 | UTILS_LIB_PATH += $(UTILS_ROOT)/lib 19 | UTILS_INC_PATH += $(UTILS_ROOT)/include 20 | UTILS_INC_PATH += $(UTILS_ROOT)/src/common 21 | UTILS_INC_PATH += $(OPENSSL_INC_DIR) 22 | 23 | CFLAGS += -fPIC $(foreach incdir,$(UTILS_INC_PATH),-I$(incdir)) -c 24 | 25 | all: $(SH_LIB_NAME) 26 | 27 | # Compile and link the sbu_crypto library with hard-coded library run path to utils/lib 28 | # (to assure the private version of openssl libraries are used) 29 | $(SH_LIB_NAME): $(LIB_SRC_O) 30 | gcc -shared -o $(SH_LIB_NAME) $(LIB_SRC_O) -Wl,-rpath=$(OPENSSL_LIB_DIR) -L $(OPENSSL_LIB_DIR) -lcrypto -lssl 31 | 32 | vpath %.c $(UTILS_ROOT)/src/common 33 | 34 | %.o: %.c 35 | gcc $(CFLAGS) $< 36 | 37 | clean: 38 | rm -f $(SH_LIB_NAME) $(LIB_SRC_O) 39 | 40 | .PHONY: clean all 41 | 42 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | 9 | /************* Include Files ****************/ 10 | #include "cc_pal_init.h" 11 | #include "cc_pal_dma_plat.h" 12 | #include "cc_pal_log.h" 13 | #include "cc_pal_mutex.h" 14 | #include "cc_pal_pm.h" 15 | 16 | /** 17 | * @brief PAL layer entry point. 18 | * The function initializes customer platform sub components, 19 | * such as memory mapping used later by CRYS to get physical contiguous memory. 20 | * 21 | * 22 | * @return Returns a non-zero value in case of failure 23 | */ 24 | int CC_PalInit(void) 25 | { // IG - need to use palInit of cc_linux for all PALs 26 | uint32_t rc = CC_OK; 27 | 28 | CC_PalLogInit(); 29 | 30 | rc = CC_PalDmaInit(0, 0); 31 | if (rc != CC_OK) { 32 | return rc; 33 | } 34 | 35 | #ifdef CC_IOT 36 | /* Initialize power management module */ 37 | CC_PalPowerSaveModeInit(); 38 | #endif 39 | 40 | return rc; 41 | } 42 | 43 | 44 | /** 45 | * @brief PAL layer entry point. 46 | * The function initializes customer platform sub components, 47 | * such as memory mapping used later by CRYS to get physical contiguous memory. 48 | * 49 | * 50 | * @return None 51 | */ 52 | void CC_PalTerminate(void) 53 | { 54 | CC_PalDmaTerminate(); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/no_os/test_pal_cli.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include 14 | #include "test_pal_cli.h" 15 | 16 | /******************************************************************************/ 17 | uint32_t Test_PalCLIRegisterCommand(struct Test_PalCliCommand *commandToRegister) 18 | { 19 | return 0; 20 | } 21 | 22 | /******************************************************************************/ 23 | const char *Test_PalCLIGetParameter(const char *commandString, 24 | uint32_t wantedParamIndx, uint32_t *paramStringLength) 25 | { 26 | return NULL; 27 | } 28 | -------------------------------------------------------------------------------- /shared/include/pal/cc_pal_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /*! 8 | @addtogroup cc_pal_init 9 | @{ 10 | */ 11 | 12 | /*! 13 | @file 14 | @brief This file contains the PAL layer entry point. 15 | 16 | It includes the definitions and APIs for PAL initialization and termination. 17 | */ 18 | 19 | #ifndef _CC_PAL_INIT_H 20 | #define _CC_PAL_INIT_H 21 | 22 | #include "cc_pal_types.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" 26 | { 27 | #endif 28 | 29 | 30 | /*! 31 | @brief This function performs all initializations that may be required by 32 | your PAL implementation, specifically by the DMA-able buffer scheme. 33 | 34 | It is called by ::CC_LibInit. 35 | 36 | The existing implementation allocates a contiguous memory pool that is later 37 | used by the CryptoCell implementation. 38 | If no initializations are needed in your environment, the function can be 39 | minimized to return OK. 40 | 41 | @return A non-zero value on failure. 42 | */ 43 | int CC_PalInit(void); 44 | 45 | 46 | 47 | /*! 48 | @brief This function terminates the PAL implementation and frees the resources 49 | that were allocated by ::CC_PalInit. 50 | 51 | @return Void. 52 | */ 53 | void CC_PalTerminate(void); 54 | 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | /*! 62 | @} 63 | */ 64 | #endif 65 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/no_os/test_pal_time.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include "test_pal_time.h" 17 | 18 | /******************************************************************************/ 19 | /* The smallest resolution in no_os is seconds */ 20 | void Test_PalDelay(const uint32_t usec) 21 | { 22 | /* Rounds up */ 23 | uint32_t secs = (usec + 999) / 1000; 24 | 25 | /* Gets the end time */ 26 | uint32_t retTime = time(0) + secs; 27 | 28 | /* Loop until end time arrives */ 29 | while (time(0) < retTime); 30 | } 31 | -------------------------------------------------------------------------------- /shared/hw/include/mps2/dx_reg_base_host.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from Arm Limited (or its affiliates). * 5 | * (C) COPYRIGHT [2001-2019] Arm Limited (or its affiliates). * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from Arm Limited (or its affiliates). * 11 | *****************************************************************************/ 12 | 13 | #ifndef __DX_REG_BASE_HOST_H__ 14 | #define __DX_REG_BASE_HOST_H__ 15 | 16 | /* Identify platform: ARM MPS2 PLUS */ 17 | #define DX_PLAT_MPS2_PLUS 1 18 | 19 | #define DX_BASE_CC 0x50010000 20 | #define DX_BASE_CODE 0x50030000 21 | 22 | #define DX_BASE_ENV_REGS 0x50028000 23 | #define DX_BASE_ENV_NVM_LOW 0x5002A000 24 | #define DX_BASE_ENV_NVM_HI 0x5002B000 25 | #define DX_BASE_ENV_PERF_RAM 0x40009000 26 | 27 | #define DX_BASE_HOST_RGF 0x0UL 28 | #define DX_BASE_CRY_KERNEL 0x0UL 29 | 30 | #define DX_BASE_RNG 0x0000UL 31 | #endif /*__DX_REG_BASE_HOST_H__*/ 32 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/icv_key_response/lib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for building sbu_crypto library 3 | SH_LIB_NAME = lib_icv_key_response.so 4 | 5 | LIB_SRC_O = main.o dmpu_common.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o 6 | 7 | UTILS_ROOT = $(shell pwd)/../../../.. 8 | SHARED_DIR = $(UTILS_ROOT)/../shared 9 | HOSTSRC_DIR = $(UTILS_ROOT)/../host/src 10 | UTILS_LIB_PATH = $(UTILS_ROOT)/lib 11 | UTILS_INC_PATH = $(SHARED_DIR)/include $(SHARED_DIR)/include/proj/$(PROJ_PRD) $(UTILS_ROOT)/include 12 | UTILS_INC_PATH += $(UTILS_ROOT)/src/common $(UTILS_ROOT)/src/dmpu_asset_pkg_util/common $(HOSTSRC_DIR)/cc3x_productionlib/common $(SHARED_DIR)/include/pal $(SHARED_DIR)/include/pal/$(TEE_OS) 13 | 14 | include $(UTILS_ROOT)/src/Makefile.openssl 15 | 16 | UTILS_INC_PATH += $(OPENSSL_INC_DIR) 17 | 18 | CFLAGS += -fPIC $(foreach incdir,$(UTILS_INC_PATH),-I$(incdir)) -c 19 | 20 | all: $(SH_LIB_NAME) 21 | 22 | # Compile and link the sbu_crypto library with hard-coded library run path to utils/lib 23 | # (to assure the private version of openssl libraries are used) 24 | $(SH_LIB_NAME): $(LIB_SRC_O) 25 | gcc -shared -o $(SH_LIB_NAME) $(LIB_SRC_O) -Wl,-rpath=$(OPENSSL_LIB_DIR) -L $(OPENSSL_LIB_DIR) -lcrypto -lssl 26 | 27 | vpath %.c $(UTILS_ROOT)/src/common $(UTILS_ROOT)/src/dmpu_asset_pkg_util/common 28 | 29 | %.o: %.c 30 | gcc $(CFLAGS) $< 31 | 32 | clean: 33 | rm -f $(SH_LIB_NAME) $(LIB_SRC_O) 34 | 35 | .PHONY: clean all 36 | 37 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/oem_asset_package/lib/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for building sbu_crypto library 3 | SH_LIB_NAME = lib_oem_asset_pkg.so 4 | 5 | LIB_SRC_O = main.o dmpu_common.o common_crypto_asym.o common_crypto_sym.o common_rsa_keypair_util.o common_rsa_keypair.o common_util_files.o 6 | 7 | UTILS_ROOT = $(shell pwd)/../../../.. 8 | SHARED_DIR = $(UTILS_ROOT)/../shared 9 | HOSTSRC_DIR = $(UTILS_ROOT)/../host/src 10 | UTILS_LIB_PATH = $(UTILS_ROOT)/lib 11 | UTILS_INC_PATH = $(SHARED_DIR)/include $(SHARED_DIR)/include/proj/$(PROJ_PRD) $(UTILS_ROOT)/include 12 | UTILS_INC_PATH += $(UTILS_ROOT)/src/common $(HOSTSRC_DIR)/cc3x_productionlib/common $(UTILS_ROOT)/src/dmpu_asset_pkg_util/common $(SHARED_DIR)/include/pal $(SHARED_DIR)/include/pal/$(TEE_OS) 13 | 14 | include $(UTILS_ROOT)/src/Makefile.openssl 15 | 16 | UTILS_INC_PATH += $(OPENSSL_INC_DIR) 17 | 18 | CFLAGS += -fPIC $(foreach incdir,$(UTILS_INC_PATH),-I$(incdir)) -c 19 | 20 | all: $(SH_LIB_NAME) 21 | 22 | # Compile and link the sbu_crypto library with hard-coded library run path to utils/lib 23 | # (to assure the private version of openssl libraries are used) 24 | $(SH_LIB_NAME): $(LIB_SRC_O) 25 | gcc -shared -o $(SH_LIB_NAME) $(LIB_SRC_O) -Wl,-rpath=$(OPENSSL_LIB_DIR) -L $(OPENSSL_LIB_DIR) -lcrypto -lssl 26 | 27 | vpath %.c $(UTILS_ROOT)/src/common $(UTILS_ROOT)/src/dmpu_asset_pkg_util/common 28 | 29 | %.o: %.c 30 | gcc $(CFLAGS) $< 31 | 32 | clean: 33 | rm -f $(SH_LIB_NAME) $(LIB_SRC_O) 34 | 35 | .PHONY: clean all 36 | 37 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/common_utils/global_defines_rsa_format.py: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | # 3 | # Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 6 | # 7 | 8 | 9 | 10 | 11 | # Filename - globaldefinesrsaformat.py 12 | # Description - This file contains global defines used in the RSA 13 | # Format parser 14 | #################################################################### 15 | 16 | # Parameter type 17 | PARAM_MOD = 1 18 | PARAM_PRIV_EXP = 2 19 | PARAM_EXP = 3 20 | 21 | # PEM header and footer 22 | PEM_START = "-----BEGIN RSA PRIVATE KEY-----\n" 23 | PEM_END = "\n-----END RSA PRIVATE KEY-----\n" 24 | 25 | # PEM header size 26 | PEM_HEADER_SIZE_BYTES = 4 27 | 28 | # PEM version size 29 | PEM_VERSION_SIZE_BYTES = 3 30 | 31 | # Parameters ASN.1 DER type 32 | PARAM_HEADER_INTEGER_TYPE = 2 33 | 34 | # Length ASN.1 DER 35 | PARAM_LENGTH_INDICATION_BIT = 7 36 | PARAM_LENGTH_INDICATION = 0x1 << PARAM_LENGTH_INDICATION_BIT 37 | 38 | PARAM_LENGTH_BITS_MASK = 0x7F 39 | 40 | # Size of expected Mod & Priv exponent 41 | RSA_MOD_SIZE_BYTES = 256 42 | 43 | # Modulus & Priv Exponent ASN.1 header size 44 | MOD_HEADER_FIXED_SIZE_BYTES = 4 45 | 46 | # Exponent ASN.1 header size 47 | EXP_HEADER_FIXED_SIZE_BYTES = 2 48 | 49 | # Exponent expected value 50 | EXP_EXPECTED_VAL = 65537 51 | 52 | # AES key fixed size 53 | AES_KEY_SIZE_IN_BYTES = 32 54 | -------------------------------------------------------------------------------- /host/src/cc3x_productionlib/common/prod_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _PROD_UTIL_H 8 | #define _PROD_UTIL_H 9 | 10 | #include 11 | #include "cc_production_asset.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" 15 | { 16 | #endif 17 | 18 | #define PROD_MIN(a , b ) ( ( (a) < (b) ) ? (a) : (b) ) 19 | 20 | uint32_t CC_PROD_PkgVerify(CCProdAssetPkg_t *pPkgAsset, 21 | const uint8_t *pAssetId, uint32_t assetIdSize, 22 | const uint8_t *pLabel, uint32_t labelSize, 23 | uint8_t *pContext, uint32_t contextSize, 24 | CCPlainAsset_t pPlainAsset, 25 | unsigned long workspaceAddr, 26 | uint32_t workspaceSize); 27 | 28 | uint32_t CC_PROD_BitListFromNum(uint32_t *pWordBuff, 29 | uint32_t wordBuffSize, 30 | uint32_t numVal); 31 | 32 | uint32_t CC_PROD_GetZeroCount(uint32_t *pBuff, 33 | uint32_t buffWordSize, 34 | uint32_t *pZeroCount); 35 | 36 | 37 | uint32_t CCProd_Init(void); 38 | 39 | void CCPROD_Fini(void); 40 | 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif //_PROD_UTIL_H 46 | 47 | -------------------------------------------------------------------------------- /host/src/tests/proj/test_proj_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _TEST_PROJ_COMMON_H_ 8 | #define _TEST_PROJ_COMMON_H_ 9 | 10 | 11 | 12 | /* Error types */ 13 | /*! Defines test proj base error. */ 14 | #define TEST_PROJ_BASE_ERROR (0x00FFFF00) 15 | 16 | #define TEST_OK (0x00000000) 17 | #define TEST_INVALID_PARAM_ERR (TEST_PROJ_BASE_ERROR + 0x00000001) 18 | #define TEST_COMPARE_ERR (TEST_PROJ_BASE_ERROR + 0x00000002) 19 | #define TEST_HW_FAIL_ERR (TEST_PROJ_BASE_ERROR + 0x00000003) 20 | #define TEST_MAPPING_ERR (TEST_PROJ_BASE_ERROR + 0x00000004) 21 | #define TEST_EXECUTE_FAIL (TEST_PROJ_BASE_ERROR + 0x00000005) 22 | #define TEST_MAX_THREADS 16 23 | #define TEST_MAX_FILE_NAME 256 24 | #define THREAD_STACK_SIZE (128*1024) /* stack has 128KB for 64bit CPU */ 25 | 26 | 27 | #ifdef BIG__ENDIAN 28 | #define TEST_CONVERT_BYTE_ARR_TO_WORD(inPtr, outWord) {\ 29 | outWord = (*inPtr<<24);\ 30 | outWord |= (*(inPtr+1)<<16);\ 31 | outWord |= (*(inPtr+2)<<8);\ 32 | outWord |= (*(inPtr+3));\ 33 | } 34 | #else 35 | #define TEST_CONVERT_BYTE_ARR_TO_WORD(inPtr, outWord) {\ 36 | outWord = (*(inPtr+3))<<24;\ 37 | outWord |= (*(inPtr+2))<<16;\ 38 | outWord |= (*(inPtr+1))<<8;\ 39 | outWord |= (*inPtr);\ 40 | } 41 | #endif 42 | 43 | #endif /* _TEST_PROJ_COMMON_H_ */ 44 | -------------------------------------------------------------------------------- /host/src/pal/linux/cc_pal_fips.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | #include "cc_pal_fips.h" 9 | #include "cc_pal_mem.h" 10 | 11 | CCFipsStateData_t gStateData = { CC_FIPS_STATE_CRYPTO_APPROVED, CC_TEE_FIPS_ERROR_OK, CC_FIPS_TRACE_NONE }; 12 | 13 | 14 | CCError_t CC_PalFipsWaitForReeStatus(void) 15 | { 16 | FipsSetReeStatus(CC_TEE_FIPS_REE_STATUS_OK); 17 | return CC_OK; 18 | } 19 | 20 | CCError_t CC_PalFipsStopWaitingRee(void) 21 | { 22 | return CC_OK; 23 | } 24 | 25 | CCError_t CC_PalFipsGetState(CCFipsState_t *pFipsState) 26 | { 27 | *pFipsState = gStateData.state; 28 | 29 | return CC_OK; 30 | } 31 | 32 | 33 | CCError_t CC_PalFipsGetError(CCFipsError_t *pFipsError) 34 | { 35 | *pFipsError = gStateData.error; 36 | 37 | return CC_OK; 38 | } 39 | 40 | 41 | CCError_t CC_PalFipsGetTrace(CCFipsTrace_t *pFipsTrace) 42 | { 43 | *pFipsTrace = gStateData.trace; 44 | 45 | return CC_OK; 46 | } 47 | 48 | CCError_t CC_PalFipsSetState(CCFipsState_t fipsState) 49 | { 50 | gStateData.state = fipsState; 51 | 52 | return CC_OK; 53 | } 54 | 55 | CCError_t CC_PalFipsSetError(CCFipsError_t fipsError) 56 | { 57 | gStateData.error = fipsError; 58 | 59 | return CC_OK; 60 | } 61 | 62 | CCError_t CC_PalFipsSetTrace(CCFipsTrace_t fipsTrace) 63 | { 64 | gStateData.trace = (gStateData.trace | fipsTrace); 65 | 66 | return CC_OK; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal_fips.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #include "cc_pal_types.h" 8 | #include "cc_pal_fips.h" 9 | #include "cc_pal_mem.h" 10 | 11 | CCFipsStateData_t gStateData = { CC_FIPS_STATE_CRYPTO_APPROVED, CC_TEE_FIPS_ERROR_OK, CC_FIPS_TRACE_NONE }; 12 | 13 | 14 | CCError_t CC_PalFipsWaitForReeStatus(void) 15 | { 16 | FipsSetReeStatus(CC_TEE_FIPS_REE_STATUS_OK); 17 | return CC_OK; 18 | } 19 | 20 | CCError_t CC_PalFipsStopWaitingRee(void) 21 | { 22 | return CC_OK; 23 | } 24 | 25 | CCError_t CC_PalFipsGetState(CCFipsState_t *pFipsState) 26 | { 27 | *pFipsState = gStateData.state; 28 | 29 | return CC_OK; 30 | } 31 | 32 | 33 | CCError_t CC_PalFipsGetError(CCFipsError_t *pFipsError) 34 | { 35 | *pFipsError = gStateData.error; 36 | 37 | return CC_OK; 38 | } 39 | 40 | 41 | CCError_t CC_PalFipsGetTrace(CCFipsTrace_t *pFipsTrace) 42 | { 43 | *pFipsTrace = gStateData.trace; 44 | 45 | return CC_OK; 46 | } 47 | 48 | CCError_t CC_PalFipsSetState(CCFipsState_t fipsState) 49 | { 50 | gStateData.state = fipsState; 51 | 52 | return CC_OK; 53 | } 54 | 55 | CCError_t CC_PalFipsSetError(CCFipsError_t fipsError) 56 | { 57 | gStateData.error = fipsError; 58 | 59 | return CC_OK; 60 | } 61 | 62 | CCError_t CC_PalFipsSetTrace(CCFipsTrace_t fipsTrace) 63 | { 64 | gStateData.trace = (CCFipsTrace_t)(gStateData.trace | fipsTrace); 65 | 66 | return CC_OK; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /utils/src/dmpu_asset_pkg_util/oem_key_request/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for managing build and installation 2 | 3 | # shared library to build 4 | UTIL_ROOT = $(shell pwd) 5 | UTILS_DIR_ROOT = $(UTIL_ROOT)/../../.. 6 | HOST_DIR_ROOT = $(UTILS_DIR_ROOT)/../host 7 | UTILS_LIB_PATH = ./lib 8 | UTILS_LIB_NAME = lib_oem_key_request.so 9 | UTILS_SCRIPTS_DIRNAME = $(UTIL_ROOT) 10 | 11 | include $(UTILS_ROOT)/src/Makefile.openssl 12 | 13 | UTILS_INC_PATH += $(OPENSSL_INC_DIR) 14 | 15 | DEPENDENCY_ON_EXISTENCE_OF = $(filter-out $(wildcard $(1)), $(1)) 16 | 17 | INSTALL_LIST = install_lib install_scripts 18 | 19 | all: $(INSTALL_LIST) 20 | 21 | install_lib: build_lib $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/lib) 22 | @echo Installing dmpu_oem_key_request_util library 23 | @cp $(UTILS_LIB_PATH)/$(UTILS_LIB_NAME) $(UTILS_DIR_ROOT)/lib 24 | 25 | build_lib: 26 | @echo build_lib for dmpu_oem_key_request_util.py. 27 | @make -C $(UTILS_LIB_PATH) 28 | 29 | install_scripts: $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin) $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTILS_DIR_ROOT)/bin/example) 30 | @echo Installing scripts for dmpu_oem_key_request_util.py. 31 | @cp $(UTIL_ROOT)/../common/*.py $(UTILS_DIR_ROOT)/bin 32 | @cp $(UTIL_ROOT)/*.py $(UTILS_DIR_ROOT)/bin 33 | @cp $(UTIL_ROOT)/examples/*.cfg $(UTILS_DIR_ROOT)/bin/example 34 | 35 | $(UTILS_DIR_ROOT)/%: 36 | @echo Creating directory for dmpu package 37 | @mkdir $@ 38 | 39 | 40 | clean: 41 | @make -C $(UTILS_LIB_PATH) clean 42 | 43 | .PHONY: install_lib install_sd_scripts clean 44 | 45 | -------------------------------------------------------------------------------- /host/src/pal/linux/cc_pal_buff_attr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | 9 | /************* Include Files ****************/ 10 | #include "cc_pal_types.h" 11 | #include "cc_pal_buff_attr.h" 12 | /************************ Defines ******************************/ 13 | 14 | /************************ Enums ******************************/ 15 | 16 | /************************ Typedefs ******************************/ 17 | 18 | /************************ Global Data ******************************/ 19 | 20 | /************************ Private Functions ******************************/ 21 | 22 | /************************ Public Functions ******************************/ 23 | 24 | CCError_t CC_PalDataBufferAttrGet(const unsigned char *pDataBuffer, /*!< [in] Address of the buffer to map. */ 25 | size_t buffSize, /*!< [in] Buffer size in bytes. */ 26 | uint8_t buffType, /* ! [in] Input for read / output for write */ 27 | uint8_t *pBuffNs /*!< [out] HNONSEC buffer attribute (0 for secure, 1 for non-secure) */ 28 | ) 29 | { 30 | CC_UNUSED_PARAM(pDataBuffer); 31 | CC_UNUSED_PARAM(buffSize); 32 | CC_UNUSED_PARAM(buffType); 33 | 34 | *pBuffNs = DATA_BUFFER_IS_SECURE; 35 | 36 | return CC_OK; 37 | } 38 | -------------------------------------------------------------------------------- /codesafe/src/mbedtls_api/ecp_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | #ifndef ECP_COMMON_H 7 | #define ECP_COMMON_H 8 | #ifdef __cplusplus 9 | extern "C" 10 | { 11 | #endif 12 | 13 | 14 | #include "cc_pal_types_plat.h" 15 | #include "cc_ecpki_types.h" 16 | #include "mbedtls/ecp.h" 17 | 18 | /* 19 | *\brief Curve types 20 | * 21 | */ 22 | typedef enum 23 | { 24 | ECP_TYPE_NONE = 0, 25 | ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */ 26 | ECP_TYPE_25519, /* MONTGOMERY : y^2 = x^3 + a x^2 + x EDWARDS: x^2 + y^2 = 1 + dx^2y^2 (modp) */ 27 | } ecp_curve_type; 28 | 29 | /** 30 | * \brief mapping CC ECP return codes to mbedtls 31 | * 32 | */ 33 | int error_mapping_cc_to_mbedtls_ecc (CCError_t cc_error); 34 | 35 | /** 36 | * \brief get the cfurve type 37 | * 38 | */ 39 | static inline ecp_curve_type ecp_get_type(const mbedtls_ecp_group *grp) 40 | { 41 | if (grp->G.X.p == NULL) 42 | return (ECP_TYPE_NONE); 43 | 44 | if (grp->G.Y.p == NULL) 45 | return (ECP_TYPE_25519); 46 | else 47 | return (ECP_TYPE_SHORT_WEIERSTRASS); 48 | } 49 | 50 | /** 51 | * \brief map mbedtls group id to CC domain id 52 | * 53 | */ 54 | 55 | int ecp_grp_id_to_domain_id (const mbedtls_ecp_group_id id, CCEcpkiDomainID_t *domain_id); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* MBEDTLS_COMMON_H */ 62 | -------------------------------------------------------------------------------- /host/src/pal/no_os/cc_pal_buff_attr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | 9 | /************* Include Files ****************/ 10 | #include "cc_pal_types.h" 11 | #include "cc_pal_buff_attr.h" 12 | /************************ Defines ******************************/ 13 | 14 | /************************ Enums ******************************/ 15 | 16 | /************************ Typedefs ******************************/ 17 | 18 | /************************ Global Data ******************************/ 19 | 20 | /************************ Private Functions ******************************/ 21 | 22 | /************************ Public Functions ******************************/ 23 | 24 | CCError_t CC_PalDataBufferAttrGet(const unsigned char *pDataBuffer, /*!< [in] Address of the buffer to map. */ 25 | size_t buffSize, /*!< [in] Buffer size in bytes. */ 26 | uint8_t buffType, /* ! [in] Input for read / output for write */ 27 | uint8_t *pBuffNs /*!< [out] HNONSEC buffer attribute (0 for secure, 1 for non-secure) */ 28 | ) 29 | { 30 | CC_UNUSED_PARAM(pDataBuffer); 31 | CC_UNUSED_PARAM(buffSize); 32 | CC_UNUSED_PARAM(buffType); 33 | 34 | *pBuffNs = DATA_BUFFER_IS_SECURE; 35 | 36 | return CC_OK; 37 | } 38 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/proj_integration_tests.cfg: -------------------------------------------------------------------------------- 1 | # Project configuration for cc312 generic (development) host project 2 | PROJ_NAME = cc312_integration_tests 3 | TARGET_DIR = cc3x 4 | PROJ_PRD = cc3x 5 | HOST_LIBNAME = cc3x_lib 6 | 7 | 8 | ifneq (,$(findstring gnu,$(CROSS_COMPILE))) 9 | TEE_OS = linux 10 | TEST_BOARD = zynq 11 | TEST_PRODUCT = cc3x 12 | else 13 | TEE_OS = freertos 14 | TEST_BOARD = mps2+ 15 | TEST_PRODUCT = cc3x 16 | endif 17 | 18 | # Associated device identification info. 19 | CC_HW_VERSION = 0xFF 20 | CC_TEE_HW_INC_DIR = hw/include 21 | 22 | # max buffer size for DLLI 23 | DLLI_MAX_BUFF_SIZE = 0x10000 24 | 25 | # List of targets to build for host/src 26 | PROJ_TARGETS += cc3x_lib cc3x_productionlib tests pal 27 | PROJ_TESTS = integration_cc3x 28 | INTEG_TESTS = runtime_integration_test # cmpu_integration_test dmpu_integration_test 29 | 30 | # If the following flag = 1, then use specific ECC functions 31 | # with SCA protection on program level (different from HW level) 32 | CC_CONFIG_SUPPORT_ECC_SCA_SW_PROTECT = 0 33 | 34 | # Low level driver support 35 | FW_ENABLE_AES_DRIVER = 1 36 | 37 | CC_CONFIG_SB_CERT_VERSION_MAJOR = 1 38 | CC_CONFIG_SB_CERT_VERSION_MINOR = 0 39 | 40 | CFLAGS_EXTRA += -DCC_SRAM_INDIRECT_ACCESS 41 | CFLAGS_EXTRA += -DUSE_MBEDTLS_CRYPTOCELL 42 | 43 | ifneq (,$(findstring gnu,$(CROSS_COMPILE))) 44 | CFLAGS_EXTRA += -DMBEDTLS_CONFIG_FILE='' 45 | else 46 | CFLAGS_EXTRA += -DDX_PLAT_MPS2_PLUS 47 | CFLAGS_EXTRA += -DMBEDTLS_CONFIG_FILE='' 48 | endif 49 | 50 | -------------------------------------------------------------------------------- /shared/include/cc_lli_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef _CC_LLI_DEFS_H_ 9 | #define _CC_LLI_DEFS_H_ 10 | #ifdef __KERNEL__ 11 | #include 12 | #else 13 | #include 14 | #endif 15 | #include "cc_bitops.h" 16 | 17 | /* Max DLLI size */ 18 | #define DLLI_SIZE_BIT_SIZE 0x18 // DX_DSCRPTR_QUEUE_WORD1_DIN_SIZE_BIT_SIZE 19 | 20 | #define CC_MAX_MLLI_ENTRY_SIZE 0x10000 21 | 22 | #define LLI_SET_ADDR(lli_p, addr) \ 23 | BITFIELD_SET(((uint32_t *)(lli_p))[LLI_WORD0_OFFSET], LLI_LADDR_BIT_OFFSET, LLI_LADDR_BIT_SIZE, (addr & UINT32_MAX)); \ 24 | BITFIELD_SET(((uint32_t *)(lli_p))[LLI_WORD1_OFFSET], LLI_HADDR_BIT_OFFSET, LLI_HADDR_BIT_SIZE, ((addr >> 32) & UINT16_MAX)); 25 | 26 | #define LLI_SET_SIZE(lli_p, size) \ 27 | BITFIELD_SET(((uint32_t *)(lli_p))[LLI_WORD1_OFFSET], LLI_SIZE_BIT_OFFSET, LLI_SIZE_BIT_SIZE, size) 28 | 29 | 30 | /* Size of entry */ 31 | #define LLI_ENTRY_WORD_SIZE 2 32 | #define LLI_ENTRY_BYTE_SIZE (LLI_ENTRY_WORD_SIZE * sizeof(uint32_t)) 33 | 34 | /* Word0[31:0] = ADDR[31:0] */ 35 | #define LLI_WORD0_OFFSET 0 36 | #define LLI_LADDR_BIT_OFFSET 0 37 | #define LLI_LADDR_BIT_SIZE 32 38 | /* Word1[31:16] = ADDR[47:32]; Word1[15:0] = SIZE */ 39 | #define LLI_WORD1_OFFSET 1 40 | #define LLI_SIZE_BIT_OFFSET 0 41 | #define LLI_SIZE_BIT_SIZE 16 42 | #define LLI_HADDR_BIT_OFFSET 16 43 | #define LLI_HADDR_BIT_SIZE 16 44 | 45 | 46 | #endif /*_CC_LLI_DEFS_H_*/ 47 | -------------------------------------------------------------------------------- /utils/src/cc3x_boot_cert/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for managing SBU build and installation 3 | ifeq ($(CC_CONFIG_SB_X509_CERT_SUPPORTED),1) 4 | SUB_DIRS_PREFIX = x509cert 5 | else 6 | SUB_DIRS_PREFIX = cert 7 | endif 8 | 9 | $(info $$SUB_DIRS_PREFIX is [${SUB_DIRS_PREFIX}]) 10 | 11 | # shared library to build 12 | SBU_ROOT = $(shell pwd) 13 | UTIL_ROOT = $(SBU_ROOT)/../.. 14 | SBU_CRYP_LIB_PATH = $(SUB_DIRS_PREFIX)_lib 15 | SBU_CRYP_LIB_NAME = libsbu_crypto.so 16 | SBU_SCRIPTS_DIRNAME = $(SUB_DIRS_PREFIX)_utils 17 | SBU_COMMON_SCRIPTS_DIRNAME = common_utils 18 | 19 | DEPENDENCY_ON_EXISTENCE_OF = $(filter-out $(wildcard $(1)), $(1)) 20 | 21 | INSTALL_LIST = install_lib install_sbu 22 | 23 | all: $(INSTALL_LIST) 24 | 25 | install_lib: build_lib $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTIL_ROOT)/lib) 26 | @echo Installing sbu_crypto library 27 | @cp $(SBU_ROOT)/$(SBU_CRYP_LIB_PATH)/$(SBU_CRYP_LIB_NAME) $(UTIL_ROOT)/lib 28 | 29 | build_lib: 30 | @make -C $(SBU_ROOT)/$(SBU_CRYP_LIB_PATH) 31 | 32 | 33 | install_sbu: $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTIL_ROOT)/bin) $(call DEPENDENCY_ON_EXISTENCE_OF,$(UTIL_ROOT)/bin/$(SBU_COMMON_SCRIPTS_DIRNAME)) 34 | @echo Installing SBU scripts 35 | @cp $(SBU_ROOT)/$(SBU_SCRIPTS_DIRNAME)/*.py $(UTIL_ROOT)/bin 36 | @cp $(SBU_ROOT)/$(SBU_COMMON_SCRIPTS_DIRNAME)/*.py $(UTIL_ROOT)/bin/$(SBU_COMMON_SCRIPTS_DIRNAME) 37 | 38 | $(UTIL_ROOT)/%: 39 | @echo Creating directory $@ 40 | @mkdir $@ 41 | 42 | 43 | 44 | 45 | clean: 46 | @make -C $(SBU_CRYP_LIB_PATH) clean 47 | 48 | .PHONY: install_lib install_sbu clean 49 | 50 | 51 | -------------------------------------------------------------------------------- /shared/include/pal/cc_pal_dma_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | /*! 9 | @file 10 | @brief This file contains the platform-dependent DMA definitions. 11 | @defgroup ssi_pal_dma_defs CryptoCell PAL DMA specific definitions 12 | @{ 13 | @ingroup ssi_pal 14 | */ 15 | 16 | #ifndef _CC_PAL_DMA_DEFS_H 17 | #define _CC_PAL_DMA_DEFS_H 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | /*! Definition for DMA buffer handle.*/ 26 | typedef void *CC_PalDmaBufferHandle; 27 | 28 | /*! DMA directions configuration. */ 29 | typedef enum { 30 | CC_PAL_DMA_DIR_NONE = 0, /*!< No direction. */ 31 | CC_PAL_DMA_DIR_TO_DEVICE = 1, /*!< The original buffer is the input to the operation. It should be copied or mapped to the temporary buffer prior to activating the HW on it. */ 32 | CC_PAL_DMA_DIR_FROM_DEVICE = 2, /*!< The temporary buffer holds the output of the HW. This API should copy or map it to the original output buffer.*/ 33 | CC_PAL_DMA_DIR_BI_DIRECTION = 3, /*!< The result is written over the original data at the same address. Should be treated as \p CC_PAL_DMA_DIR_TO_DEVICE and \p CC_PAL_DMA_DIR_FROM_DEVICE.*/ 34 | CC_PAL_DMA_DIR_MAX, /*!< Maximal DMA direction options. */ 35 | CC_PAL_DMA_DIR_RESERVE32 = 0x7FFFFFFF /*!< Reserved.*/ 36 | }CCPalDmaBufferDirection_t; 37 | 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | /** 43 | @} 44 | */ 45 | #endif 46 | 47 | 48 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/cc3x_sym/driver/bypass_driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _BYPASS_DRIVER_H 8 | #define _BYPASS_DRIVER_H 9 | 10 | #include "driver_defs.h" 11 | 12 | /****************************************************************************** 13 | * FUNCTION PROTOTYPES 14 | ******************************************************************************/ 15 | /****************************************************************************************************/ 16 | /** 17 | * @brief This function is used to perform the BYPASS operation in one integrated process. 18 | * 19 | * 20 | * @param[in] pInputBuffInfo A structure which represents the data input buffer. 21 | * @param[in] inputDataAddrType - the memory address input type: SRAM_ADDR or DLLI_ADDR. 22 | * @param[in] pOutputBuffInfo A structure which represents the data output buffer. 23 | * @param[in] outputDataAddrType - the memory address input type: SRAM_ADDR or DLLI_ADDR. 24 | * @param[in] blockSize - number of bytes to copy. 25 | * 26 | * @return drvError_t - On success BYPASS_DRV_OK is returned, on failure a value defined in driver_defs.h 27 | * 28 | */ 29 | drvError_t ProcessBypass(CCBuffInfo_t *pInputBuffInf, dataAddrType_t inputDataAddrType, 30 | CCBuffInfo_t *pOutputBuffInfo, dataAddrType_t outputDataAddrType, 31 | uint32_t blockSize); 32 | 33 | #endif /* _BYPASS_DRIVER_H */ 34 | 35 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/pki/rsa/rsa_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | #ifndef LLF_RSA_PRIVATE_H 9 | #define LLF_RSA_PRIVATE_H 10 | 11 | /* 12 | * All the includes that are needed for code using this module to 13 | * compile correctly should be #included here. 14 | */ 15 | 16 | #include "cc_error.h" 17 | #include "cc_rsa_types.h" 18 | 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | 26 | typedef union { 27 | struct { 28 | /* the Barrett mod N tag NP for N-modulus - used in the modular multiplication and 29 | exponentiation, calculated in CC_RsaPrivKeyBuild function */ 30 | uint32_t NP[CC_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; 31 | 32 | }NonCrt; 33 | 34 | struct { 35 | /* the Barrett mod P tag PP for P-factor - used in the modular multiplication and 36 | exponentiation, calculated in CC_RsaPrivKeyBuild function */ 37 | uint32_t PP[CC_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; 38 | 39 | /* the Barrett mod Q tag QP for Q-factor - used in the modular multiplication and 40 | exponentiation, calculated in CC_RsaPubKeyBuild function */ 41 | uint32_t QP[CC_PKA_BARRETT_MOD_TAG_BUFF_SIZE_IN_WORDS]; 42 | 43 | }Crt; 44 | 45 | }RsaPrivKeyDb_t; 46 | 47 | CCError_t RsaInitPrivKeyDb(CCRsaPrivKey_t *pPrivKey); 48 | 49 | CCError_t RsaExecPrivKeyExp(CCRsaPrivKey_t *pPrivKey, 50 | CCRsaPrimeData_t *pPrivData); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /utils/src/common/common_crypto_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _COMMON_CRYPTO_ENCODE_H 8 | #define _COMMON_CRYPTO_ENCODE_H 9 | 10 | #include 11 | 12 | #define CC_COMMON_CALC_BASE64_ENCODE_SIZE(origSize) ((((origSize+2)/3)*4)+1) 13 | #define CC_COMMON_CALC_BASE64_MAX_DECODE_SIZE(encodedSize) ((encodedSize*3)/4) /* max size in case no padding to encoded buffer */ 14 | 15 | /** 16 | * @brief performs base64-encode 17 | * 18 | * @param[in] pBuff - the buffer to encode 19 | * @param[in] buffLen - input buffer length 20 | * @param[in/out] pEncBuffLen - encoded buffer length 21 | * @param[out] pEncBuff - encoded buffer 22 | */ 23 | /*********************************************************/ 24 | int32_t CC_CommonBase64Encode(uint8_t *pBuff, 25 | uint32_t buffLen, 26 | uint8_t *pEncBuff, 27 | uint32_t *pEecBuffLen); 28 | 29 | 30 | /** 31 | * @brief performs base64-decode 32 | * 33 | * @param[in] pEncBuff - base64-encoded buffer 34 | * @param[in] encBuffLen - input buffer length 35 | * @param[in/out] pDecBuffLen - decoded buffer length 36 | * @param[out] pDecBuff - decoded buffer 37 | */ 38 | /*********************************************************/ 39 | int32_t CC_CommonBase64Decode(uint8_t *pEncBuff, 40 | uint32_t encBuffLen, 41 | uint8_t *pDecBuff, 42 | uint32_t *pDecBuffLen); 43 | 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /host/src/pal/freertos/cc_pal_fips.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | /************* Include Files ****************/ 9 | #include "cc_pal_types.h" 10 | #include "cc_pal_fips.h" 11 | #include "cc_pal_mem.h" 12 | 13 | CCFipsStateData_t gStateData = { CC_FIPS_STATE_CRYPTO_APPROVED, CC_TEE_FIPS_ERROR_OK, CC_FIPS_TRACE_NONE }; 14 | 15 | 16 | CCError_t CC_PalFipsWaitForReeStatus(void) 17 | { 18 | FipsSetReeStatus(CC_TEE_FIPS_REE_STATUS_OK); 19 | return CC_OK; 20 | } 21 | 22 | CCError_t CC_PalFipsStopWaitingRee(void) 23 | { 24 | return CC_OK; 25 | } 26 | 27 | CCError_t CC_PalFipsGetState(CCFipsState_t *pFipsState) 28 | { 29 | *pFipsState = gStateData.state; 30 | 31 | return CC_OK; 32 | } 33 | 34 | 35 | CCError_t CC_PalFipsGetError(CCFipsError_t *pFipsError) 36 | { 37 | *pFipsError = gStateData.error; 38 | 39 | return CC_OK; 40 | } 41 | 42 | 43 | CCError_t CC_PalFipsGetTrace(CCFipsTrace_t *pFipsTrace) 44 | { 45 | *pFipsTrace = gStateData.trace; 46 | 47 | return CC_OK; 48 | } 49 | 50 | CCError_t CC_PalFipsSetState(CCFipsState_t fipsState) 51 | { 52 | gStateData.state = fipsState; 53 | 54 | return CC_OK; 55 | } 56 | 57 | CCError_t CC_PalFipsSetError(CCFipsError_t fipsError) 58 | { 59 | gStateData.error = fipsError; 60 | 61 | return CC_OK; 62 | } 63 | 64 | CCError_t CC_PalFipsSetTrace(CCFipsTrace_t fipsTrace) 65 | { 66 | gStateData.trace = (CCFipsTrace_t)(gStateData.trace | fipsTrace); 67 | 68 | return CC_OK; 69 | } 70 | 71 | -------------------------------------------------------------------------------- /shared/include/cc_util/cc_util_asset_prov_int.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef _CC_UTIL_ASSET_PROV_INT_H 8 | #define _CC_UTIL_ASSET_PROV_INT_H 9 | 10 | /*! 11 | @file 12 | @brief This file contains the functions and definitions for the ICV or OEM Asset provisioning in run-time library. 13 | */ 14 | 15 | #ifdef __cplusplus 16 | extern "C" 17 | { 18 | #endif 19 | #include "cc_pal_types.h" 20 | #include "cc_bitops.h" 21 | 22 | #define CC_ASSET_PROV_MAX_ASSET_SIZE (4*CC_1K_SIZE_IN_BYTES) 23 | 24 | #define CC_ASSET_PROV_TOKEN 0x41736574UL 25 | #define CC_ASSET_PROV_VERSION 0x10000UL 26 | 27 | #define CC_ASSET_PROV_NONCE_SIZE 12 28 | #define CC_ASSET_PROV_RESERVED_SIZE 8 29 | #define CC_ASSET_PROV_RESERVED_WORD_SIZE (CC_ASSET_PROV_RESERVED_SIZE/CC_32BIT_WORD_SIZE) 30 | #define CC_ASSET_PROV_TAG_SIZE 16 31 | #define CC_ASSET_PROV_BLOCK_SIZE 16 32 | 33 | #define CC_ASSET_PROV_ADATA_SIZE (3*CC_32BIT_WORD_SIZE+CC_ASSET_PROV_RESERVED_SIZE) // token||version||assetSize||reserved 34 | 35 | 36 | typedef struct { 37 | uint32_t token; 38 | uint32_t version; 39 | uint32_t assetSize; 40 | uint32_t reserved[CC_ASSET_PROV_RESERVED_WORD_SIZE]; 41 | uint8_t nonce[CC_ASSET_PROV_NONCE_SIZE]; 42 | uint8_t encAsset[CC_ASSET_PROV_MAX_ASSET_SIZE+CC_ASSET_PROV_TAG_SIZE]; 43 | }CCAssetProvPkg_t; 44 | 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /*_CC_UTIL_ASSET_PROV_INT_H*/ 51 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/linux/test_pal_cli.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include "test_pal_cli.h" 16 | 17 | /******************************************************************************/ 18 | uint32_t Test_PalCLIRegisterCommand(struct Test_PalCliCommand *commandToRegister) 19 | { 20 | (void)commandToRegister; 21 | return 0; 22 | } 23 | 24 | /******************************************************************************/ 25 | const char *Test_PalCLIGetParameter(const char *commandString, 26 | uint32_t wantedParamIndx, uint32_t *paramStringLength) 27 | { 28 | (void)commandString; 29 | (void)wantedParamIndx; 30 | (void)paramStringLength; 31 | return NULL; 32 | } 33 | -------------------------------------------------------------------------------- /host/src/tests/TestAL/pal/linux/test_pal_time.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * The confidential and proprietary information contained in this file may * 3 | * only be used by a person authorised under and to the extent permitted * 4 | * by a subsisting licensing agreement from ARM Limited or its affiliates. * 5 | * (C) COPYRIGHT [2001-2017] ARM Limited or its affiliates. * 6 | * ALL RIGHTS RESERVED * 7 | * This entire notice must be reproduced on all copies of this file * 8 | * and copies of this file may only be made by a person if such person is * 9 | * permitted to do so under the terms of a subsisting license agreement * 10 | * from ARM Limited or its affiliates. * 11 | *******************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include "test_pal_time.h" 17 | 18 | /******************************************************************************/ 19 | void Test_PalDelay(const uint32_t usec) 20 | { 21 | usleep(usec); 22 | } 23 | 24 | /******************************************************************************/ 25 | uint32_t Test_PalGetTimestamp(void) 26 | { 27 | struct timeval te; 28 | uint32_t ms; 29 | 30 | /* Gets current time */ 31 | gettimeofday(&te, NULL); 32 | 33 | /* Calculates timestamp in milliseconds */ 34 | ms = te.tv_sec*1000LL + te.tv_usec/1000; 35 | 36 | return ms; 37 | } 38 | -------------------------------------------------------------------------------- /host/src/cc3x_lib/cc_plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | #ifndef CC_PLAT_H 8 | #define CC_PLAT_H 9 | 10 | #define NULL_SRAM_ADDR ((CCSramAddr_t)0xFFFFFFFF) 11 | 12 | #define _WriteWordsToSram(addr, data, size) \ 13 | do { \ 14 | uint32_t ii; \ 15 | volatile uint32_t dummy; \ 16 | CC_HAL_WRITE_REGISTER( CC_REG_OFFSET (HOST_RGF,SRAM_ADDR), (addr)); \ 17 | for( ii = 0 ; ii < size/sizeof(uint32_t) ; ii++ ) { \ 18 | CC_HAL_WRITE_REGISTER( CC_REG_OFFSET (HOST_RGF,SRAM_DATA), SWAP_TO_LE(((uint32_t *)data)[ii])); \ 19 | do { \ 20 | dummy = CC_HAL_READ_REGISTER( CC_REG_OFFSET (HOST_RGF, SRAM_DATA_READY)); \ 21 | }while(!(dummy & 0x1)); \ 22 | } \ 23 | }while(0) 24 | 25 | #define _ReadWordsFromSram( addr , data , size ) \ 26 | do { \ 27 | uint32_t ii; \ 28 | volatile uint32_t dummy; \ 29 | CC_HAL_WRITE_REGISTER( CC_REG_OFFSET (HOST_RGF,SRAM_ADDR) ,(addr) ); \ 30 | dummy = CC_HAL_READ_REGISTER( CC_REG_OFFSET (HOST_RGF,SRAM_DATA)); \ 31 | for( ii = 0 ; ii < size/sizeof(uint32_t) ; ii++ ) { \ 32 | do { \ 33 | dummy = CC_HAL_READ_REGISTER( CC_REG_OFFSET (HOST_RGF, SRAM_DATA_READY)); \ 34 | }while(!(dummy & 0x1)); \ 35 | dummy = CC_HAL_READ_REGISTER( CC_REG_OFFSET (HOST_RGF,SRAM_DATA));\ 36 | ((uint32_t*)data)[ii] = SWAP_TO_LE(dummy); \ 37 | } \ 38 | do { \ 39 | dummy = CC_HAL_READ_REGISTER( CC_REG_OFFSET (HOST_RGF, SRAM_DATA_READY)); \ 40 | }while(!(dummy & 0x1)); \ 41 | }while(0) 42 | 43 | #define CLEAR_TRNG_SRC() 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /host/src/tests/integration_cc3x/runtime_integration_test/README.txt: -------------------------------------------------------------------------------- 1 | The purpose of the integration tests is to test and verify the user's system integration, 2 | including the CryptoCell hardware and Software, 3 | including the HAL and PAL layers required by the cc_lib. 4 | The HAL and PAL layers are assumed to be implemented by the user for the user's system. 5 | 6 | These integration tests use simple scenarios for verifying successful 7 | integration of Arm's product on the customer's platform. 8 | 9 | The user is advised to read the following: 10 | - Chapter "Appendix C - Integration test" in the Software Integrators Manual 11 | document, in order to implement a subset of a function to serve as an 12 | abstraction layer between the integration test and the operating system of the user's choice. 13 | - Chapter "2.2.1 Unpacking the shipment" in the Release Notes document - for 14 | the compilation process of the supplied code, which is as an example only. 15 | 16 | 17 | The integration tests package was tested for the following environment: 18 | . MPS2+ board, deployed with Cortex M3. 19 | . Customized FreeRTOS 20 | . arm-compiler-5 5.06 compiler. 21 | 22 | Assumptions : 23 | 1. The user created a dedicated PAL and HAL layers, which match the user's platform. 24 | 2. The user compiled mbedtls libraries (according to the instructions in the Release Notes). 25 | 4. The code is extracted and compiled according to the description in the Release Notes document. 26 | 5. The environment variables CROSS_COMPILE,KERNEL_DIR, ARCH and CORTEX are set prior to the compilation. 27 | 28 | -------------------------------------------------------------------------------- /shared/src/proj/cc3x/cc_hash_info.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | /* this file contains the definitions of the hashes used in the rsa */ 8 | 9 | #include "cc_hash_defs.h" 10 | #include "cc_general_defs.h" 11 | 12 | const HmacHash_t HmacHashInfo_t[CC_HASH_NumOfModes] = { 13 | /*CC_HASH_SHA1_mode */ {CC_HASH_SHA1_DIGEST_SIZE_IN_BYTES, CC_HASH_SHA1_mode}, 14 | /*CC_HASH_SHA224_mode */ {CC_HASH_SHA224_DIGEST_SIZE_IN_BYTES, CC_HASH_SHA224_mode}, 15 | /*CC_HASH_SHA256_mode */ {CC_HASH_SHA256_DIGEST_SIZE_IN_BYTES, CC_HASH_SHA256_mode}, 16 | /*CC_HASH_SHA384_mode */ {CC_HASH_SHA384_DIGEST_SIZE_IN_BYTES, CC_HASH_SHA384_mode}, 17 | /*CC_HASH_SHA512_mode */ {CC_HASH_SHA512_DIGEST_SIZE_IN_BYTES, CC_HASH_SHA512_mode}, 18 | /*CC_HASH_MD5_mode */ {CC_HASH_MD5_DIGEST_SIZE_IN_BYTES, CC_HASH_MD5_mode}, 19 | }; 20 | 21 | const uint8_t HmacSupportedHashModes_t[CC_HASH_NumOfModes] = { 22 | /*CC_HASH_SHA1_mode */ CC_TRUE, 23 | /*CC_HASH_SHA224_mode */ CC_TRUE, 24 | /*CC_HASH_SHA256_mode */ CC_TRUE, 25 | /*CC_HASH_SHA384_mode */ CC_TRUE, 26 | /*CC_HASH_SHA512_mode */ CC_TRUE, 27 | /*CC_HASH_MD5_mode */ CC_FALSE, 28 | }; 29 | 30 | const char HashAlgMode2mbedtlsString[CC_HASH_NumOfModes][CC_HASH_NAME_MAX_SIZE] = { 31 | "SHA1", 32 | "SHA224", 33 | "SHA256", 34 | "SHA384", 35 | "SHA512", 36 | "MD5" 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /codesafe/src/crypto_api/ec_wrst/cc_ecpki_domain.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: BSD-3-Clause OR Arm’s non-OSI source license 5 | */ 6 | 7 | 8 | /************* Include Files ****************/ 9 | #include "cc_pal_mem.h" 10 | #include "cc_ecpki_types.h" 11 | #include "cc_common.h" 12 | #include "cc_common_math.h" 13 | #include "cc_ecpki_error.h" 14 | #include "cc_ecpki_local.h" 15 | #include "pki.h" 16 | #include "ec_wrst.h" 17 | #include "cc_ecpki_types.h" 18 | #include "cc_ecpki_error.h" 19 | #include "cc_fips_defs.h" 20 | #include "cc_ecpki_domains_defs.h" 21 | 22 | 23 | /************************ Defines ***************************************/ 24 | 25 | /************************ Enums *****************************************/ 26 | 27 | /************************ Typedefs **************************************/ 28 | 29 | /************************ Global Data ***********************************/ 30 | 31 | extern const getDomainFuncP ecDomainsFuncP[CC_ECPKI_DomainID_OffMode]; 32 | /************* Private function prototype *******************************/ 33 | 34 | /************************ Public Functions ******************************/ 35 | 36 | /** 37 | @brief the function returns the domain pointer 38 | @return return domain pointer 39 | 40 | */ 41 | const CCEcpkiDomain_t *CC_EcpkiGetEcDomain(CCEcpkiDomainID_t domainId) 42 | { 43 | if (domainId >= CC_ECPKI_DomainID_OffMode) { 44 | return NULL; 45 | } 46 | 47 | if (ecDomainsFuncP[domainId] == NULL) { 48 | return NULL; 49 | } 50 | 51 | return ((ecDomainsFuncP[domainId])()); 52 | } 53 | --------------------------------------------------------------------------------