From 8e18aaa1e2bc39ffdbc45e66e867e95e458caadc Mon Sep 17 00:00:00 2001 From: Martin Turon Date: Wed, 28 Sep 2022 01:11:23 +0000 Subject: [PATCH] [test] Fix #22903 - fix unit test break when SECURITY_TEST_MODE=1 (#22904) --- src/transport/CryptoContext.cpp | 11 ++++++----- src/transport/tests/TestSessionManagerDispatch.cpp | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/transport/CryptoContext.cpp b/src/transport/CryptoContext.cpp index ac92cb4750e3e8..825aebac579e64 100644 --- a/src/transport/CryptoContext.cpp +++ b/src/transport/CryptoContext.cpp @@ -97,11 +97,12 @@ CHIP_ERROR CryptoContext::InitFromSecret(const ByteSpan & secret, const ByteSpan (void) infoLen; #warning \ - "Warning: CONFIG_SECURITY_TEST_MODE=1 bypassing key negotiation... All sessions will use known, fixed test key, and NodeID=0 in NONCE. Node can only communicate with other nodes built with this flag set. Requires build flag 'treat_warnings_as_errors=false'." - ChipLogError(SecureChannel, - "Warning: CONFIG_SECURITY_TEST_MODE=1 bypassing key negotiation... All sessions will use known, fixed test key, " - "and NodeID=0 in NONCE. " - "Node can only communicate with other nodes built with this flag set."); + "Warning: CHIP_CONFIG_SECURITY_TEST_MODE=1 bypassing key negotiation... All sessions will use known, fixed test key, and NodeID=0 in NONCE. Node can only communicate with other nodes built with this flag set. Requires build flag 'treat_warnings_as_errors=false'." + ChipLogError( + SecureChannel, + "Warning: CHIP_CONFIG_SECURITY_TEST_MODE=1 bypassing key negotiation... All sessions will use known, fixed test key, " + "and NodeID=0 in NONCE. " + "Node can only communicate with other nodes built with this flag set."); ReturnErrorOnFailure(mHKDF.HKDF_SHA256(kTestSharedSecret, CHIP_CONFIG_TEST_SHARED_SECRET_LENGTH, testSalt.data(), testSalt.size(), SEKeysInfo, sizeof(SEKeysInfo), &mKeys[0][0], sizeof(mKeys))); diff --git a/src/transport/tests/TestSessionManagerDispatch.cpp b/src/transport/tests/TestSessionManagerDispatch.cpp index 5cd224c9f4c443..641c568c9e701b 100644 --- a/src/transport/tests/TestSessionManagerDispatch.cpp +++ b/src/transport/tests/TestSessionManagerDispatch.cpp @@ -140,6 +140,7 @@ struct MessageTestEntry theMessageTestVector[] = { .sessionId = 0x0bb8, // 3000 .peerNodeId = 0x0000000000000000ULL, }, +#if !CHIP_CONFIG_SECURITY_TEST_MODE { .name = "secure group message (no privacy)", .peerAddr = "::1", @@ -169,6 +170,7 @@ struct MessageTestEntry theMessageTestVector[] = { .groupId = 2, .sourceNodeId = 0x0000000000000002ULL, }, +#endif // !CHIP_CONFIG_SECURITY_TEST_MODE }; const uint16_t theMessageTestVectorLength = sizeof(theMessageTestVector) / sizeof(theMessageTestVector[0]);