disable dfu ecc validation

This saves 4KB of space
This commit is contained in:
Shuanglei Tao
2025-10-10 16:51:36 +08:00
parent 5cf41c77d1
commit 1a1b529585
8 changed files with 2193 additions and 2758 deletions

View File

@@ -276,8 +276,8 @@
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x3ac00</StartAddress>
<Size>0x5000</Size>
<StartAddress>0x3bc00</StartAddress>
<Size>0x4000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>

View File

@@ -276,8 +276,8 @@
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x28000</StartAddress>
<Size>0x6000</Size>
<StartAddress>0x29000</StartAddress>
<Size>0x5000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>

View File

@@ -167,10 +167,10 @@ extern "C" {
#ifdef S210
#define NRF_CLOCK_LFCLKSRC NRF_CLOCK_LFCLKSRC_XTAL_20_PPM
#else
#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_SYNTH, \
.rc_ctiv = 0, \
.rc_temp_ctiv = 0, \
.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_RC, \
.rc_ctiv = 16, \
.rc_temp_ctiv = 2, \
.xtal_accuracy = 0}
#endif
#ifdef __cplusplus

View File

@@ -270,54 +270,54 @@ static nrf_dfu_res_code_t dfu_handle_prevalidate(dfu_signed_command_t const * p_
#endif
// Check the signature
switch (p_command->signature_type)
{
case DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256:
{
// prepare the actual hash destination.
hash_data.p_le_data = &hash[0];
hash_data.len = sizeof(hash);
// switch (p_command->signature_type)
// {
// case DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256:
// {
// // prepare the actual hash destination.
// hash_data.p_le_data = &hash[0];
// hash_data.len = sizeof(hash);
NRF_LOG_INFO("Init command:\r\n");
NRF_LOG_HEXDUMP_INFO(&s_dfu_settings.init_command[0], s_dfu_settings.progress.command_size);
NRF_LOG_INFO("\r\n");
// NRF_LOG_INFO("Init command:\r\n");
// NRF_LOG_HEXDUMP_INFO(&s_dfu_settings.init_command[0], s_dfu_settings.progress.command_size);
// NRF_LOG_INFO("\r\n");
NRF_LOG_INFO("p_Init command:\r\n");
NRF_LOG_HEXDUMP_INFO(&p_init_cmd[0], init_cmd_len);
NRF_LOG_INFO("\r\n");
// NRF_LOG_INFO("p_Init command:\r\n");
// NRF_LOG_HEXDUMP_INFO(&p_init_cmd[0], init_cmd_len);
// NRF_LOG_INFO("\r\n");
err_code = nrf_crypto_hash_compute(NRF_CRYPTO_HASH_ALG_SHA256, p_init_cmd, init_cmd_len, &hash_data);
if (err_code != NRF_SUCCESS)
{
return NRF_DFU_RES_CODE_OPERATION_FAILED;
}
// err_code = nrf_crypto_hash_compute(NRF_CRYPTO_HASH_ALG_SHA256, p_init_cmd, init_cmd_len, &hash_data);
// if (err_code != NRF_SUCCESS)
// {
// return NRF_DFU_RES_CODE_OPERATION_FAILED;
// }
// prepare the signature received over the air.
memcpy(&sig[0], p_command->signature.bytes, p_command->signature.size);
// // prepare the signature received over the air.
// memcpy(&sig[0], p_command->signature.bytes, p_command->signature.size);
NRF_LOG_INFO("Signature\r\n");
NRF_LOG_HEXDUMP_INFO(&p_command->signature.bytes[0], p_command->signature.size);
NRF_LOG_INFO("\r\n");
// NRF_LOG_INFO("Signature\r\n");
// NRF_LOG_HEXDUMP_INFO(&p_command->signature.bytes[0], p_command->signature.size);
// NRF_LOG_INFO("\r\n");
crypto_sig.p_le_data = sig;
crypto_sig.len = p_command->signature.size;
// crypto_sig.p_le_data = sig;
// crypto_sig.len = p_command->signature.size;
NRF_LOG_INFO("signature len: %d\r\n", p_command->signature.size);
// NRF_LOG_INFO("signature len: %d\r\n", p_command->signature.size);
// calculate the signature
err_code = nrf_crypto_verify(NRF_CRYPTO_CURVE_SECP256R1, &crypto_key_pk, &hash_data, &crypto_sig);
if (err_code != NRF_SUCCESS)
{
return NRF_DFU_RES_CODE_INVALID_OBJECT;
}
// // calculate the signature
// err_code = nrf_crypto_verify(NRF_CRYPTO_CURVE_SECP256R1, &crypto_key_pk, &hash_data, &crypto_sig);
// if (err_code != NRF_SUCCESS)
// {
// return NRF_DFU_RES_CODE_INVALID_OBJECT;
// }
NRF_LOG_INFO("Image verified\r\n");
}
break;
// NRF_LOG_INFO("Image verified\r\n");
// }
// break;
default:
return NRF_DFU_RES_CODE_OPERATION_FAILED;
}
// default:
// return NRF_DFU_RES_CODE_OPERATION_FAILED;
// }
// Get the update size
m_firmware_size_req = 0;

View File

@@ -545,14 +545,14 @@ nrf_dfu_result_t nrf_dfu_validation_prevalidate(void)
}
// Validate signature.
if (signature_required(p_command->init.type))
{
ret_val = nrf_dfu_validation_signature_check(signature_type,
p_signature,
signature_len,
m_init_packet_data_ptr,
m_init_packet_data_len);
}
// if (signature_required(p_command->init.type))
// {
// ret_val = nrf_dfu_validation_signature_check(signature_type,
// p_signature,
// signature_len,
// m_init_packet_data_ptr,
// m_init_packet_data_len);
// }
// Validate versions.
if (ret_val == NRF_DFU_RES_CODE_SUCCESS)
@@ -639,7 +639,7 @@ static bool nrf_dfu_validation_hash_ok(uint8_t const * p_hash, uint32_t src_addr
nrf_crypto_hash_context_t hash_context = {0};
crypto_init();
// crypto_init();
if (little_endian)
{
@@ -971,15 +971,16 @@ bool nrf_dfu_validation_boot_validate(boot_validation_t const * p_validation, ui
return nrf_dfu_validation_hash_ok(p_validation->bytes, data_addr, data_len, false);
case VALIDATE_ECDSA_P256_SHA256:
{
nrf_dfu_result_t res_code = nrf_dfu_validation_signature_check(
DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256,
p_validation->bytes,
NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE,
p_data,
data_len);
return (res_code == NRF_DFU_RES_CODE_SUCCESS);
}
// {
// nrf_dfu_result_t res_code = nrf_dfu_validation_signature_check(
// DFU_SIGNATURE_TYPE_ECDSA_P256_SHA256,
// p_validation->bytes,
// NRF_CRYPTO_ECDSA_SECP256R1_SIGNATURE_SIZE,
// p_data,
// data_len);
// return (res_code == NRF_DFU_RES_CODE_SUCCESS);
// }
return true;
default:
ASSERT(false);

View File

@@ -5155,12 +5155,12 @@
// <2=> NRF_CLOCK_LF_SRC_SYNTH
#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 2
#define NRF_SDH_CLOCK_LF_SRC 0
#endif
// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval.
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 0
#define NRF_SDH_CLOCK_LF_RC_CTIV 16
#endif
// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature.
@@ -5168,7 +5168,7 @@
// <i> if the temperature has not changed.
#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2
#endif
// <o> NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute timing.
@@ -5187,7 +5187,7 @@
// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM
#ifndef NRF_SDH_CLOCK_LF_ACCURACY
#define NRF_SDH_CLOCK_LF_ACCURACY 7
#define NRF_SDH_CLOCK_LF_ACCURACY 1
#endif
// </h>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff