Skip to content

Commit

Permalink
Merge branch 'master' into release-candidate
Browse files Browse the repository at this point in the history
* master: (25 commits)
  configs:no_rot: Add configration for MIMXRT1050_EVK
  Allow boot messages on SWO instead of serial port.
  Don't try to retarget console to serial.
  [DISCO_L475VG_IOT01A] Every first boot after 2nd storage erase fails. Checked reset reson up to watchdog or higher
  Provide alternate entry point for bootloader instead of main
  IOTSTOR-922 - [Bootloader] Possible deadlock in upgdade.cpp / upgradeApplicationFromStorage() - refactoring remove event handling
  Add CI builds for DISCO_F769NI
  Add configuration option for DISCO_F769NI
  add support for L496AG
  IOTSTOR-859 - Combine block_device_fake_rot.json and internal_flash_no_rot.json app configs
  Add Uhuru Raven config
  Change target.default_lib to target.c_lib
  Allow specifying a startup delay before initializing storage hardware.
  Remove empty else paths
  Clean up the main.cpp programn flow.
  Fix Greentea test builds by providing same configs.
  Don't wrap mbed-trace
  Drop unused debug prints
  Drop unused PAAL update layer
  Add Renesas GR-PEACH and LYCHEE support
  ...
  • Loading branch information
Seppo Takalo committed Apr 17, 2020
2 parents c1f0bbc + 94579e9 commit 1ee8b2d
Show file tree
Hide file tree
Showing 42 changed files with 586 additions and 1,638 deletions.
6 changes: 5 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def bootloaderBuildStep(stepName,
""")

// Archive the binary
def file_extension = ("${target}" == "NRF52_DK" || "${target}" == "NRF52840_DK" || "${target}" == "LPC55S69_NS") ? "hex" : "bin"
def file_extension = ("${target}" == "NRF52840_DK" || "${target}" == "LPC55S69_NS") ? "hex" : "bin"
def binary_path = build_dir + "/${repoName}.${file_extension}"
archiveArtifacts artifacts: binary_path
archiveArtifacts artifacts: build_dir + "/${repoName}_application.map"
Expand All @@ -110,6 +110,7 @@ def build_test_config = [
["NUCLEO_F303RE", "mbed_app.json", "GCC_ARM"],
["NUCLEO_F411RE", "mbed_app.json", "GCC_ARM"],
["NUCLEO_F429ZI", "mbed_app.json", "GCC_ARM"],
["DISCO_F769NI", "mbed_app.json", "GCC_ARM"],

// Bootloaders for just testing the build
["NRF52840_DK", "configs/kvstore_and_fw_candidate_on_sd.json", "GCC_ARM"],
Expand All @@ -123,13 +124,15 @@ def build_test_config = [
["K64F", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["K64F", "configs/internal_kvstore_with_sd.json", "GCC_ARM"],
["K66F", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["NRF52840_DK", "configs/internal_kvstore_with_qspif.json", "GCC_ARM"],
["NUCLEO_L4R5ZI", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["NUCLEO_F429ZI", "configs/internal_flash_no_rot.json", "GCC_ARM"],
["UBLOX_EVK_ODIN_W2", "configs/internal_kvstore_with_sd.json", "GCC_ARM"],
["NUCLEO_F411RE", "configs/kvstore_and_fw_candidate_on_sd.json", "GCC_ARM"],
["DISCO_L475VG_IOT01A", "configs/internal_kvstore_with_qspif.json", "GCC_ARM"],
["LPC55S69_NS", "configs/psa.json", "GCC_ARM"],
["NUCLEO_F303RE", "configs/internal_kvstore_with_spif.json", "GCC_ARM"],
["DISCO_F769NI", "configs/internal_flash_no_rot.json", "GCC_ARM"],
]


Expand Down Expand Up @@ -254,6 +257,7 @@ def smoke_test_config = [
"NUCLEO_F303RE": ["toolchains": [ "GCC_ARM"], "raas": "https://auli.mbedcloudtesting.com:443"],
"NUCLEO_F411RE": ["toolchains": [ "GCC_ARM"], "raas": "https://ruka.mbedcloudtesting.com:443"],
"NUCLEO_F429ZI": ["toolchains": [ "GCC_ARM"], "raas": "https://ruka.mbedcloudtesting.com:443"],
"DISCO_F769NI": ["toolchains": [ "GCC_ARM"], "raas": "https://rauni.mbedcloudtesting.com:443"],
]

for (target in smoke_test_config.keySet()) {
Expand Down
74 changes: 37 additions & 37 deletions TESTS/bootloader/hmac/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

extern "C" arm_uc_error_t ARM_UC_cryptoHMACSHA256(arm_uc_buffer_t *key, arm_uc_buffer_t *input,
extern "C" int32_t ARM_UC_cryptoHMACSHA256(arm_uc_buffer_t *key, arm_uc_buffer_t *input,
arm_uc_buffer_t *output);

using namespace utest::v1;
Expand Down Expand Up @@ -65,7 +65,7 @@ static uint8_t hash_bootloader[HASH_SIZE] = { 0 };

static control_t test_unit(const size_t call_count)
{
arm_uc_error_t result;
int32_t result;

arm_uc_buffer_t key_buffer = { 0 };
arm_uc_buffer_t input_buffer = { 0 };
Expand All @@ -75,35 +75,35 @@ static control_t test_unit(const size_t call_count)
* Test invalid buffers.
*/
result = ARM_UC_cryptoHMACSHA256(NULL, NULL, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, NULL, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, NULL, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, &input_buffer, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, NULL, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

/**
Expand All @@ -114,35 +114,35 @@ static control_t test_unit(const size_t call_count)
output_buffer.ptr = hash_bootloader;

result = ARM_UC_cryptoHMACSHA256(NULL, NULL, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, NULL, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, NULL, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, &input_buffer, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, NULL, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

/**
Expand All @@ -154,36 +154,36 @@ static control_t test_unit(const size_t call_count)

/* ARM_UC_CU_ERR_INVALID_PARAMETER */
result = ARM_UC_cryptoHMACSHA256(NULL, NULL, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, NULL, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(&key_buffer, NULL, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, &input_buffer, NULL);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

result = ARM_UC_cryptoHMACSHA256(NULL, NULL, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code,
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result,
"bootloader hmac returned wrong error code");

/* ERR_NONE */
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "valid input should have succeeded");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "valid input should have succeeded");

/**
* Test key length.
Expand All @@ -195,12 +195,12 @@ static control_t test_unit(const size_t call_count)

/* max key size */
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "valid input should have succeeded");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "valid input should have succeeded");

/* max key size plus 1 */
key_buffer.size = SHA256_BLOCK_SIZE + 1;
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result.code, "too large key size should have failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(ARM_UC_CU_ERR_INVALID_PARAMETER, result, "too large key size should have failed");

return CaseNext;
}
Expand Down Expand Up @@ -277,7 +277,7 @@ static control_t test_nist_vectors(const size_t call_count)
/**
* Use test vectors on ARM_UC_cryptoHMACSHA256.
*/
arm_uc_error_t result;
int32_t result;
arm_uc_buffer_t key_buffer = { 0 };
arm_uc_buffer_t input_buffer = { 0 };
arm_uc_buffer_t output_buffer = { 0 };
Expand All @@ -296,7 +296,7 @@ static control_t test_nist_vectors(const size_t call_count)

memset(hash_bootloader, 0, HASH_SIZE);
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(HASH_SIZE, output_buffer.size, "bootloader incorrect hash length");
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(nist_cavs_1_hmac, hash_bootloader, nist_cavs_1_hmac_len,
"bootloader hmac incorrect");
Expand All @@ -318,7 +318,7 @@ static control_t test_nist_vectors(const size_t call_count)

memset(hash_bootloader, 0, HASH_SIZE);
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(HASH_SIZE, output_buffer.size, "bootloader incorrect hash length");
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(nist_cavs_2_hmac, hash_bootloader, nist_cavs_2_hmac_len,
"bootloader hmac incorrect");
Expand All @@ -340,7 +340,7 @@ static control_t test_nist_vectors(const size_t call_count)

memset(hash_bootloader, 0, HASH_SIZE);
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(HASH_SIZE, output_buffer.size, "bootloader incorrect hash length");
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(nist_cavs_3_hmac, hash_bootloader, nist_cavs_3_hmac_len,
"bootloader hmac incorrect");
Expand All @@ -362,7 +362,7 @@ static control_t test_nist_vectors(const size_t call_count)

memset(hash_bootloader, 0, HASH_SIZE);
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(HASH_SIZE, output_buffer.size, "bootloader incorrect hash length");
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(nist_cavs_4_hmac, hash_bootloader, nist_cavs_4_hmac_len,
"bootloader hmac incorrect");
Expand All @@ -384,7 +384,7 @@ static control_t test_nist_vectors(const size_t call_count)

memset(hash_bootloader, 0, HASH_SIZE);
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(HASH_SIZE, output_buffer.size, "bootloader incorrect hash length");
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(nist_cavs_5_hmac, hash_bootloader, nist_cavs_5_hmac_len,
"bootloader hmac incorrect");
Expand All @@ -406,7 +406,7 @@ static control_t test_nist_vectors(const size_t call_count)

memset(hash_bootloader, 0, HASH_SIZE);
result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(HASH_SIZE, output_buffer.size, "bootloader incorrect hash length");
TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(nist_cavs_6_hmac, hash_bootloader, nist_cavs_6_hmac_len,
"bootloader hmac incorrect");
Expand Down Expand Up @@ -465,8 +465,8 @@ static control_t test_random_vector(const size_t call_count)
output_buffer.size_max = HASH_SIZE;
output_buffer.ptr = hash_bootloader;

arm_uc_error_t result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result.code, "bootloader hmac failed");
int32_t result = ARM_UC_cryptoHMACSHA256(&key_buffer, &input_buffer, &output_buffer);
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_NONE, result, "bootloader hmac failed");
TEST_ASSERT_EQUAL_INT_MESSAGE(HASH_SIZE, output_buffer.size, "incorrect hash length");

printf("%" PRIu32 ": ", output_buffer.size);
Expand Down
1 change: 1 addition & 0 deletions TESTS/smoke/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Following table is parsed automatically by build scripts, so follow the format E
|NUCLEO_F303RE|../../BUILD/mbed_app/NUCLEO_F303RE/GCC_ARM/mbed-bootloader.bin|0x8000|0x8400|0x40000|0x40070|
|NUCLEO_F411RE|../../BUILD/mbed_app/NUCLEO_F411RE/GCC_ARM/mbed-bootloader.bin|0x8000|0x8400|0x40000|0x40070|
|NUCLEO_F429ZI|../../BUILD/mbed_app/NUCLEO_F429ZI/GCC_ARM/mbed-bootloader.bin|0x8000|0x8400|0x100000|0x100070|
|DISCO_F769NI|../../BUILD/mbed_app/DISCO_F769NI/GCC_ARM/mbed-bootloader.bin|0x40000|0x40400|0x100000|0x100070|


## Finding the values
Expand Down
Loading

0 comments on commit 1ee8b2d

Please sign in to comment.