Skip to content

Commit

Permalink
fix payload representation type
Browse files Browse the repository at this point in the history
  • Loading branch information
jepenven-silabs committed Aug 29, 2023
1 parent 4bdc108 commit 510faf1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/protocols/secure_channel/CheckinMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CHIP_ERROR CheckinMessage::ParseCheckinMessagePayload(Crypto::Aes128KeyHandle &
VerifyOrReturnError(payload.size() <= (sMinPayloadSize + sMaxAppDataSize), CHIP_ERROR_INVALID_ARGUMENT);

CHIP_ERROR err = CHIP_NO_ERROR;
uint16_t appDataSize = GetAppDataSize(payload);
size_t appDataSize = GetAppDataSize(payload);

// To prevent workbuffer usage, appData size needs to be large enough to hold both the appData and the counter
VerifyOrReturnError(appData.size() >= sizeof(CounterType) + appDataSize, CHIP_ERROR_INVALID_ARGUMENT);
Expand All @@ -92,9 +92,9 @@ CHIP_ERROR CheckinMessage::ParseCheckinMessagePayload(Crypto::Aes128KeyHandle &
return err;
}

uint16_t CheckinMessage::GetAppDataSize(ByteSpan & payload)
size_t CheckinMessage::GetAppDataSize(ByteSpan & payload)
{
return (payload.size() <= sMinPayloadSize) ? 0 : static_cast<uint16_t>(payload.size() - sMinPayloadSize);
return (payload.size() <= sMinPayloadSize) ? 0 : payload.size() - sMinPayloadSize;
}

} // namespace SecureChannel
Expand Down
6 changes: 3 additions & 3 deletions src/protocols/secure_channel/CheckinMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ class DLL_EXPORT CheckinMessage
static CHIP_ERROR ParseCheckinMessagePayload(Crypto::Aes128KeyHandle & key, ByteSpan & payload, CounterType & counter,
MutableByteSpan & appData);

static inline size_t GetCheckinPayloadSize(uint16_t & appDataSize) { return appDataSize + sMinPayloadSize; }
static inline size_t GetCheckinPayloadSize(size_t appDataSize) { return appDataSize + sMinPayloadSize; }

/**
* @brief Get the App Data Size
*
* @param payload The undecrypted payload
* @return uint16_t size in byte of the application data from the payload
* @return size_t size in byte of the application data from the payload
*/
static uint16_t GetAppDataSize(ByteSpan & payload);
static size_t GetAppDataSize(ByteSpan & payload);

static constexpr uint16_t sMinPayloadSize =
CHIP_CRYPTO_AEAD_NONCE_LENGTH_BYTES + sizeof(CounterType) + CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES;
Expand Down

0 comments on commit 510faf1

Please sign in to comment.