Skip to content

Latest commit

 

History

History
921 lines (789 loc) · 25.5 KB

pkixder_input_tests.cpp

File metadata and controls

921 lines (789 loc) · 25.5 KB
 
1
2
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
May 14, 2014
May 14, 2014
3
4
5
6
7
8
9
10
/* This code is made available to you under your choice of the following sets
* of licensing terms:
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* Copyright 2013 Mozilla Contributors
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <functional>
#include <vector>
Feb 7, 2015
Feb 7, 2015
27
#include "pkixgtest.h"
Aug 3, 2018
Aug 3, 2018
29
#include "mozpkix/pkixder.h"
Jul 15, 2014
Jul 15, 2014
31
using namespace mozilla::pkix;
32
33
34
35
using namespace mozilla::pkix::der;
namespace {
Jul 18, 2014
Jul 18, 2014
36
class pkixder_input_tests : public ::testing::Test { };
Jul 1, 2014
Jul 1, 2014
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
static const uint8_t DER_SEQUENCE_EMPTY[] = {
0x30, // SEQUENCE
0x00, // length
};
static const uint8_t DER_SEQUENCE_NOT_EMPTY[] = {
0x30, // SEQUENCE
0x01, // length
'X', // value
};
static const uint8_t DER_SEQUENCE_NOT_EMPTY_VALUE[] = {
'X', // value
};
static const uint8_t DER_SEQUENCE_NOT_EMPTY_VALUE_TRUNCATED[] = {
0x30, // SEQUENCE
0x01, // length
};
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const uint8_t DER_SEQUENCE_OF_INT8[] = {
0x30, // SEQUENCE
0x09, // length
0x02, 0x01, 0x01, // INTEGER length 1 value 0x01
0x02, 0x01, 0x02, // INTEGER length 1 value 0x02
0x02, 0x01, 0x03 // INTEGER length 1 value 0x03
};
const uint8_t DER_TRUNCATED_SEQUENCE_OF_INT8[] = {
0x30, // SEQUENCE
0x09, // length
0x02, 0x01, 0x01, // INTEGER length 1 value 0x01
0x02, 0x01, 0x02 // INTEGER length 1 value 0x02
// MISSING DATA HERE ON PURPOSE
};
const uint8_t DER_OVERRUN_SEQUENCE_OF_INT8[] = {
0x30, // SEQUENCE
0x09, // length
0x02, 0x01, 0x01, // INTEGER length 1 value 0x01
0x02, 0x01, 0x02, // INTEGER length 1 value 0x02
0x02, 0x02, 0xFF, 0x03 // INTEGER length 2 value 0xFF03
};
const uint8_t DER_INT16[] = {
0x02, // INTEGER
0x02, // length
0x12, 0x34 // 0x1234
};
Sep 3, 2014
Sep 3, 2014
88
89
static const Input EMPTY_INPUT;
Jul 31, 2014
Jul 31, 2014
90
TEST_F(pkixder_input_tests, InputInit)
Jul 31, 2014
Jul 31, 2014
92
Input buf;
93
ASSERT_EQ(Success,
Jul 19, 2014
Jul 19, 2014
94
buf.Init(DER_SEQUENCE_OF_INT8, sizeof DER_SEQUENCE_OF_INT8));
Jul 31, 2014
Jul 31, 2014
97
TEST_F(pkixder_input_tests, InputInitWithNullPointerOrZeroLength)
Jul 31, 2014
Jul 31, 2014
99
Input buf;
Jul 19, 2014
Jul 19, 2014
100
ASSERT_EQ(Result::ERROR_BAD_DER, buf.Init(nullptr, 0));
Jul 19, 2014
Jul 19, 2014
102
ASSERT_EQ(Result::ERROR_BAD_DER, buf.Init(nullptr, 100));
May 7, 2014
May 7, 2014
104
// Though it seems odd to initialize with zero-length and non-null ptr, this
Jul 31, 2014
Jul 31, 2014
105
// is working as intended. The Reader class was intended to protect against
May 7, 2014
May 7, 2014
106
107
// buffer overflows, and there's no risk with the current behavior. See bug
// 1000354.
Jul 19, 2014
Jul 19, 2014
108
109
ASSERT_EQ(Success, buf.Init((const uint8_t*) "hello", 0));
ASSERT_TRUE(buf.GetLength() == 0);
Jul 31, 2014
Jul 31, 2014
112
TEST_F(pkixder_input_tests, InputInitWithLargeData)
Jul 31, 2014
Jul 31, 2014
114
Input buf;
115
116
// Data argument length does not matter, it is not touched, just
// needs to be non-null
Jul 19, 2014
Jul 19, 2014
117
ASSERT_EQ(Result::ERROR_BAD_DER, buf.Init((const uint8_t*) "", 0xffff+1));
Jul 19, 2014
Jul 19, 2014
119
ASSERT_EQ(Success, buf.Init((const uint8_t*) "", 0xffff));
Jul 31, 2014
Jul 31, 2014
122
TEST_F(pkixder_input_tests, InputInitMultipleTimes)
Jul 31, 2014
Jul 31, 2014
124
Input buf;
125
126
ASSERT_EQ(Success,
Jul 19, 2014
Jul 19, 2014
127
buf.Init(DER_SEQUENCE_OF_INT8, sizeof DER_SEQUENCE_OF_INT8));
Jul 18, 2014
Jul 18, 2014
129
ASSERT_EQ(Result::FATAL_ERROR_INVALID_ARGS,
Jul 19, 2014
Jul 19, 2014
130
buf.Init(DER_SEQUENCE_OF_INT8, sizeof DER_SEQUENCE_OF_INT8));
131
132
133
134
135
}
TEST_F(pkixder_input_tests, PeekWithinBounds)
{
const uint8_t der[] = { 0x11, 0x11 };
Jul 31, 2014
Jul 31, 2014
136
137
Input buf(der);
Reader input(buf);
138
139
140
141
142
143
144
ASSERT_TRUE(input.Peek(0x11));
ASSERT_FALSE(input.Peek(0x22));
}
TEST_F(pkixder_input_tests, PeekPastBounds)
{
const uint8_t der[] = { 0x11, 0x22 };
Jul 31, 2014
Jul 31, 2014
145
Input buf;
Jul 19, 2014
Jul 19, 2014
146
ASSERT_EQ(Success, buf.Init(der, 1));
Jul 31, 2014
Jul 31, 2014
147
Reader input(buf);
148
149
150
151
152
153
154
155
156
157
uint8_t readByte;
ASSERT_EQ(Success, input.Read(readByte));
ASSERT_EQ(0x11, readByte);
ASSERT_FALSE(input.Peek(0x22));
}
TEST_F(pkixder_input_tests, ReadByte)
{
const uint8_t der[] = { 0x11, 0x22 };
Jul 31, 2014
Jul 31, 2014
158
159
Input buf(der);
Reader input(buf);
160
161
162
163
164
165
166
167
168
169
170
171
172
uint8_t readByte1;
ASSERT_EQ(Success, input.Read(readByte1));
ASSERT_EQ(0x11, readByte1);
uint8_t readByte2;
ASSERT_EQ(Success, input.Read(readByte2));
ASSERT_EQ(0x22, readByte2);
}
TEST_F(pkixder_input_tests, ReadBytePastEnd)
{
const uint8_t der[] = { 0x11, 0x22 };
Jul 31, 2014
Jul 31, 2014
173
Input buf;
Jul 19, 2014
Jul 19, 2014
174
ASSERT_EQ(Success, buf.Init(der, 1));
Jul 31, 2014
Jul 31, 2014
175
Reader input(buf);
176
177
178
179
180
181
uint8_t readByte1 = 0;
ASSERT_EQ(Success, input.Read(readByte1));
ASSERT_EQ(0x11, readByte1);
uint8_t readByte2 = 0;
Jul 18, 2014
Jul 18, 2014
182
ASSERT_EQ(Result::ERROR_BAD_DER, input.Read(readByte2));
183
184
185
ASSERT_NE(0x22, readByte2);
}
May 30, 2014
May 30, 2014
186
187
188
189
190
191
192
193
194
195
TEST_F(pkixder_input_tests, ReadByteWrapAroundPointer)
{
// The original implementation of our buffer read overflow checks was
// susceptible to integer overflows which could make the checks ineffective.
// This attempts to verify that we've fixed that. Unfortunately, decrementing
// a null pointer is undefined behavior according to the C++ language spec.,
// but this should catch the problem on at least some compilers, if not all of
// them.
const uint8_t* der = nullptr;
--der;
Jul 31, 2014
Jul 31, 2014
196
Input buf;
Jul 19, 2014
Jul 19, 2014
197
ASSERT_EQ(Success, buf.Init(der, 0));
Jul 31, 2014
Jul 31, 2014
198
Reader input(buf);
Jul 19, 2014
Jul 19, 2014
199
May 30, 2014
May 30, 2014
200
uint8_t b;
Jul 18, 2014
Jul 18, 2014
201
ASSERT_EQ(Result::ERROR_BAD_DER, input.Read(b));
May 30, 2014
May 30, 2014
202
203
}
204
205
206
TEST_F(pkixder_input_tests, ReadWord)
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
207
208
Input buf(der);
Reader input(buf);
209
210
211
212
213
214
215
216
217
218
219
220
221
uint16_t readWord1 = 0;
ASSERT_EQ(Success, input.Read(readWord1));
ASSERT_EQ(0x1122, readWord1);
uint16_t readWord2 = 0;
ASSERT_EQ(Success, input.Read(readWord2));
ASSERT_EQ(0x3344, readWord2);
}
TEST_F(pkixder_input_tests, ReadWordPastEnd)
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
222
Input buf;
Jul 19, 2014
Jul 19, 2014
223
ASSERT_EQ(Success, buf.Init(der, 2)); // Initialize with too-short length
Jul 31, 2014
Jul 31, 2014
224
Reader input(buf);
225
226
227
228
229
230
uint16_t readWord1 = 0;
ASSERT_EQ(Success, input.Read(readWord1));
ASSERT_EQ(0x1122, readWord1);
uint16_t readWord2 = 0;
Jul 18, 2014
Jul 18, 2014
231
ASSERT_EQ(Result::ERROR_BAD_DER, input.Read(readWord2));
232
233
234
235
236
237
ASSERT_NE(0x3344, readWord2);
}
TEST_F(pkixder_input_tests, ReadWordWithInsufficentData)
{
const uint8_t der[] = { 0x11, 0x22 };
Jul 31, 2014
Jul 31, 2014
238
Input buf;
Jul 19, 2014
Jul 19, 2014
239
ASSERT_EQ(Success, buf.Init(der, 1));
Jul 31, 2014
Jul 31, 2014
240
Reader input(buf);
241
242
uint16_t readWord1 = 0;
Jul 18, 2014
Jul 18, 2014
243
ASSERT_EQ(Result::ERROR_BAD_DER, input.Read(readWord1));
244
245
246
ASSERT_NE(0x1122, readWord1);
}
May 30, 2014
May 30, 2014
247
248
249
250
251
252
253
254
255
256
TEST_F(pkixder_input_tests, ReadWordWrapAroundPointer)
{
// The original implementation of our buffer read overflow checks was
// susceptible to integer overflows which could make the checks ineffective.
// This attempts to verify that we've fixed that. Unfortunately, decrementing
// a null pointer is undefined behavior according to the C++ language spec.,
// but this should catch the problem on at least some compilers, if not all of
// them.
const uint8_t* der = nullptr;
--der;
Jul 31, 2014
Jul 31, 2014
257
Input buf;
Jul 19, 2014
Jul 19, 2014
258
ASSERT_EQ(Success, buf.Init(der, 0));
Jul 31, 2014
Jul 31, 2014
259
Reader input(buf);
May 30, 2014
May 30, 2014
260
uint16_t b;
Jul 18, 2014
Jul 18, 2014
261
ASSERT_EQ(Result::ERROR_BAD_DER, input.Read(b));
May 30, 2014
May 30, 2014
262
263
}
Dec 28, 2014
Dec 28, 2014
264
TEST_F(pkixder_input_tests, Skip)
265
266
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
267
268
Input buf(der);
Reader input(buf);
269
270
271
272
273
274
275
276
277
278
279
280
281
282
ASSERT_EQ(Success, input.Skip(1));
uint8_t readByte1 = 0;
ASSERT_EQ(Success, input.Read(readByte1));
ASSERT_EQ(0x22, readByte1);
ASSERT_EQ(Success, input.Skip(1));
uint8_t readByte2 = 0;
ASSERT_EQ(Success, input.Read(readByte2));
ASSERT_EQ(0x44, readByte2);
}
Dec 28, 2014
Dec 28, 2014
283
TEST_F(pkixder_input_tests, Skip_ToEnd)
284
285
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
286
287
Input buf(der);
Reader input(buf);
288
289
290
291
ASSERT_EQ(Success, input.Skip(sizeof der));
ASSERT_TRUE(input.AtEnd());
}
Dec 28, 2014
Dec 28, 2014
292
TEST_F(pkixder_input_tests, Skip_PastEnd)
293
294
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
295
296
Input buf(der);
Reader input(buf);
Jul 18, 2014
Jul 18, 2014
298
ASSERT_EQ(Result::ERROR_BAD_DER, input.Skip(sizeof der + 1));
Dec 28, 2014
Dec 28, 2014
301
TEST_F(pkixder_input_tests, Skip_ToNewInput)
302
303
{
const uint8_t der[] = { 0x01, 0x02, 0x03, 0x04 };
Jul 31, 2014
Jul 31, 2014
304
305
Input buf(der);
Reader input(buf);
Jul 31, 2014
Jul 31, 2014
307
Reader skippedInput;
308
309
310
311
312
313
314
315
ASSERT_EQ(Success, input.Skip(3, skippedInput));
uint8_t readByte1 = 0;
ASSERT_EQ(Success, input.Read(readByte1));
ASSERT_EQ(0x04, readByte1);
ASSERT_TRUE(input.AtEnd());
Jul 31, 2014
Jul 31, 2014
316
// Reader has no Remaining() or Length() so we simply read the bytes
317
318
319
320
321
322
323
324
325
326
327
// and then expect to be at the end.
for (uint8_t i = 1; i <= 3; ++i) {
uint8_t readByte = 0;
ASSERT_EQ(Success, skippedInput.Read(readByte));
ASSERT_EQ(i, readByte);
}
ASSERT_TRUE(skippedInput.AtEnd());
}
Dec 28, 2014
Dec 28, 2014
328
TEST_F(pkixder_input_tests, Skip_ToNewInputPastEnd)
329
330
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
331
332
Input buf(der);
Reader input(buf);
Jul 31, 2014
Jul 31, 2014
334
Reader skippedInput;
Jul 18, 2014
Jul 18, 2014
335
ASSERT_EQ(Result::ERROR_BAD_DER, input.Skip(sizeof der * 2, skippedInput));
Dec 28, 2014
Dec 28, 2014
338
TEST_F(pkixder_input_tests, Skip_ToInput)
339
340
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
341
342
Input buf(der);
Reader input(buf);
343
344
345
const uint8_t expectedItemData[] = { 0x11, 0x22, 0x33 };
Jul 31, 2014
Jul 31, 2014
346
Input item;
347
ASSERT_EQ(Success, input.Skip(sizeof expectedItemData, item));
Jul 19, 2014
Jul 19, 2014
348
Jul 31, 2014
Jul 31, 2014
349
350
Input expected(expectedItemData);
ASSERT_TRUE(InputsAreEqual(expected, item));
Dec 28, 2014
Dec 28, 2014
353
TEST_F(pkixder_input_tests, Skip_WrapAroundPointer)
May 30, 2014
May 30, 2014
354
355
356
357
358
359
360
361
{
// The original implementation of our buffer read overflow checks was
// susceptible to integer overflows which could make the checks ineffective.
// This attempts to verify that we've fixed that. Unfortunately, decrementing
// a null pointer is undefined behavior according to the C++ language spec.,
// but this should catch the problem on at least some compilers, if not all of
// them.
const uint8_t* der = nullptr;
May 2, 2019
May 2, 2019
362
// coverity[FORWARD_NULL]
May 30, 2014
May 30, 2014
363
--der;
Jul 31, 2014
Jul 31, 2014
364
Input buf;
Jul 19, 2014
Jul 19, 2014
365
ASSERT_EQ(Success, buf.Init(der, 0));
Jul 31, 2014
Jul 31, 2014
366
Reader input(buf);
Jul 18, 2014
Jul 18, 2014
367
ASSERT_EQ(Result::ERROR_BAD_DER, input.Skip(1));
May 30, 2014
May 30, 2014
368
369
}
Dec 28, 2014
Dec 28, 2014
370
TEST_F(pkixder_input_tests, Skip_ToInputPastEnd)
371
372
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
373
374
Input buf(der);
Reader input(buf);
Jul 31, 2014
Jul 31, 2014
376
Input skipped;
Jul 19, 2014
Jul 19, 2014
377
ASSERT_EQ(Result::ERROR_BAD_DER, input.Skip(sizeof der + 1, skipped));
Dec 28, 2014
Dec 28, 2014
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
TEST_F(pkixder_input_tests, SkipToEnd_ToInput)
{
static const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Input buf(der);
Reader input(buf);
Input skipped;
ASSERT_EQ(Success, input.SkipToEnd(skipped));
}
TEST_F(pkixder_input_tests, SkipToEnd_ToInput_InputAlreadyInited)
{
static const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Input buf(der);
Reader input(buf);
static const uint8_t initialValue[] = { 0x01, 0x02, 0x03 };
Input x(initialValue);
// Fails because skipped was already initialized once, and Inputs are not
// allowed to be Init()d multiple times.
ASSERT_EQ(Result::FATAL_ERROR_INVALID_ARGS, input.SkipToEnd(x));
ASSERT_TRUE(InputsAreEqual(x, Input(initialValue)));
}
May 15, 2014
May 15, 2014
404
TEST_F(pkixder_input_tests, ExpectTagAndSkipValue)
Jul 31, 2014
Jul 31, 2014
406
407
Input buf(DER_SEQUENCE_OF_INT8);
Reader input(buf);
May 15, 2014
May 15, 2014
409
ASSERT_EQ(Success, ExpectTagAndSkipValue(input, SEQUENCE));
410
411
412
ASSERT_EQ(Success, End(input));
}
May 15, 2014
May 15, 2014
413
TEST_F(pkixder_input_tests, ExpectTagAndSkipValueWithTruncatedData)
Jul 31, 2014
Jul 31, 2014
415
416
Input buf(DER_TRUNCATED_SEQUENCE_OF_INT8);
Reader input(buf);
Jul 18, 2014
Jul 18, 2014
418
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndSkipValue(input, SEQUENCE));
May 15, 2014
May 15, 2014
421
TEST_F(pkixder_input_tests, ExpectTagAndSkipValueWithOverrunData)
Jul 31, 2014
Jul 31, 2014
423
424
Input buf(DER_OVERRUN_SEQUENCE_OF_INT8);
Reader input(buf);
May 15, 2014
May 15, 2014
425
ASSERT_EQ(Success, ExpectTagAndSkipValue(input, SEQUENCE));
Jul 18, 2014
Jul 18, 2014
426
ASSERT_EQ(Result::ERROR_BAD_DER, End(input));
427
428
429
430
}
TEST_F(pkixder_input_tests, AtEndOnUnInitializedInput)
{
Jul 31, 2014
Jul 31, 2014
431
Reader input;
432
433
434
435
436
437
ASSERT_TRUE(input.AtEnd());
}
TEST_F(pkixder_input_tests, AtEndAtBeginning)
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
438
439
Input buf(der);
Reader input(buf);
440
441
442
443
444
445
ASSERT_FALSE(input.AtEnd());
}
TEST_F(pkixder_input_tests, AtEndAtEnd)
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
446
447
Input buf(der);
Reader input(buf);
448
449
450
451
ASSERT_EQ(Success, input.Skip(sizeof der));
ASSERT_TRUE(input.AtEnd());
}
Jul 31, 2014
Jul 31, 2014
452
TEST_F(pkixder_input_tests, MarkAndGetInput)
453
454
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
455
456
Input buf(der);
Reader input(buf);
Jul 31, 2014
Jul 31, 2014
458
Reader::Mark mark = input.GetMark();
459
460
461
462
463
const uint8_t expectedItemData[] = { 0x11, 0x22, 0x33 };
ASSERT_EQ(Success, input.Skip(sizeof expectedItemData));
Jul 31, 2014
Jul 31, 2014
464
465
466
467
Input item;
ASSERT_EQ(Success, input.GetInput(mark, item));
Input expected(expectedItemData);
ASSERT_TRUE(InputsAreEqual(expected, item));
Aug 4, 2014
Aug 4, 2014
470
// Cannot run this test on debug builds because of the NotReached
Feb 7, 2015
Feb 7, 2015
471
#ifdef NDEBUG
Jul 31, 2014
Jul 31, 2014
472
TEST_F(pkixder_input_tests, MarkAndGetInputDifferentInput)
May 2, 2014
May 2, 2014
473
474
{
const uint8_t der[] = { 0x11, 0x22, 0x33, 0x44 };
Jul 31, 2014
Jul 31, 2014
475
476
Input buf(der);
Reader input(buf);
May 2, 2014
May 2, 2014
477
Jul 31, 2014
Jul 31, 2014
478
479
Reader another;
Reader::Mark mark = another.GetMark();
May 2, 2014
May 2, 2014
480
481
482
ASSERT_EQ(Success, input.Skip(3));
Jul 31, 2014
Jul 31, 2014
483
484
Input item;
ASSERT_EQ(Result::FATAL_ERROR_INVALID_ARGS, input.GetInput(mark, item));
May 2, 2014
May 2, 2014
485
486
487
}
#endif
Sep 3, 2014
Sep 3, 2014
488
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_AtEnd)
Sep 3, 2014
Sep 3, 2014
490
491
492
493
Reader input(EMPTY_INPUT);
uint8_t tag;
Input value;
ASSERT_EQ(Result::ERROR_BAD_DER, ReadTagAndGetValue(input, tag, value));
Sep 3, 2014
Sep 3, 2014
496
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_TruncatedAfterTag)
Sep 3, 2014
Sep 3, 2014
498
499
static const uint8_t DER[] = { SEQUENCE };
Input buf(DER);
Jul 31, 2014
Jul 31, 2014
500
Reader input(buf);
Sep 3, 2014
Sep 3, 2014
501
502
503
uint8_t tag;
Input value;
ASSERT_EQ(Result::ERROR_BAD_DER, ReadTagAndGetValue(input, tag, value));
Sep 3, 2014
Sep 3, 2014
506
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_ValidEmpty)
Sep 3, 2014
Sep 3, 2014
508
Input buf(DER_SEQUENCE_EMPTY);
Jul 31, 2014
Jul 31, 2014
509
Reader input(buf);
Sep 3, 2014
Sep 3, 2014
510
511
512
513
514
515
uint8_t tag = 0;
Input value;
ASSERT_EQ(Success, ReadTagAndGetValue(input, tag, value));
ASSERT_EQ(SEQUENCE, tag);
ASSERT_EQ(0u, value.GetLength());
ASSERT_TRUE(input.AtEnd());
Sep 3, 2014
Sep 3, 2014
518
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_ValidNotEmpty)
Sep 3, 2014
Sep 3, 2014
520
Input buf(DER_SEQUENCE_NOT_EMPTY);
Jul 31, 2014
Jul 31, 2014
521
Reader input(buf);
Sep 3, 2014
Sep 3, 2014
522
523
524
525
526
527
uint8_t tag = 0;
Input value;
ASSERT_EQ(Success, ReadTagAndGetValue(input, tag, value));
ASSERT_EQ(SEQUENCE, tag);
Input expected(DER_SEQUENCE_NOT_EMPTY_VALUE);
ASSERT_TRUE(InputsAreEqual(expected, value));
528
529
530
ASSERT_TRUE(input.AtEnd());
}
Sep 3, 2014
Sep 3, 2014
531
532
TEST_F(pkixder_input_tests,
ReadTagAndGetValue_Input_InvalidNotEmptyValueTruncated)
Sep 3, 2014
Sep 3, 2014
534
Input buf(DER_SEQUENCE_NOT_EMPTY_VALUE_TRUNCATED);
Jul 31, 2014
Jul 31, 2014
535
Reader input(buf);
Sep 3, 2014
Sep 3, 2014
536
537
538
uint8_t tag;
Input value;
ASSERT_EQ(Result::ERROR_BAD_DER, ReadTagAndGetValue(input, tag, value));
Sep 3, 2014
Sep 3, 2014
541
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_InvalidWrongLength)
Jul 31, 2014
Jul 31, 2014
543
544
Input buf(DER_TRUNCATED_SEQUENCE_OF_INT8);
Reader input(buf);
Sep 3, 2014
Sep 3, 2014
545
546
uint8_t tag;
Input value;
Jul 18, 2014
Jul 18, 2014
547
ASSERT_EQ(Result::ERROR_BAD_DER,
Sep 3, 2014
Sep 3, 2014
548
ReadTagAndGetValue(input, tag, value));
Aug 21, 2014
Aug 21, 2014
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_InvalidHighTagNumberForm1)
{
// High tag number form is not allowed (illegal 1 byte tag)
//
// If the decoder treats 0x1F as a valid low tag number tag, then it will
// treat the actual tag (1) as a length, and then it will return Success
// with value == { 0x00 } and tag == 0x1f.
//
// It is illegal to encode tag 1 in the high tag number form because it isn't
// the shortest encoding (the low tag number form is).
static const uint8_t DER[] = {
0x1F, // high tag number form indicator
1, // tag 1 (not legal!)
0 // length zero
};
Input buf(DER);
Reader input(buf);
uint8_t tag;
Input value;
ASSERT_EQ(Result::ERROR_BAD_DER,
ReadTagAndGetValue(input, tag, value));
}
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_InvalidHighTagNumberForm2)
{
// High tag number form is not allowed (legal 1 byte tag).
//
// ReadTagAndGetValue's check to prohibit the high tag number form has no
// effect on whether this test passes or fails, because ReadTagAndGetValue
// will interpret the second byte (31) as a length, and the input doesn't
// have 31 bytes following it. This test is here to guard against the case
// where somebody actually implements high tag number form parsing, to remind
// that person that they need to add tests here, including in particular
// tests for overly-long encodings.
static const uint8_t DER[] = {
0x1F, // high tag number form indicator
31, // tag 31
0 // length zero
};
Input buf(DER);
Reader input(buf);
uint8_t tag;
Input value;
ASSERT_EQ(Result::ERROR_BAD_DER,
ReadTagAndGetValue(input, tag, value));
}
TEST_F(pkixder_input_tests, ReadTagAndGetValue_Input_InvalidHighTagNumberForm3)
{
// High tag number form is not allowed (2 byte legal tag)
//
// ReadTagAndGetValue's check to prohibit the high tag number form has no
// effect on whether this test passes or fails, because ReadTagAndGetValue
// will interpret the second byte as a length, and the input doesn't have
// that many bytes following it. This test is here to guard against the case
// where somebody actually implements high tag number form parsing, to remind
// that person that they need to add tests here, including in particular
// tests for overly-long encodings.
static const uint8_t DER[] = {
0x1F, // high tag number form indicator
0x80 | 0x01, 0x00, // tag 0x100 (256)
0 // length zero
};
Input buf(DER);
Reader input(buf);
uint8_t tag;
Input value;
ASSERT_EQ(Result::ERROR_BAD_DER,
ReadTagAndGetValue(input, tag, value));
}
Jul 31, 2014
Jul 31, 2014
622
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Reader_ValidEmpty)
Jul 1, 2014
Jul 1, 2014
623
{
Jul 31, 2014
Jul 31, 2014
624
625
626
Input buf(DER_SEQUENCE_EMPTY);
Reader input(buf);
Reader value;
Jul 1, 2014
Jul 1, 2014
627
628
629
630
631
ASSERT_EQ(Success, ExpectTagAndGetValue(input, SEQUENCE, value));
ASSERT_TRUE(value.AtEnd());
ASSERT_TRUE(input.AtEnd());
}
Jul 31, 2014
Jul 31, 2014
632
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Reader_ValidNotEmpty)
Jul 1, 2014
Jul 1, 2014
633
{
Jul 31, 2014
Jul 31, 2014
634
635
636
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
Reader value;
Jul 1, 2014
Jul 1, 2014
637
638
639
640
641
642
ASSERT_EQ(Success, ExpectTagAndGetValue(input, SEQUENCE, value));
ASSERT_TRUE(value.MatchRest(DER_SEQUENCE_NOT_EMPTY_VALUE));
ASSERT_TRUE(input.AtEnd());
}
TEST_F(pkixder_input_tests,
Jul 31, 2014
Jul 31, 2014
643
ExpectTagAndGetValue_Reader_InvalidNotEmptyValueTruncated)
Jul 1, 2014
Jul 1, 2014
644
{
Jul 31, 2014
Jul 31, 2014
645
646
647
Input buf(DER_SEQUENCE_NOT_EMPTY_VALUE_TRUNCATED);
Reader input(buf);
Reader value;
Jul 18, 2014
Jul 18, 2014
648
649
ASSERT_EQ(Result::ERROR_BAD_DER,
ExpectTagAndGetValue(input, SEQUENCE, value));
Jul 1, 2014
Jul 1, 2014
650
651
}
Jul 31, 2014
Jul 31, 2014
652
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Reader_InvalidWrongLength)
Jul 1, 2014
Jul 1, 2014
653
{
Jul 31, 2014
Jul 31, 2014
654
655
656
Input buf(DER_TRUNCATED_SEQUENCE_OF_INT8);
Reader input(buf);
Reader value;
Jul 18, 2014
Jul 18, 2014
657
658
ASSERT_EQ(Result::ERROR_BAD_DER,
ExpectTagAndGetValue(input, SEQUENCE, value));
Jul 1, 2014
Jul 1, 2014
659
660
}
Sep 3, 2014
Sep 3, 2014
661
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Reader_InvalidWrongTag)
Jul 1, 2014
Jul 1, 2014
662
{
Jul 31, 2014
Jul 31, 2014
663
664
665
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
Reader value;
Jul 18, 2014
Jul 18, 2014
666
667
ASSERT_EQ(Result::ERROR_BAD_DER,
ExpectTagAndGetValue(input, INTEGER, value));
Jul 1, 2014
Jul 1, 2014
668
669
}
Jul 31, 2014
Jul 31, 2014
670
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Input_ValidEmpty)
Jul 1, 2014
Jul 1, 2014
671
{
Jul 31, 2014
Jul 31, 2014
672
673
674
Input buf(DER_SEQUENCE_EMPTY);
Reader input(buf);
Input value;
Jul 1, 2014
Jul 1, 2014
675
ASSERT_EQ(Success, ExpectTagAndGetValue(input, SEQUENCE, value));
Jul 19, 2014
Jul 19, 2014
676
ASSERT_EQ(0u, value.GetLength());
Jul 1, 2014
Jul 1, 2014
677
678
679
ASSERT_TRUE(input.AtEnd());
}
Jul 31, 2014
Jul 31, 2014
680
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Input_ValidNotEmpty)
Jul 1, 2014
Jul 1, 2014
681
{
Jul 31, 2014
Jul 31, 2014
682
683
684
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
Input value;
Jul 1, 2014
Jul 1, 2014
685
ASSERT_EQ(Success, ExpectTagAndGetValue(input, SEQUENCE, value));
Jul 31, 2014
Jul 31, 2014
686
687
Input expected(DER_SEQUENCE_NOT_EMPTY_VALUE);
ASSERT_TRUE(InputsAreEqual(expected, value));
Jul 1, 2014
Jul 1, 2014
688
689
690
691
ASSERT_TRUE(input.AtEnd());
}
TEST_F(pkixder_input_tests,
Jul 31, 2014
Jul 31, 2014
692
ExpectTagAndGetValue_Input_InvalidNotEmptyValueTruncated)
Jul 1, 2014
Jul 1, 2014
693
{
Jul 31, 2014
Jul 31, 2014
694
695
696
Input buf(DER_SEQUENCE_NOT_EMPTY_VALUE_TRUNCATED);
Reader input(buf);
Input value;
Jul 18, 2014
Jul 18, 2014
697
698
ASSERT_EQ(Result::ERROR_BAD_DER,
ExpectTagAndGetValue(input, SEQUENCE, value));
Jul 1, 2014
Jul 1, 2014
699
700
}
Jul 31, 2014
Jul 31, 2014
701
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Input_InvalidWrongLength)
Jul 1, 2014
Jul 1, 2014
702
{
Jul 31, 2014
Jul 31, 2014
703
704
705
Input buf(DER_TRUNCATED_SEQUENCE_OF_INT8);
Reader input(buf);
Input value;
Jul 18, 2014
Jul 18, 2014
706
707
ASSERT_EQ(Result::ERROR_BAD_DER,
ExpectTagAndGetValue(input, SEQUENCE, value));
Jul 1, 2014
Jul 1, 2014
708
709
}
Sep 3, 2014
Sep 3, 2014
710
TEST_F(pkixder_input_tests, ExpectTagAndGetValue_Input_InvalidWrongTag)
Jul 1, 2014
Jul 1, 2014
711
{
Jul 31, 2014
Jul 31, 2014
712
713
714
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
Input value;
Jul 18, 2014
Jul 18, 2014
715
716
ASSERT_EQ(Result::ERROR_BAD_DER,
ExpectTagAndGetValue(input, INTEGER, value));
Jul 1, 2014
Jul 1, 2014
717
718
}
Sep 3, 2014
Sep 3, 2014
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
TEST_F(pkixder_input_tests, ExpectTagAndEmptyValue_ValidEmpty)
{
Input buf(DER_SEQUENCE_EMPTY);
Reader input(buf);
ASSERT_EQ(Success, ExpectTagAndEmptyValue(input, SEQUENCE));
ASSERT_TRUE(input.AtEnd());
}
TEST_F(pkixder_input_tests, ExpectTagAndEmptyValue_InValidNotEmpty)
{
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndEmptyValue(input, SEQUENCE));
}
TEST_F(pkixder_input_tests,
ExpectTagAndEmptyValue_Input_InvalidNotEmptyValueTruncated)
{
Input buf(DER_SEQUENCE_NOT_EMPTY_VALUE_TRUNCATED);
Reader input(buf);
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndEmptyValue(input, SEQUENCE));
}
TEST_F(pkixder_input_tests, ExpectTagAndEmptyValue_InvalidWrongLength)
{
Input buf(DER_TRUNCATED_SEQUENCE_OF_INT8);
Reader input(buf);
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndEmptyValue(input, SEQUENCE));
}
TEST_F(pkixder_input_tests, ExpectTagAndEmptyValue_InvalidWrongTag)
{
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndEmptyValue(input, INTEGER));
}
Jul 31, 2014
Jul 31, 2014
756
TEST_F(pkixder_input_tests, ExpectTagAndGetTLV_Input_ValidEmpty)
Jul 1, 2014
Jul 1, 2014
757
{
Jul 31, 2014
Jul 31, 2014
758
759
760
Input buf(DER_SEQUENCE_EMPTY);
Reader input(buf);
Input tlv;
Jul 1, 2014
Jul 1, 2014
761
ASSERT_EQ(Success, ExpectTagAndGetTLV(input, SEQUENCE, tlv));
Jul 31, 2014
Jul 31, 2014
762
763
Input expected(DER_SEQUENCE_EMPTY);
ASSERT_TRUE(InputsAreEqual(expected, tlv));
Jul 1, 2014
Jul 1, 2014
764
765
766
ASSERT_TRUE(input.AtEnd());
}
Jul 31, 2014
Jul 31, 2014
767
TEST_F(pkixder_input_tests, ExpectTagAndGetTLV_Input_ValidNotEmpty)
Jul 1, 2014
Jul 1, 2014
768
{
Jul 31, 2014
Jul 31, 2014
769
770
771
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
Input tlv;
Jul 1, 2014
Jul 1, 2014
772
ASSERT_EQ(Success, ExpectTagAndGetTLV(input, SEQUENCE, tlv));
Jul 31, 2014
Jul 31, 2014
773
774
Input expected(DER_SEQUENCE_NOT_EMPTY);
ASSERT_TRUE(InputsAreEqual(expected, tlv));
Jul 1, 2014
Jul 1, 2014
775
776
777
778
ASSERT_TRUE(input.AtEnd());
}
TEST_F(pkixder_input_tests,
Jul 31, 2014
Jul 31, 2014
779
ExpectTagAndGetTLV_Input_InvalidNotEmptyValueTruncated)
Jul 1, 2014
Jul 1, 2014
780
{
Jul 31, 2014
Jul 31, 2014
781
782
783
Input buf(DER_SEQUENCE_NOT_EMPTY_VALUE_TRUNCATED);
Reader input(buf);
Input tlv;
Jul 18, 2014
Jul 18, 2014
784
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndGetTLV(input, SEQUENCE, tlv));
Jul 1, 2014
Jul 1, 2014
785
786
}
Jul 31, 2014
Jul 31, 2014
787
TEST_F(pkixder_input_tests, ExpectTagAndGetTLV_Input_InvalidWrongLength)
Jul 1, 2014
Jul 1, 2014
788
{
Jul 31, 2014
Jul 31, 2014
789
790
791
Input buf(DER_TRUNCATED_SEQUENCE_OF_INT8);
Reader input(buf);
Input tlv;
Jul 18, 2014
Jul 18, 2014
792
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndGetTLV(input, SEQUENCE, tlv));
Jul 1, 2014
Jul 1, 2014
793
794
}
Jul 31, 2014
Jul 31, 2014
795
TEST_F(pkixder_input_tests, ExpectTagAndGetTLV_Input_InvalidWrongTag)
Jul 1, 2014
Jul 1, 2014
796
{
Jul 31, 2014
Jul 31, 2014
797
798
799
Input buf(DER_SEQUENCE_NOT_EMPTY);
Reader input(buf);
Input tlv;
Jul 18, 2014
Jul 18, 2014
800
ASSERT_EQ(Result::ERROR_BAD_DER, ExpectTagAndGetTLV(input, INTEGER, tlv));
Jul 1, 2014
Jul 1, 2014
801
802
}
803
804
TEST_F(pkixder_input_tests, EndAtEnd)
{
Jul 31, 2014
Jul 31, 2014
805
806
Input buf(DER_INT16);
Reader input(buf);
807
808
809
810
811
812
ASSERT_EQ(Success, input.Skip(4));
ASSERT_EQ(Success, End(input));
}
TEST_F(pkixder_input_tests, EndBeforeEnd)
{
Jul 31, 2014
Jul 31, 2014
813
814
Input buf(DER_INT16);
Reader input(buf);
815
ASSERT_EQ(Success, input.Skip(2));
Jul 18, 2014
Jul 18, 2014
816
ASSERT_EQ(Result::ERROR_BAD_DER, End(input));
817
818
819
820
}
TEST_F(pkixder_input_tests, EndAtBeginning)
{
Jul 31, 2014
Jul 31, 2014
821
822
Input buf(DER_INT16);
Reader input(buf);
Jul 18, 2014
Jul 18, 2014
823
ASSERT_EQ(Result::ERROR_BAD_DER, End(input));
824
825
826
827
}
// TODO: Need tests for Nested too?
Jul 31, 2014
Jul 31, 2014
828
Result NestedOfHelper(Reader& input, std::vector<uint8_t>& readValues)
829
830
{
uint8_t value = 0;
Jul 15, 2014
Jul 15, 2014
831
832
833
834
Result rv = input.Read(value);
EXPECT_EQ(Success, rv);
if (rv != Success) {
return rv;
835
836
837
838
839
840
841
}
readValues.push_back(value);
return Success;
}
TEST_F(pkixder_input_tests, NestedOf)
{
Jul 31, 2014
Jul 31, 2014
842
843
Input buf(DER_SEQUENCE_OF_INT8);
Reader input(buf);
844
845
846
std::vector<uint8_t> readValues;
ASSERT_EQ(Success,
Jan 21, 2015
Jan 21, 2015
847
848
849
850
NestedOf(input, SEQUENCE, INTEGER, EmptyAllowed::No,
[&readValues](Reader& r) {
return NestedOfHelper(r, readValues);
}));
Feb 7, 2015
Feb 7, 2015
851
ASSERT_EQ(3u, readValues.size());
852
853
854
855
856
857
858
859
ASSERT_EQ(0x01, readValues[0]);
ASSERT_EQ(0x02, readValues[1]);
ASSERT_EQ(0x03, readValues[2]);
ASSERT_EQ(Success, End(input));
}
TEST_F(pkixder_input_tests, NestedOfWithTruncatedData)
{
Jul 31, 2014
Jul 31, 2014
860
861
Input buf(DER_TRUNCATED_SEQUENCE_OF_INT8);
Reader input(buf);
862
863
std::vector<uint8_t> readValues;
Jul 18, 2014
Jul 18, 2014
864
865
ASSERT_EQ(Result::ERROR_BAD_DER,
NestedOf(input, SEQUENCE, INTEGER, EmptyAllowed::No,
Jan 21, 2015
Jan 21, 2015
866
867
868
[&readValues](Reader& r) {
return NestedOfHelper(r, readValues);
}));
Feb 7, 2015
Feb 7, 2015
869
ASSERT_EQ(0u, readValues.size());
May 14, 2014
May 14, 2014
871
May 30, 2014
May 30, 2014
872
TEST_F(pkixder_input_tests, MatchRestAtEnd)
May 14, 2014
May 14, 2014
873
874
{
static const uint8_t der[1] = { };
Jul 31, 2014
Jul 31, 2014
875
Input buf;
Jul 19, 2014
Jul 19, 2014
876
ASSERT_EQ(Success, buf.Init(der, 0));
Jul 31, 2014
Jul 31, 2014
877
Reader input(buf);
May 14, 2014
May 14, 2014
878
879
ASSERT_TRUE(input.AtEnd());
static const uint8_t toMatch[] = { 1 };
May 30, 2014
May 30, 2014
880
ASSERT_FALSE(input.MatchRest(toMatch));
May 14, 2014
May 14, 2014
881
882
}
May 30, 2014
May 30, 2014
883
TEST_F(pkixder_input_tests, MatchRest1Match)
May 14, 2014
May 14, 2014
884
885
{
static const uint8_t der[] = { 1 };
Jul 31, 2014
Jul 31, 2014
886
887
Input buf(der);
Reader input(buf);
May 14, 2014
May 14, 2014
888
ASSERT_FALSE(input.AtEnd());
May 30, 2014
May 30, 2014
889
ASSERT_TRUE(input.MatchRest(der));
May 14, 2014
May 14, 2014
890
891
}
May 30, 2014
May 30, 2014
892
TEST_F(pkixder_input_tests, MatchRest1Mismatch)
May 14, 2014
May 14, 2014
893
894
{
static const uint8_t der[] = { 1 };
Jul 31, 2014
Jul 31, 2014
895
896
Input buf(der);
Reader input(buf);
May 14, 2014
May 14, 2014
897
static const uint8_t toMatch[] = { 2 };
May 30, 2014
May 30, 2014
898
ASSERT_FALSE(input.MatchRest(toMatch));
May 14, 2014
May 14, 2014
899
900
901
ASSERT_FALSE(input.AtEnd());
}
May 30, 2014
May 30, 2014
902
TEST_F(pkixder_input_tests, MatchRest2WithTrailingByte)
May 14, 2014
May 14, 2014
903
904
{
static const uint8_t der[] = { 1, 2, 3 };
Jul 31, 2014
Jul 31, 2014
905
906
Input buf(der);
Reader input(buf);
May 14, 2014
May 14, 2014
907
static const uint8_t toMatch[] = { 1, 2 };
May 30, 2014
May 30, 2014
908
ASSERT_FALSE(input.MatchRest(toMatch));
May 14, 2014
May 14, 2014
909
910
}
May 30, 2014
May 30, 2014
911
TEST_F(pkixder_input_tests, MatchRest2Mismatch)
May 14, 2014
May 14, 2014
912
913
{
static const uint8_t der[] = { 1, 2, 3 };
Jul 31, 2014
Jul 31, 2014
914
915
Input buf(der);
Reader input(buf);
May 14, 2014
May 14, 2014
916
static const uint8_t toMatchMismatch[] = { 1, 3 };
May 30, 2014
May 30, 2014
917
918
ASSERT_FALSE(input.MatchRest(toMatchMismatch));
ASSERT_TRUE(input.MatchRest(der));
May 14, 2014
May 14, 2014
919
920
}
Mar 16, 2016
Mar 16, 2016
921
} // namespace