Skip to content

Commit

Permalink
Mark MCSP responses as NOT_IMPLEMENTED (#14853)
Browse files Browse the repository at this point in the history
* Validate session type before trying  to cast and return the secure session counter

* Completely remove the counter response: MCSP not yet implemented for groups it seems

* Fix typo
  • Loading branch information
andy31415 authored and pull[bot] committed Aug 21, 2023
1 parent 6b29604 commit 4240195
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/protocols/secure_channel/MessageCounterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,26 +222,20 @@ CHIP_ERROR MessageCounterManager::SendMsgCounterSyncResp(Messaging::ExchangeCont
FixedByteSpan<kChallengeSize> challenge)
{
System::PacketBufferHandle msgBuf;

VerifyOrDie(exchangeContext->HasSessionHandle());

// Allocate new buffer.
msgBuf = MessagePacketBuffer::New(kSyncRespMsgSize);
VerifyOrReturnError(!msgBuf.IsNull(), CHIP_ERROR_NO_MEMORY);

{
uint8_t * msg = msgBuf->Start();
Encoding::LittleEndian::BufferWriter bbuf(msg, kSyncRespMsgSize);
bbuf.Put32(
exchangeContext->GetSessionHandle()->AsSecureSession()->GetSessionMessageCounter().GetLocalMessageCounter().Value());
bbuf.Put(challenge.data(), kChallengeSize);
VerifyOrReturnError(bbuf.Fit(), CHIP_ERROR_NO_MEMORY);
}
VerifyOrReturnError(exchangeContext->GetSessionHandle()->GetSessionType() == Transport::Session::SessionType::kGroup,
CHIP_ERROR_INVALID_ARGUMENT);

msgBuf->SetDataLength(kSyncRespMsgSize);
// NOTE: not currently implemented. When implementing, the following should be done:
// - allocate a new buffer: MessagePacketBuffer::New
// - setup payload and place the local message counter + challange in it
// - exchangeContext->SendMessage(Protocols::SecureChannel::MsgType::MsgCounterSyncRsp, ...)
//
// You can view the history of this file for a partial implementation that got
// removed due to it using non-group sessions.

return exchangeContext->SendMessage(Protocols::SecureChannel::MsgType::MsgCounterSyncRsp, std::move(msgBuf),
Messaging::SendFlags(Messaging::SendMessageFlags::kNoAutoRequestAck));
return CHIP_ERROR_NOT_IMPLEMENTED;
}

CHIP_ERROR MessageCounterManager::HandleMsgCounterSyncReq(Messaging::ExchangeContext * exchangeContext,
Expand Down

0 comments on commit 4240195

Please sign in to comment.