Skip to content

Commit 031f36e

Browse files
authored
Merge pull request arduino#217 from lagosantol/lagosantol-patch-issue216
Fixed encoding of KeySlot ID.
2 parents a90cdf5 + e104e77 commit 031f36e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libraries/SSLClient/src/SSLClient.cpp

+6-1
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",

0 commit comments

Comments
 (0)