Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed encoding of KeySlot ID. #217

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading