Skip to content

Commit 23876ec

Browse files
fabik111andreagilardoni
authored andcommitted
update signature length
1 parent aacd035 commit 23876ec

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

extras/test/src/test_command_encode.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,25 +442,52 @@ SCENARIO("Test the encoding of command messages") {
442442
{
443443
ProvisioningSignatureMessage command;
444444
command.c.id = CommandId::ProvisioningSignature;
445-
memset(command.params.signature, 0xCA, 32);
445+
memset(command.params.signature, 0xCA, 246);
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, 0x20,
453+
0xda, 0x00, 0x01, 0x20, 0x11, 0x81, 0x58, 0xF6,
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,
457457
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
458+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
459+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
460+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
461+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
462+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
463+
0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA,
464+
0xCA, 0xCA, 0xCA, 0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 0xCA, 0xCA,
458485
};
459486

460487
// Test the encoding is
461488
//DA 00012011 # tag(73744)
462489
// 81 # array(1)
463-
// 58 20 # bytes(32)
490+
// 58 F6 # bytes(32)
464491
// CA.... omissis # values
465492
THEN("The encoding is successful") {
466493
REQUIRE(err == Encoder::Status::Complete);

src/cbor/MessageEncoder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ CborError CBORMessageEncoder::encodeProvisioningListWifiNetworks(CborEncoder * a
222222
CborError CBORMessageEncoder::encodeProvisioningUniqueId(CborEncoder * array_encoder, Message * message)
223223
{
224224
ProvisioningUniqueIdMessage * provisioningUniqueId = (ProvisioningUniqueIdMessage *) message;
225-
CHECK_CBOR(cbor_encode_byte_string(array_encoder, (uint8_t *) provisioningUniqueId->params.uniqueId, 32));
225+
CHECK_CBOR(cbor_encode_byte_string(array_encoder, (uint8_t *) provisioningUniqueId->params.uniqueId, UID_SIZE));
226226
return CborNoError;
227227
}
228228

229229
CborError CBORMessageEncoder::encodeProvisioningSignature(CborEncoder * array_encoder, Message * message)
230230
{
231231
ProvisioningSignatureMessage * provisioningSignature = (ProvisioningSignatureMessage *) message;
232-
CHECK_CBOR(cbor_encode_byte_string(array_encoder, (uint8_t *) provisioningSignature->params.signature, 32));
232+
CHECK_CBOR(cbor_encode_byte_string(array_encoder, (uint8_t *) provisioningSignature->params.signature, SIGNATURE_SIZE));
233233
return CborNoError;
234234
}

src/message/Commands.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define URL_SIZE 256
2727
#define ID_SIZE 16
2828
#define MAX_LIB_VERSION_SIZE 10
29+
#define UID_SIZE 32
30+
#define SIGNATURE_SIZE 246
2931

3032
/******************************************************************************
3133
TYPEDEF
@@ -193,7 +195,7 @@ struct ProvisioningUniqueIdMessage {
193195
struct ProvisioningSignatureMessage {
194196
Command c;
195197
struct {
196-
char signature[32]; //The payload is an array of char with a maximum length of 32, not null terminated. It's not a string.
198+
char signature[246]; //The payload is an array of char with a maximum length of 246, not null terminated. It's not a string.
197199
} params;
198200
};
199201

0 commit comments

Comments
 (0)