Skip to content

Commit 5204ba7

Browse files
fabik111andreagilardoni
authored andcommitted
fix JWT cbor message length
1 parent e8d9d4b commit 5204ba7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

extras/test/src/test_command_encode.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,15 @@ SCENARIO("Test the encoding of command messages") {
442442
{
443443
ProvisioningJWTMessage command;
444444
command.c.id = CommandId::ProvisioningJWT;
445-
memset(command.params.jwt, 0xCA, 246);
445+
memset(command.params.jwt, 0xCA, 268);
446446
uint8_t buffer[512];
447447
size_t bytes_encoded = sizeof(buffer);
448448

449449
CBORMessageEncoder encoder;
450450
Encoder::Status err = encoder.encode((Message*)&command, buffer, bytes_encoded);
451451

452452
uint8_t expected_result[] = {
453-
0xda, 0x00, 0x01, 0x20, 0x11, 0x81, 0x58, 0xF6,
453+
0xda, 0x00, 0x01, 0x20, 0x11, 0x81, 0x59, 0x01, 0x0C,
454454
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
455455
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
456456
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
@@ -481,7 +481,10 @@ SCENARIO("Test the encoding of command messages") {
481481
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
482482
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
483483
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
484-
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
484+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
485+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
486+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
487+
0xCA, 0xCA, 0xCA, 0xCA,
485488
};
486489

487490
// Test the encoding is

src/message/Commands.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define ID_SIZE 16
2828
#define MAX_LIB_VERSION_SIZE 10
2929
#define UHWID_SIZE 32
30-
#define PROVISIONING_JWT_SIZE 246
30+
#define PROVISIONING_JWT_SIZE 268 // Max length of jwt is 268
3131
#define WIFI_SSID_SIZE 33 // Max length of ssid is 32 + \0
3232
#define WIFI_PWD_SIZE 64 // Max length of password is 63 + \0
3333
#define LORA_APPEUI_SIZE 17 // appeui is 8 octets * 2 (hex format) + \0
@@ -208,7 +208,7 @@ struct ProvisioningUniqueHardwareIdMessage {
208208
struct ProvisioningJWTMessage {
209209
Command c;
210210
struct {
211-
char jwt[PROVISIONING_JWT_SIZE]; //The payload is an array of char with a maximum length of 246, not null terminated. It's not a string.
211+
char jwt[PROVISIONING_JWT_SIZE]; //The payload is an array of char with a maximum length of 268, not null terminated. It's not a string.
212212
} params;
213213
};
214214

0 commit comments

Comments
 (0)