Skip to content

Commit

Permalink
Merge pull request #217 from lagosantol/lagosantol-patch-issue216
Browse files Browse the repository at this point in the history
Fixed encoding of KeySlot ID.
  • Loading branch information
pennam authored Jan 9, 2024
2 parents a90cdf5 + e104e77 commit 031f36e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/SSLClient/src/SSLClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,12 @@ void SSLClient::setEccSlot(int KeySlot, const byte cert[], int certLen) {
0x83, 0xA3, 0x5E, 0x5B, 0x64, 0x1D, 0x29, 0xED, 0x85
};

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

if ((ret = mbedtls_pem_write_buffer("-----BEGIN EC PRIVATE KEY-----\n",
"-----END EC PRIVATE KEY-----\n",
Expand Down

0 comments on commit 031f36e

Please sign in to comment.