-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add secure and crypto regression test. (#218)
1 parent
947608f
commit 162e03f
Showing
247 changed files
with
1,279,394 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /bin/bash | ||
|
||
$(dirname `realpath $0`)/../test/cmake/crypto/run.sh build all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /bin/bash | ||
|
||
$(dirname `realpath $0`)/../test/cmake/nx_secure/run.sh build all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /bin/bash | ||
|
||
CTEST_PARALLEL_LEVEL=4 $(dirname `realpath $0`)/../test/cmake/crypto/run.sh test all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /bin/bash | ||
|
||
CTEST_PARALLEL_LEVEL=4 $(dirname `realpath $0`)/../test/cmake/nx_secure/run.sh test all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR) | ||
cmake_policy(SET CMP0054 NEW) | ||
cmake_policy(SET CMP0057 NEW) | ||
cmake_policy(SET CMP0077 NEW) | ||
|
||
project(crypto_test LANGUAGES C) | ||
|
||
set(CPU_ARCH "linux") | ||
set(COMPILER "gnu") | ||
|
||
# Set build configurations | ||
set(BUILD_CONFIGURATIONS default_build_coverage fips_build_coverage | ||
standalone_build curve25519_448_build) | ||
set(CMAKE_CONFIGURATION_TYPES | ||
${BUILD_CONFIGURATIONS} | ||
CACHE STRING "list of supported configuration types" FORCE) | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
${CMAKE_CONFIGURATION_TYPES}) | ||
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE) | ||
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST | ||
CMAKE_CONFIGURATION_TYPES))) | ||
set(CMAKE_BUILD_TYPE | ||
"${BUILD_TYPE}" | ||
CACHE STRING "Build Type of the project" FORCE) | ||
endif() | ||
|
||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") | ||
|
||
set(default_build_coverage "") | ||
set(fips_build_coverage -DNX_CRYPTO_SELF_TEST) | ||
set(standalone_build -DNX_CRYPTO_STANDALONE_ENABLE -DNX_CRYPTO_SELF_TEST) | ||
set(curve25519_448_build -DNX_CRYPTO_ENABLE_CURVE25519_448) | ||
|
||
add_compile_options( | ||
-std=c99 | ||
-ggdb | ||
-g3 | ||
-gdwarf-2 | ||
-fdiagnostics-color | ||
-Werror | ||
${${CMAKE_BUILD_TYPE}}) | ||
|
||
if($ENV{ENABLE_64}) | ||
message(STATUS "Building for 64bit") | ||
else() | ||
add_compile_options(-m32) | ||
add_link_options(-m32) | ||
message(STATUS "Building for 32bit") | ||
endif() | ||
|
||
enable_testing() | ||
|
||
set(NXD_ENABLE_FILE_SERVERS | ||
OFF | ||
CACHE BOOL | ||
"Includes a dependency on FileX to support 'server' protocol handlers" | ||
FORCE) | ||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../.. netxduo) | ||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/regression regression) | ||
|
||
|
||
# Coverage | ||
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") | ||
target_compile_options(netxduo PRIVATE -fprofile-arcs -ftest-coverage) | ||
target_link_options(netxduo PRIVATE -fprofile-arcs -ftest-coverage) | ||
endif() | ||
|
||
# Build ThreadX library once | ||
if(NOT ("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_build")) | ||
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh build_libs) | ||
add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh | ||
build_libs) | ||
add_dependencies(netxduo build_libs) | ||
target_include_directories(netxduo PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc) | ||
add_library(threadx SHARED IMPORTED GLOBAL) | ||
add_library("azrtos::threadx" ALIAS threadx) | ||
set_target_properties( | ||
threadx PROPERTIES IMPORTED_LOCATION | ||
${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so) | ||
endif() | ||
|
||
target_compile_options( | ||
netxduo | ||
PRIVATE -Werror | ||
-Wall | ||
-Wextra | ||
-pedantic | ||
-fmessage-length=0 | ||
-fsigned-char | ||
-ffunction-sections | ||
-fdata-sections | ||
-Wunused | ||
-Wuninitialized | ||
-Wmissing-declarations | ||
-Wconversion | ||
-Wpointer-arith | ||
-Wshadow | ||
-Wlogical-op | ||
-Waggregate-return | ||
-Wfloat-equal) | ||
|
||
# Leave files from crypto_libraries only | ||
get_target_property(SOURCES_LIST netxduo SOURCES) | ||
set(NEW_SOURCES_LIST "") | ||
foreach(SOURCE ${SOURCES_LIST}) | ||
if(("${SOURCE}" MATCHES ".*crypto_libraries/.*") | ||
AND NOT (("${SOURCE}" MATCHES ".*nx_crypto_module_start.*") | ||
OR (("${SOURCE}" MATCHES ".*nx_crypto_generic_ciphersuites.*") | ||
AND ("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_build")))) | ||
list(APPEND NEW_SOURCES_LIST ${SOURCE}) | ||
endif() | ||
endforeach() | ||
set_target_properties(netxduo PROPERTIES SOURCES "${NEW_SOURCES_LIST}") | ||
|
||
if("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_build") | ||
set_target_properties(netxduo PROPERTIES INCLUDE_DIRECTORIES | ||
"${CMAKE_CURRENT_SOURCE_DIR}/../../../crypto_libraries/inc") | ||
target_include_directories(netxduo PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../../crypto_libraries/ports/${CPU_ARCH}/${COMPILER}/inc") | ||
set_target_properties(netxduo PROPERTIES LINK_LIBRARIES "") | ||
set_target_properties(netxduo PROPERTIES INTERFACE_LINK_LIBRARIES "") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
cd $(dirname $0) | ||
mkdir -p coverage_report/$1 | ||
gcovr --object-directory=build/$1/netxduo/CMakeFiles/netxduo.dir/crypto_libraries -r ../../../crypto_libraries --xml-pretty --output coverage_report/$1.xml | ||
gcovr --object-directory=build/$1/netxduo/CMakeFiles/netxduo.dir/crypto_libraries -r ../../../crypto_libraries --html --html-details --output coverage_report/$1/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../nx_secure/libs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) | ||
cmake_policy(SET CMP0057 NEW) | ||
|
||
project(regression_test LANGUAGES C) | ||
|
||
get_filename_component(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../regression/nx_secure_test | ||
ABSOLUTE) | ||
|
||
set(crypto_test_cases | ||
${SOURCE_DIR}/nx_secure_3des_test.c | ||
${SOURCE_DIR}/nx_secure_3des_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_sha_additional_test.c | ||
${SOURCE_DIR}/nx_secure_sha256_rfc_test.c | ||
${SOURCE_DIR}/nx_secure_sha256_test.c | ||
${SOURCE_DIR}/nx_secure_sha384_test.c | ||
${SOURCE_DIR}/nx_secure_sha512_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_md5_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_md5_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha1_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha256_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha384_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha512_test.c | ||
${SOURCE_DIR}/nx_secure_rsa_test.c | ||
${SOURCE_DIR}/nx_secure_rsa_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_aes_test.c | ||
${SOURCE_DIR}/nx_secure_aes_additional_test.c | ||
${SOURCE_DIR}/nx_secure_aes_ccm_test.c | ||
${SOURCE_DIR}/nx_secure_des_test.c | ||
${SOURCE_DIR}/nx_secure_des_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_drbg_test.c | ||
${SOURCE_DIR}/nx_secure_ec_test.c | ||
${SOURCE_DIR}/nx_secure_ec_additional_test.c | ||
${SOURCE_DIR}/nx_secure_ecdh_test.c | ||
${SOURCE_DIR}/nx_secure_ecdh_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_ecdh_self_test.c | ||
${SOURCE_DIR}/nx_secure_ecdsa_test.c | ||
${SOURCE_DIR}/nx_secure_ecdsa_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_ecjpake_self_test.c | ||
${SOURCE_DIR}/nx_secure_huge_number_test.c | ||
${SOURCE_DIR}/nx_secure_md5_test.c | ||
${SOURCE_DIR}/nx_secure_phash_prf_test.c | ||
${SOURCE_DIR}/nx_secure_pkcs1_v1_5_test.c) | ||
set(test_utility_files ${SOURCE_DIR}/../crypto_test/cryptotestcontrol.c) | ||
if(("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_build")) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/crypto_standalone.cmake) | ||
endif() | ||
|
||
if(NOT("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_build")) | ||
add_library(test_utility ${test_utility_files}) | ||
target_link_libraries(test_utility PUBLIC azrtos::netxduo) | ||
else() | ||
add_library(test_utility ${crypto_source_files} ${test_utility_files}) | ||
endif() | ||
|
||
target_include_directories(test_utility PUBLIC ${SOURCE_DIR}/test) | ||
target_compile_definitions(test_utility PUBLIC BATCH_TEST CTEST) | ||
if(("${CMAKE_BUILD_TYPE}" STREQUAL "fips_build_coverage") OR ("${CMAKE_BUILD_TYPE}" STREQUAL "standalone_build")) | ||
target_link_libraries(test_utility PUBLIC crypto) | ||
endif() | ||
|
||
foreach(test_case ${crypto_test_cases}) | ||
get_filename_component(test_name ${test_case} NAME_WE) | ||
add_executable(${test_name} ${test_case}) | ||
target_link_libraries(${test_name} PRIVATE test_utility) | ||
add_test( | ||
NAME ${CMAKE_BUILD_TYPE}::${test_name} | ||
COMMAND ${test_name} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/..) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) | ||
set(CPU_ARCH "linux") | ||
set(COMPILER "gnu") | ||
|
||
get_filename_component(CRYPTO_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../crypto_libraries | ||
ABSOLUTE) | ||
|
||
set(crypto_source_files | ||
# Network security and crypto components (CRYPTO - STANDALONE) | ||
${CRYPTO_DIR}/src/nx_crypto_3des.c | ||
${CRYPTO_DIR}/src/nx_crypto_aes.c | ||
${CRYPTO_DIR}/src/nx_crypto_cbc.c | ||
${CRYPTO_DIR}/src/nx_crypto_ccm.c | ||
${CRYPTO_DIR}/src/nx_crypto_ctr.c | ||
${CRYPTO_DIR}/src/nx_crypto_des.c | ||
${CRYPTO_DIR}/src/nx_crypto_dh.c | ||
${CRYPTO_DIR}/src/nx_crypto_drbg.c | ||
${CRYPTO_DIR}/src/nx_crypto_ec.c | ||
${CRYPTO_DIR}/src/nx_crypto_ec_secp192r1_fixed_points.c | ||
${CRYPTO_DIR}/src/nx_crypto_ec_secp224r1_fixed_points.c | ||
${CRYPTO_DIR}/src/nx_crypto_ec_secp256r1_fixed_points.c | ||
${CRYPTO_DIR}/src/nx_crypto_ec_secp384r1_fixed_points.c | ||
${CRYPTO_DIR}/src/nx_crypto_ec_secp521r1_fixed_points.c | ||
${CRYPTO_DIR}/src/nx_crypto_ecdh.c | ||
${CRYPTO_DIR}/src/nx_crypto_ecdsa.c | ||
${CRYPTO_DIR}/src/nx_crypto_ecjpake.c | ||
${CRYPTO_DIR}/src/nx_crypto_gcm.c | ||
${CRYPTO_DIR}/src/nx_crypto_hkdf.c | ||
${CRYPTO_DIR}/src/nx_crypto_hmac.c | ||
${CRYPTO_DIR}/src/nx_crypto_hmac_md5.c | ||
${CRYPTO_DIR}/src/nx_crypto_hmac_sha1.c | ||
${CRYPTO_DIR}/src/nx_crypto_hmac_sha2.c | ||
${CRYPTO_DIR}/src/nx_crypto_hmac_sha5.c | ||
${CRYPTO_DIR}/src/nx_crypto_huge_number.c | ||
${CRYPTO_DIR}/src/nx_crypto_huge_number_extended.c | ||
${CRYPTO_DIR}/src/nx_crypto_initialize.c | ||
${CRYPTO_DIR}/src/nx_crypto_md5.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_3des.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_aes.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_des.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_drbg.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_ecdh.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_ecdsa.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_hmac_md5.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_hmac_sha.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_md5.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_pkcs1.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_prf.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_rsa.c | ||
${CRYPTO_DIR}/src/nx_crypto_method_self_test_sha.c | ||
${CRYPTO_DIR}/src/nx_crypto_methods.c | ||
${CRYPTO_DIR}/src/nx_crypto_null_cipher.c | ||
${CRYPTO_DIR}/src/nx_crypto_phash.c | ||
${CRYPTO_DIR}/src/nx_crypto_pkcs1_v1.5.c | ||
${CRYPTO_DIR}/src/nx_crypto_rsa.c | ||
${CRYPTO_DIR}/src/nx_crypto_sha1.c | ||
${CRYPTO_DIR}/src/nx_crypto_sha2.c | ||
${CRYPTO_DIR}/src/nx_crypto_sha5.c | ||
${CRYPTO_DIR}/src/nx_crypto_tls_prf_1.c | ||
${CRYPTO_DIR}/src/nx_crypto_tls_prf_sha256.c | ||
${CRYPTO_DIR}/src/nx_crypto_tls_prf_sha384.c | ||
${CRYPTO_DIR}/src/nx_crypto_tls_prf_sha512.c | ||
${CRYPTO_DIR}/src/nx_crypto_xcbc_mac.c) | ||
|
||
include_directories(crypto_source_files PUBLIC ${CRYPTO_DIR}/inc) | ||
include_directories(crypto_source_files PUBLIC "${CRYPTO_DIR}/ports/${CPU_ARCH}/${COMPILER}/inc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
cd $(dirname $0) | ||
|
||
# if threadx repo does not exist, clone it | ||
[ -d ../threadx ] || git clone https://github.com/azure-rtos/threadx.git ../threadx --depth 1 | ||
[ -f .run.sh ] || ln -sf ../threadx/scripts/cmake_bootstrap.sh .run.sh | ||
./.run.sh $* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR) | ||
cmake_policy(SET CMP0054 NEW) | ||
cmake_policy(SET CMP0057 NEW) | ||
cmake_policy(SET CMP0077 NEW) | ||
|
||
project(nx_secure_test LANGUAGES C) | ||
|
||
# Set build configurations | ||
set(BUILD_CONFIGURATIONS | ||
default_build_coverage | ||
psk_build_coverage | ||
tls_1_0_enable_build | ||
tls_1_1_enable_build | ||
tls_1_3_enable_build_coverage | ||
client_disable_build | ||
server_disable_build | ||
tls_1_3_client_disable_build | ||
tls_1_3_server_disable_build | ||
ecjpake_build | ||
dtls_build_coverage | ||
eal4_build_coverage | ||
sesip_build_coverage | ||
no_ecc_build_coverage | ||
no_renegotiation_build | ||
no_client_renegotiation_build | ||
no_x509_build | ||
hash_clone_build | ||
curve25519_448_build) | ||
set(CMAKE_CONFIGURATION_TYPES | ||
${BUILD_CONFIGURATIONS} | ||
CACHE STRING "list of supported configuration types" FORCE) | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS | ||
${CMAKE_CONFIGURATION_TYPES}) | ||
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE) | ||
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST | ||
CMAKE_CONFIGURATION_TYPES))) | ||
set(CMAKE_BUILD_TYPE | ||
"${BUILD_TYPE}" | ||
CACHE STRING "Build Type of the project" FORCE) | ||
endif() | ||
|
||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") | ||
|
||
set(default_build_coverage -DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY -DNX_DISABLE_ASSERT) | ||
set(psk_build_coverage | ||
-DNX_SECURE_ENABLE_PSK_CIPHERSUITES -DNX_SECURE_ENABLE_AEAD_CIPHER | ||
-DNX_SECURE_X509_DISABLE_CRL) | ||
set(tls_1_3_enable_build_coverage | ||
-DNX_SECURE_TLS_ENABLE_TLS_1_3 | ||
-DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY | ||
-DNX_SECURE_ENABLE_PSK_CIPHERSUITES) | ||
set(tls_1_1_enable_build -DNX_SECURE_TLS_ENABLE_TLS_1_1 | ||
-DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY) | ||
set(tls_1_0_enable_build | ||
-DNX_SECURE_TLS_ENABLE_TLS_1_0 -DNX_SECURE_TLS_ENABLE_TLS_1_1 | ||
-DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY) | ||
set(client_disable_build -DNX_SECURE_TLS_CLIENT_DISABLED) | ||
set(server_disable_build -DNX_SECURE_TLS_SERVER_DISABLED) | ||
set(tls_1_3_client_disable_build -DNX_SECURE_TLS_ENABLE_TLS_1_3 -DNX_SECURE_TLS_CLIENT_DISABLED) | ||
set(tls_1_3_server_disable_build -DNX_SECURE_TLS_ENABLE_TLS_1_3 -DNX_SECURE_TLS_SERVER_DISABLED) | ||
set(dtls_build_coverage | ||
-DNX_SECURE_ENABLE_DTLS -DNX_SECURE_ENABLE_PSK_CIPHERSUITES | ||
-DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY -DNX_SECURE_TLS_ENABLE_TLS_1_1) | ||
set(ecjpake_build | ||
-DNX_SECURE_ENABLE_DTLS -DNX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE | ||
-DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY) | ||
set(eal4_build_coverage | ||
-DNX_SECURE_KEY_CLEAR -DNX_SECURE_POWER_ON_SELF_TEST_MODULE_INTEGRITY_CHECK | ||
-DCERT_BUILD -DNX_SECURE_DISABLE_ECC_CIPHERSUITE) | ||
set(sesip_build_coverage | ||
-DNX_SECURE_KEY_CLEAR -DNX_SECURE_POWER_ON_SELF_TEST_MODULE_INTEGRITY_CHECK | ||
-DNX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION -DNX_SECURE_TLS_ENABLE_TLS_1_3) | ||
set(no_ecc_build_coverage | ||
-DNX_SECURE_DISABLE_ECC_CIPHERSUITE | ||
-DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY | ||
-DNX_SECURE_ENABLE_PSK_CIPHERSUITES | ||
-DNX_SECURE_ENABLE_AEAD_CIPHER | ||
-DNX_SECURE_TLS_ENABLE_TLS_1_0 | ||
-DNX_SECURE_ENABLE_DTLS | ||
-DNX_SECURE_ENABLE_ECJPAKE_CIPHERSUITE) | ||
set(no_renegotiation_build -DNX_SECURE_TLS_DISABLE_SECURE_RENEGOTIATION -DNX_SECURE_TLS_SNI_EXTENSION_DISABLED -DNX_SECURE_TLS_USE_SCSV_CIPHPERSUITE) | ||
set(no_client_renegotiation_build -DNX_SECURE_TLS_DISABLE_CLIENT_INITIATED_RENEGOTIATION) | ||
set(no_x509_build | ||
-DNX_SECURE_ENABLE_PSK_CIPHERSUITES -DNX_SECURE_ENABLE_AEAD_CIPHER | ||
-DNX_SECURE_DISABLE_X509 -DNX_SECURE_DISABLE_ECC_CIPHERSUITE) | ||
set(hash_clone_build -DNX_SECURE_INCLUDE_USER_DEFINE_FILE -DHASH_CLONE_BUILD) | ||
set(curve25519_448_build | ||
-DNX_CRYPTO_ENABLE_CURVE25519_448 | ||
-DNX_SECURE_TLS_ENABLE_TLS_1_3 | ||
-DNX_SECURE_ENABLE_CLIENT_CERTIFICATE_VERIFY | ||
-DNX_SECURE_ENABLE_PSK_CIPHERSUITES) | ||
|
||
add_compile_options( | ||
-ggdb | ||
-g3 | ||
-gdwarf-2 | ||
-fdiagnostics-color | ||
-Werror | ||
-DTX_INCLUDE_USER_DEFINE_FILE | ||
-DNX_SECURE_X509_STRICT_NAME_COMPARE | ||
-DNX_SECURE_ALLOW_SELF_SIGNED_CERTIFICATES | ||
-DNX_ENABLE_EXTENDED_NOTIFY_SUPPORT | ||
${${CMAKE_BUILD_TYPE}}) | ||
|
||
if($ENV{ENABLE_64}) | ||
message(STATUS "Building for 64bit") | ||
else() | ||
add_compile_options(-m32) | ||
add_link_options(-m32) | ||
message(STATUS "Building for 32bit") | ||
endif() | ||
|
||
enable_testing() | ||
|
||
|
||
if("s${CMAKE_BUILD_TYPE}" STREQUAL "shash_clone_build") | ||
include_directories(${CMAKE_CURRENT_LIST_DIR}/../../regression/nx_secure_test/hash_clone) | ||
endif() | ||
|
||
set(NXD_ENABLE_FILE_SERVERS OFF CACHE BOOL "Includes a dependency on FileX to support 'server' protocol handlers" FORCE) | ||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../.. netxduo) | ||
add_subdirectory(${PROJECT_SOURCE_DIR}/regression regression) | ||
|
||
# Coverage | ||
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage") | ||
target_compile_options(netxduo PRIVATE -fprofile-arcs -ftest-coverage) | ||
target_link_options(netxduo PRIVATE -fprofile-arcs -ftest-coverage) | ||
endif() | ||
|
||
# Build ThreadX library once | ||
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh build_libs) | ||
add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run.sh | ||
build_libs) | ||
add_dependencies(netxduo build_libs) | ||
target_include_directories(netxduo PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc) | ||
add_library(threadx SHARED IMPORTED GLOBAL) | ||
add_library("azrtos::threadx" ALIAS threadx) | ||
set_target_properties( | ||
threadx PROPERTIES IMPORTED_LOCATION | ||
${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so) | ||
|
||
target_compile_options( | ||
netxduo | ||
PRIVATE -Wall | ||
-Wextra | ||
-pedantic | ||
-fmessage-length=0 | ||
-fsigned-char | ||
-ffunction-sections | ||
-fdata-sections | ||
-Wunused | ||
-Wuninitialized | ||
-Wmissing-declarations | ||
-Wconversion | ||
-Wpointer-arith | ||
-Wshadow | ||
-Wlogical-op | ||
-Waggregate-return | ||
-Wfloat-equal | ||
-std=c99) | ||
|
||
# Remove addons | ||
get_target_property(SOURCES_LIST netxduo SOURCES) | ||
set(NEW_SOURCES_LIST "") | ||
foreach(SOURCE ${SOURCES_LIST}) | ||
if(NOT ("${SOURCE}" MATCHES ".*addons.*")) | ||
list(APPEND NEW_SOURCES_LIST ${SOURCE}) | ||
endif() | ||
endforeach() | ||
set_target_properties(netxduo PROPERTIES SOURCES "${NEW_SOURCES_LIST}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
cd $(dirname $0) | ||
root_path=$(cd ../../../nx_secure/src; pwd) | ||
mkdir -p coverage_report/$1 | ||
extra_args="" | ||
if [ "$1" == "default_build_coverage" ]; | ||
then | ||
exclude_list="nx*_secure_dtls_*.c \ | ||
nx_secure_tls_server_handshake.c \ | ||
nx_secure_tls_process_clienthello.c \ | ||
nx_secure_tls_1_3_server_handshake.c \ | ||
nx_secure_tls_send_server* \ | ||
nx_secure_tls_process_client*" | ||
for e in $exclude_list | ||
do | ||
for f in $(ls $root_path/$e); | ||
do | ||
extra_args+="-e $f " | ||
done | ||
done | ||
fi | ||
gcovr --object-directory=build/$1/netxduo/CMakeFiles/netxduo.dir/nx_secure -r ../../../nx_secure --xml-pretty $extra_args --output coverage_report/$1.xml | ||
gcovr --object-directory=build/$1/netxduo/CMakeFiles/netxduo.dir/nx_secure -r ../../../nx_secure --html --html-details $extra_args --output coverage_report/$1/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR) | ||
|
||
project(libs LANGUAGES C) | ||
|
||
if(DEFINED ENV{ENABLE_64}) | ||
message(STATUS "Building for 64bit") | ||
else() | ||
add_compile_options(-m32) | ||
add_link_options(-m32) | ||
message(STATUS "Building for 32bit") | ||
endif() | ||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") | ||
|
||
get_filename_component( | ||
externals ${CMAKE_CURRENT_SOURCE_DIR}/../.. ABSOLUTE) | ||
add_subdirectory(${externals}/threadx threadx) | ||
if(NOT DEFINED ENV{ENABLE_IDLE}) | ||
target_compile_options(threadx PRIVATE -DTX_LINUX_NO_IDLE_ENABLE) | ||
endif() | ||
|
||
get_target_property(dirs threadx INCLUDE_DIRECTORIES) | ||
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/inc) | ||
foreach(dir ${dirs}) | ||
file(GLOB header_files ${dir}/*.h) | ||
foreach(header_file ${header_files}) | ||
execute_process(COMMAND ln -sf ${header_file} ${CMAKE_BINARY_DIR}/inc) | ||
endforeach() | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) | ||
cmake_policy(SET CMP0057 NEW) | ||
|
||
project(regression_test LANGUAGES C) | ||
|
||
get_filename_component(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../regression/nx_secure_test | ||
ABSOLUTE) | ||
|
||
set(nx_secure_test_cases | ||
${SOURCE_DIR}/nx_secure_tls_session_receive_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_send_record_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_client_handshake_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_finished_hash_generate_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_generate_keys_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_generate_premaster_secret_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_handshake_hash_init_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_generate_keys_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_session_renegotiate_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_session_keys_set_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_newest_supported_version_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_verify_mac_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_hash_record_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_x509_certificate_initialize_test.c | ||
${SOURCE_DIR}/nx_secure_x509_certificate_verify_test.c | ||
${SOURCE_DIR}/nx_secure_x509_crl_verify_test.c | ||
${SOURCE_DIR}/nx_secure_x509_parse_test.c | ||
${SOURCE_DIR}/nx_secure_x509_list_test.c | ||
${SOURCE_DIR}/nx_secure_x509_store_test.c | ||
${SOURCE_DIR}/nx_secure_x509_name_check_test.c | ||
${SOURCE_DIR}/nx_secure_x509_crl_test.c | ||
${SOURCE_DIR}/nx_secure_x509_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_x509_expiration_check_test.c | ||
${SOURCE_DIR}/nx_secure_x509_key_usage_test.c | ||
${SOURCE_DIR}/nx_secure_x509_pkcs7_decode_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_handshake_header_test.c | ||
${SOURCE_DIR}/nx_secure_tls_session_sni_extension_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_handshake_fragmentation_test.c | ||
${SOURCE_DIR}/nx_secure_tls_handshake_fragmentation_ecc_test.c | ||
${SOURCE_DIR}/nx_secure_tls_hash_clone_test.c | ||
${SOURCE_DIR}/nx_secure_tls_header_test.c | ||
${SOURCE_DIR}/nx_secure_tls_two_way_test.c | ||
${SOURCE_DIR}/nx_secure_tls_two_way_test_version_1_1.c | ||
${SOURCE_DIR}/nx_secure_tls_alert_test.c | ||
${SOURCE_DIR}/nx_secure_tls_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_tls_error_checking_2_test.c | ||
${SOURCE_DIR}/nx_secure_tls_tcp_fragment_test.c | ||
${SOURCE_DIR}/nx_secure_tls_user_defined_key_test.c | ||
${SOURCE_DIR}/nx_secure_tls_no_client_cert_test.c | ||
${SOURCE_DIR}/nx_secure_tls_metadata_size_test.c | ||
${SOURCE_DIR}/nx_secure_tls_multiple_handshake_msg_test.c | ||
${SOURCE_DIR}/nx_secure_tls_multithread_test.c | ||
${SOURCE_DIR}/nx_secure_distinguished_name_compare_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ciphersuites_test.c | ||
${SOURCE_DIR}/nx_secure_tls_client_handshake_test.c | ||
${SOURCE_DIR}/nx_secure_tls_clienthello_extension_test.c | ||
${SOURCE_DIR}/nx_secure_tls_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_coverage_2_test.c | ||
${SOURCE_DIR}/nx_secure_tls_coverage_3_test.c | ||
${SOURCE_DIR}/nx_secure_tls_handshake_fail_test.c | ||
${SOURCE_DIR}/nx_secure_tls_packet_chain_test.c | ||
${SOURCE_DIR}/nx_secure_tls_receive_alert_test.c | ||
${SOURCE_DIR}/nx_secure_tls_receive_test.c | ||
${SOURCE_DIR}/nx_secure_tls_record_decrypt_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_record_encrypt_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_record_layer_version_test.c | ||
${SOURCE_DIR}/nx_secure_tls_record_length_test.c | ||
${SOURCE_DIR}/nx_secure_tls_serverhello_extension_test.c | ||
${SOURCE_DIR}/nx_secure_tls_unrecognized_ciphersuites_test.c | ||
${SOURCE_DIR}/nx_secure_tls_unsupported_ciphersuites_test.c | ||
${SOURCE_DIR}/nx_secure_tls_non_blocking_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_basic_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_protocol_version_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_client_cert_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_ciphersuites_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_curves_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_crl_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_packet_chain_test.c | ||
${SOURCE_DIR}/nx_secure_tls_ecc_point_format_test.c | ||
${SOURCE_DIR}/nx_secure_tls_receive_wrong_packet_test.c | ||
${SOURCE_DIR}/nx_secure_tls_shutdown_test.c | ||
${SOURCE_DIR}/nx_secure_tls_session_delete_test.c | ||
${SOURCE_DIR}/nx_secure_tls_cert_verify_test.c | ||
${SOURCE_DIR}/nx_secure_tls_session_start_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_basic_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_error_checking_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_sliding_window_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_retransmit_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_retransmit_interval_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_retransmit_change_cipher_spec_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_ciphersuites_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_handshake_fail_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_ecjpake_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_sessions_receive_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_sessions_connect_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_sessions_reuse_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_sessions_connect_fail_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_sessions_send_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_sessions_retransmit_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_sessions_ecjpake_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_multiple_ip_address_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_no_free_sessions_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_concurrent_sessions_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_concurrent_sessions_retransmit_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_abort_waiting_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_fragment_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_abnormal_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_out_of_order_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_version_1_0_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_nxe_api_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_ecc_basic_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_ecc_ciphersuites_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_ecc_curves_test.c | ||
${SOURCE_DIR}/nx_secure_dtls_ecc_client_cert_test.c | ||
${SOURCE_DIR}/nx_secure_tls_nxe_api_test.c | ||
${SOURCE_DIR}/nx_secure_tls_server_handshake_test.c | ||
${SOURCE_DIR}/nx_secure_tls_cert_callback_fail_test.c | ||
${SOURCE_DIR}/nx_secure_tls_send_and_receive_record_test.c | ||
${SOURCE_DIR}/nx_secure_tls_branch_test.c | ||
${SOURCE_DIR}/nx_secure_crypto_self_test.c | ||
${SOURCE_DIR}/nx_secure_crypto_cleanup_test.c | ||
${SOURCE_DIR}/nx_secure_crypto_method_cleanup_test.c | ||
${SOURCE_DIR}/nx_secure_tls_certificate_verify_test.c | ||
${SOURCE_DIR}/nx_secure_tls_no_remote_certs_allocated_test.c | ||
${SOURCE_DIR}/nx_secure_tls_partial_remote_certs_allocated_test.c | ||
${SOURCE_DIR}/nx_secure_tls_process_certificate_verify_test.c | ||
${SOURCE_DIR}/nx_secure_tls_process_changecipherspec_test.c | ||
${SOURCE_DIR}/nx_secure_tls_process_certificate_request_test.c | ||
${SOURCE_DIR}/nx_secure_tls_process_finished_test.c | ||
${SOURCE_DIR}/nx_secure_tls_packet_trim_test.c | ||
${SOURCE_DIR}/nx_secure_tls_process_record_test.c | ||
${SOURCE_DIR}/nx_secure_tls_rsa_4096_test.c | ||
${SOURCE_DIR}/nx_secure_tls_rsa_private_key_test.c | ||
${SOURCE_DIR}/nx_secure_tls_serverhello_session_id_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_version_negotiation_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_handshake_fail_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_ciphersuites_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_clienthello_length_checking_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_key_share_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_provisioned_psk_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_hello_retry_cookie_test.c | ||
${SOURCE_DIR}/nx_secure_tls_client_ca_select_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_receive_invalid_server_handshake_message_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_invalid_client_state_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_serverhello_length_checking_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_session_create_ext_test.c | ||
${SOURCE_DIR}/nx_secure_tls_1_3_before_key_generation_test.c | ||
${SOURCE_DIR}/nx_secure_tls_send_plaintext_alert_after_key_generation_test.c | ||
${SOURCE_DIR}/nx_secure_tls_server_ciphersuite_priority_test.c | ||
${SOURCE_DIR}/nx_secure_tls_session_create_ext_test.c | ||
${SOURCE_DIR}/nx_secure_tls_transmit_mutex_wait_test.c | ||
${SOURCE_DIR}/nx_secure_tls_empty_clienthello_extension_test.c | ||
${SOURCE_DIR}/nx_secure_tls_payload_size_test.c | ||
${SOURCE_DIR}/nx_secure_tls_serverhello_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_hash_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_certificate_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_server_key_exchange_coverage_test.c | ||
${SOURCE_DIR}/nx_secure_tls_send_certificate_test.c | ||
${SOURCE_DIR}/nx_secure_tls_send_clienthello_test.c) | ||
|
||
# Pure crypto related test cases | ||
if("s${CMAKE_BUILD_TYPE}" STREQUAL "sdefault_build_coverage") | ||
list( | ||
APPEND | ||
nx_secure_test_cases | ||
${SOURCE_DIR}/nx_secure_3des_test.c | ||
${SOURCE_DIR}/nx_secure_aes_test.c | ||
${SOURCE_DIR}/nx_secure_aes_ccm_test.c | ||
${SOURCE_DIR}/nx_secure_des_test.c | ||
${SOURCE_DIR}/nx_secure_ec_test.c | ||
${SOURCE_DIR}/nx_secure_ecdh_self_test.c | ||
${SOURCE_DIR}/nx_secure_ecdh_test.c | ||
${SOURCE_DIR}/nx_secure_ecdsa_test.c | ||
${SOURCE_DIR}/nx_secure_ecjpake_self_test.c | ||
${SOURCE_DIR}/nx_secure_hkdf_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_md5_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha1_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha224_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha256_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha384_test.c | ||
${SOURCE_DIR}/nx_secure_hmac_sha512_test.c | ||
${SOURCE_DIR}/nx_secure_phash_prf_test.c | ||
${SOURCE_DIR}/nx_secure_rsa_test.c | ||
${SOURCE_DIR}/nx_secure_sha256_rfc_test.c | ||
${SOURCE_DIR}/nx_secure_sha224_test.c | ||
${SOURCE_DIR}/nx_secure_sha256_test.c | ||
${SOURCE_DIR}/nx_secure_sha384_test.c | ||
${SOURCE_DIR}/nx_secure_sha512_test.c) | ||
endif() | ||
|
||
set(test_utility_files | ||
${SOURCE_DIR}/netxtestcontrol.c | ||
${SOURCE_DIR}/nx_crypto_ciphersuites_regression.c | ||
${SOURCE_DIR}/nx_ram_network_driver_test_1500.c) | ||
|
||
if("s${CMAKE_BUILD_TYPE}" STREQUAL "shash_clone_build") | ||
list(APPEND test_utility_files | ||
${SOURCE_DIR}/hash_clone/nx_crypto_clone_cleanup_test.c | ||
${SOURCE_DIR}/hash_clone/nx_crypto_hash_clone_test.c | ||
${SOURCE_DIR}/hash_clone/nx_crypto_ciphersuites_hc.c) | ||
endif() | ||
|
||
add_library(test_utility ${test_utility_files}) | ||
target_link_libraries(test_utility PUBLIC azrtos::netxduo) | ||
target_include_directories(test_utility PUBLIC ${SOURCE_DIR}/test) | ||
target_compile_definitions(test_utility PUBLIC BATCH_TEST CTEST) | ||
|
||
foreach(test_case ${nx_secure_test_cases}) | ||
get_filename_component(test_name ${test_case} NAME_WE) | ||
add_executable(${test_name} ${test_case}) | ||
target_link_libraries(${test_name} PRIVATE test_utility) | ||
add_test( | ||
NAME ${CMAKE_BUILD_TYPE}::${test_name} | ||
COMMAND ${test_name} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/..) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
cd $(dirname $0) | ||
|
||
# if threadx repo does not exist, clone it | ||
[ -d ../threadx ] || git clone https://github.com/azure-rtos/threadx.git ../threadx --depth 1 | ||
[ -f .run.sh ] || ln -sf ../threadx/scripts/cmake_bootstrap.sh .run.sh | ||
./.run.sh $* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: main.c | ||
* | ||
* Description: | ||
* | ||
* Version: 1.0 | ||
* Created: 04/29/2020 04:45:06 PM | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: YOUR NAME (), | ||
* Company: | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "nx_crypto_phash.h" | ||
#include "nx_crypto_tls_prf_1.h" | ||
#include "nx_crypto_tls_prf_sha256.h" | ||
#include "nx_crypto_tls_prf_sha384.h" | ||
#include "nx_crypto_tls_prf_sha512.h" | ||
#include "nx_crypto_hkdf.h" | ||
#include "nx_crypto_3des.h" | ||
#include "nx_crypto.h" | ||
#include "nx_crypto_md5.h" | ||
#include "nx_crypto_sha1.h" | ||
#include "nx_crypto_sha2.h" | ||
#include "nx_crypto_sha5.h" | ||
#include "nx_crypto.h" | ||
#include "nx_crypto_hmac_sha1.h" | ||
#include "nx_crypto_hmac_sha2.h" | ||
#include "nx_crypto_hmac_sha5.h" | ||
#include "nx_crypto_hmac_md5.h" | ||
#include "nx_crypto_aes.h" | ||
#include "nx_crypto_rsa.h" | ||
#include "nx_crypto_null.h" | ||
#include "nx_crypto_ecjpake.h" | ||
#include "nx_crypto_ecdsa.h" | ||
#include "nx_crypto_ecdh.h" | ||
#include "nx_crypto_drbg.h" | ||
#include "nx_crypto_pkcs1_v1.5.h" | ||
#include "nx_crypto_dh.h" | ||
#include "nx_crypto_drbg.h" | ||
|
||
int main() | ||
{ | ||
|
||
printf(" sizeof(NX_CRYPTO_AES), %d\n", sizeof(NX_CRYPTO_AES)); | ||
printf(" sizeof(NX_CRYPTO_DRBG), %d\n", sizeof(NX_CRYPTO_DRBG)); | ||
printf(" sizeof(NX_CRYPTO_ECDSA), %d\n", sizeof(NX_CRYPTO_ECDSA)); | ||
printf(" sizeof(NX_CRYPTO_ECDH), %d\n", sizeof(NX_CRYPTO_ECDH)); | ||
printf(" sizeof(NX_CRYPTO_SHA1_HMAC), %d\n", sizeof(NX_CRYPTO_SHA1_HMAC)); | ||
printf(" sizeof(NX_CRYPTO_SHA256_HMAC), %d\n", sizeof(NX_CRYPTO_SHA256_HMAC)); | ||
printf(" sizeof(NX_CRYPTO_SHA512_HMAC), %d\n", sizeof(NX_CRYPTO_SHA512_HMAC)); | ||
printf(" sizeof(NX_CRYPTO_MD5_HMAC), %d\n", sizeof(NX_CRYPTO_MD5_HMAC)); | ||
printf(" sizeof(NX_CRYPTO_RSA), %d\n", sizeof(NX_CRYPTO_RSA)); | ||
printf(" sizeof(NX_CRYPTO_ECJPAKE), %d\n", sizeof(NX_CRYPTO_ECJPAKE)); | ||
printf(" sizeof(NX_CRYPTO_MD5), %d\n", sizeof(NX_CRYPTO_MD5)); | ||
printf(" sizeof(NX_CRYPTO_SHA1), %d\n", sizeof(NX_CRYPTO_SHA1)); | ||
printf(" sizeof(NX_CRYPTO_SHA256), %d\n", sizeof(NX_CRYPTO_SHA256)); | ||
// printf(" sizeof(NX_CRYPTO_SHA384), %d\n", sizeof(NX_CRYPTO_SHA384)); | ||
printf(" sizeof(NX_CRYPTO_SHA512), %d\n", sizeof(NX_CRYPTO_SHA512)); | ||
printf(" sizeof(NX_CRYPTO_TLS_PRF_1), %d\n", sizeof(NX_CRYPTO_TLS_PRF_1)); | ||
printf(" sizeof(NX_CRYPTO_TLS_PRF_SHA256), %d\n", sizeof(NX_CRYPTO_TLS_PRF_SHA256)); | ||
printf(" sizeof(NX_CRYPTO_TLS_PRF_SHA384), %d\n", sizeof(NX_CRYPTO_TLS_PRF_SHA384)); | ||
printf(" sizeof(NX_CRYPTO_TLS_PRF_SHA512), %d\n", sizeof(NX_CRYPTO_TLS_PRF_SHA512)); | ||
printf(" sizeof(NX_CRYPTO_HMAC), %d\n", sizeof(NX_CRYPTO_HMAC)); | ||
printf(" sizeof(NX_CRYPTO_HKDF) + sizeof(NX_CRYPTO_HMAC), %d\n", sizeof(NX_CRYPTO_HKDF) + sizeof(NX_CRYPTO_HMAC)); | ||
printf(" sizeof(NX_CRYPTO_DES), %d\n", sizeof(NX_CRYPTO_DES)); | ||
printf(" sizeof(NX_CRYPTO_3DES), %d\n", sizeof(NX_CRYPTO_3DES)); | ||
printf(" sizeof(NX_CRYPTO_PKCS1), %d\n", sizeof(NX_CRYPTO_PKCS1)); | ||
printf(" sizeof(NX_CRYPTO_DH), %d\n", sizeof(NX_CRYPTO_DH)); | ||
printf(" sizeof(NX_CRYPTO_DRBG), %d\n", sizeof(NX_CRYPTO_DRBG)); | ||
|
||
return(0); | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
unsigned char device_cert_der[] = { | ||
0x30, 0x82, 0x03, 0xdb, 0x30, 0x82, 0x02, 0xc3, 0xa0, 0x03, 0x02, 0x01, | ||
0x02, 0x02, 0x02, 0x10, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, | ||
0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x6f, 0x31, 0x0b, | ||
0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, | ||
0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, | ||
0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, | ||
0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, | ||
0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x4e, | ||
0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x27, 0x30, 0x25, | ||
0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4e, 0x58, 0x20, 0x53, 0x65, | ||
0x63, 0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6e, | ||
0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, | ||
0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x33, 0x33, 0x31, 0x32, | ||
0x31, 0x30, 0x39, 0x30, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x37, 0x30, 0x33, | ||
0x32, 0x39, 0x32, 0x31, 0x30, 0x39, 0x30, 0x39, 0x5a, 0x30, 0x75, 0x31, | ||
0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, | ||
0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, | ||
0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, | ||
0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, | ||
0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x12, 0x30, | ||
0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x4e, 0x58, 0x20, 0x53, | ||
0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, | ||
0x04, 0x03, 0x0c, 0x1c, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, | ||
0x65, 0x20, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x20, 0x43, 0x65, 0x72, | ||
0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x82, 0x01, 0x22, | ||
0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, | ||
0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, | ||
0x02, 0x82, 0x01, 0x01, 0x00, 0xc4, 0x7e, 0xd4, 0xe3, 0xa2, 0x0c, 0x78, | ||
0xe6, 0x0f, 0xa5, 0x3c, 0x01, 0x9b, 0x01, 0xdf, 0x96, 0xf6, 0x8e, 0xa0, | ||
0x80, 0x4b, 0xb1, 0xc7, 0x20, 0x3c, 0xca, 0x81, 0x9a, 0xce, 0x08, 0x5f, | ||
0x70, 0x99, 0x8d, 0x44, 0x46, 0xbc, 0xf5, 0xb1, 0x80, 0x3c, 0xe0, 0xc9, | ||
0x09, 0x11, 0xb4, 0x07, 0x89, 0x5f, 0x06, 0x89, 0xec, 0xbe, 0xf8, 0x29, | ||
0x48, 0x40, 0x55, 0x60, 0x1d, 0x59, 0xb3, 0x7b, 0x84, 0x77, 0xc3, 0x34, | ||
0xf4, 0xd3, 0x51, 0x3e, 0x2f, 0x9d, 0x10, 0xbb, 0xaf, 0x47, 0xb2, 0xc5, | ||
0x78, 0x8a, 0x85, 0xea, 0xbb, 0xe5, 0xb3, 0x8a, 0x25, 0xaf, 0xd6, 0xb9, | ||
0xb3, 0x47, 0xf3, 0x5f, 0x7b, 0xc2, 0x69, 0xe3, 0x08, 0xf5, 0x45, 0xae, | ||
0x53, 0xb4, 0x79, 0x6e, 0xdd, 0xcf, 0xc0, 0x53, 0x81, 0x62, 0xd3, 0x2c, | ||
0xc9, 0x19, 0xcb, 0x5d, 0xfc, 0xa9, 0xd8, 0xa7, 0xab, 0x65, 0x52, 0x02, | ||
0x46, 0x56, 0xc0, 0x5b, 0xef, 0xee, 0x0a, 0xf1, 0x35, 0x87, 0xf7, 0x14, | ||
0xec, 0x1b, 0x77, 0x11, 0x81, 0x4d, 0xca, 0xdc, 0x55, 0x66, 0x40, 0xa4, | ||
0x04, 0xdc, 0x2a, 0x9f, 0xfe, 0x9f, 0x99, 0x4d, 0xb2, 0x5a, 0xcb, 0x58, | ||
0x97, 0x1d, 0xd4, 0x74, 0x16, 0xd0, 0x7e, 0x1d, 0x5e, 0x9b, 0xf7, 0xf3, | ||
0x5b, 0xd4, 0xf5, 0xde, 0xa5, 0x71, 0x36, 0x13, 0x7f, 0xea, 0xba, 0x0b, | ||
0x3e, 0xbd, 0xef, 0x7c, 0x34, 0x41, 0xe1, 0xb7, 0x99, 0x46, 0x9f, 0x81, | ||
0xc6, 0xcf, 0x72, 0x94, 0x65, 0x52, 0xf0, 0x88, 0x17, 0xf6, 0x00, 0xf4, | ||
0xd0, 0x9a, 0x66, 0xe7, 0x1e, 0xa5, 0xfd, 0x4b, 0x95, 0xf3, 0x0e, 0x0f, | ||
0x10, 0x60, 0x74, 0x54, 0xda, 0xb0, 0x91, 0x0a, 0x10, 0x07, 0x19, 0x30, | ||
0x71, 0x34, 0x5f, 0xe2, 0x1c, 0x08, 0x77, 0x2e, 0xbc, 0xa3, 0x13, 0x18, | ||
0x22, 0x5e, 0xf9, 0xe0, 0x67, 0x8e, 0xbc, 0xc0, 0x7d, 0x02, 0x03, 0x01, | ||
0x00, 0x01, 0xa3, 0x7b, 0x30, 0x79, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, | ||
0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x2c, 0x06, 0x09, 0x60, 0x86, 0x48, | ||
0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, 0x16, 0x1d, 0x4f, 0x70, | ||
0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, | ||
0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, | ||
0x61, 0x74, 0x65, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, | ||
0x04, 0x14, 0x5c, 0xac, 0x85, 0x36, 0xd2, 0x6c, 0x5b, 0x71, 0xd0, 0x7e, | ||
0x78, 0xe6, 0x4b, 0xc7, 0x9e, 0x0b, 0x06, 0xaa, 0x70, 0x8b, 0x30, 0x1f, | ||
0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x8e, | ||
0x6a, 0xb0, 0xfe, 0x49, 0xc5, 0x6a, 0x96, 0x9e, 0xba, 0xb8, 0xb6, 0x58, | ||
0xfc, 0x52, 0x7f, 0xab, 0x51, 0xf2, 0x3a, 0x30, 0x0d, 0x06, 0x09, 0x2a, | ||
0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, | ||
0x01, 0x01, 0x00, 0x58, 0x39, 0x3d, 0xc9, 0xcf, 0x4a, 0x8b, 0x15, 0x82, | ||
0xcf, 0xce, 0x12, 0xb8, 0x4f, 0x6e, 0x83, 0x71, 0x9b, 0x52, 0xeb, 0xe9, | ||
0xdc, 0xe4, 0xe1, 0x77, 0x3b, 0x74, 0xd7, 0xc5, 0xd7, 0x50, 0x9a, 0xb9, | ||
0x1f, 0x0a, 0x27, 0x0a, 0x9b, 0x19, 0xf0, 0x2d, 0x86, 0xf7, 0x71, 0xec, | ||
0x7c, 0x87, 0x65, 0x19, 0xd0, 0x86, 0xe2, 0xf1, 0xd5, 0x22, 0x21, 0xe3, | ||
0xbf, 0x0d, 0xcb, 0x42, 0x7f, 0x70, 0xe5, 0x13, 0x96, 0x6d, 0x5b, 0xc1, | ||
0x7e, 0xd0, 0x34, 0x82, 0xaf, 0x29, 0xed, 0x7f, 0x6e, 0xc6, 0x7f, 0x8b, | ||
0xe8, 0x20, 0xc6, 0x39, 0x51, 0x9b, 0xec, 0x15, 0xa8, 0x9a, 0x63, 0xa5, | ||
0x92, 0x4a, 0xbc, 0x45, 0xf0, 0x86, 0xef, 0x09, 0xc0, 0xe4, 0x32, 0x3c, | ||
0x7a, 0x62, 0x51, 0x67, 0x0b, 0x0b, 0x8a, 0x2e, 0x07, 0xd5, 0x7c, 0xd5, | ||
0xd0, 0x4f, 0x93, 0x1d, 0x2d, 0x00, 0x6d, 0x99, 0x89, 0x55, 0xb3, 0x99, | ||
0x98, 0x1b, 0x13, 0x60, 0xb4, 0x80, 0x57, 0xbe, 0xe3, 0x25, 0xb6, 0x9a, | ||
0x75, 0x95, 0x3d, 0xba, 0xe5, 0x48, 0xa6, 0x3b, 0x1c, 0xd7, 0x50, 0x90, | ||
0x19, 0x4c, 0xf5, 0x22, 0x94, 0x7f, 0x79, 0xd5, 0x5e, 0x5a, 0xfb, 0x29, | ||
0x34, 0xf8, 0xd7, 0xf5, 0x2e, 0x95, 0x81, 0xb7, 0x2c, 0x8f, 0x2f, 0xcf, | ||
0xdd, 0xc4, 0xcf, 0x1b, 0x2e, 0x2b, 0xe8, 0x4d, 0x92, 0xf6, 0x8f, 0xba, | ||
0x08, 0x1a, 0x8a, 0x13, 0x2c, 0x2d, 0x38, 0xce, 0xfe, 0xa5, 0x59, 0xc5, | ||
0xea, 0x3a, 0x07, 0x8b, 0xf9, 0x8d, 0x33, 0x25, 0xc0, 0x4e, 0x75, 0x51, | ||
0xfc, 0xd1, 0x12, 0xec, 0x85, 0xb1, 0xb5, 0xf4, 0xc2, 0xb8, 0x05, 0x3c, | ||
0x00, 0x4a, 0x1b, 0xab, 0xb2, 0xab, 0x69, 0x58, 0x33, 0x93, 0xf8, 0x47, | ||
0x12, 0x75, 0xc2, 0x3a, 0x82, 0xe1, 0x2d, 0x95, 0xa9, 0x9c, 0xb9, 0xe3, | ||
0x3d, 0x29, 0x93, 0x65, 0xa1, 0x79, 0xee | ||
}; | ||
unsigned int device_cert_der_len = 991; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
static unsigned char google_cert_der[] = { | ||
0x30, 0x82, 0x04, 0x80, 0x30, 0x82, 0x03, 0x68, 0xa0, 0x03, 0x02, 0x01, | ||
0x02, 0x02, 0x08, 0x0e, 0x3a, 0xa9, 0x10, 0x46, 0xfa, 0x76, 0x95, 0x30, | ||
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, | ||
0x05, 0x00, 0x30, 0x49, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, | ||
0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, | ||
0x04, 0x0a, 0x13, 0x0a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, | ||
0x6e, 0x63, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, | ||
0x1c, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x74, 0x65, | ||
0x72, 0x6e, 0x65, 0x74, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, | ||
0x74, 0x79, 0x20, 0x47, 0x32, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x37, 0x30, | ||
0x33, 0x30, 0x39, 0x30, 0x32, 0x32, 0x33, 0x34, 0x39, 0x5a, 0x17, 0x0d, | ||
0x31, 0x37, 0x30, 0x36, 0x30, 0x31, 0x30, 0x32, 0x31, 0x39, 0x30, 0x30, | ||
0x5a, 0x30, 0x68, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, | ||
0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, | ||
0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, | ||
0x61, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, | ||
0x4d, 0x6f, 0x75, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, | ||
0x77, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, | ||
0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x17, | ||
0x30, 0x15, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0e, 0x77, 0x77, 0x77, | ||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x30, | ||
0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, | ||
0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, | ||
0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd7, 0x29, 0xb4, 0x37, | ||
0x13, 0x0c, 0x2d, 0xc2, 0xb4, 0x93, 0xc9, 0xd2, 0xaf, 0xa5, 0xed, 0x99, | ||
0x96, 0xa1, 0x54, 0x3a, 0x72, 0xec, 0x9f, 0x2e, 0x67, 0x3b, 0xfe, 0x58, | ||
0x01, 0xaa, 0xbf, 0x14, 0x6b, 0x68, 0x9e, 0x06, 0x28, 0xfd, 0x2b, 0x63, | ||
0x7f, 0x6e, 0xfe, 0x88, 0xc5, 0x29, 0x8f, 0x32, 0x84, 0x85, 0x99, 0x6b, | ||
0x21, 0xa4, 0xf3, 0x74, 0xe1, 0xa7, 0x2b, 0x26, 0x4b, 0x5d, 0x43, 0x31, | ||
0x92, 0xd7, 0x2a, 0x04, 0x50, 0xfd, 0x66, 0xe3, 0x9f, 0xe5, 0x8e, 0x4e, | ||
0xbd, 0x84, 0x72, 0x79, 0x25, 0x65, 0x5e, 0x75, 0x2e, 0xd8, 0xa4, 0xe2, | ||
0xa0, 0xe2, 0xa0, 0x52, 0x9a, 0x65, 0x8f, 0xc7, 0x51, 0xd7, 0xd3, 0x29, | ||
0xbf, 0x94, 0xa2, 0xa6, 0x95, 0x05, 0x06, 0x3f, 0x7e, 0xaa, 0xe5, 0x24, | ||
0x6e, 0x7c, 0xac, 0x45, 0x4c, 0xe0, 0x3d, 0x23, 0xf2, 0x4b, 0xca, 0x60, | ||
0x2e, 0x9c, 0x5a, 0x62, 0x21, 0x28, 0x2f, 0x48, 0xf4, 0xb7, 0xa9, 0xa4, | ||
0xe8, 0xae, 0xc8, 0x99, 0x6f, 0xf9, 0x4d, 0xea, 0xe0, 0xc0, 0x1b, 0xdb, | ||
0xcf, 0x8d, 0x05, 0xcc, 0x8a, 0x50, 0x6d, 0x12, 0x1d, 0xb8, 0xce, 0xfa, | ||
0x38, 0x33, 0x6d, 0x50, 0xee, 0x1d, 0x39, 0xf6, 0x07, 0x37, 0x4f, 0xce, | ||
0x91, 0x51, 0xaa, 0x4e, 0x6c, 0xf3, 0xe6, 0x1d, 0x36, 0x86, 0x4f, 0xbd, | ||
0xdf, 0x1a, 0x9f, 0xab, 0x9b, 0x19, 0x1b, 0x5a, 0x50, 0x0d, 0x7b, 0xed, | ||
0xe9, 0xed, 0x2a, 0x71, 0x70, 0xc3, 0xf8, 0xc4, 0x4d, 0xa6, 0xee, 0x5d, | ||
0x27, 0x21, 0x11, 0x55, 0x5f, 0xb5, 0x27, 0x4a, 0x46, 0x52, 0x74, 0xcb, | ||
0x12, 0xa7, 0xc2, 0xfc, 0xa8, 0x95, 0xa2, 0x6f, 0x97, 0x2b, 0xfb, 0xbb, | ||
0x58, 0x2a, 0x75, 0xed, 0x57, 0xc3, 0x45, 0x73, 0x3c, 0x11, 0xdd, 0xb7, | ||
0xb4, 0xfb, 0xc7, 0x84, 0xbe, 0xf8, 0xe6, 0x82, 0x0e, 0xbd, 0x42, 0x0f, | ||
0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x01, 0x4b, 0x30, 0x82, 0x01, | ||
0x47, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x16, 0x30, 0x14, | ||
0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, | ||
0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x19, 0x06, 0x03, | ||
0x55, 0x1d, 0x11, 0x04, 0x12, 0x30, 0x10, 0x82, 0x0e, 0x77, 0x77, 0x77, | ||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x30, | ||
0x68, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01, 0x01, 0x04, | ||
0x5c, 0x30, 0x5a, 0x30, 0x2b, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, | ||
0x07, 0x30, 0x02, 0x86, 0x1f, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, | ||
0x70, 0x6b, 0x69, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, | ||
0x6f, 0x6d, 0x2f, 0x47, 0x49, 0x41, 0x47, 0x32, 0x2e, 0x63, 0x72, 0x74, | ||
0x30, 0x2b, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, | ||
0x86, 0x1f, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x6c, 0x69, | ||
0x65, 0x6e, 0x74, 0x73, 0x31, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, | ||
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x30, 0x1d, 0x06, | ||
0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x56, 0x84, 0x33, 0x5a, | ||
0xf3, 0xdd, 0x0c, 0x48, 0xf2, 0xc8, 0xb3, 0x5f, 0xc8, 0x9d, 0x51, 0x53, | ||
0xbe, 0x20, 0x27, 0xba, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, | ||
0x01, 0xff, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, | ||
0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x4a, 0xdd, 0x06, 0x16, 0x1b, | ||
0xbc, 0xf6, 0x68, 0xb5, 0x76, 0xf5, 0x81, 0xb6, 0xbb, 0x62, 0x1a, 0xba, | ||
0x5a, 0x81, 0x2f, 0x30, 0x21, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x1a, | ||
0x30, 0x18, 0x30, 0x0c, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0xd6, | ||
0x79, 0x02, 0x05, 0x01, 0x30, 0x08, 0x06, 0x06, 0x67, 0x81, 0x0c, 0x01, | ||
0x02, 0x02, 0x30, 0x30, 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04, 0x29, 0x30, | ||
0x27, 0x30, 0x25, 0xa0, 0x23, 0xa0, 0x21, 0x86, 0x1f, 0x68, 0x74, 0x74, | ||
0x70, 0x3a, 0x2f, 0x2f, 0x70, 0x6b, 0x69, 0x2e, 0x67, 0x6f, 0x6f, 0x67, | ||
0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x47, 0x49, 0x41, 0x47, 0x32, | ||
0x2e, 0x63, 0x72, 0x6c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, | ||
0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, | ||
0x62, 0x25, 0x75, 0x56, 0xb8, 0x66, 0x96, 0xfb, 0x4e, 0x08, 0x65, 0x2a, | ||
0xf0, 0x34, 0x69, 0xae, 0xa8, 0x56, 0x08, 0x40, 0x19, 0xd7, 0x13, 0x53, | ||
0xbc, 0x3b, 0xc3, 0xe1, 0x7c, 0xb4, 0xe0, 0x50, 0x11, 0x32, 0x31, 0x03, | ||
0x6d, 0x50, 0x82, 0xfc, 0x3a, 0x4d, 0xda, 0xe7, 0xc7, 0x5b, 0x08, 0xf2, | ||
0x9e, 0xe3, 0x01, 0x43, 0xbe, 0x8f, 0x0a, 0xc4, 0x11, 0xb6, 0xe5, 0x83, | ||
0x50, 0x5f, 0xd3, 0xcc, 0x4d, 0x0c, 0xd4, 0x09, 0xc9, 0x77, 0x3b, 0xbe, | ||
0x91, 0xad, 0xae, 0xc7, 0x56, 0x54, 0xb3, 0xf8, 0xb5, 0x97, 0xa7, 0xe7, | ||
0x2f, 0xab, 0xc8, 0xb5, 0x70, 0xf4, 0xbc, 0x48, 0xda, 0xdb, 0x92, 0xcb, | ||
0x4d, 0x1c, 0xaa, 0x87, 0x50, 0x8e, 0x5b, 0x8d, 0x69, 0xbd, 0x19, 0x78, | ||
0xd1, 0x90, 0x6f, 0x3a, 0xa6, 0x62, 0x91, 0x63, 0xf6, 0xfe, 0x12, 0xda, | ||
0x5e, 0x23, 0xbc, 0x4c, 0xfd, 0xea, 0x6d, 0xff, 0x2a, 0xbd, 0xe0, 0x82, | ||
0xb9, 0xf6, 0x5a, 0xe5, 0x77, 0x98, 0xff, 0x39, 0x21, 0x00, 0x4f, 0xaf, | ||
0x8b, 0x7d, 0x38, 0x8e, 0x65, 0xa0, 0xe2, 0x02, 0x59, 0xb7, 0xdd, 0xe8, | ||
0xbc, 0x3b, 0x04, 0x8b, 0x8c, 0x2f, 0x58, 0xea, 0x16, 0xc0, 0xac, 0xc0, | ||
0xb6, 0x1a, 0x00, 0x5e, 0x04, 0x3f, 0x75, 0x72, 0x21, 0xef, 0x7c, 0x85, | ||
0xb4, 0x80, 0x72, 0x7d, 0xaa, 0xda, 0xdc, 0x4a, 0xb1, 0x83, 0x34, 0xb7, | ||
0xb0, 0x1c, 0x4b, 0x2c, 0x8e, 0xe6, 0xde, 0x40, 0x36, 0x24, 0xfa, 0x9a, | ||
0x6c, 0x70, 0xe3, 0x9c, 0x7e, 0x41, 0x5d, 0x7a, 0x74, 0xf0, 0xe0, 0xac, | ||
0xcd, 0xf4, 0x87, 0x2f, 0x72, 0xaf, 0xf5, 0x0f, 0x6c, 0xd7, 0xe2, 0x08, | ||
0x92, 0x11, 0xbe, 0x41, 0x4b, 0xc4, 0x1b, 0xd7, 0x44, 0x44, 0x0f, 0x94, | ||
0x44, 0x29, 0x44, 0x8e, 0x12, 0x95, 0xd2, 0x81, 0x05, 0xd2, 0x7e, 0x61, | ||
0x55, 0xa8, 0xfa, 0xfc | ||
}; | ||
static unsigned int google_cert_der_len = 1156; |
140 changes: 140 additions & 0 deletions
140
test/regression/nx_secure_test/hash_clone/nx_crypto_ciphersuites_hc.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/**************************************************************************/ | ||
/* */ | ||
/* Copyright (c) Microsoft Corporation. All rights reserved. */ | ||
/* */ | ||
/* This software is licensed under the Microsoft Software License */ | ||
/* Terms for Microsoft Azure RTOS. Full text of the license can be */ | ||
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ | ||
/* and in the root directory of this software. */ | ||
/* */ | ||
/**************************************************************************/ | ||
|
||
|
||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
#include "nx_secure_tls.h" | ||
#include "nx_crypto_hash_clone_test.h" | ||
#include "nx_crypto_sha2.h" | ||
|
||
|
||
|
||
/* Define cryptographic methods for use with TLS. */ | ||
|
||
extern NX_CRYPTO_METHOD crypto_method_none; | ||
extern NX_CRYPTO_METHOD crypto_method_null; | ||
extern NX_CRYPTO_METHOD crypto_method_aes_cbc_128; | ||
extern NX_CRYPTO_METHOD crypto_method_aes_cbc_256; | ||
extern NX_CRYPTO_METHOD crypto_method_aes_ccm_8; | ||
extern NX_CRYPTO_METHOD crypto_method_aes_ccm_16; | ||
extern NX_CRYPTO_METHOD crypto_method_aes_128_gcm_16; | ||
extern NX_CRYPTO_METHOD crypto_method_aes_256_gcm_16; | ||
extern NX_CRYPTO_METHOD crypto_method_ecdsa; | ||
extern NX_CRYPTO_METHOD crypto_method_ecdhe; | ||
extern NX_CRYPTO_METHOD crypto_method_hmac_sha1; | ||
extern NX_CRYPTO_METHOD crypto_method_hmac_sha256; | ||
extern NX_CRYPTO_METHOD crypto_method_hmac_md5; | ||
extern NX_CRYPTO_METHOD crypto_method_rsa; | ||
extern NX_CRYPTO_METHOD crypto_method_pkcs1; | ||
extern NX_CRYPTO_METHOD crypto_method_auth_psk; | ||
extern NX_CRYPTO_METHOD crypto_method_ec_secp256; | ||
extern NX_CRYPTO_METHOD crypto_method_ec_secp384; | ||
extern NX_CRYPTO_METHOD crypto_method_ec_secp521; | ||
extern NX_CRYPTO_METHOD crypto_method_md5; | ||
extern NX_CRYPTO_METHOD crypto_method_sha1; | ||
extern NX_CRYPTO_METHOD crypto_method_sha224; | ||
|
||
extern NX_CRYPTO_METHOD crypto_method_sha384; | ||
extern NX_CRYPTO_METHOD crypto_method_sha512; | ||
extern NX_CRYPTO_METHOD crypto_method_hkdf_sha1; | ||
extern NX_CRYPTO_METHOD crypto_method_hkdf_sha256; | ||
extern NX_CRYPTO_METHOD crypto_method_tls_prf_1; | ||
extern NX_CRYPTO_METHOD crypto_method_tls_prf_sha256; | ||
extern NX_CRYPTO_METHOD crypto_method_tls_prf_sha384; | ||
extern NX_CRYPTO_METHOD crypto_method_hkdf; | ||
extern NX_CRYPTO_METHOD crypto_method_hmac; | ||
|
||
NX_CRYPTO_METHOD crypto_method_sha256_hc = | ||
{ | ||
NX_CRYPTO_HASH_SHA256, /* SHA256 algorithm */ | ||
0, /* Key size in bits */ | ||
0, /* IV size in bits, not used */ | ||
NX_CRYPTO_SHA256_ICV_LEN_IN_BITS, /* Transmitted ICV size in bits */ | ||
NX_CRYPTO_SHA2_BLOCK_SIZE_IN_BYTES, /* Block size in bytes */ | ||
sizeof(NX_CRYPTO_HASH_CLONE_TEST), /* Metadata size in bytes */ | ||
_nx_crypto_method_hash_clone_test_init, /* SHA256 initialization routine */ | ||
_nx_crypto_method_hash_clone_test_cleanup, /* SHA256 cleanup routine */ | ||
_nx_crypto_method_hash_clone_test_operation /* SHA256 operation */ | ||
}; | ||
|
||
/* Ciphersuite table without ECC. */ | ||
/* Lookup table used to map ciphersuites to cryptographic routines. */ | ||
NX_SECURE_TLS_CIPHERSUITE_INFO _nx_crypto_ciphersuite_lookup_table_hc[] = | ||
{ | ||
/* Ciphersuite, public cipher, public_auth, session cipher & cipher mode, iv size, key size, hash method, hash size, TLS PRF */ | ||
#ifdef NX_SECURE_ENABLE_AEAD_CIPHER | ||
{TLS_RSA_WITH_AES_128_GCM_SHA256, &crypto_method_rsa, &crypto_method_rsa, &crypto_method_aes_128_gcm_16, 16, 16, &crypto_method_null, 0, &crypto_method_tls_prf_sha256}, | ||
#endif /* NX_SECURE_ENABLE_AEAD_CIPHER */ | ||
{TLS_RSA_WITH_AES_256_CBC_SHA256, &crypto_method_rsa, &crypto_method_rsa, &crypto_method_aes_cbc_256, 16, 32, &crypto_method_hmac_sha256, 32, &crypto_method_tls_prf_sha256}, | ||
{TLS_RSA_WITH_AES_128_CBC_SHA256, &crypto_method_rsa, &crypto_method_rsa, &crypto_method_aes_cbc_128, 16, 16, &crypto_method_hmac_sha256, 32, &crypto_method_tls_prf_sha256}, | ||
|
||
#ifdef NX_SECURE_ENABLE_PSK_CIPHERSUITES | ||
{TLS_PSK_WITH_AES_128_CBC_SHA256, &crypto_method_null, &crypto_method_auth_psk, &crypto_method_aes_cbc_128, 16, 16, &crypto_method_hmac_sha256, 32, &crypto_method_tls_prf_sha256}, | ||
#ifdef NX_SECURE_ENABLE_AEAD_CIPHER | ||
{TLS_PSK_WITH_AES_128_CCM_8, &crypto_method_null, &crypto_method_auth_psk, &crypto_method_aes_ccm_8, 16, 16, &crypto_method_null, 0, &crypto_method_tls_prf_sha256}, | ||
#endif | ||
#endif /* NX_SECURE_ENABLE_PSK_CIPHERSUITES */ | ||
}; | ||
|
||
const UINT _nx_crypto_ciphersuite_lookup_table_hc_size = sizeof(_nx_crypto_ciphersuite_lookup_table_hc) / sizeof(NX_SECURE_TLS_CIPHERSUITE_INFO); | ||
|
||
/* Lookup table for X.509 digital certificates - they need a public-key algorithm and a hash routine for verification. */ | ||
NX_SECURE_X509_CRYPTO _nx_crypto_x509_cipher_lookup_table_hc[] = | ||
{ | ||
/* OID identifier, public cipher, hash method */ | ||
{NX_SECURE_TLS_X509_TYPE_RSA_SHA_256, &crypto_method_rsa, &crypto_method_sha256_hc}, | ||
{NX_SECURE_TLS_X509_TYPE_RSA_SHA_384, &crypto_method_rsa, &crypto_method_sha384}, | ||
{NX_SECURE_TLS_X509_TYPE_RSA_SHA_512, &crypto_method_rsa, &crypto_method_sha512}, | ||
{NX_SECURE_TLS_X509_TYPE_RSA_SHA_1, &crypto_method_rsa, &crypto_method_sha1}, | ||
{NX_SECURE_TLS_X509_TYPE_RSA_MD5, &crypto_method_rsa, &crypto_method_md5}, | ||
}; | ||
|
||
const UINT _nx_crypto_x509_cipher_lookup_table_hc_size = sizeof(_nx_crypto_x509_cipher_lookup_table_hc) / sizeof(NX_SECURE_X509_CRYPTO); | ||
|
||
/* Define the object we can pass into TLS. */ | ||
NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers_hc = | ||
{ | ||
/* Ciphersuite lookup table and size. */ | ||
_nx_crypto_ciphersuite_lookup_table_hc, | ||
sizeof(_nx_crypto_ciphersuite_lookup_table_hc) / sizeof(NX_SECURE_TLS_CIPHERSUITE_INFO), | ||
|
||
#ifndef NX_SECURE_DISABLE_X509 | ||
/* X.509 certificate cipher table and size. */ | ||
_nx_crypto_x509_cipher_lookup_table_hc, | ||
sizeof(_nx_crypto_x509_cipher_lookup_table_hc) / sizeof(NX_SECURE_X509_CRYPTO), | ||
#endif | ||
|
||
/* TLS version-specific methods. */ | ||
#if (NX_SECURE_TLS_TLS_1_0_ENABLED || NX_SECURE_TLS_TLS_1_1_ENABLED) | ||
&crypto_method_md5, | ||
&crypto_method_sha1, | ||
&crypto_method_tls_prf_1, | ||
#endif | ||
|
||
#if (NX_SECURE_TLS_TLS_1_2_ENABLED) | ||
&crypto_method_sha256_hc, | ||
&crypto_method_tls_prf_sha256, | ||
#endif | ||
|
||
#if (NX_SECURE_TLS_TLS_1_3_ENABLED) | ||
&crypto_method_hkdf, | ||
&crypto_method_hmac, | ||
&crypto_method_ecdhe, | ||
#endif | ||
}; | ||
|
||
|
||
|
||
#endif /* NX_CRYPTO_STANDALONE_ENABLE */ | ||
|
||
|
||
|
||
|
405 changes: 405 additions & 0 deletions
405
test/regression/nx_secure_test/hash_clone/nx_crypto_clone_cleanup_test.c
Large diffs are not rendered by default.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
test/regression/nx_secure_test/hash_clone/nx_crypto_clone_cleanup_test.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
|
||
|
||
|
||
#ifndef SRC_NX_CRYPTO_CLONE_CLEANUP_TEST_H_ | ||
#define SRC_NX_CRYPTO_CLONE_CLEANUP_TEST_H_ | ||
|
||
/* Determine if a C++ compiler is being used. If so, ensure that standard | ||
C is used to process the API information. */ | ||
#ifdef __cplusplus | ||
|
||
/* Yes, C++ compiler is present. Use standard C. */ | ||
extern "C" { | ||
|
||
#endif | ||
|
||
#include "nx_secure_tls.h" | ||
#include "nx_crypto.h" | ||
#include "nx_crypto_sha2.h" | ||
|
||
#define NX_CRYPTO_HASH_METADATA_SIZE 2048 | ||
#define NX_CRYPTO_HASH_INSTANCE_COUNT 32 | ||
|
||
typedef struct NX_CRYPTO_CLONE_CLEANUP_TEST_STRUCT | ||
{ | ||
|
||
UINT nx_crypto_hash_operation; | ||
UINT nx_crypto_hash_initialized; | ||
UINT nx_crypto_hash_cloned; | ||
UINT nx_crypto_hash_calculated; | ||
UINT nx_crypto_hash_algorithm; | ||
UCHAR nx_crypto_hash_metadata[NX_CRYPTO_HASH_METADATA_SIZE]; | ||
|
||
} NX_CRYPTO_CLONE_CLEANUP_TEST; | ||
|
||
typedef struct NX_CRYPTO_HASH_CLONE_STRUCT | ||
{ | ||
|
||
UINT nx_crypto_hash_operation; | ||
|
||
} NX_CRYPTO_HASH_CLONE; | ||
|
||
|
||
UINT _nx_crypto_clone_cleanup_test_initialize(NX_CRYPTO_CLONE_CLEANUP_TEST *context, UINT algorithm); | ||
UINT _nx_crypto_clone_cleanup_test_update(NX_CRYPTO_CLONE_CLEANUP_TEST *context, UCHAR *input_ptr, UINT input_length); | ||
UINT _nx_crypto_clone_cleanup_test_digest_calculate(NX_CRYPTO_CLONE_CLEANUP_TEST *context, UCHAR *digest, UINT algorithm); | ||
|
||
UINT _nx_crypto_method_clone_cleanup_test_init(struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
VOID **handle, | ||
VOID *crypto_metadata, | ||
ULONG crypto_metadata_size); | ||
|
||
UINT _nx_crypto_method_clone_cleanup_test_cleanup(VOID *crypto_metadata); | ||
|
||
UINT _nx_crypto_method_clone_cleanup_test_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ | ||
VOID *handle, /* Crypto handler */ | ||
struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
UCHAR *input, ULONG input_length_in_byte, | ||
UCHAR *iv_ptr, | ||
UCHAR *output, ULONG output_length_in_byte, | ||
VOID *crypto_metadata, ULONG crypto_metadata_size, | ||
VOID *packet_ptr, | ||
VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); | ||
|
||
UINT nx_crypto_clone_cleanup_test_clone(VOID *dest_metadata, VOID *source_metadata, ULONG length); | ||
UINT nx_crypto_clone_cleanup(VOID *metadata, ULONG length); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* SRC_NX_CRYPTO_CLONE_CLEANUP_TEST_H_ */ | ||
|
109 changes: 109 additions & 0 deletions
109
test/regression/nx_secure_test/hash_clone/nx_crypto_hash_clone_test.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
|
||
|
||
#include "nx_crypto_hash_clone_test.h" | ||
|
||
|
||
|
||
|
||
NX_CRYPTO_KEEP UINT _nx_crypto_method_hash_clone_test_init(struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
VOID **handle, | ||
VOID *crypto_metadata, | ||
ULONG crypto_metadata_size) | ||
{ | ||
UINT status; | ||
|
||
if ((method == NX_CRYPTO_NULL) || (crypto_metadata == NX_CRYPTO_NULL)) | ||
{ | ||
return(NX_CRYPTO_PTR_ERROR); | ||
} | ||
|
||
/* Verify the metadata addrsss is 4-byte aligned. */ | ||
if((((ULONG)crypto_metadata) & 0x3) != 0) | ||
{ | ||
return(NX_CRYPTO_PTR_ERROR); | ||
} | ||
|
||
if(crypto_metadata_size < sizeof(NX_CRYPTO_HASH_CLONE_TEST)) | ||
{ | ||
return(NX_CRYPTO_PTR_ERROR); | ||
} | ||
|
||
|
||
NX_CRYPTO_MEMSET(crypto_metadata, 0, sizeof(NX_CRYPTO_HASH_CLONE_TEST)); | ||
|
||
status = _nx_crypto_method_clone_cleanup_test_init(method, key, key_size_in_bits, | ||
handle, crypto_metadata, crypto_metadata_size); | ||
|
||
return(status); | ||
} | ||
|
||
|
||
NX_CRYPTO_KEEP UINT _nx_crypto_method_hash_clone_test_cleanup(VOID *crypto_metadata) | ||
{ | ||
UINT status; | ||
|
||
if (!crypto_metadata) | ||
return (NX_CRYPTO_SUCCESS); | ||
|
||
|
||
status = _nx_crypto_method_clone_cleanup_test_cleanup(crypto_metadata); | ||
|
||
return(status); | ||
} | ||
|
||
|
||
NX_CRYPTO_KEEP UINT _nx_crypto_method_hash_clone_test_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ | ||
VOID *handle, /* Crypto handler */ | ||
struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, | ||
NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
UCHAR *input, | ||
ULONG input_length_in_byte, | ||
UCHAR *iv_ptr, | ||
UCHAR *output, | ||
ULONG output_length_in_byte, | ||
VOID *crypto_metadata, | ||
ULONG crypto_metadata_size, | ||
VOID *packet_ptr, | ||
VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)) | ||
{ | ||
UINT status; | ||
|
||
if (method == NX_CRYPTO_NULL) | ||
{ | ||
return(NX_CRYPTO_PTR_ERROR); | ||
} | ||
|
||
/* Verify the metadata addrsss is 4-byte aligned. */ | ||
if((crypto_metadata == NX_CRYPTO_NULL) || ((((ULONG)crypto_metadata) & 0x3) != 0)) | ||
{ | ||
return(NX_CRYPTO_PTR_ERROR); | ||
} | ||
|
||
if(crypto_metadata_size < sizeof(NX_CRYPTO_HASH_CLONE_TEST)) | ||
{ | ||
return(NX_CRYPTO_PTR_ERROR); | ||
} | ||
|
||
|
||
status = _nx_crypto_method_clone_cleanup_test_operation(op, handle, method, key, key_size_in_bits, | ||
input, input_length_in_byte, iv_ptr, | ||
output, output_length_in_byte, | ||
crypto_metadata, crypto_metadata_size, | ||
packet_ptr, nx_crypto_hw_process_callback); | ||
|
||
return(status); | ||
} | ||
|
||
UINT nx_crypto_hash_clone_test_clone(VOID *dest_metadata, VOID *source_metadata, ULONG length) | ||
{ | ||
|
||
if (length != sizeof(NX_CRYPTO_HASH_CLONE_TEST)) | ||
{ | ||
NX_CRYPTO_MEMCPY(dest_metadata, source_metadata, length); | ||
return(NX_CRYPTO_SUCCESS); | ||
} | ||
|
||
return(nx_crypto_clone_cleanup_test_clone(dest_metadata, source_metadata, length)); | ||
} |
74 changes: 74 additions & 0 deletions
74
test/regression/nx_secure_test/hash_clone/nx_crypto_hash_clone_test.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
|
||
#ifndef SRC_NX_CRYPTO_HASH_CLONE_TEST_H_ | ||
#define SRC_NX_CRYPTO_HASH_CLONE_TEST_H_ | ||
|
||
/* Determine if a C++ compiler is being used. If so, ensure that standard | ||
C is used to process the API information. */ | ||
#ifdef __cplusplus | ||
|
||
/* Yes, C++ compiler is present. Use standard C. */ | ||
extern "C" { | ||
|
||
#endif | ||
|
||
#include "nx_secure_tls.h" | ||
#include "nx_crypto.h" | ||
|
||
typedef struct NX_CRYPTO_HASH_CLONE_TEST_STRUCT | ||
{ | ||
|
||
UINT nx_crypto_hash_operation; | ||
|
||
} NX_CRYPTO_HASH_CLONE_TEST; | ||
|
||
|
||
UINT _nx_crypto_method_hash_clone_test_init(struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
VOID **handle, | ||
VOID *crypto_metadata, | ||
ULONG crypto_metadata_size); | ||
|
||
UINT _nx_crypto_method_hash_clone_test_cleanup(VOID *crypto_metadata); | ||
|
||
UINT _nx_crypto_method_hash_clone_test_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ | ||
VOID *handle, /* Crypto handler */ | ||
struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
UCHAR *input, ULONG input_length_in_byte, | ||
UCHAR *iv_ptr, | ||
UCHAR *output, ULONG output_length_in_byte, | ||
VOID *crypto_metadata, ULONG crypto_metadata_size, | ||
VOID *packet_ptr, | ||
VOID (*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); | ||
|
||
UINT nx_crypto_hash_clone_test_clone(VOID *dest_metadata, VOID *source_metadata, ULONG length); | ||
UINT nx_crypto_clone_cleanup_test_clone(VOID *dest_metadata, VOID *source_metadata, ULONG length); | ||
|
||
|
||
UINT _nx_crypto_method_clone_cleanup_test_init(struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
VOID **handle, | ||
VOID *crypto_metadata, | ||
ULONG crypto_metadata_size); | ||
|
||
UINT _nx_crypto_method_clone_cleanup_test_cleanup(VOID *crypto_metadata); | ||
|
||
UINT _nx_crypto_method_clone_cleanup_test_operation(UINT op, /* Encrypt, Decrypt, Authenticate */ | ||
VOID *handle, /* Crypto handler */ | ||
struct NX_CRYPTO_METHOD_STRUCT *method, | ||
UCHAR *key, NX_CRYPTO_KEY_SIZE key_size_in_bits, | ||
UCHAR *input, ULONG input_length_in_byte, | ||
UCHAR *iv_ptr, | ||
UCHAR *output, ULONG output_length_in_byte, | ||
VOID *crypto_metadata, ULONG crypto_metadata_size, | ||
VOID *packet_ptr, | ||
VOID(*nx_crypto_hw_process_callback)(VOID *packet_ptr, UINT status)); | ||
|
||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* SRC_NX_CRYPTO_HASH_CLONE_TEST_H_ */ | ||
|
14 changes: 14 additions & 0 deletions
14
test/regression/nx_secure_test/hash_clone/nx_secure_user.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
|
||
#ifndef SRC_NX_SECURE_USER_H | ||
#define SRC_NX_SECURE_USER_H | ||
|
||
UINT nx_crypto_hash_clone_test_clone(VOID *dest_metadata, VOID *source_metadata, ULONG length); | ||
#define NX_SECURE_HASH_METADATA_CLONE nx_crypto_hash_clone_test_clone | ||
|
||
UINT nx_crypto_clone_cleanup(VOID *metadata, ULONG length); | ||
#define NX_SECURE_HASH_CLONE_CLEANUP nx_crypto_clone_cleanup | ||
|
||
|
||
|
||
#endif /* SRC_NX_SECURE_USER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
unsigned char ica_cert_der[] = { | ||
0x30, 0x82, 0x03, 0xdf, 0x30, 0x82, 0x02, 0xc7, 0xa0, 0x03, 0x02, 0x01, | ||
0x02, 0x02, 0x01, 0x02, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, | ||
0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x7a, 0x31, 0x0b, 0x30, | ||
0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, | ||
0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, | ||
0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x09, 0x53, 0x61, | ||
0x6e, 0x20, 0x44, 0x69, 0x65, 0x67, 0x6f, 0x31, 0x16, 0x30, 0x14, 0x06, | ||
0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, | ||
0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, 0x14, 0x30, 0x12, 0x06, | ||
0x03, 0x55, 0x04, 0x0b, 0x0c, 0x0b, 0x4e, 0x65, 0x74, 0x58, 0x20, 0x53, | ||
0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, | ||
0x04, 0x03, 0x0c, 0x13, 0x4e, 0x65, 0x74, 0x58, 0x20, 0x53, 0x65, 0x63, | ||
0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, | ||
0x1e, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x33, 0x33, 0x31, 0x32, 0x31, 0x30, | ||
0x30, 0x30, 0x32, 0x5a, 0x17, 0x0d, 0x32, 0x37, 0x30, 0x33, 0x32, 0x39, | ||
0x32, 0x31, 0x30, 0x30, 0x30, 0x32, 0x5a, 0x30, 0x6f, 0x31, 0x0b, 0x30, | ||
0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, | ||
0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x43, 0x41, 0x31, | ||
0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0d, 0x45, 0x78, | ||
0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x31, | ||
0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x4e, 0x58, | ||
0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x65, 0x31, 0x27, 0x30, 0x25, 0x06, | ||
0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4e, 0x58, 0x20, 0x53, 0x65, 0x63, | ||
0x75, 0x72, 0x65, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x49, 0x6e, 0x74, | ||
0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x20, 0x43, 0x41, | ||
0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, | ||
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, | ||
0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xa7, 0xa4, 0xd9, | ||
0xd0, 0x19, 0x84, 0x4e, 0xab, 0x8e, 0x08, 0xad, 0x30, 0xe6, 0x79, 0x46, | ||
0x46, 0xe2, 0xd3, 0x13, 0xc1, 0x69, 0xa9, 0x4a, 0xc9, 0xc8, 0x95, 0x54, | ||
0xa8, 0x76, 0x41, 0x63, 0x10, 0xc4, 0xe4, 0xfd, 0x08, 0x69, 0x7f, 0x89, | ||
0x79, 0x82, 0x62, 0xd7, 0x90, 0x73, 0x55, 0x06, 0x0d, 0x62, 0xec, 0x1b, | ||
0x2d, 0xaf, 0xf2, 0x39, 0x14, 0x47, 0x5b, 0x9d, 0x7a, 0xd2, 0xe3, 0xf9, | ||
0xae, 0x37, 0x49, 0xd0, 0xb8, 0x01, 0xf2, 0x1a, 0x84, 0x9a, 0x50, 0x37, | ||
0x4d, 0xd6, 0xed, 0x7c, 0x44, 0xef, 0xd1, 0xb8, 0x05, 0x4b, 0x3c, 0x05, | ||
0x59, 0x4a, 0xcd, 0xc1, 0xce, 0x6d, 0xb9, 0xbe, 0xb0, 0xc4, 0xe5, 0x44, | ||
0x02, 0xfd, 0xfa, 0x61, 0x3e, 0x59, 0x3e, 0x4b, 0x0f, 0xe6, 0x20, 0xda, | ||
0xf1, 0xca, 0xb5, 0x67, 0x52, 0x2b, 0x2e, 0x1b, 0xfc, 0xf1, 0xc6, 0x55, | ||
0x88, 0xf9, 0x28, 0xaa, 0xd9, 0x55, 0x6a, 0xc7, 0x61, 0x94, 0x24, 0x8d, | ||
0x63, 0xfb, 0xa6, 0x8a, 0x06, 0x21, 0xe2, 0x8e, 0xf7, 0xa8, 0x0b, 0x91, | ||
0x39, 0xff, 0x8d, 0xde, 0xb8, 0x0b, 0x16, 0x8a, 0xc6, 0xac, 0xe0, 0x61, | ||
0x69, 0x98, 0x4a, 0x90, 0xfd, 0x03, 0xe3, 0x38, 0x90, 0xc7, 0xe3, 0x13, | ||
0x40, 0x12, 0xc5, 0x44, 0x07, 0x44, 0x57, 0x43, 0xbb, 0xa4, 0x67, 0x72, | ||
0x20, 0xbb, 0x97, 0xe6, 0xa1, 0x32, 0xb2, 0x73, 0xf2, 0x8d, 0xe3, 0x23, | ||
0xdc, 0x06, 0xc0, 0x1f, 0xfc, 0xe3, 0x3a, 0xcc, 0x9c, 0xf8, 0x00, 0x87, | ||
0x39, 0x0d, 0x1e, 0x4d, 0x59, 0x15, 0x16, 0xe6, 0x63, 0x5b, 0x53, 0x6d, | ||
0x79, 0x2f, 0xb7, 0x5a, 0xcc, 0x37, 0xc9, 0x96, 0xff, 0x46, 0xac, 0xdd, | ||
0x44, 0x9f, 0x3a, 0xc8, 0x83, 0xeb, 0x1b, 0x67, 0xa0, 0x2d, 0xa8, 0x34, | ||
0x19, 0xf0, 0x5b, 0xe8, 0x59, 0xf7, 0xc9, 0x08, 0xab, 0x09, 0x71, 0x78, | ||
0x75, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x7b, 0x30, 0x79, 0x30, 0x09, | ||
0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x2c, 0x06, | ||
0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x1f, | ||
0x16, 0x1d, 0x4f, 0x70, 0x65, 0x6e, 0x53, 0x53, 0x4c, 0x20, 0x47, 0x65, | ||
0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x20, 0x43, 0x65, 0x72, 0x74, | ||
0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1d, 0x06, 0x03, 0x55, | ||
0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x8e, 0x6a, 0xb0, 0xfe, 0x49, 0xc5, | ||
0x6a, 0x96, 0x9e, 0xba, 0xb8, 0xb6, 0x58, 0xfc, 0x52, 0x7f, 0xab, 0x51, | ||
0xf2, 0x3a, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, | ||
0x16, 0x80, 0x14, 0x1b, 0x8d, 0x06, 0xd9, 0x6b, 0xad, 0xee, 0x82, 0x24, | ||
0x26, 0x55, 0x9a, 0x1b, 0x03, 0x44, 0x92, 0x0a, 0x06, 0x92, 0x48, 0x30, | ||
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, | ||
0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x18, 0x5a, 0x50, 0xb6, 0x44, | ||
0xba, 0x68, 0xac, 0x7f, 0x06, 0x0f, 0xbc, 0x1a, 0x58, 0x59, 0xf1, 0xf1, | ||
0xe3, 0xb8, 0x0d, 0x74, 0xdd, 0x74, 0x26, 0x6a, 0xea, 0xfc, 0xfe, 0x06, | ||
0x53, 0xe9, 0x80, 0xe3, 0x07, 0x83, 0x8a, 0xc9, 0xc9, 0xc0, 0x93, 0xb4, | ||
0xc2, 0x59, 0x71, 0xa7, 0x58, 0xac, 0x32, 0x0f, 0x32, 0x9c, 0x5b, 0x4d, | ||
0x53, 0xcb, 0xdc, 0x04, 0x00, 0x04, 0x27, 0x37, 0x2d, 0x11, 0x5b, 0xaa, | ||
0xf6, 0x45, 0x8a, 0xc4, 0x74, 0x2e, 0x47, 0x83, 0xb8, 0x5e, 0x3a, 0xc0, | ||
0x10, 0xaf, 0xc1, 0xd2, 0x61, 0x1c, 0x85, 0x31, 0x16, 0x74, 0x05, 0xf4, | ||
0xc6, 0xd8, 0x35, 0x83, 0x13, 0xca, 0x25, 0x5b, 0x22, 0xc6, 0x2c, 0x32, | ||
0x8d, 0x3a, 0x3f, 0x78, 0x79, 0x57, 0xbe, 0x97, 0x96, 0x90, 0x20, 0x7d, | ||
0xe5, 0xe6, 0xe6, 0x42, 0xde, 0xd3, 0xd4, 0xb4, 0x18, 0x34, 0x9d, 0xc3, | ||
0x95, 0x2d, 0xb2, 0x91, 0x1d, 0xfe, 0x3c, 0xee, 0x5c, 0xda, 0xdd, 0xd7, | ||
0xf5, 0x05, 0xf1, 0xbd, 0xa0, 0x2f, 0x0a, 0x03, 0x2e, 0x45, 0x26, 0x9c, | ||
0xac, 0x16, 0x59, 0x9a, 0x7f, 0xf2, 0x3a, 0x3e, 0xdb, 0x4b, 0x63, 0x58, | ||
0x38, 0x0b, 0x64, 0x5e, 0x24, 0x15, 0x92, 0xb5, 0xcf, 0x33, 0xe9, 0x61, | ||
0x1f, 0xb9, 0x33, 0xa1, 0x09, 0x41, 0x9f, 0x05, 0x11, 0xad, 0x07, 0x0b, | ||
0x60, 0x67, 0x1a, 0x4c, 0x6c, 0x93, 0x36, 0x90, 0x20, 0xac, 0xb3, 0x99, | ||
0x61, 0xa0, 0xda, 0xe5, 0x8d, 0x3f, 0x66, 0xd1, 0xf3, 0x91, 0x40, 0x60, | ||
0xcf, 0x97, 0xbb, 0x15, 0xb1, 0x81, 0x4e, 0xbf, 0xba, 0xef, 0x20, 0x36, | ||
0x6f, 0x00, 0x40, 0xa2, 0xa3, 0x24, 0x5c, 0x61, 0xd5, 0xa5, 0x64, 0xbf, | ||
0xbe, 0x29, 0xdf, 0x47, 0x4b, 0xc8, 0x76, 0x4f, 0x2e, 0x4c, 0x5c, 0xed, | ||
0x99, 0x26, 0xe8, 0xf1, 0x72, 0x5e, 0x9b, 0x86, 0x73, 0xda, 0xfb | ||
}; | ||
unsigned int ica_cert_der_len = 995; |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
712 changes: 712 additions & 0 deletions
712
test/regression/nx_secure_test/nx_crypto_ciphersuites_regression.c
Large diffs are not rendered by default.
Oops, something went wrong.
2,806 changes: 2,806 additions & 0 deletions
2,806
test/regression/nx_secure_test/nx_ram_network_driver_test_1500.c
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
test/regression/nx_secure_test/nx_ram_network_driver_test_1500.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#ifndef _NX_RAM_NETWORK_DRIVER_TEST_1500_H_ | ||
#define _NX_RAM_NETWORK_DRIVER_TEST_1500_H_ | ||
#include "tx_api.h" | ||
#include "tx_timer.h" | ||
#define NX_RAMDRIVER_OP_BYPASS 0 | ||
#define NX_RAMDRIVER_OP_DROP 1 | ||
#define NX_RAMDRIVER_OP_DELAY 2 | ||
#define NX_RAMDRIVER_OP_DUPLICATE 3 | ||
|
||
#define NX_RAMDRIVER_TIMER_UNUSED 0 | ||
#define NX_RAMDRIVER_TIMER_USED 1 | ||
#define NX_RAMDRIVER_TIMER_DIRTY 2 | ||
|
||
#define NX_MAX_TIMER 5 | ||
|
||
VOID _nx_ram_network_driver_timer_clean(VOID); | ||
|
||
|
||
#ifdef NX_PCAP_ENABLE | ||
|
||
/* Define return values. */ | ||
#define NX_PCAP_FILE_OK 1 | ||
#define NX_PCAP_FILE_ERROR 0 | ||
|
||
/* Define the pcap header struct. */ | ||
typedef struct NX_PCAP_HEADER_FILE_STRUCT | ||
{ | ||
UINT magic_number; /* magic number */ | ||
USHORT version_major; /* major version number */ | ||
USHORT version_minor; /* minor version number */ | ||
INT this_zone; /* GMT to local correction */ | ||
UINT sig_figs; /* accuracy of timestamps */ | ||
UINT snapshot_length; /* max length of captured packets, in octets */ | ||
UINT link_type; /* data link type */ | ||
} NX_PCAP_FILE_HEADER; | ||
|
||
typedef struct NX_PCAP_PACKET_HEADER_STRUCT | ||
{ | ||
UINT time_stamp_second; /* timestamp seconds */ | ||
UINT time_stamp_microseconds; /* timestamp microseconds */ | ||
UINT capture_length; /* number of octets of packet saved in file */ | ||
UINT actual_length; /* actual length of packet */ | ||
} NX_PCAP_PACKET_HEADER; | ||
|
||
/* Define time value. */ | ||
typedef struct timeval NX_TIME_VALUE; | ||
|
||
#endif /* NX_PCAP_ENABLE */ | ||
|
||
#endif /* _NX_RAM_NETWORK_DRIVER_TEST_1500_H_ */ |
382 changes: 382 additions & 0 deletions
382
test/regression/nx_secure_test/nx_secure_3des_error_checking_test.c
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,278 @@ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
#include "nx_crypto_3des.h" | ||
#include "tls_test_utility.h" | ||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
#include "nx_secure_tls.h" | ||
#endif | ||
|
||
#define MAXIMUM_KEY_BITS 256 | ||
|
||
/* Define software 3DES method. */ | ||
static NX_CRYPTO_METHOD test_crypto_method_3des = | ||
{ | ||
NX_CRYPTO_ENCRYPTION_3DES_CBC, /* 3DES crypto algorithm filled at runtime*/ | ||
0, /* Key size in bits */ | ||
NX_CRYPTO_3DES_IV_LEN_IN_BITS, /* IV size in bits */ | ||
0, /* ICV size in bits, not used. */ | ||
NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS, /* Block size in bytes. */ | ||
sizeof(NX_CRYPTO_3DES), /* Metadata size in bytes */ | ||
_nx_crypto_method_3des_init, /* 3DES initialization routine. */ | ||
NX_CRYPTO_NULL, /* 3DES cleanup routine, not used. */ | ||
_nx_crypto_method_3des_operation /* 3DES operation */ | ||
|
||
}; | ||
|
||
/* 3DES context. */ | ||
static NX_CRYPTO_3DES _3des_ctx; | ||
|
||
/* Input to hold plain plus nonce. */ | ||
static UCHAR key[24]; | ||
|
||
/* IV. */ | ||
static UCHAR iv[8] = {0, 1, 2, 3, 4, 5, 6, 7}; | ||
|
||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
static TX_THREAD thread_0; | ||
#endif | ||
|
||
static VOID thread_0_entry(ULONG thread_input); | ||
|
||
#ifdef CTEST | ||
void test_application_define(void *first_unused_memory); | ||
void test_application_define(void *first_unused_memory) | ||
#else | ||
void nx_secure_3des_test_application_define(void *first_unused_memory) | ||
#endif | ||
{ | ||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
tx_thread_create(&thread_0, "Thread 0", thread_0_entry, 0, | ||
first_unused_memory, 4096, | ||
16, 16, 4, TX_AUTO_START); | ||
#else | ||
thread_0_entry(0); | ||
#endif | ||
} | ||
|
||
#define TEST_TEXT_LENGTH 32 | ||
|
||
static VOID thread_0_entry(ULONG thread_input) | ||
{ | ||
UINT i, status, backup; | ||
UCHAR input[TEST_TEXT_LENGTH]; | ||
UCHAR output[TEST_TEXT_LENGTH]; | ||
UCHAR expected[TEST_TEXT_LENGTH]; | ||
VOID *handle; | ||
|
||
/* Print out test information banner. */ | ||
printf("NetX Secure Test: 3DES Test.........................................."); | ||
|
||
/* Invalid context pointer. */ | ||
status = _nx_crypto_des_key_set( NX_CRYPTO_NULL, input); | ||
EXPECT_EQ( status, NX_CRYPTO_PTR_ERROR); | ||
|
||
/* Encryption. */ | ||
memset(output, 0xFF, sizeof(output)); | ||
|
||
/* Set key and IV. */ | ||
for (i = 0; i < 24; i++) | ||
{ | ||
key[i] = i; | ||
input[i] = i; | ||
} | ||
|
||
test_crypto_method_3des.nx_crypto_init(&test_crypto_method_3des, | ||
(UCHAR *)key, | ||
(NX_CRYPTO_3DES_KEY_LEN_IN_BITS), | ||
&handle, | ||
&_3des_ctx, | ||
sizeof(_3des_ctx)); | ||
|
||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_ENCRYPT, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
(UCHAR *)key, | ||
(NX_CRYPTO_3DES_KEY_LEN_IN_BITS), | ||
input, | ||
sizeof(input), | ||
(UCHAR *)iv, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Decryption. */ | ||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_DECRYPT, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
(UCHAR *)key, | ||
(NX_CRYPTO_3DES_KEY_LEN_IN_BITS), | ||
(UCHAR *)output, | ||
sizeof(output), | ||
(UCHAR *)iv, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
EXPECT_EQ(0, memcmp(output, input, sizeof(input))); | ||
|
||
/* Test the support of filling plain text in several updates. */ | ||
EXPECT_TRUE(TEST_TEXT_LENGTH > (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3)); | ||
|
||
/* Generate test data. */ | ||
srand(time(NULL)); | ||
|
||
for (i = 0; i < TEST_TEXT_LENGTH; i++) | ||
{ | ||
input[i] = (UCHAR)rand(); | ||
} | ||
|
||
/* Encryption. */ | ||
|
||
memset(output, 0xFF, sizeof(output)); | ||
memset(expected, 0xFF, sizeof(expected)); | ||
|
||
/* Calculate the expected result. */ | ||
test_crypto_method_3des.nx_crypto_init(&test_crypto_method_3des, | ||
(UCHAR *)key, | ||
(NX_CRYPTO_3DES_KEY_LEN_IN_BITS), | ||
&handle, | ||
&_3des_ctx, | ||
sizeof(_3des_ctx)); | ||
|
||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_ENCRYPT, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
(UCHAR *)key, | ||
(NX_CRYPTO_3DES_KEY_LEN_IN_BITS), | ||
input, | ||
TEST_TEXT_LENGTH, | ||
(UCHAR *)iv, | ||
(UCHAR *)expected, | ||
sizeof(expected), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Fill plain text in several times. */ | ||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_ENCRYPT_INITIALIZE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
NX_CRYPTO_NULL, | ||
0, | ||
NX_CRYPTO_NULL, | ||
0, | ||
(UCHAR *)iv, | ||
NX_CRYPTO_NULL, | ||
0, | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_ENCRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
NX_CRYPTO_NULL, | ||
0, | ||
input, | ||
(NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_ENCRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
NX_CRYPTO_NULL, | ||
0, | ||
(UCHAR *)input + (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
TEST_TEXT_LENGTH - (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output + (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
sizeof(output) - (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
EXPECT_EQ(0, memcmp(output, expected, sizeof(expected))); | ||
|
||
/* Decryption. */ | ||
|
||
/* Calculate the expected result. */ | ||
test_crypto_method_3des.nx_crypto_init(&test_crypto_method_3des, | ||
(UCHAR *)key, | ||
(NX_CRYPTO_3DES_KEY_LEN_IN_BITS), | ||
&handle, | ||
&_3des_ctx, | ||
sizeof(_3des_ctx)); | ||
|
||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_DECRYPT, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
(UCHAR *)key, | ||
(NX_CRYPTO_3DES_KEY_LEN_IN_BITS), | ||
(UCHAR *)expected, | ||
TEST_TEXT_LENGTH, | ||
(UCHAR *)iv, | ||
(UCHAR *)expected, | ||
sizeof(expected), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Fill cipher text in several times. */ | ||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_DECRYPT_INITIALIZE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
NX_CRYPTO_NULL, | ||
0, | ||
NX_CRYPTO_NULL, | ||
0, | ||
(UCHAR *)iv, | ||
NX_CRYPTO_NULL, | ||
0, | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_DECRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
NX_CRYPTO_NULL, | ||
0, | ||
output, | ||
(NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
test_crypto_method_3des.nx_crypto_operation(NX_CRYPTO_DECRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_3des, | ||
NX_CRYPTO_NULL, | ||
0, | ||
(UCHAR *)output + (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
TEST_TEXT_LENGTH - (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output + (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
sizeof(output) - (NX_CRYPTO_3DES_BLOCK_SIZE_IN_BITS >> 3), | ||
&_3des_ctx, | ||
sizeof(_3des_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
EXPECT_EQ(0, memcmp(output, expected, TEST_TEXT_LENGTH)); | ||
|
||
printf("SUCCESS!\n"); | ||
test_control_return(0); | ||
} |
648 changes: 648 additions & 0 deletions
648
test/regression/nx_secure_test/nx_secure_aes_additional_test.c
Large diffs are not rendered by default.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
test/regression/nx_secure_test/nx_secure_aes_additional_test_data.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
#include "nx_api.h" | ||
#else | ||
#include "nx_crypto_port.h" | ||
#endif | ||
|
||
typedef struct | ||
{ | ||
UINT algorithm; | ||
UCHAR *key; | ||
UINT key_len; | ||
UCHAR *iv; | ||
UINT iv_len; | ||
UCHAR *plain; | ||
UINT plain_len; | ||
UCHAR *secret; | ||
UINT secret_len; | ||
} AES_DATA; | ||
|
||
/* 3F1EDC0698B1D258DE68EE79340A752149B609286057E16E73C39F36D2D61D0B */ | ||
static UCHAR key_ctr_256_99[] = { | ||
0x3F, 0x1E, 0xDC, 0x06, 0x98, 0xB1, 0xD2, 0x58, 0xDE, 0x68, 0xEE, 0x79, 0x34, 0x0A, 0x75, 0x21, | ||
0x49, 0xB6, 0x09, 0x28, 0x60, 0x57, 0xE1, 0x6E, 0x73, 0xC3, 0x9F, 0x36, 0xD2, 0xD6, 0x1D, 0x0B, | ||
}; | ||
|
||
/* F9999E1CCC7798453C31FD0200000001 */ | ||
static UCHAR iv_ctr_256_99[] = { | ||
0xF9, 0x99, 0x9E, 0x1C, 0xCC, 0x77, 0x98, 0x45, 0x3C, 0x31, 0xFD, 0x02, 0x00, 0x00, 0x00, 0x01, | ||
}; | ||
|
||
/* Input the plain text which is not multiples of 16. */ | ||
static UCHAR plain_ctr_256_99[] = { 0x0, 0x0, 0x0, 0x0}; | ||
|
||
/* A42E843B22E6CC7C09AD783FACE7F251 */ | ||
static UCHAR key_cbc_128_0[] = { | ||
0xA4, 0x2E, 0x84, 0x3B, 0x22, 0xE6, 0xCC, 0x7C, 0x09, 0xAD, 0x78, 0x3F, 0xAC, 0xE7, 0xF2, 0x51, | ||
}; | ||
|
||
/* 87BFAE15B37B90751B426240F5BC0C16 */ | ||
static UCHAR iv_cbc_128_0[] = { | ||
0x87, 0xBF, 0xAE, 0x15, 0xB3, 0x7B, 0x90, 0x75, 0x1B, 0x42, 0x62, 0x40, 0xF5, 0xBC, 0x0C, 0x16, | ||
}; | ||
|
||
/* 997F8E2A478FF2479A83B90BD44EDE5C */ | ||
static UCHAR plain_cbc_128_0[] = { 0x0, 0x0, 0x0, 0x0}; | ||
|
||
/* A42E843B22E6CC7C09AD783FACE7F251 */ | ||
static UCHAR key_cbc_128_1[] = { | ||
0xA4, 0x2E, 0x84, 0x3B, 0x22, 0xE6, 0xCC, 0x7C, 0x09, 0xAD, 0x78, 0x3F, 0xAC, 0xE7, 0xF2, 0x51, | ||
}; | ||
|
||
/* 87BFAE15B37B90751B426240F5BC0C16 */ | ||
static UCHAR iv_cbc_128_1[] = { | ||
0x87, 0xBF, 0xAE, 0x15, 0xB3, 0x7B, 0x90, 0x75, 0x1B, 0x42, 0x62, 0x40, 0xF5, 0xBC, 0x0C, 0x16, | ||
}; | ||
|
||
/* 997F8E2A478FF2479A83B90BD44EDE5C */ | ||
static UCHAR plain_cbc_128_1[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10}; | ||
|
||
static AES_DATA aes_data[] = | ||
{ | ||
{NX_CRYPTO_ENCRYPTION_AES_CTR, key_ctr_256_99, sizeof(key_ctr_256_99), iv_ctr_256_99, sizeof(iv_ctr_256_99), plain_ctr_256_99, sizeof(plain_ctr_256_99), NULL, 0}, | ||
{NX_CRYPTO_ENCRYPTION_AES_CBC, key_cbc_128_0, sizeof(key_cbc_128_0), iv_cbc_128_0, sizeof(iv_cbc_128_0), plain_cbc_128_0, sizeof(plain_cbc_128_0), NULL, 0}, | ||
{NX_CRYPTO_ENCRYPTION_AES_CBC, key_cbc_128_1, sizeof(key_cbc_128_1), iv_cbc_128_1, sizeof(iv_cbc_128_1), plain_cbc_128_1, sizeof(plain_cbc_128_1), NULL, 0}, | ||
}; |
416 changes: 416 additions & 0 deletions
416
test/regression/nx_secure_test/nx_secure_aes_ccm_test.c
Large diffs are not rendered by default.
Oops, something went wrong.
12,963 changes: 12,963 additions & 0 deletions
12,963
test/regression/nx_secure_test/nx_secure_aes_ccm_test_data.c
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,305 @@ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
|
||
#include "nx_crypto_aes.h" | ||
|
||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
#include "nx_secure_tls.h" | ||
#endif | ||
#include "tls_test_utility.h" | ||
|
||
#define MAXIMUM_KEY_BITS 256 | ||
|
||
#include "nx_secure_aes_test_data.c" | ||
|
||
/* Define software AES method. */ | ||
NX_CRYPTO_METHOD test_crypto_method_aes = | ||
{ | ||
0, /* AES crypto algorithm filled at runtime */ | ||
0, /* Key size in bits */ | ||
NX_CRYPTO_AES_IV_LEN_IN_BITS, /* IV size in bits */ | ||
0, /* ICV size in bits, not used. */ | ||
NX_CRYPTO_AES_BLOCK_SIZE_IN_BITS >> 3, /* Block size in bytes. */ | ||
sizeof(NX_AES), /* Metadata size in bytes */ | ||
_nx_crypto_method_aes_init, /* AES initialization routine. */ | ||
NX_CRYPTO_NULL, /* AES cleanup routine, not used. */ | ||
_nx_crypto_method_aes_operation /* AES operation */ | ||
|
||
}; | ||
|
||
/* AES context. */ | ||
static NX_CRYPTO_AES aes_ctx; | ||
|
||
/* Input to hold plain plus nonce. */ | ||
static ULONG key[(MAXIMUM_KEY_BITS >> 5) + 1]; | ||
|
||
/* IV. */ | ||
static ULONG iv[4]; | ||
|
||
#define TEST_TEXT_LENGTH (NX_CRYPTO_AES_BLOCK_SIZE * 3) | ||
|
||
/* Output. */ | ||
static ULONG output[TEST_TEXT_LENGTH >> 2]; | ||
|
||
/* Buffers for packet chain tests. */ | ||
static UCHAR plain_text_buffer[TEST_TEXT_LENGTH]; | ||
static UCHAR cipher_text_buffer[TEST_TEXT_LENGTH]; | ||
|
||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
static TX_THREAD thread_0; | ||
#endif | ||
|
||
static VOID thread_0_entry(ULONG thread_input); | ||
|
||
#ifdef CTEST | ||
void test_application_define(void *first_unused_memory); | ||
void test_application_define(void *first_unused_memory) | ||
#else | ||
void nx_secure_aes_test_application_define(void *first_unused_memory) | ||
#endif | ||
{ | ||
#ifndef NX_CRYPTO_STANDALONE_ENABLE | ||
tx_thread_create(&thread_0, "Thread 0", thread_0_entry, 0, | ||
first_unused_memory, 4096, | ||
16, 16, 4, TX_AUTO_START); | ||
#else | ||
thread_0_entry(0); | ||
#endif | ||
} | ||
|
||
static VOID thread_0_entry(ULONG thread_input) | ||
{ | ||
UINT i, j, status; | ||
UCHAR *nonce; | ||
UINT nonce_len; | ||
NX_CRYPTO_METHOD test_method; | ||
|
||
/* Print out test information banner. */ | ||
printf("NetX Secure Test: AES Test..........................................."); | ||
|
||
for (i = 0; i < sizeof(aes_data) / sizeof(AES_DATA); i++) | ||
{ | ||
|
||
/* Encryption. */ | ||
memset(output, 0xFF, sizeof(output)); | ||
|
||
/* Conjunction of key and nonce for CTR mode. */ | ||
/* It does not affect CBC mode. */ | ||
memcpy(key, aes_data[i].key, aes_data[i].key_len); | ||
memcpy(key + (aes_data[i].key_len >> 2), aes_data[i].iv, 4); | ||
|
||
if (aes_data[i].algorithm == NX_CRYPTO_ENCRYPTION_AES_CBC) | ||
{ | ||
memcpy(iv, aes_data[i].iv, sizeof(iv)); | ||
} | ||
else | ||
{ | ||
memcpy(iv, aes_data[i].iv + 4, 8); | ||
} | ||
|
||
/* Set crypto algorithm. */ | ||
test_crypto_method_aes.nx_crypto_algorithm = aes_data[i].algorithm; | ||
|
||
test_crypto_method_aes.nx_crypto_init(&test_crypto_method_aes, | ||
(UCHAR *)key, | ||
(aes_data[i].key_len << 3), | ||
NX_CRYPTO_NULL, | ||
&aes_ctx, | ||
sizeof(aes_ctx)); | ||
|
||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_ENCRYPT, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
(UCHAR *)key, | ||
(aes_data[i].key_len << 3), | ||
aes_data[i].plain, | ||
aes_data[i].plain_len, | ||
(UCHAR *)iv, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
EXPECT_EQ(0, memcmp(output, aes_data[i].secret, aes_data[i].secret_len)); | ||
|
||
/* Decryption. */ | ||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_DECRYPT, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
(UCHAR *)key, | ||
(aes_data[i].key_len << 3), | ||
aes_data[i].secret, | ||
aes_data[i].secret_len, | ||
(UCHAR *)iv, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
EXPECT_EQ(0, memcmp(output, aes_data[i].plain, aes_data[i].plain_len)); | ||
} | ||
|
||
srand(time(NULL)); | ||
|
||
/* Tests for NX_CRYPTO_ENCRYPT_UPDATE and NX_CRYPTO_DECRYPT_UPDATE. */ | ||
for (i = 0; i < sizeof(aes_data) / sizeof(AES_DATA); i++) | ||
{ | ||
|
||
/* Conjunction of key and nonce for CTR mode. */ | ||
/* It does not affect CBC mode. */ | ||
memcpy(key, aes_data[i].key, aes_data[i].key_len); | ||
memcpy(key + (aes_data[i].key_len >> 2), aes_data[i].iv, 4); | ||
|
||
if (aes_data[i].algorithm == NX_CRYPTO_ENCRYPTION_AES_CBC) | ||
{ | ||
memcpy(iv, aes_data[i].iv, sizeof(iv)); | ||
nonce = NX_CRYPTO_NULL; | ||
nonce_len = 0; | ||
} | ||
else | ||
{ | ||
memcpy(iv, aes_data[i].iv + 4, 8); | ||
nonce = (UCHAR *)key + aes_data[i].key_len; | ||
nonce_len = 4; | ||
} | ||
|
||
/* Set crypto algorithm. */ | ||
test_crypto_method_aes.nx_crypto_algorithm = aes_data[i].algorithm; | ||
|
||
/* Generate test data. */ | ||
for (j = 0; j < TEST_TEXT_LENGTH; j++) | ||
{ | ||
plain_text_buffer[j] = (UCHAR)rand(); | ||
} | ||
|
||
test_crypto_method_aes.nx_crypto_init(&test_crypto_method_aes, | ||
(UCHAR *)key, | ||
(aes_data[i].key_len << 3), | ||
NX_CRYPTO_NULL, | ||
&aes_ctx, | ||
sizeof(aes_ctx)); | ||
|
||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_ENCRYPT, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
(UCHAR *)key, | ||
(aes_data[i].key_len << 3), | ||
plain_text_buffer, | ||
TEST_TEXT_LENGTH, | ||
(UCHAR *)iv, | ||
cipher_text_buffer, | ||
sizeof(cipher_text_buffer), | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Tests for NX_CRYPTO_ENCRYPT_UPDATE and NX_CRYPTO_DECRYPT_UPDATE. */ | ||
|
||
/* Encryption. */ | ||
memset(output, 0xFF, sizeof(output)); | ||
|
||
/* Initialize the context. */ | ||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_ENCRYPT_INITIALIZE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
NX_CRYPTO_NULL, | ||
0, | ||
nonce, | ||
nonce_len, | ||
(UCHAR *)iv, | ||
NX_CRYPTO_NULL, | ||
0, | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Update one block of input. */ | ||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_ENCRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
NX_CRYPTO_NULL, | ||
0, | ||
plain_text_buffer, | ||
NX_CRYPTO_AES_BLOCK_SIZE, | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Update the rest. */ | ||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_ENCRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
NX_CRYPTO_NULL, | ||
0, | ||
plain_text_buffer + NX_CRYPTO_AES_BLOCK_SIZE, | ||
TEST_TEXT_LENGTH - NX_CRYPTO_AES_BLOCK_SIZE, | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output + NX_CRYPTO_AES_BLOCK_SIZE, | ||
sizeof(output) - NX_CRYPTO_AES_BLOCK_SIZE, | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
EXPECT_EQ(0, memcmp(output, cipher_text_buffer, TEST_TEXT_LENGTH)); | ||
|
||
/* Decryption. */ | ||
memset(output, 0xFF, sizeof(output)); | ||
|
||
/* Initialize the context. */ | ||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_DECRYPT_INITIALIZE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
NX_CRYPTO_NULL, | ||
0, | ||
nonce, | ||
nonce_len, | ||
(UCHAR *)iv, | ||
NX_CRYPTO_NULL, | ||
0, | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Update one block of input. */ | ||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_DECRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
NX_CRYPTO_NULL, | ||
0, | ||
cipher_text_buffer, | ||
NX_CRYPTO_AES_BLOCK_SIZE, | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output, | ||
sizeof(output), | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
/* Update the rest. */ | ||
test_crypto_method_aes.nx_crypto_operation(NX_CRYPTO_DECRYPT_UPDATE, | ||
NX_CRYPTO_NULL, | ||
&test_crypto_method_aes, | ||
NX_CRYPTO_NULL, | ||
0, | ||
cipher_text_buffer + NX_CRYPTO_AES_BLOCK_SIZE, | ||
TEST_TEXT_LENGTH - NX_CRYPTO_AES_BLOCK_SIZE, | ||
NX_CRYPTO_NULL, | ||
(UCHAR *)output + NX_CRYPTO_AES_BLOCK_SIZE, | ||
sizeof(output) - NX_CRYPTO_AES_BLOCK_SIZE, | ||
&aes_ctx, | ||
sizeof(aes_ctx), | ||
NX_CRYPTO_NULL, NX_CRYPTO_NULL); | ||
|
||
EXPECT_EQ(0, memcmp(output, plain_text_buffer, TEST_TEXT_LENGTH)); | ||
} | ||
|
||
printf("SUCCESS!\n"); | ||
test_control_return(0); | ||
} |
Oops, something went wrong.