forked from espressif/esp-idf
hal: minor fixes needed in the crypto hal test app
This commit is contained in:
@@ -53,9 +53,9 @@ This contains tests for the following features of the crypto peripherals:
|
|||||||
The HMAC tests need an HMAC key to be burned in the `BLOCK_KEY3` and `BLOCK_KEY4` of the efuses. As this verification application is independent of the efuse component, the user needs to manually burn the keys and their key purposes using `espefuse.py`.
|
The HMAC tests need an HMAC key to be burned in the `BLOCK_KEY3` and `BLOCK_KEY4` of the efuses. As this verification application is independent of the efuse component, the user needs to manually burn the keys and their key purposes using `espefuse.py`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
espefuse.py -p $ESPPORT burn_key BLOCK_KEY3 hmac_key.bin HMAC_DOWN_JTAG
|
espefuse.py -p $ESPPORT burn_key BLOCK_KEY3 main/hmac/hmac_key.bin HMAC_DOWN_JTAG
|
||||||
|
|
||||||
espefuse.py -p $ESPPORT burn_key BLOCK_KEY4 hmac_key.bin HMAC_UP
|
espefuse.py -p $ESPPORT burn_key BLOCK_KEY4 main/hmac/hmac_key.bin HMAC_UP
|
||||||
```
|
```
|
||||||
|
|
||||||
# Burning the HMAC keys for Digital Signature tests
|
# Burning the HMAC keys for Digital Signature tests
|
||||||
@@ -63,11 +63,11 @@ espefuse.py -p $ESPPORT burn_key BLOCK_KEY4 hmac_key.bin HMAC_UP
|
|||||||
The tests needs some HMAC keys to be burned in the `BLOCK_KEY1`, `BLOCK_KEY2` and `BLOCK_KEY3` of the efuses. As this verification application is independent of the efuse component, the user needs to manually burn the keys and their key purposes using `espefuse.py`.
|
The tests needs some HMAC keys to be burned in the `BLOCK_KEY1`, `BLOCK_KEY2` and `BLOCK_KEY3` of the efuses. As this verification application is independent of the efuse component, the user needs to manually burn the keys and their key purposes using `espefuse.py`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
espefuse.py -p $ESPPORT burn_key BLOCK_KEY1 ds_key1.bin HMAC_DOWN_DIGITAL_SIGNATURE --no-read-protect --no-write-protect --do-not-confirm
|
espefuse.py -p $ESPPORT burn_key BLOCK_KEY1 main/ds/ds_key1.bin HMAC_DOWN_DIGITAL_SIGNATURE --do-not-confirm
|
||||||
|
|
||||||
espefuse.py -p $ESPPORT burn_key BLOCK_KEY2 ds_key2.bin HMAC_DOWN_DIGITAL_SIGNATURE --no-read-protect --no-write-protect --do-not-confirm
|
espefuse.py -p $ESPPORT burn_key BLOCK_KEY2 main/ds/ds_key2.bin HMAC_DOWN_DIGITAL_SIGNATURE --do-not-confirm
|
||||||
|
|
||||||
espefuse.py -p $ESPPORT burn_key BLOCK_KEY3 ds_key3.bin HMAC_DOWN_DIGITAL_SIGNATURE --no-read-protect --no-write-protect --do-not-confirm
|
espefuse.py -p $ESPPORT burn_key BLOCK_KEY3 main/ds/ds_key3.bin HMAC_DOWN_DIGITAL_SIGNATURE --do-not-confirm
|
||||||
```
|
```
|
||||||
|
|
||||||
# Burning the ECDSA keys
|
# Burning the ECDSA keys
|
||||||
@@ -75,9 +75,9 @@ espefuse.py -p $ESPPORT burn_key BLOCK_KEY3 ds_key3.bin HMAC_DOWN_DIGITAL_SIGNAT
|
|||||||
The ECDSA tests need some ECDSA keys to be burned in the `BLOCK_KEY1` and `BLOCK_KEY2` of the efuses. As this verification application is independent of the efuse component, the user needs to manually burn the keys and their key purposes using `espefuse.py`.
|
The ECDSA tests need some ECDSA keys to be burned in the `BLOCK_KEY1` and `BLOCK_KEY2` of the efuses. As this verification application is independent of the efuse component, the user needs to manually burn the keys and their key purposes using `espefuse.py`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
espefuse.py -p $ESPPORT burn_key BLOCK_KEY1 ecdsa192_priv_key.pem ECDSA_KEY --no-read-protect --no-write-protect --do-not-confirm
|
espefuse.py -p $ESPPORT burn_key BLOCK_KEY1 main/ecdsa/ecdsa192_priv_key.pem ECDSA_KEY --do-not-confirm
|
||||||
|
|
||||||
espefuse.py -p $ESPPORT burn_key BLOCK_KEY2 ecdsa256_priv_key.pem ECDSA_KEY --no-read-protect --no-write-protect --do-not-confirm
|
espefuse.py -p $ESPPORT burn_key BLOCK_KEY2 main/ecdsa/ecdsa256_priv_key.pem ECDSA_KEY --do-not-confirm
|
||||||
```
|
```
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
@@ -4,6 +4,9 @@
|
|||||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "unity.h"
|
||||||
#include "unity_fixture.h"
|
#include "unity_fixture.h"
|
||||||
#include "unity_fixture_extras.h"
|
#include "unity_fixture_extras.h"
|
||||||
|
|
||||||
@@ -34,7 +37,14 @@ static void run_all_tests(void)
|
|||||||
#endif /* CONFIG_IDF_ENV_FPGA */
|
#endif /* CONFIG_IDF_ENV_FPGA */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_task(void *pvParameters)
|
||||||
|
{
|
||||||
|
vTaskDelay(2); /* Delay a bit to let the main task be deleted */
|
||||||
|
UNITY_MAIN_FUNC(run_all_tests);
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
UNITY_MAIN_FUNC(run_all_tests);
|
xTaskCreatePinnedToCore(test_task, "testTask", CONFIG_UNITY_FREERTOS_STACK_SIZE, NULL, CONFIG_UNITY_FREERTOS_PRIORITY, NULL, CONFIG_UNITY_FREERTOS_CPU);
|
||||||
}
|
}
|
||||||
|
@@ -531,10 +531,10 @@ TEST(ds, digital_signature_invalid_data)
|
|||||||
|
|
||||||
TEST_GROUP_RUNNER(ds)
|
TEST_GROUP_RUNNER(ds)
|
||||||
{
|
{
|
||||||
RUN_TEST_CASE(ds, digital_siganture_parameter_encryption);
|
RUN_TEST_CASE(ds, digital_signature_parameter_encryption);
|
||||||
RUN_TEST_CASE(ds, digital_siganture_wrong_hmac_key_purpose);
|
RUN_TEST_CASE(ds, digital_signature_wrong_hmac_key_purpose);
|
||||||
RUN_TEST_CASE(ds, digital_siganture_blocking_wrong_hmac_key_purpose);
|
RUN_TEST_CASE(ds, digital_signature_blocking_wrong_hmac_key_purpose);
|
||||||
RUN_TEST_CASE(ds, digital_siganture_operation);
|
RUN_TEST_CASE(ds, digital_signature_operation);
|
||||||
RUN_TEST_CASE(ds, digital_siganture_blocking_operation);
|
RUN_TEST_CASE(ds, digital_signature_blocking_operation);
|
||||||
RUN_TEST_CASE(ds, digital_siganture_invalid_data);
|
RUN_TEST_CASE(ds, digital_signature_invalid_data);
|
||||||
}
|
}
|
||||||
|
@@ -120,11 +120,11 @@ static void test_ecdsa_sign(bool is_p256, uint8_t* sha, uint8_t* r_le, uint8_t*
|
|||||||
|
|
||||||
if (is_p256) {
|
if (is_p256) {
|
||||||
conf.curve = ECDSA_CURVE_SECP256R1;
|
conf.curve = ECDSA_CURVE_SECP256R1;
|
||||||
conf.efuse_key_blk = 5;
|
conf.efuse_key_blk = 6;
|
||||||
len = 32;
|
len = 32;
|
||||||
} else {
|
} else {
|
||||||
conf.curve = ECDSA_CURVE_SECP192R1;
|
conf.curve = ECDSA_CURVE_SECP192R1;
|
||||||
conf.efuse_key_blk = 6;
|
conf.efuse_key_blk = 5;
|
||||||
len = 24;
|
len = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded import Dut
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
@@ -8,4 +10,8 @@ from pytest_embedded import Dut
|
|||||||
@pytest.mark.supported_targets
|
@pytest.mark.supported_targets
|
||||||
@pytest.mark.generic
|
@pytest.mark.generic
|
||||||
def test_crypto(dut: Dut) -> None:
|
def test_crypto(dut: Dut) -> None:
|
||||||
dut.expect('main_task: Returned from app_main()')
|
# if the env variable IDF_FPGA_ENV is set, we would need a longer timeout
|
||||||
|
# as tests for efuses burning security peripherals would be run
|
||||||
|
timeout = 600 if os.environ.get('IDF_ENV_FPGA') else 60
|
||||||
|
|
||||||
|
dut.expect('main_task: Returned from app_main()', timeout=timeout)
|
||||||
|
Reference in New Issue
Block a user