Skip to content

Commit 77818d9

Browse files
authored
Merge pull request #6939 from danielinux/iotsafe_4B_ID
IoT-SAFE: allow for 4B ID fields
2 parents 9e468a9 + bda44ed commit 77818d9

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

IDE/iotsafe/memory-tls.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,12 @@ static int client_loop(void)
146146
#if (IOTSAFE_ID_SIZE == 1)
147147
byte cert_file_id, privkey_id, keypair_id, peer_pubkey_id, peer_cert_id, serv_cert_id;
148148
byte ca_cert_id;
149-
#else
149+
#elif (IOTSAFE_ID_SIZE == 2)
150150
word16 cert_file_id, privkey_id, keypair_id, peer_pubkey_id, peer_cert_id, serv_cert_id;
151151
word16 ca_cert_id;
152+
#else
153+
word32 cert_file_id, privkey_id, keypair_id, peer_pubkey_id, peer_cert_id, serv_cert_id;
154+
word32 ca_cert_id;
152155
#endif
153156
cert_file_id = CRT_CLIENT_FILE_ID;
154157
privkey_id = PRIVKEY_ID;

IDE/iotsafe/user_settings.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,21 @@
3434
* - Default: one-byte ID sim, with hardcoded server certificate
3535
*/
3636

37-
#ifdef TWO_BYTES_ID_DEMO
37+
#if defined(FOUR_BYTES_ID_DEMO)
38+
#define IOTSAFE_ID_SIZE 2
39+
#define CRT_CLIENT_FILE_ID 0xABCD3430 /* pre-provisioned */
40+
#define CRT_SERVER_FILE_ID 0xABCD3330
41+
#define PRIVKEY_ID 0xABCD3230 /* pre-provisioned */
42+
#define ECDH_KEYPAIR_ID 0xABCD3330
43+
#define PEER_PUBKEY_ID 0xABCD3730
44+
#define PEER_CERT_ID 0xABCD3430
45+
46+
/* In this version of the demo, the server certificate is
47+
* stored in a buffer, while the CA is read from a file slot in IoT-SAFE
48+
*/
49+
#define SOFT_SERVER_CERT
50+
51+
#elif defined(TWO_BYTES_ID_DEMO)
3852
#define IOTSAFE_ID_SIZE 2
3953
#define CRT_CLIENT_FILE_ID 0x3430 /* pre-provisioned */
4054
#define CRT_SERVER_FILE_ID 0x3330

wolfssl/wolfcrypt/port/iotsafe/iotsafe.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ struct wc_IOTSAFE {
9393
word16 ecdh_keypair_slot;
9494
word16 peer_pubkey_slot;
9595
word16 peer_cert_slot;
96+
#elif (IOTSAFE_ID_SIZE == 4)
97+
word32 privkey_id;
98+
word32 ecdh_keypair_slot;
99+
word32 peer_pubkey_slot;
100+
word32 peer_cert_slot;
96101
#else
97102
#error "IOTSAFE: ID_SIZE not supported"
98103
#endif

0 commit comments

Comments
 (0)