Skip to content

Commit a89758a

Browse files
committed
comments integration
1 parent 6a9068f commit a89758a

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

src/lib/support/CodeUtils.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@
161161
*
162162
* @brief
163163
* This is for use when the calling function returns a Variant type. It returns a CHIP_ERROR variant with the corresponding error
164-
* code if the expression returns an error. For a CHIP_ERROR expression, this means any value other
165-
* than CHIP_NO_ERROR. For an integer expression, this means non-zero.
164+
* code if the expression returns an error.
166165
*
167166
* Example usage:
168167
*

src/protocols/secure_channel/CASESession.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ CHIP_ERROR CASESession::PrepareSigma2Resume(EncodeSigma2ResumeInputs & outSigma2
11621162
outSigma2ResData.resumptionId = mNewResumptionId;
11631163

11641164
ReturnErrorOnFailure(GenerateSigmaResumeMIC(ByteSpan(mInitiatorRandom), mNewResumptionId, ByteSpan(kKDFS2RKeyInfo),
1165-
ByteSpan(kResume2MIC_Nonce), outSigma2ResData.resumeMICSpan));
1165+
ByteSpan(kResume2MIC_Nonce), outSigma2ResData.resumeMIC));
11661166

11671167
outSigma2ResData.responderMrpConfig = &mLocalMRPConfig.Value();
11681168

@@ -1191,7 +1191,7 @@ CHIP_ERROR CASESession::EncodeSigma2Resume(System::PacketBufferHandle & msgR2Res
11911191

11921192
ReturnErrorOnFailure(tlvWriter.StartContainer(AnonymousTag(), kTLVType_Structure, outerContainerType));
11931193
ReturnErrorOnFailure(tlvWriter.Put(AsTlvContextTag(Sigma2ResumeTags::kResumptionID), input.resumptionId));
1194-
ReturnErrorOnFailure(tlvWriter.Put(AsTlvContextTag(Sigma2ResumeTags::kSigma2ResumeMIC), input.resumeMICSpan));
1194+
ReturnErrorOnFailure(tlvWriter.Put(AsTlvContextTag(Sigma2ResumeTags::kSigma2ResumeMIC), input.resumeMIC));
11951195
ReturnErrorOnFailure(tlvWriter.Put(AsTlvContextTag(Sigma2ResumeTags::kResponderSessionID), input.responderSessionId));
11961196

11971197
ReturnErrorOnFailure(

src/protocols/secure_channel/CASESession.h

+10-11
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,14 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler,
194194
// Helper Enum for use in HandleSigma1_and_SendSigma2
195195
enum class Step : uint8_t
196196
{
197-
kNone,
198197
kSendSigma2,
199198
kSendSigma2Resume,
200199
};
201200
// Making NextStep a Variant allows HandleSigma() to return either a Step value (indicating
202201
// the next Sigma step to send) or a CHIP_ERROR (indicating a failure that will trigger
203202
// a Status Report).
204203
using NextStep = Variant<Step, CHIP_ERROR>;
205-
// This struct only serves as a base struct for EncodedSigma1Inputs and ParsedSigma1
204+
// This struct only serves as a base struct for EncodeSigma1Inputs and ParsedSigma1
206205
struct Sigma1Param
207206
{
208207
ByteSpan initiatorRandom;
@@ -242,31 +241,31 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler,
242241
{
243242
ByteSpan resumptionId;
244243
uint8_t sigma2ResumeMICBuffer[Crypto::CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES];
245-
MutableByteSpan resumeMICSpan{ sigma2ResumeMICBuffer };
244+
MutableByteSpan resumeMIC{ sigma2ResumeMICBuffer };
246245
uint16_t responderSessionId;
247246
const ReliableMessageProtocolConfig * responderMrpConfig;
248247
};
249248

250249
/**
251250
* @brief Encodes a Sigma1 message into TLV format and allocates a buffer for it, which is owned by the PacketBufferHandle
252-
*outparam.
251+
* outparam.
253252
*
254253
* @param outMsg PacketBufferHandle passed by reference. A new buffer will be allocated and assigned to it within the
255-
*method.
254+
* method.
256255
*
257256
* @param inParam a struct containing all the values that will be encoded into TLV format
258257
*
259258
**/
260259
static CHIP_ERROR EncodeSigma1(System::PacketBufferHandle & outMsg, EncodeSigma1Inputs & inParam);
261260

262261
/**
263-
* Parse a sigma1 message. This function will return success only if the
262+
* Parse a Sigma1 message. This function will return success only if the
264263
* message passes schema checks. Specifically:
265264
* * The tags come in order.
266265
* * The required tags are present.
267266
* * The values for the tags that are present satisfy schema requirements
268267
* (e.g. constraints on octet string lengths)
269-
* * Either resumptionID and initiatorResume1MICBuffer are both present or both
268+
* * Either resumptionID and initiatorResume1MICBuffer are both present or both are
270269
* absent.
271270
*
272271
* On success, the members of outParam will be set to the values corresponding to the message.
@@ -280,10 +279,10 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler,
280279

281280
/**
282281
* @brief Encodes a Sigma2 message into TLV format and allocates a buffer for it, which is owned by the PacketBufferHandle
283-
*outparam.
282+
* outparam.
284283
*
285284
* @param outMsg PacketBufferHandle passed by reference. A new buffer will be allocated and assigned to it within the
286-
*method.
285+
* method.
287286
*
288287
* @param inParam a struct containing all the values that will be encoded into TLV format
289288
*
@@ -293,10 +292,10 @@ class DLL_EXPORT CASESession : public Messaging::UnsolicitedMessageHandler,
293292

294293
/**
295294
* @brief Encodes a Sigma2_Resume message into TLV format and allocates a buffer for it, which is owned by the
296-
*PacketBufferHandle outparam.
295+
* PacketBufferHandle outparam.
297296
*
298297
* @param outMsg PacketBufferHandle passed by reference. A new buffer will be allocated and assigned to it within the
299-
*method.
298+
* method.
300299
*
301300
* @param inParam a struct containing all the values that will be encoded into TLV format
302301
*

src/protocols/secure_channel/tests/TestCASESession.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -888,10 +888,10 @@ TEST_F(TestCASESession, EncodeSigma1Test)
888888

889889
uint8_t random[32];
890890
EXPECT_EQ(chip::Crypto::DRBG_get_bytes(&random[0], sizeof(random)), CHIP_NO_ERROR);
891-
encodeParams.initiatorRandom = ByteSpan(random, sizeof(random));
891+
encodeParams.initiatorRandom = ByteSpan(random);
892892
encodeParams.initiatorSessionId = 7315;
893893
uint8_t destinationId[32] = { 0xDE, 0xAD };
894-
encodeParams.destinationId = ByteSpan(destinationId, sizeof(destinationId));
894+
encodeParams.destinationId = ByteSpan(destinationId);
895895

896896
ReliableMessageProtocolConfig mrpConfig = GetDefaultMRPConfig();
897897
encodeParams.initiatorMrpConfig = &mrpConfig;
@@ -937,15 +937,15 @@ TEST_F(TestCASESession, EncodeSigma1Test)
937937
tlvReader.Init(std::move(msg1));
938938

939939
CASESessionAccess session;
940-
CASESessionAccess::ParsedSigma1 parseParams;
940+
CASESessionAccess::ParsedSigma1 parsedMessage;
941941

942-
EXPECT_EQ(CHIP_NO_ERROR, session.ParseSigma1(tlvReader, parseParams));
942+
EXPECT_EQ(CHIP_NO_ERROR, session.ParseSigma1(tlvReader, parsedMessage));
943943

944944
// compare parsed values with original values
945-
EXPECT_TRUE(parseParams.initiatorRandom.data_equal(encodeParams.initiatorRandom));
946-
EXPECT_EQ(parseParams.initiatorSessionId, encodeParams.initiatorSessionId);
947-
EXPECT_TRUE(parseParams.destinationId.data_equal(encodeParams.destinationId));
948-
EXPECT_TRUE(parseParams.initiatorEphPubKey.data_equal(
945+
EXPECT_TRUE(parsedMessage.initiatorRandom.data_equal(encodeParams.initiatorRandom));
946+
EXPECT_EQ(parsedMessage.initiatorSessionId, encodeParams.initiatorSessionId);
947+
EXPECT_TRUE(parsedMessage.destinationId.data_equal(encodeParams.destinationId));
948+
EXPECT_TRUE(parsedMessage.initiatorEphPubKey.data_equal(
949949
ByteSpan(encodeParams.initiatorEphPubKey->ConstBytes(), encodeParams.initiatorEphPubKey->Length())));
950950
}
951951

@@ -971,20 +971,20 @@ TEST_F(TestCASESession, EncodeSigma1Test)
971971
tlvReader.Init(std::move(msg2));
972972

973973
CASESessionAccess session;
974-
CASESessionAccess::ParsedSigma1 parseParams;
974+
CASESessionAccess::ParsedSigma1 parsedMessage;
975975

976-
EXPECT_EQ(CHIP_NO_ERROR, session.ParseSigma1(tlvReader, parseParams));
976+
EXPECT_EQ(CHIP_NO_ERROR, session.ParseSigma1(tlvReader, parsedMessage));
977977

978978
// RoundTrip
979-
EXPECT_TRUE(parseParams.initiatorRandom.data_equal(encodeParams.initiatorRandom));
980-
EXPECT_EQ(parseParams.initiatorSessionId, encodeParams.initiatorSessionId);
981-
EXPECT_TRUE(parseParams.destinationId.data_equal(encodeParams.destinationId));
982-
EXPECT_TRUE(parseParams.initiatorEphPubKey.data_equal(
979+
EXPECT_TRUE(parsedMessage.initiatorRandom.data_equal(encodeParams.initiatorRandom));
980+
EXPECT_EQ(parsedMessage.initiatorSessionId, encodeParams.initiatorSessionId);
981+
EXPECT_TRUE(parsedMessage.destinationId.data_equal(encodeParams.destinationId));
982+
EXPECT_TRUE(parsedMessage.initiatorEphPubKey.data_equal(
983983
ByteSpan(encodeParams.initiatorEphPubKey->ConstBytes(), encodeParams.initiatorEphPubKey->Length())));
984984

985-
EXPECT_TRUE(parseParams.resumptionId.data_equal(encodeParams.resumptionId));
986-
EXPECT_TRUE(parseParams.initiatorResumeMIC.data_equal(encodeParams.initiatorResumeMIC));
987-
EXPECT_TRUE(parseParams.initiatorMrpParamsPresent);
985+
EXPECT_TRUE(parsedMessage.resumptionId.data_equal(encodeParams.resumptionId));
986+
EXPECT_TRUE(parsedMessage.initiatorResumeMIC.data_equal(encodeParams.initiatorResumeMIC));
987+
EXPECT_TRUE(parsedMessage.initiatorMrpParamsPresent);
988988
}
989989
// Release EphemeralKeyPair
990990
gDeviceOperationalKeystore.ReleaseEphemeralKeypair(ephemeralKey);

0 commit comments

Comments
 (0)