@@ -58,10 +58,22 @@ - (MTRCertificateTLVBytes)exampleRCACertTLV
58
58
options: 0 ];
59
59
}
60
60
61
+ - (NSData *)exampleRCACertPublicKey
62
+ {
63
+ // Needs to match the "Public Key" listed above.
64
+ const unsigned char publicKeyBytes[] = " \x04\x61\xE7\x5C\xFE\x03\xEC\x90\x5E\xF4\x53\x77\xE5\xF4\xB5\x1D "
65
+ " \xE4\x3D\x55\xF4\xD4\xE7\xEA\x7B\x22\x76\x5E\x59\xCA\x0A\x9B\xDB "
66
+ " \x59\x8F\x69\xDB\x12\x8B\xFB\x35\xBF\x03\x1F\xE9\x51\xED\x53\x37 "
67
+ " \x5D\x35\xB0\x53\x22\xF4\xDF\x7E\xBA\xEC\x02\xAC\x52\xF3\x1B\x9A "
68
+ " \xD7 " ;
69
+ return [NSData dataWithBytes: publicKeyBytes length: sizeof (publicKeyBytes) - 1 ];
70
+ }
71
+
61
72
- (void )testParseRootCertificateTLV
62
73
{
63
74
MTRCertificateInfo * info = [[MTRCertificateInfo alloc ] initWithTLVBytes: self .exampleRCACertTLV];
64
75
XCTAssertNotNil (info);
76
+ XCTAssertEqualObjects (info.publicKeyData , self.exampleRCACertPublicKey );
65
77
XCTAssertEqual ([NSDate .now compare: info.notBefore], NSOrderedDescending);
66
78
XCTAssertEqual ([NSDate .now compare: info.notAfter], NSOrderedAscending);
67
79
@@ -113,11 +125,22 @@ - (MTRCertificateTLVBytes)exampleNOCertTLV
113
125
options: 0 ];
114
126
}
115
127
128
+ - (NSData *)exampleNOCertPublicKey
129
+ {
130
+ // Needs to match the "Public Key" listed above.
131
+ const unsigned char publicKeyBytes[] = " \x04\xFD\x7F\x7A\x19\x37\xE0\x6D\xA4\xC2\xC9\x95\xC5\x5F\x01\x10 "
132
+ " \xD2\xB0\xFC\x93\x50\x4C\x4A\x2A\xD5\x65\x90\x8B\x42\x7C\xAF\x60 "
133
+ " \x4A\x1C\x24\xF9\xC1\x75\x61\x4C\x45\xDC\x87\x34\x0F\xB4\x1C\x24 "
134
+ " \xD2\x40\x11\x3F\x82\x6D\x8B\x2A\x24\x0E\xE4\xA5\x9B\x30\xC6\xA9 "
135
+ " \x51 " ;
136
+ return [NSData dataWithBytes: publicKeyBytes length: sizeof (publicKeyBytes) - 1 ];
137
+ }
138
+
116
139
- (void )testParseOperationalCertificateTLV
117
140
{
118
141
MTRCertificateInfo * info = [[MTRCertificateInfo alloc ] initWithTLVBytes: self .exampleNOCertTLV];
119
142
XCTAssertNotNil (info);
120
- XCTAssertNotNil (info.publicKeyData );
143
+ XCTAssertEqualObjects (info.publicKeyData , self. exampleNOCertPublicKey );
121
144
XCTAssertEqual ([NSDate .now compare: info.notBefore], NSOrderedDescending);
122
145
XCTAssertEqual ([NSDate .now compare: info.notAfter], NSOrderedAscending);
123
146
0 commit comments