Skip to content

Commit b791b75

Browse files
[SecureChannel] Update Check-In Protocol Test vectors (#33272)
* Update Check-In Protocol vectors * Move TestCheckMsg to gtest * Restyled by whitespace --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 464ddb6 commit b791b75

File tree

3 files changed

+112
-211
lines changed

3 files changed

+112
-211
lines changed

src/protocols/secure_channel/tests/BUILD.gn

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@ import("${chip_root}/src/app/icd/icd.gni")
66

77
chip_test_suite("tests") {
88
output_name = "libSecureChannelTests"
9-
test_sources = [ "TestCheckInCounter.cpp" ]
9+
10+
test_sources = [
11+
"TestCheckInCounter.cpp",
12+
"TestCheckinMsg.cpp",
13+
]
14+
15+
sources = [ "CheckIn_Message_test_vectors.h" ]
1016

1117
cflags = [ "-Wconversion" ]
1218
public_deps = [
19+
"${chip_root}/src/app/icd/server:icd-server-config",
20+
"${chip_root}/src/credentials/tests:cert_test_vectors",
1321
"${chip_root}/src/lib/core",
1422
"${chip_root}/src/lib/support",
1523
"${chip_root}/src/lib/support:test_utils",
1624
"${chip_root}/src/lib/support:testing",
25+
"${chip_root}/src/protocols/secure_channel",
1726
"${chip_root}/src/protocols/secure_channel:check-in-counter",
1827
"${dir_pw_unit_test}",
1928
]
@@ -25,7 +34,6 @@ chip_test_suite_using_nltest("tests_nltest") {
2534

2635
test_sources = [
2736
"TestCASESession.cpp",
28-
"TestCheckinMsg.cpp",
2937
"TestDefaultSessionResumptionStorage.cpp",
3038
"TestPASESession.cpp",
3139
"TestPairingSession.cpp",
@@ -36,11 +44,7 @@ chip_test_suite_using_nltest("tests_nltest") {
3644
# "TestMessageCounterManager.cpp",
3745
]
3846

39-
sources = [ "CheckIn_Message_test_vectors.h" ]
40-
4147
public_deps = [
42-
"${chip_root}/src/app/icd/server:icd-server-config",
43-
"${chip_root}/src/credentials/tests:cert_test_vectors",
4448
"${chip_root}/src/crypto/tests:tests.lib",
4549
"${chip_root}/src/lib/core",
4650
"${chip_root}/src/lib/support",

src/protocols/secure_channel/tests/CheckIn_Message_test_vectors.h

+24-23
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,20 @@ const CheckIn_Message_test_vector vector3 = { .key = kKey3,
143143

144144
const uint8_t kKey4[] = { 0xca, 0x67, 0xd4, 0x1f, 0xf7, 0x11, 0x29, 0x10, 0xfd, 0xd1, 0x8a, 0x1b, 0xf9, 0x9e, 0xa9, 0x74 };
145145

146-
const uint8_t kApplicationData4[] = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61,
147-
0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x75, 0x65, 0x72 };
146+
const uint8_t kApplicationData4[] = {
147+
0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72
148+
};
148149

149150
const uint8_t kNonce4[] = { 0x7a, 0x97, 0x72, 0x24, 0x3c, 0x97, 0xc8, 0x7d, 0x5f, 0x3a, 0x31, 0xc4, 0xe6 };
150151

151-
const uint8_t kCiphertext4[] = { 0xdb, 0xbc, 0x1a, 0xa5, 0x66, 0xc4, 0x43, 0xc2, 0x05, 0x86, 0x06,
152-
0x6b, 0x42, 0x7b, 0xfc, 0xaa, 0xad, 0x78, 0xca, 0x5d, 0xad };
152+
const uint8_t kCiphertext4[] = { 0xdb, 0xbc, 0x1a, 0xa5, 0x66, 0xc4, 0x43, 0xc2, 0x05, 0x86,
153+
0x06, 0x6b, 0x42, 0x7b, 0xfc, 0xaa, 0xad, 0x78, 0xda, 0x4a };
153154

154-
const uint8_t kMic4[] = { 0x3d, 0x79, 0x78, 0xf7, 0x04, 0xe6, 0x30, 0xac, 0x04, 0x3f, 0xbf, 0xaa, 0x81, 0x25, 0xb2, 0xac };
155+
const uint8_t kMic4[] = { 0x10, 0x5a, 0x13, 0x42, 0xad, 0xbf, 0x3f, 0x47, 0x98, 0xcd, 0x81, 0xb9, 0xef, 0x97, 0xbb, 0xb7 };
155156

156157
const uint8_t kPayload4[] = { 0x7a, 0x97, 0x72, 0x24, 0x3c, 0x97, 0xc8, 0x7d, 0x5f, 0x3a, 0x31, 0xc4, 0xe6, 0xdb, 0xbc, 0x1a, 0xa5,
157-
0x66, 0xc4, 0x43, 0xc2, 0x05, 0x86, 0x06, 0x6b, 0x42, 0x7b, 0xfc, 0xaa, 0xad, 0x78, 0xca, 0x5d, 0xad,
158-
0x3d, 0x79, 0x78, 0xf7, 0x04, 0xe6, 0x30, 0xac, 0x04, 0x3f, 0xbf, 0xaa, 0x81, 0x25, 0xb2, 0xac };
158+
0x66, 0xc4, 0x43, 0xc2, 0x05, 0x86, 0x06, 0x6b, 0x42, 0x7b, 0xfc, 0xaa, 0xad, 0x78, 0xda, 0x4a, 0x10,
159+
0x5a, 0x13, 0x42, 0xad, 0xbf, 0x3f, 0x47, 0x98, 0xcd, 0x81, 0xb9, 0xef, 0x97, 0xbb, 0xb7 };
159160

160161
const CheckIn_Message_test_vector vector4 = { .key = kKey4,
161162
.key_len = sizeof(kKey4),
@@ -178,19 +179,19 @@ const CheckIn_Message_test_vector vector4 = { .key = kKey4,
178179
const uint8_t kKey5[] = { 0xca, 0x67, 0xd4, 0x1f, 0xf7, 0x11, 0x29, 0x10, 0xfd, 0xd1, 0x8a, 0x1b, 0xf9, 0x9e, 0xa9, 0x74 };
179180

180181
const uint8_t kApplicationData5[] = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6c, 0x6f,
181-
0x6e, 0x67, 0x75, 0x65, 0x72, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67 };
182+
0x6e, 0x67, 0x65, 0x72, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67 };
182183

183184
const uint8_t kNonce5[] = { 0x06, 0x34, 0x67, 0x6e, 0xa6, 0xe0, 0x70, 0x7b, 0x7a, 0xd7, 0x81, 0x4f, 0xf8 };
184185

185186
const uint8_t kCiphertext5[] = { 0x2e, 0x5b, 0x18, 0xd1, 0x9a, 0x23, 0xb2, 0xe4, 0xfa, 0xdf, 0x82, 0x92, 0x53, 0x51,
186-
0x7f, 0xf3, 0xc9, 0x1d, 0x9d, 0x50, 0xd6, 0x62, 0x5d, 0x18, 0x29, 0x0f, 0xb1, 0x21 };
187+
0x7f, 0xf3, 0xc9, 0x1d, 0x8d, 0x47, 0x84, 0x31, 0x5a, 0x1e, 0x32, 0x08, 0xb8 };
187188

188-
const uint8_t kMic5[] = { 0x8b, 0x5d, 0xef, 0x99, 0x65, 0xb4, 0xdc, 0x3a, 0x87, 0x25, 0xc2, 0xeb, 0x2e, 0x18, 0x25, 0x98 };
189+
const uint8_t kMic5[] = { 0xec, 0xf6, 0x11, 0x8b, 0x02, 0x1a, 0x5a, 0x4c, 0xd4, 0xe9, 0xd4, 0x13, 0x8d, 0xff, 0x29, 0x71 };
189190

190-
const uint8_t kPayload5[] = { 0x06, 0x34, 0x67, 0x6e, 0xa6, 0xe0, 0x70, 0x7b, 0x7a, 0xd7, 0x81, 0x4f, 0xf8, 0x2e, 0x5b,
191-
0x18, 0xd1, 0x9a, 0x23, 0xb2, 0xe4, 0xfa, 0xdf, 0x82, 0x92, 0x53, 0x51, 0x7f, 0xf3, 0xc9,
192-
0x1d, 0x9d, 0x50, 0xd6, 0x62, 0x5d, 0x18, 0x29, 0x0f, 0xb1, 0x21, 0x8b, 0x5d, 0xef, 0x99,
193-
0x65, 0xb4, 0xdc, 0x3a, 0x87, 0x25, 0xc2, 0xeb, 0x2e, 0x18, 0x25, 0x98 };
191+
const uint8_t kPayload5[] = { 0x06, 0x34, 0x67, 0x6e, 0xa6, 0xe0, 0x70, 0x7b, 0x7a, 0xd7, 0x81, 0x4f, 0xf8, 0x2e,
192+
0x5b, 0x18, 0xd1, 0x9a, 0x23, 0xb2, 0xe4, 0xfa, 0xdf, 0x82, 0x92, 0x53, 0x51, 0x7f,
193+
0xf3, 0xc9, 0x1d, 0x8d, 0x47, 0x84, 0x31, 0x5a, 0x1e, 0x32, 0x08, 0xb8, 0xec, 0xf6,
194+
0x11, 0x8b, 0x02, 0x1a, 0x5a, 0x4c, 0xd4, 0xe9, 0xd4, 0x13, 0x8d, 0xff, 0x29, 0x71 };
194195

195196
const CheckIn_Message_test_vector vector5 = { .key = kKey5,
196197
.key_len = sizeof(kKey5),
@@ -216,25 +217,25 @@ const uint8_t kInvalidNonceKey[] = {
216217
0xca, 0x67, 0xd4, 0x1f, 0xf7, 0x11, 0x29, 0x10, 0xfd, 0xd1, 0x8a, 0x1b, 0xf9, 0x9e, 0xa9, 0x74
217218
};
218219

219-
const uint8_t kInvalidNonceApplicationData[] = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6c,
220-
0x6f, 0x6e, 0x67, 0x75, 0x65, 0x72, 0x20, 0x6c, 0x6f, 0x6e, 0x67,
221-
0x75, 0x65, 0x72, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67 };
220+
const uint8_t kInvalidNonceApplicationData[] = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20,
221+
0x6c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x20, 0x6c, 0x6f, 0x6e,
222+
0x67, 0x65, 0x72, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67 };
222223

223224
const uint8_t kInvalidNonceNonce[] = { 0x06, 0x34, 0x67, 0x6e, 0xa6, 0xe0, 0x70, 0x7b, 0x7a, 0xd7, 0x81, 0x4f, 0xf8 };
224225

225226
const uint8_t kInvalidNonceCiphertext[] = { 0x29, 0x5b, 0x18, 0xd1, 0x9a, 0x23, 0xb2, 0xe4, 0xfa, 0xdf, 0x82, 0x92,
226-
0x53, 0x51, 0x7f, 0xf3, 0xc9, 0x1d, 0x9d, 0x50, 0xd6, 0x62, 0x42, 0x03,
227-
0x35, 0x01, 0xaa, 0x23, 0xad, 0x19, 0xcb, 0x6f, 0x5b, 0xee, 0x56, 0xb3 };
227+
0x53, 0x51, 0x7f, 0xf3, 0xc9, 0x1d, 0x8d, 0x47, 0x84, 0x2e, 0x41, 0x02,
228+
0x3c, 0x03, 0xad, 0x66, 0xac, 0x4d, 0xca, 0x72, 0x47, 0xe0 };
228229

229230
const uint8_t kInvalidNonceMic[] = {
230-
0xd5, 0x8a, 0x92, 0x2b, 0x66, 0x44, 0x89, 0x3e, 0x66, 0x31, 0x8b, 0xb5, 0x53, 0x79, 0x24, 0x8b
231+
0xe4, 0xc6, 0x6b, 0xd9, 0xd3, 0x99, 0x13, 0xe2, 0x3d, 0x82, 0x32, 0xb9, 0x61, 0xfa, 0x92, 0x26
231232
};
232233

233234
const uint8_t kInvalidNoncePayload[] = { 0x06, 0x34, 0x67, 0x6e, 0xa6, 0xe0, 0x70, 0x7b, 0x7a, 0xd7, 0x81, 0x4f, 0xf8,
234235
0x29, 0x5b, 0x18, 0xd1, 0x9a, 0x23, 0xb2, 0xe4, 0xfa, 0xdf, 0x82, 0x92, 0x53,
235-
0x51, 0x7f, 0xf3, 0xc9, 0x1d, 0x9d, 0x50, 0xd6, 0x62, 0x42, 0x03, 0x35, 0x01,
236-
0xaa, 0x23, 0xad, 0x19, 0xcb, 0x6f, 0x5b, 0xee, 0x56, 0xb3, 0xd5, 0x8a, 0x92,
237-
0x2b, 0x66, 0x44, 0x89, 0x3e, 0x66, 0x31, 0x8b, 0xb5, 0x53, 0x79, 0x24, 0x8b };
236+
0x51, 0x7f, 0xf3, 0xc9, 0x1d, 0x8d, 0x47, 0x84, 0x2e, 0x41, 0x02, 0x3c, 0x03,
237+
0xad, 0x66, 0xac, 0x4d, 0xca, 0x72, 0x47, 0xe0, 0xe4, 0xc6, 0x6b, 0xd9, 0xd3,
238+
0x99, 0x13, 0xe2, 0x3d, 0x82, 0x32, 0xb9, 0x61, 0xfa, 0x92, 0x26 };
238239

239240
const CheckIn_Message_test_vector invalidNonceVector = { .key = kInvalidNonceKey,
240241
.key_len = sizeof(kInvalidNonceKey),

0 commit comments

Comments
 (0)