Skip to content

Commit 6bddeb0

Browse files
authored
Merge branch 'arduino:main' into main
2 parents 2f96751 + bba294b commit 6bddeb0

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

extras/tls/mbedtls_alt/ecdsa_se05x.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int mbedtls_ecdsa_sign(mbedtls_ecp_group *grp,
126126

127127
smStatus_t status = SM_NOT_OK;
128128
SE05x_Result_t result;
129+
SE05x_ECSignatureAlgo_t ecSignAlgo;
129130
uint32_t keyID = 0;
130131
uint8_t magic_bytes[] = ALT_KEYS_MAGIC;
131132
uint8_t buffer[150] = {0};
@@ -166,9 +167,32 @@ int mbedtls_ecdsa_sign(mbedtls_ecp_group *grp,
166167
return -1;
167168
}
168169

170+
// decide on the algo based on the input size
171+
// (input being the hash)
172+
switch(blen) {
173+
case 20:
174+
ecSignAlgo = kSE05x_ECSignatureAlgo_SHA;
175+
break;
176+
case 28:
177+
ecSignAlgo = kSE05x_ECSignatureAlgo_SHA_224;
178+
break;
179+
case 32:
180+
ecSignAlgo = kSE05x_ECSignatureAlgo_SHA_256;
181+
break;
182+
case 48:
183+
ecSignAlgo = kSE05x_ECSignatureAlgo_SHA_384;
184+
break;
185+
case 64:
186+
ecSignAlgo = kSE05x_ECSignatureAlgo_SHA_512;
187+
break;
188+
default:
189+
SMLOG_E("Unsupported hash length: %d\r\n", blen);
190+
return -1;
191+
}
192+
169193
SMLOG_I("Using SE05x for ecdsa sign. blen: %d\r\n", blen);
170194
status = Se05x_API_ECDSASign(
171-
pSession, keyID, kSE05x_ECSignatureAlgo_SHA_384, (uint8_t *)buf, blen, signature, &signature_len);
195+
pSession, keyID, ecSignAlgo, (uint8_t *)buf, blen, signature, &signature_len);
172196
if (status != SM_OK) {
173197
SMLOG_E("Error in Se05x_API_ECDSASign\r\n");
174198
return -1;

libraries/SSLClient/src/SSLClient.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,12 @@ void SSLClient::setEccSlot(int KeySlot, const byte cert[], int certLen) {
377377
0x83, 0xA3, 0x5E, 0x5B, 0x64, 0x1D, 0x29, 0xED, 0x85
378378
};
379379

380-
key[28] = KeySlot;
380+
// store the KeySlot in BigEndian before the 64 bit magic word (0xA5A6B5B6A5A6B5B6)
381+
// as per https://github.com/NXPPlugNTrust/nano-package?tab=readme-ov-file#mbedtls-alt-files
382+
key[25] = (KeySlot & 0xFF000000) >> 24;
383+
key[26] = (KeySlot & 0x00FF0000) >> 16;
384+
key[27] = (KeySlot & 0x0000FF00) >> 8;
385+
key[28] = (KeySlot & 0x000000FF) >> 0;
381386

382387
if ((ret = mbedtls_pem_write_buffer("-----BEGIN EC PRIVATE KEY-----\n",
383388
"-----END EC PRIVATE KEY-----\n",
104 Bytes
Binary file not shown.

libraries/WiFiS3/src/Modem.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ bool ModemClass::buf_read(const string &prompt, string &data_res) {
256256
break;
257257
}
258258
else if (string::npos != data_res.rfind(RESULT_ERROR)) {
259+
found = true;
259260
data_res.substr(0, data_res.length() - (sizeof(RESULT_ERROR) - 1));
260261
res = false;
261262
break;

platform.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ compiler.warning_flags.default=
1414
compiler.warning_flags.more=-Wall
1515
compiler.warning_flags.all=-Wall -Wextra
1616

17+
compiler.optimization_flags=-Os
18+
compiler.optimization_flags.release=-Os
19+
compiler.optimization_flags.debug=-Og
20+
1721
compiler.path={build.compiler_path}
1822
compiler.c.cmd={build.crossprefix}gcc
19-
compiler.c.flags=-c {compiler.warning_flags} -Os -g3 -nostdlib {build.defines} -MMD -std=gnu11 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin
23+
compiler.c.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -nostdlib {build.defines} -MMD -std=gnu11 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin
2024
compiler.c.elf.cmd={build.crossprefix}g++
2125
compiler.c.elf.flags=-Wl,--gc-sections --specs=nosys.specs {compiler.warning_flags} -mcpu={build.mcu} {build.float-abi} {build.fpu}
2226
compiler.S.cmd={build.crossprefix}g++
23-
compiler.S.flags=-c -g -x assembler-with-cpp -Os -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections
27+
compiler.S.flags=-c -g -x assembler-with-cpp {compiler.optimization_flags} -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections
2428
compiler.cpp.cmd={build.crossprefix}g++
25-
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib {build.defines} -MMD -std=gnu++17 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin
29+
compiler.cpp.flags=-c {compiler.warning_flags} {compiler.optimization_flags} -g3 -fno-use-cxa-atexit -fno-rtti -fno-exceptions -MMD -nostdlib {build.defines} -MMD -std=gnu++17 -mcpu={build.mcu} {build.float-abi} {build.fpu} -fsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -fno-builtin
2630
compiler.ar.cmd={build.crossprefix}ar
2731
compiler.ar.flags=rcs
2832
compiler.ar.extra_flags=

0 commit comments

Comments
 (0)