Skip to content

Commit

Permalink
Add ICAC cert test vector which exercises the non-consecutive extensi…
Browse files Browse the repository at this point in the history
…ons tag parsing
  • Loading branch information
ssnover committed Sep 17, 2023
1 parent 21536dd commit ed227f7
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion rs-matter/src/cert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,10 @@ mod tests {

#[test]
fn test_tlv_conversions() {
let test_input: [&[u8]; 3] = [
let test_input: [&[u8]; 4] = [
&test_vectors::NOC1_SUCCESS,
&test_vectors::ICAC1_SUCCESS,
&test_vectors::ICAC2_SUCCESS,
&test_vectors::RCA1_SUCCESS,
];

Expand Down Expand Up @@ -964,6 +965,41 @@ mod tests {
89, 175, 253, 78, 212, 7, 69, 207, 140, 45, 129, 249, 64, 104, 70, 68, 43, 164, 19,
126, 114, 138, 79, 104, 238, 20, 226, 88, 118, 105, 56, 12, 92, 31, 171, 24,
];
// This cert has two of the fields in the extensions list swapped to a different order to be non-consecutive
pub const ICAC2_SUCCESS: [u8; 621] = [
21, 49, 1, 25, 1, 21, 48, 1, 17, 0, 216, 184, 140, 35, 236, 61, 104, 93, 172, 232, 160,
39, 189, 250, 251, 104, 36, 2, 1, 55, 3, 39, 19, 254, 111, 27, 53, 189, 134, 103, 200,
24, 38, 4, 6, 102, 72, 44, 38, 5, 22, 244, 223, 50, 55, 6, 39, 17, 198, 189, 6, 26,
205, 152, 127, 190, 39, 21, 242, 137, 119, 166, 227, 250, 211, 102, 36, 22, 1, 24, 36,
7, 1, 36, 8, 1, 48, 9, 65, 4, 255, 205, 50, 37, 213, 13, 210, 66, 226, 218, 18, 124,
157, 34, 3, 202, 13, 102, 34, 95, 189, 33, 187, 19, 138, 187, 219, 242, 173, 208, 249,
3, 108, 76, 55, 59, 116, 42, 233, 74, 167, 55, 101, 61, 1, 158, 198, 105, 73, 220, 94,
203, 38, 194, 71, 241, 254, 206, 16, 249, 203, 72, 132, 212, 55, 10, 53, 1, 40, 1, 24,
48, 5, 20, 88, 240, 172, 159, 2, 82, 193, 71, 83, 67, 184, 97, 99, 61, 125, 67, 232,
202, 171, 107, 48, 4, 20, 240, 120, 145, 62, 218, 150, 208, 177, 31, 6, 138, 53, 177,
29, 201, 85, 46, 50, 148, 61, 36, 2, 5, 54, 3, 4, 2, 4, 1, 24, 24, 48, 11, 64, 47, 118,
45, 153, 222, 242, 163, 93, 58, 174, 62, 121, 25, 194, 150, 83, 148, 228, 25, 172, 167,
49, 66, 193, 48, 205, 127, 14, 115, 255, 7, 33, 160, 43, 17, 180, 237, 73, 7, 24, 101,
232, 140, 1, 17, 194, 134, 173, 187, 76, 205, 187, 131, 159, 137, 130, 98, 176, 136,
72, 188, 218, 182, 142, 24, 49, 2, 7, 1, 21, 48, 1, 16, 67, 38, 73, 198, 26, 31, 20,
101, 57, 46, 16, 143, 77, 160, 128, 161, 36, 2, 1, 55, 3, 39, 20, 255, 90, 200, 17,
145, 105, 71, 215, 24, 38, 4, 123, 59, 211, 42, 38, 5, 35, 11, 27, 52, 55, 6, 39, 19,
254, 111, 27, 53, 189, 134, 103, 200, 24, 36, 7, 1, 36, 8, 1, 48, 9, 65, 4, 88, 188,
13, 87, 50, 3, 213, 248, 182, 12, 240, 164, 220, 127, 150, 65, 81, 244, 125, 24, 48,
203, 83, 111, 133, 175, 182, 10, 40, 80, 147, 28, 39, 121, 183, 61, 159, 178, 231, 133,
75, 189, 143, 136, 191, 254, 115, 228, 186, 129, 56, 137, 213, 177, 13, 46, 97, 202,
95, 41, 5, 16, 24, 228, 55, 10, 53, 1, 41, 1, 36, 2, 0, 24, 48, 5, 20, 243, 119, 107,
152, 3, 212, 205, 76, 85, 38, 158, 240, 27, 213, 11, 235, 33, 21, 38, 5, 48, 4, 20, 88,
240, 172, 159, 2, 82, 193, 71, 83, 67, 184, 97, 99, 61, 125, 67, 232, 202, 171, 107,
36, 2, 96, 24, 48, 11, 64, 70, 43, 150, 195, 194, 170, 43, 125, 91, 213, 210, 221, 175,
131, 131, 85, 22, 247, 213, 18, 101, 189, 30, 134, 20, 226, 217, 145, 41, 225, 181,
150, 28, 200, 52, 237, 218, 195, 144, 209, 205, 73, 88, 114, 139, 216, 85, 170, 63,
238, 164, 69, 35, 69, 39, 87, 211, 234, 57, 98, 19, 43, 13, 0, 24, 48, 3, 64, 186, 205,
180, 254, 158, 160, 208, 170, 245, 103, 40, 213, 109, 32, 37, 181, 151, 231, 59, 199,
255, 91, 132, 201, 39, 40, 244, 140, 61, 28, 67, 185, 57, 196, 168, 45, 252, 49, 245,
108, 172, 202, 121, 106, 121, 59, 25, 9, 44, 145, 227, 207, 195, 146, 223, 43, 253, 63,
244, 195, 46, 78, 228, 8, 24,
];
// A single byte in the auth key id is changed in this
pub const NOC1_AUTH_KEY_FAIL: [u8; 247] = [
0x15, 0x30, 0x1, 0x1, 0x1, 0x24, 0x2, 0x1, 0x37, 0x3, 0x24, 0x13, 0x1, 0x24, 0x15, 0x1,
Expand Down

0 comments on commit ed227f7

Please sign in to comment.