File: RsaPkcs7Tests.c

package info (click to toggle)
edk2 2025.11-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 338,436 kB
  • sloc: ansic: 2,166,377; asm: 270,725; perl: 235,301; python: 149,900; sh: 34,744; cpp: 23,311; makefile: 3,334; pascal: 1,602; xml: 806; lisp: 35; ruby: 16; sed: 6; tcl: 4
file content (670 lines) | stat: -rw-r--r-- 34,310 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
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
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
/** @file
  Application for RSA Key Retrieving (from PEM and X509) & Signature Validation.

  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
  Copyright (c) Microsoft Corporation.
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "TestBaseCryptLib.h"

//
// Password-protected PEM Key data for RSA Private Key Retrieving (encryption key is "client").
// (Generated by OpenSSL utility).
// $ openssl genrsa -aes256 -out TestKeyPem -passout pass:client 1024
// password should match PemPass in this file
// $ xxd --include TestKeyPem
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  TestKeyPem[] = {
  0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52,
  0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b,
  0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x50, 0x72, 0x6f, 0x63,
  0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x34, 0x2c, 0x45, 0x4e, 0x43,
  0x52, 0x59, 0x50, 0x54, 0x45, 0x44, 0x0a, 0x44, 0x45, 0x4b, 0x2d, 0x49,
  0x6e, 0x66, 0x6f, 0x3a, 0x20, 0x41, 0x45, 0x53, 0x2d, 0x32, 0x35, 0x36,
  0x2d, 0x43, 0x42, 0x43, 0x2c, 0x34, 0x42, 0x44, 0x31, 0x30, 0x45, 0x39,
  0x35, 0x42, 0x38, 0x33, 0x39, 0x42, 0x30, 0x44, 0x33, 0x35, 0x36, 0x31,
  0x38, 0x41, 0x44, 0x36, 0x45, 0x46, 0x44, 0x36, 0x34, 0x32, 0x34, 0x44,
  0x36, 0x0a, 0x0a, 0x42, 0x50, 0x39, 0x49, 0x32, 0x42, 0x30, 0x6c, 0x50,
  0x7a, 0x4c, 0x50, 0x50, 0x38, 0x2f, 0x4b, 0x71, 0x35, 0x34, 0x2f, 0x56,
  0x68, 0x75, 0x4b, 0x35, 0x5a, 0x63, 0x72, 0x32, 0x55, 0x6c, 0x32, 0x75,
  0x43, 0x57, 0x4a, 0x62, 0x59, 0x33, 0x50, 0x77, 0x39, 0x6e, 0x4c, 0x6d,
  0x45, 0x41, 0x6a, 0x47, 0x74, 0x4a, 0x68, 0x57, 0x46, 0x66, 0x50, 0x47,
  0x38, 0x62, 0x6d, 0x41, 0x6f, 0x73, 0x56, 0x0a, 0x47, 0x76, 0x42, 0x30,
  0x6d, 0x2b, 0x7a, 0x5a, 0x43, 0x2b, 0x30, 0x6c, 0x57, 0x6c, 0x72, 0x59,
  0x7a, 0x51, 0x4b, 0x6a, 0x57, 0x79, 0x44, 0x6e, 0x4d, 0x58, 0x72, 0x33,
  0x51, 0x39, 0x69, 0x57, 0x32, 0x4b, 0x33, 0x68, 0x4d, 0x6b, 0x71, 0x51,
  0x4c, 0x31, 0x68, 0x65, 0x71, 0x52, 0x66, 0x66, 0x74, 0x47, 0x57, 0x51,
  0x5a, 0x36, 0x78, 0x4e, 0x6a, 0x72, 0x30, 0x7a, 0x6f, 0x51, 0x59, 0x73,
  0x0a, 0x34, 0x76, 0x69, 0x55, 0x46, 0x72, 0x7a, 0x2b, 0x52, 0x76, 0x4b,
  0x43, 0x2f, 0x33, 0x69, 0x71, 0x57, 0x59, 0x78, 0x55, 0x35, 0x4c, 0x6a,
  0x45, 0x74, 0x63, 0x5a, 0x4f, 0x2b, 0x53, 0x6d, 0x39, 0x42, 0x4c, 0x62,
  0x66, 0x58, 0x49, 0x71, 0x56, 0x72, 0x53, 0x6a, 0x54, 0x79, 0x58, 0x49,
  0x39, 0x70, 0x76, 0x78, 0x6f, 0x67, 0x50, 0x39, 0x38, 0x6b, 0x2b, 0x6c,
  0x41, 0x66, 0x37, 0x47, 0x36, 0x0a, 0x75, 0x39, 0x2b, 0x30, 0x31, 0x4d,
  0x47, 0x5a, 0x69, 0x36, 0x6b, 0x53, 0x73, 0x67, 0x48, 0x57, 0x7a, 0x43,
  0x41, 0x49, 0x51, 0x75, 0x38, 0x72, 0x6a, 0x4d, 0x34, 0x65, 0x74, 0x64,
  0x50, 0x62, 0x4a, 0x49, 0x77, 0x34, 0x65, 0x47, 0x6f, 0x32, 0x45, 0x49,
  0x44, 0x45, 0x54, 0x61, 0x52, 0x70, 0x73, 0x76, 0x47, 0x6a, 0x54, 0x6f,
  0x30, 0x51, 0x56, 0x69, 0x79, 0x79, 0x4a, 0x4f, 0x48, 0x32, 0x0a, 0x61,
  0x32, 0x71, 0x69, 0x2f, 0x47, 0x7a, 0x2f, 0x64, 0x48, 0x61, 0x62, 0x68,
  0x4d, 0x4e, 0x35, 0x4e, 0x53, 0x58, 0x56, 0x4d, 0x31, 0x54, 0x2f, 0x6d,
  0x69, 0x6f, 0x74, 0x68, 0x78, 0x59, 0x72, 0x2f, 0x4a, 0x69, 0x37, 0x6d,
  0x4e, 0x45, 0x75, 0x4a, 0x57, 0x38, 0x74, 0x6d, 0x75, 0x55, 0x4b, 0x58,
  0x33, 0x66, 0x63, 0x39, 0x42, 0x39, 0x32, 0x51, 0x6e, 0x54, 0x68, 0x43,
  0x69, 0x49, 0x2f, 0x0a, 0x79, 0x4f, 0x31, 0x32, 0x4c, 0x46, 0x58, 0x38,
  0x74, 0x4b, 0x4a, 0x37, 0x4b, 0x7a, 0x6f, 0x6b, 0x36, 0x44, 0x74, 0x6d,
  0x35, 0x73, 0x41, 0x74, 0x2b, 0x65, 0x4b, 0x76, 0x6f, 0x61, 0x47, 0x62,
  0x75, 0x4a, 0x78, 0x62, 0x52, 0x63, 0x36, 0x63, 0x4d, 0x58, 0x57, 0x46,
  0x36, 0x4d, 0x72, 0x4d, 0x30, 0x53, 0x78, 0x65, 0x4e, 0x6b, 0x5a, 0x77,
  0x5a, 0x36, 0x6c, 0x62, 0x4d, 0x39, 0x63, 0x55, 0x0a, 0x6c, 0x75, 0x34,
  0x4c, 0x56, 0x64, 0x34, 0x73, 0x56, 0x4c, 0x61, 0x76, 0x68, 0x75, 0x32,
  0x58, 0x48, 0x48, 0x53, 0x56, 0x30, 0x32, 0x32, 0x6d, 0x51, 0x72, 0x73,
  0x32, 0x69, 0x68, 0x74, 0x58, 0x44, 0x2b, 0x6c, 0x4d, 0x63, 0x2f, 0x35,
  0x62, 0x54, 0x41, 0x55, 0x6b, 0x4b, 0x4f, 0x42, 0x73, 0x43, 0x69, 0x4f,
  0x4b, 0x42, 0x56, 0x2b, 0x66, 0x70, 0x49, 0x62, 0x2b, 0x6d, 0x44, 0x33,
  0x58, 0x0a, 0x39, 0x37, 0x66, 0x36, 0x54, 0x66, 0x68, 0x37, 0x4f, 0x4f,
  0x6a, 0x74, 0x44, 0x79, 0x31, 0x6f, 0x52, 0x36, 0x70, 0x68, 0x48, 0x47,
  0x6e, 0x73, 0x43, 0x78, 0x72, 0x53, 0x72, 0x64, 0x48, 0x73, 0x2f, 0x34,
  0x33, 0x72, 0x61, 0x65, 0x42, 0x78, 0x59, 0x45, 0x41, 0x42, 0x4e, 0x59,
  0x68, 0x54, 0x47, 0x57, 0x49, 0x4d, 0x4a, 0x6b, 0x50, 0x63, 0x54, 0x53,
  0x73, 0x76, 0x77, 0x46, 0x37, 0x6d, 0x0a, 0x33, 0x6c, 0x38, 0x6b, 0x44,
  0x50, 0x48, 0x43, 0x4e, 0x68, 0x6e, 0x6e, 0x42, 0x69, 0x7a, 0x36, 0x2f,
  0x43, 0x38, 0x56, 0x31, 0x37, 0x78, 0x57, 0x34, 0x50, 0x2b, 0x79, 0x71,
  0x4a, 0x78, 0x58, 0x63, 0x49, 0x53, 0x72, 0x7a, 0x57, 0x53, 0x55, 0x72,
  0x34, 0x74, 0x71, 0x6b, 0x55, 0x58, 0x43, 0x57, 0x4c, 0x43, 0x66, 0x76,
  0x57, 0x7a, 0x4e, 0x65, 0x5a, 0x34, 0x4f, 0x34, 0x34, 0x54, 0x65, 0x0a,
  0x74, 0x31, 0x59, 0x65, 0x36, 0x77, 0x2b, 0x71, 0x4f, 0x55, 0x38, 0x50,
  0x42, 0x68, 0x72, 0x65, 0x4d, 0x38, 0x75, 0x32, 0x32, 0x42, 0x4f, 0x31,
  0x65, 0x2b, 0x44, 0x7a, 0x63, 0x74, 0x6c, 0x67, 0x43, 0x43, 0x6c, 0x38,
  0x79, 0x69, 0x37, 0x6f, 0x43, 0x56, 0x74, 0x66, 0x75, 0x59, 0x2f, 0x4c,
  0x72, 0x42, 0x61, 0x31, 0x74, 0x69, 0x43, 0x41, 0x37, 0x6c, 0x34, 0x75,
  0x58, 0x6b, 0x73, 0x4c, 0x0a, 0x2b, 0x31, 0x51, 0x79, 0x69, 0x4b, 0x31,
  0x6e, 0x43, 0x4f, 0x76, 0x74, 0x30, 0x46, 0x7a, 0x71, 0x62, 0x71, 0x78,
  0x54, 0x37, 0x53, 0x35, 0x4c, 0x56, 0x33, 0x5a, 0x33, 0x74, 0x34, 0x4a,
  0x46, 0x4f, 0x50, 0x62, 0x67, 0x63, 0x7a, 0x4e, 0x6b, 0x58, 0x55, 0x2b,
  0x4f, 0x74, 0x50, 0x6b, 0x6e, 0x45, 0x45, 0x76, 0x67, 0x57, 0x64, 0x76,
  0x31, 0x4f, 0x30, 0x6d, 0x52, 0x4a, 0x50, 0x31, 0x4e, 0x0a, 0x71, 0x43,
  0x32, 0x33, 0x4a, 0x6a, 0x36, 0x38, 0x4c, 0x30, 0x46, 0x63, 0x46, 0x4c,
  0x56, 0x56, 0x59, 0x76, 0x61, 0x44, 0x53, 0x76, 0x54, 0x45, 0x64, 0x50,
  0x54, 0x34, 0x62, 0x2f, 0x7a, 0x66, 0x64, 0x36, 0x51, 0x52, 0x6b, 0x38,
  0x70, 0x4d, 0x36, 0x77, 0x66, 0x61, 0x32, 0x50, 0x63, 0x75, 0x57, 0x65,
  0x79, 0x38, 0x48, 0x38, 0x76, 0x4e, 0x4b, 0x67, 0x2f, 0x65, 0x76, 0x34,
  0x77, 0x37, 0x0a, 0x6b, 0x6f, 0x6f, 0x4e, 0x59, 0x64, 0x77, 0x59, 0x69,
  0x6c, 0x37, 0x41, 0x50, 0x76, 0x42, 0x50, 0x4d, 0x63, 0x6c, 0x51, 0x76,
  0x63, 0x64, 0x71, 0x7a, 0x52, 0x7a, 0x4a, 0x6e, 0x4a, 0x74, 0x37, 0x70,
  0x35, 0x7a, 0x69, 0x2b, 0x2b, 0x4c, 0x43, 0x59, 0x55, 0x4d, 0x3d, 0x0a,
  0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53, 0x41,
  0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59,
  0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a
};

//
// Password for private key retrieving from encrypted PEM ("TestKeyPem").
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8  *PemPass = "client";

//
// Test CA X509 Certificate for X509 Verification Routine (Generated by OpenSSL utility).
// $ openssl req -x509 -days 10000 -key TestKeyPem -out TestCACert -outform DER -subj "/C=US/ST=WA/L=Seattle/O=Tianocore/OU=EDK2/CN=UEFI"
// use password from PemPass variable in this file
// $ xxd --include TestCACert
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  TestCACert[] = {
  0x30, 0x82, 0x02, 0x98, 0x30, 0x82, 0x02, 0x01, 0xa0, 0x03, 0x02, 0x01,
  0x02, 0x02, 0x14, 0x39, 0xde, 0x9e, 0xce, 0x3a, 0x36, 0x11, 0x38, 0x6f,
  0x64, 0xb4, 0x69, 0xa7, 0x93, 0xdd, 0xff, 0xbd, 0x3e, 0x75, 0x6a, 0x30,
  0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
  0x05, 0x00, 0x30, 0x5e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
  0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
  0x04, 0x08, 0x0c, 0x02, 0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03,
  0x55, 0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65,
  0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x09, 0x54,
  0x69, 0x61, 0x6e, 0x6f, 0x63, 0x6f, 0x72, 0x65, 0x31, 0x0d, 0x30, 0x0b,
  0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x45, 0x44, 0x4b, 0x32, 0x31,
  0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x55, 0x45,
  0x46, 0x49, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x36, 0x32, 0x39,
  0x32, 0x32, 0x34, 0x37, 0x33, 0x36, 0x5a, 0x17, 0x0d, 0x34, 0x37, 0x31,
  0x31, 0x31, 0x35, 0x32, 0x32, 0x34, 0x37, 0x33, 0x36, 0x5a, 0x30, 0x5e,
  0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55,
  0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02,
  0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c,
  0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x31, 0x12, 0x30, 0x10,
  0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x09, 0x54, 0x69, 0x61, 0x6e, 0x6f,
  0x63, 0x6f, 0x72, 0x65, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04,
  0x0b, 0x0c, 0x04, 0x45, 0x44, 0x4b, 0x32, 0x31, 0x0d, 0x30, 0x0b, 0x06,
  0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x55, 0x45, 0x46, 0x49, 0x30, 0x81,
  0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
  0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02,
  0x81, 0x81, 0x00, 0x9f, 0xef, 0x1b, 0x46, 0x45, 0x55, 0x33, 0x4b, 0xee,
  0x95, 0x14, 0xd3, 0x5a, 0x3e, 0xd9, 0x29, 0xfb, 0xd9, 0x29, 0x4e, 0x8b,
  0xf1, 0xf5, 0x68, 0x7c, 0x58, 0x86, 0x0c, 0xda, 0xd7, 0xe0, 0xd2, 0x9a,
  0xe8, 0x37, 0x16, 0x4d, 0x54, 0x92, 0x18, 0x20, 0x4c, 0x09, 0xa1, 0xcf,
  0xe1, 0xaa, 0x7a, 0x5a, 0x64, 0x7e, 0x5c, 0xeb, 0x4e, 0x15, 0x8e, 0x40,
  0xd1, 0xcb, 0x7d, 0x01, 0x71, 0x15, 0x11, 0xd2, 0xc7, 0xdb, 0x6b, 0x00,
  0xdc, 0x02, 0xcb, 0x5a, 0x6d, 0x2b, 0x2a, 0x75, 0xb6, 0x3f, 0xec, 0xc1,
  0x9d, 0xbf, 0xda, 0xe5, 0x3a, 0x77, 0x4b, 0x21, 0x1c, 0x99, 0x42, 0x84,
  0x5e, 0x27, 0x53, 0x9b, 0xe6, 0xc1, 0xa1, 0x95, 0x58, 0xba, 0xbe, 0x62,
  0x58, 0xd5, 0x09, 0xa8, 0xe6, 0xb6, 0x1b, 0xb1, 0x18, 0x28, 0x13, 0xc7,
  0x89, 0x1c, 0x68, 0xce, 0x15, 0xaf, 0x2e, 0x68, 0xac, 0x1c, 0xf7, 0x02,
  0x03, 0x01, 0x00, 0x01, 0xa3, 0x53, 0x30, 0x51, 0x30, 0x1d, 0x06, 0x03,
  0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x50, 0xe5, 0x05, 0xa3, 0x6e,
  0x8f, 0x00, 0xf7, 0x93, 0x30, 0xe5, 0x25, 0x20, 0xdc, 0x8a, 0xc3, 0xad,
  0x14, 0x6d, 0x90, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18,
  0x30, 0x16, 0x80, 0x14, 0x50, 0xe5, 0x05, 0xa3, 0x6e, 0x8f, 0x00, 0xf7,
  0x93, 0x30, 0xe5, 0x25, 0x20, 0xdc, 0x8a, 0xc3, 0xad, 0x14, 0x6d, 0x90,
  0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05,
  0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
  0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00,
  0x8e, 0xe4, 0x27, 0x42, 0x16, 0x6e, 0xbd, 0x28, 0x47, 0x09, 0x99, 0xc1,
  0x55, 0x02, 0x82, 0x1a, 0xe1, 0xd0, 0xf3, 0xef, 0x4d, 0xaf, 0x30, 0x9a,
  0x29, 0x4b, 0x74, 0x03, 0x6a, 0x95, 0x28, 0xf1, 0xbe, 0x62, 0x68, 0x9f,
  0x82, 0x59, 0x7a, 0x49, 0x91, 0xb6, 0xaf, 0x6b, 0x23, 0x30, 0xb4, 0xf4,
  0xdd, 0xfa, 0x30, 0x3f, 0xb6, 0xed, 0x74, 0x3f, 0x91, 0xe8, 0xd7, 0x84,
  0x1a, 0xf3, 0xc6, 0x3d, 0xd8, 0x59, 0x8d, 0x68, 0x6e, 0xb3, 0x66, 0x9e,
  0xe8, 0xeb, 0x1a, 0x8b, 0x1e, 0x92, 0x71, 0x73, 0x8c, 0x4f, 0x63, 0xce,
  0x71, 0x7b, 0x97, 0x3b, 0x59, 0xd2, 0x9b, 0xe4, 0xd0, 0xef, 0x31, 0x9f,
  0x0d, 0x61, 0x27, 0x97, 0x9d, 0xe8, 0xe0, 0xcd, 0x8d, 0xc1, 0x4d, 0xad,
  0xf7, 0x3a, 0x8d, 0xb8, 0x86, 0x8c, 0x23, 0x1d, 0x4c, 0x02, 0x5c, 0x53,
  0x46, 0x84, 0xb2, 0x97, 0x0c, 0xd3, 0x35, 0x6b
};

//
// X509 Cert Data for RSA Public Key Retrieving and X509 Verification (Generated by OpenSSL utility).
// $ openssl req -new -key TestKeyPem -out TestCertCsr -subj "/C=US/ST=WA/L=Seattle/O=Tianocore/OU=EDK2CHILD/CN=UEFI"
// $ openssl x509 -days 10000 -CA TestCACert.pem -CAkey TestKeyPem -req -out TestCert -set_serial 3432 --outform DER -in TestCertCsr
// password should be in the PemPass variable
// $ xxd --include TestCert
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  TestCert[] = {
  0x30, 0x82, 0x02, 0x31, 0x30, 0x82, 0x01, 0x9a, 0x02, 0x02, 0x0d, 0x68,
  0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
  0x0b, 0x05, 0x00, 0x30, 0x5e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
  0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
  0x55, 0x04, 0x08, 0x0c, 0x02, 0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06,
  0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c,
  0x65, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x09,
  0x54, 0x69, 0x61, 0x6e, 0x6f, 0x63, 0x6f, 0x72, 0x65, 0x31, 0x0d, 0x30,
  0x0b, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x45, 0x44, 0x4b, 0x32,
  0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x55,
  0x45, 0x46, 0x49, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x36, 0x32,
  0x39, 0x32, 0x33, 0x31, 0x35, 0x33, 0x36, 0x5a, 0x17, 0x0d, 0x34, 0x37,
  0x31, 0x31, 0x31, 0x35, 0x32, 0x33, 0x31, 0x35, 0x33, 0x36, 0x5a, 0x30,
  0x63, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
  0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c,
  0x02, 0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07,
  0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x31, 0x12, 0x30,
  0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x09, 0x54, 0x69, 0x61, 0x6e,
  0x6f, 0x63, 0x6f, 0x72, 0x65, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55,
  0x04, 0x0b, 0x0c, 0x09, 0x45, 0x44, 0x4b, 0x32, 0x43, 0x48, 0x49, 0x4c,
  0x44, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04,
  0x55, 0x45, 0x46, 0x49, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a,
  0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81,
  0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0x9f, 0xef, 0x1b,
  0x46, 0x45, 0x55, 0x33, 0x4b, 0xee, 0x95, 0x14, 0xd3, 0x5a, 0x3e, 0xd9,
  0x29, 0xfb, 0xd9, 0x29, 0x4e, 0x8b, 0xf1, 0xf5, 0x68, 0x7c, 0x58, 0x86,
  0x0c, 0xda, 0xd7, 0xe0, 0xd2, 0x9a, 0xe8, 0x37, 0x16, 0x4d, 0x54, 0x92,
  0x18, 0x20, 0x4c, 0x09, 0xa1, 0xcf, 0xe1, 0xaa, 0x7a, 0x5a, 0x64, 0x7e,
  0x5c, 0xeb, 0x4e, 0x15, 0x8e, 0x40, 0xd1, 0xcb, 0x7d, 0x01, 0x71, 0x15,
  0x11, 0xd2, 0xc7, 0xdb, 0x6b, 0x00, 0xdc, 0x02, 0xcb, 0x5a, 0x6d, 0x2b,
  0x2a, 0x75, 0xb6, 0x3f, 0xec, 0xc1, 0x9d, 0xbf, 0xda, 0xe5, 0x3a, 0x77,
  0x4b, 0x21, 0x1c, 0x99, 0x42, 0x84, 0x5e, 0x27, 0x53, 0x9b, 0xe6, 0xc1,
  0xa1, 0x95, 0x58, 0xba, 0xbe, 0x62, 0x58, 0xd5, 0x09, 0xa8, 0xe6, 0xb6,
  0x1b, 0xb1, 0x18, 0x28, 0x13, 0xc7, 0x89, 0x1c, 0x68, 0xce, 0x15, 0xaf,
  0x2e, 0x68, 0xac, 0x1c, 0xf7, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d,
  0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05,
  0x00, 0x03, 0x81, 0x81, 0x00, 0x0d, 0xa4, 0x18, 0xa2, 0xb6, 0x09, 0xe1,
  0x77, 0x22, 0x97, 0x46, 0x29, 0x1b, 0xd8, 0x67, 0x0a, 0xc0, 0x91, 0x36,
  0x53, 0xe1, 0x4c, 0x73, 0x1b, 0xc1, 0x90, 0x6d, 0x98, 0x46, 0x7e, 0x65,
  0x71, 0x1c, 0xf0, 0x62, 0x9f, 0x9e, 0x62, 0x0b, 0x8b, 0x73, 0x35, 0x4c,
  0x2d, 0xc3, 0x5d, 0x38, 0x22, 0xfe, 0x43, 0x0f, 0xf2, 0x57, 0x17, 0x75,
  0xa8, 0x76, 0x79, 0xab, 0x4e, 0x33, 0xa5, 0x91, 0xbd, 0x55, 0x5b, 0xc0,
  0x7e, 0xfb, 0x1d, 0xc9, 0xf3, 0x5f, 0x12, 0x6f, 0x7c, 0xdc, 0x24, 0x5a,
  0x84, 0x16, 0x28, 0x5b, 0xf9, 0xcc, 0x8b, 0xfe, 0x11, 0xe6, 0x29, 0xcf,
  0xac, 0x90, 0x66, 0xc0, 0x70, 0x25, 0xf8, 0x71, 0xdb, 0x29, 0xcb, 0x6b,
  0x10, 0xa7, 0xbe, 0x3e, 0x9d, 0x61, 0xd8, 0x04, 0xe0, 0x71, 0x63, 0x83,
  0xa3, 0xca, 0x26, 0x6d, 0x7f, 0xf3, 0xaa, 0x8e, 0xb2, 0x66, 0x98, 0x41,
  0xd6
};

//
// TestCase2: Non self issued CA (partial certificate chains)
//
//
// Password-protected PEM Key data for RSA Private Key Retrieving (encryption key is "non-self-issued").
// (Generated by OpenSSL utility).
// $ openssl genrsa -aes256 -out TestKeyCert2Pem -passout pass:non-self-issued 1024
// password should match TestKeyCert2PemPass in this file
// $ xxd --include TestKeyCert2Pem
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  TestKeyCert2Pem[] = {
  0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52,
  0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b,
  0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a, 0x50, 0x72, 0x6f,
  0x63, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x34, 0x2c, 0x45, 0x4e,
  0x43, 0x52, 0x59, 0x50, 0x54, 0x45, 0x44, 0x0d, 0x0a, 0x44, 0x45, 0x4b,
  0x2d, 0x49, 0x6e, 0x66, 0x6f, 0x3a, 0x20, 0x41, 0x45, 0x53, 0x2d, 0x32,
  0x35, 0x36, 0x2d, 0x43, 0x42, 0x43, 0x2c, 0x39, 0x43, 0x39, 0x38, 0x32,
  0x33, 0x31, 0x38, 0x42, 0x46, 0x37, 0x38, 0x33, 0x38, 0x46, 0x34, 0x32,
  0x45, 0x34, 0x33, 0x31, 0x32, 0x42, 0x42, 0x30, 0x43, 0x39, 0x31, 0x33,
  0x36, 0x43, 0x44, 0x0d, 0x0a, 0x0d, 0x0a, 0x62, 0x32, 0x77, 0x62, 0x64,
  0x75, 0x49, 0x30, 0x76, 0x6b, 0x48, 0x41, 0x6c, 0x45, 0x4a, 0x78, 0x30,
  0x6d, 0x69, 0x64, 0x57, 0x6f, 0x77, 0x6d, 0x71, 0x32, 0x62, 0x64, 0x75,
  0x65, 0x4f, 0x7a, 0x49, 0x71, 0x44, 0x59, 0x46, 0x6e, 0x4d, 0x41, 0x76,
  0x79, 0x58, 0x5a, 0x45, 0x74, 0x45, 0x4c, 0x79, 0x42, 0x41, 0x72, 0x7a,
  0x4c, 0x6c, 0x55, 0x72, 0x54, 0x73, 0x78, 0x41, 0x49, 0x62, 0x73, 0x0d,
  0x0a, 0x47, 0x4d, 0x46, 0x45, 0x47, 0x44, 0x59, 0x46, 0x69, 0x72, 0x7a,
  0x6c, 0x55, 0x77, 0x2f, 0x54, 0x6a, 0x36, 0x43, 0x2f, 0x78, 0x71, 0x45,
  0x67, 0x76, 0x79, 0x2b, 0x6c, 0x47, 0x57, 0x42, 0x46, 0x6b, 0x6c, 0x64,
  0x34, 0x7a, 0x49, 0x2b, 0x68, 0x73, 0x62, 0x77, 0x45, 0x70, 0x53, 0x6d,
  0x36, 0x4a, 0x61, 0x6a, 0x4e, 0x73, 0x69, 0x61, 0x79, 0x35, 0x6f, 0x6f,
  0x37, 0x6b, 0x41, 0x54, 0x68, 0x0d, 0x0a, 0x69, 0x6e, 0x51, 0x54, 0x33,
  0x43, 0x71, 0x76, 0x6e, 0x64, 0x41, 0x44, 0x50, 0x44, 0x5a, 0x72, 0x6f,
  0x38, 0x7a, 0x44, 0x52, 0x64, 0x4d, 0x2b, 0x58, 0x67, 0x65, 0x53, 0x42,
  0x37, 0x69, 0x65, 0x78, 0x6a, 0x55, 0x32, 0x55, 0x69, 0x42, 0x48, 0x4e,
  0x6b, 0x73, 0x76, 0x52, 0x77, 0x49, 0x4f, 0x75, 0x52, 0x50, 0x57, 0x41,
  0x75, 0x56, 0x4c, 0x41, 0x77, 0x6e, 0x6a, 0x57, 0x79, 0x66, 0x51, 0x0d,
  0x0a, 0x6e, 0x39, 0x52, 0x59, 0x4e, 0x78, 0x44, 0x37, 0x63, 0x73, 0x2f,
  0x56, 0x54, 0x38, 0x50, 0x50, 0x55, 0x75, 0x35, 0x69, 0x4d, 0x70, 0x65,
  0x4e, 0x49, 0x6a, 0x44, 0x44, 0x6a, 0x48, 0x5a, 0x2b, 0x78, 0x2f, 0x75,
  0x37, 0x77, 0x6e, 0x75, 0x46, 0x65, 0x76, 0x56, 0x73, 0x62, 0x67, 0x4e,
  0x50, 0x76, 0x4e, 0x78, 0x74, 0x6a, 0x74, 0x6a, 0x33, 0x66, 0x73, 0x6c,
  0x49, 0x75, 0x6d, 0x6c, 0x59, 0x0d, 0x0a, 0x53, 0x36, 0x35, 0x6b, 0x41,
  0x59, 0x6f, 0x36, 0x2f, 0x69, 0x51, 0x69, 0x50, 0x2b, 0x48, 0x52, 0x2b,
  0x59, 0x71, 0x57, 0x55, 0x53, 0x73, 0x4e, 0x7a, 0x55, 0x6f, 0x35, 0x52,
  0x72, 0x49, 0x51, 0x6d, 0x41, 0x52, 0x2f, 0x74, 0x66, 0x66, 0x55, 0x5a,
  0x66, 0x69, 0x4f, 0x37, 0x76, 0x53, 0x67, 0x4b, 0x49, 0x32, 0x47, 0x72,
  0x4e, 0x66, 0x69, 0x5a, 0x55, 0x6c, 0x49, 0x4f, 0x49, 0x7a, 0x39, 0x0d,
  0x0a, 0x67, 0x78, 0x56, 0x58, 0x73, 0x56, 0x69, 0x56, 0x2b, 0x47, 0x6b,
  0x70, 0x52, 0x49, 0x5a, 0x71, 0x7a, 0x46, 0x38, 0x53, 0x76, 0x4d, 0x72,
  0x35, 0x57, 0x4b, 0x63, 0x51, 0x49, 0x4b, 0x79, 0x61, 0x44, 0x52, 0x66,
  0x72, 0x57, 0x54, 0x75, 0x55, 0x4b, 0x4a, 0x67, 0x50, 0x57, 0x77, 0x30,
  0x42, 0x70, 0x45, 0x43, 0x65, 0x62, 0x6c, 0x77, 0x58, 0x79, 0x42, 0x56,
  0x70, 0x4b, 0x55, 0x72, 0x71, 0x0d, 0x0a, 0x77, 0x67, 0x56, 0x6c, 0x55,
  0x37, 0x42, 0x55, 0x55, 0x4b, 0x57, 0x6c, 0x36, 0x52, 0x66, 0x38, 0x32,
  0x42, 0x4d, 0x59, 0x63, 0x75, 0x47, 0x39, 0x2f, 0x36, 0x6a, 0x37, 0x61,
  0x4b, 0x6c, 0x6b, 0x42, 0x67, 0x42, 0x41, 0x33, 0x58, 0x75, 0x32, 0x33,
  0x68, 0x42, 0x64, 0x45, 0x33, 0x63, 0x55, 0x30, 0x47, 0x5a, 0x74, 0x50,
  0x66, 0x78, 0x33, 0x65, 0x4d, 0x64, 0x69, 0x2f, 0x6e, 0x4b, 0x4b, 0x0d,
  0x0a, 0x32, 0x66, 0x74, 0x33, 0x71, 0x79, 0x71, 0x2b, 0x32, 0x47, 0x56,
  0x73, 0x63, 0x74, 0x48, 0x65, 0x30, 0x75, 0x68, 0x37, 0x44, 0x4a, 0x6a,
  0x55, 0x30, 0x78, 0x37, 0x59, 0x48, 0x4f, 0x4f, 0x52, 0x51, 0x6b, 0x4f,
  0x79, 0x77, 0x79, 0x72, 0x6b, 0x34, 0x45, 0x61, 0x44, 0x42, 0x73, 0x72,
  0x71, 0x44, 0x6e, 0x51, 0x7a, 0x76, 0x2b, 0x4c, 0x34, 0x61, 0x70, 0x4a,
  0x71, 0x44, 0x31, 0x39, 0x72, 0x0d, 0x0a, 0x72, 0x64, 0x2b, 0x6e, 0x47,
  0x38, 0x75, 0x4d, 0x4b, 0x2f, 0x32, 0x4c, 0x38, 0x62, 0x73, 0x53, 0x71,
  0x4e, 0x7a, 0x46, 0x52, 0x2f, 0x46, 0x64, 0x51, 0x77, 0x6f, 0x39, 0x32,
  0x5a, 0x33, 0x6b, 0x4c, 0x63, 0x6a, 0x36, 0x61, 0x31, 0x36, 0x50, 0x6b,
  0x2f, 0x78, 0x38, 0x6e, 0x64, 0x70, 0x67, 0x54, 0x58, 0x35, 0x6a, 0x71,
  0x44, 0x41, 0x72, 0x4b, 0x36, 0x79, 0x38, 0x43, 0x65, 0x48, 0x70, 0x0d,
  0x0a, 0x33, 0x75, 0x48, 0x4b, 0x67, 0x77, 0x45, 0x52, 0x30, 0x52, 0x30,
  0x43, 0x34, 0x33, 0x6f, 0x37, 0x61, 0x41, 0x76, 0x6f, 0x79, 0x76, 0x5a,
  0x36, 0x44, 0x4e, 0x75, 0x5a, 0x46, 0x77, 0x65, 0x7a, 0x7a, 0x4c, 0x50,
  0x31, 0x35, 0x33, 0x78, 0x36, 0x35, 0x78, 0x75, 0x4b, 0x47, 0x57, 0x33,
  0x5a, 0x2b, 0x38, 0x68, 0x63, 0x5a, 0x53, 0x42, 0x32, 0x2b, 0x79, 0x76,
  0x33, 0x74, 0x36, 0x56, 0x69, 0x0d, 0x0a, 0x39, 0x45, 0x4b, 0x51, 0x65,
  0x58, 0x65, 0x36, 0x7a, 0x4f, 0x5a, 0x57, 0x36, 0x74, 0x42, 0x6d, 0x4a,
  0x51, 0x2f, 0x51, 0x65, 0x66, 0x51, 0x37, 0x45, 0x34, 0x70, 0x62, 0x78,
  0x65, 0x54, 0x46, 0x43, 0x4e, 0x33, 0x56, 0x4c, 0x51, 0x41, 0x75, 0x31,
  0x4d, 0x47, 0x75, 0x4b, 0x48, 0x70, 0x30, 0x5a, 0x59, 0x39, 0x42, 0x58,
  0x4f, 0x62, 0x77, 0x44, 0x48, 0x53, 0x39, 0x57, 0x51, 0x67, 0x6d, 0x0d,
  0x0a, 0x79, 0x31, 0x66, 0x37, 0x78, 0x70, 0x77, 0x30, 0x34, 0x38, 0x69,
  0x68, 0x67, 0x6c, 0x70, 0x32, 0x6e, 0x44, 0x32, 0x63, 0x72, 0x4b, 0x4b,
  0x57, 0x57, 0x38, 0x68, 0x6d, 0x41, 0x59, 0x6d, 0x6f, 0x51, 0x63, 0x42,
  0x36, 0x4f, 0x73, 0x58, 0x4f, 0x36, 0x45, 0x35, 0x77, 0x73, 0x4b, 0x65,
  0x75, 0x59, 0x41, 0x30, 0x6f, 0x79, 0x65, 0x61, 0x33, 0x6a, 0x6e, 0x55,
  0x4b, 0x71, 0x6a, 0x41, 0x58, 0x0d, 0x0a, 0x49, 0x56, 0x73, 0x43, 0x79,
  0x75, 0x68, 0x50, 0x48, 0x78, 0x65, 0x2b, 0x58, 0x38, 0x6e, 0x67, 0x38,
  0x52, 0x30, 0x72, 0x70, 0x78, 0x41, 0x30, 0x4d, 0x6f, 0x78, 0x71, 0x71,
  0x72, 0x67, 0x71, 0x78, 0x46, 0x32, 0x61, 0x4c, 0x33, 0x39, 0x38, 0x6d,
  0x51, 0x54, 0x46, 0x4f, 0x68, 0x4b, 0x46, 0x62, 0x2b, 0x73, 0x41, 0x69,
  0x6e, 0x7a, 0x34, 0x48, 0x59, 0x52, 0x59, 0x65, 0x4b, 0x72, 0x48, 0x0d,
  0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x52, 0x53,
  0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45,
  0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0d, 0x0a
};
//
// Password for private key retrieving from encrypted PEM ("TestKeyCert2PemPass").
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8  *TestKeyCert2PemPass = "non-self-issued";
//
// X509 Cert Data for RSA Public Key Retrieving and X509 Verification (Generated by OpenSSL utility).
// $ openssl req -new -key TestKeyCert2Pem -out TestCertCsr2 -subj "/C=US/ST=WA/L=Seattle/O=Tianocore/OU=EDK2CHILD/CN=UEFINOSELFISSUED"
// $ openssl x509 -days 10000 -CA TestCACert.pem -CAkey TestKeyPem -req -out TestCert2 -set_serial 3432 --outform DER -in TestCertCsr2
// password should be in the PemPass variable
// $ xxd --include TestCert2
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  TestCert2[] = {
  0x30, 0x82, 0x02, 0x3f, 0x30, 0x82, 0x01, 0xa8, 0x02, 0x02, 0x0d, 0x68,
  0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
  0x0b, 0x05, 0x00, 0x30, 0x5e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
  0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03,
  0x55, 0x04, 0x08, 0x0c, 0x02, 0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06,
  0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c,
  0x65, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x09,
  0x54, 0x69, 0x61, 0x6e, 0x6f, 0x63, 0x6f, 0x72, 0x65, 0x31, 0x0d, 0x30,
  0x0b, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x45, 0x44, 0x4b, 0x32,
  0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x04, 0x55,
  0x45, 0x46, 0x49, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x35, 0x30, 0x38, 0x32,
  0x31, 0x30, 0x33, 0x34, 0x36, 0x35, 0x34, 0x5a, 0x18, 0x0f, 0x32, 0x30,
  0x35, 0x33, 0x30, 0x31, 0x30, 0x36, 0x30, 0x33, 0x34, 0x36, 0x35, 0x34,
  0x5a, 0x30, 0x6f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06,
  0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
  0x08, 0x0c, 0x02, 0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55,
  0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x31,
  0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x09, 0x54, 0x69,
  0x61, 0x6e, 0x6f, 0x63, 0x6f, 0x72, 0x65, 0x31, 0x12, 0x30, 0x10, 0x06,
  0x03, 0x55, 0x04, 0x0b, 0x0c, 0x09, 0x45, 0x44, 0x4b, 0x32, 0x43, 0x48,
  0x49, 0x4c, 0x44, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x03,
  0x0c, 0x10, 0x55, 0x45, 0x46, 0x49, 0x4e, 0x4f, 0x53, 0x45, 0x4c, 0x46,
  0x49, 0x53, 0x53, 0x55, 0x45, 0x44, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06,
  0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00,
  0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xa3,
  0x08, 0x50, 0xc5, 0x20, 0xea, 0x2c, 0xf6, 0xfe, 0xa9, 0xa0, 0xee, 0x9b,
  0xa1, 0xd7, 0x5a, 0x24, 0x99, 0x8f, 0xe3, 0x27, 0xd9, 0xbf, 0x59, 0x73,
  0x5d, 0x88, 0x1a, 0x0d, 0x98, 0x0e, 0xaf, 0xe8, 0x98, 0x77, 0x67, 0x04,
  0xdc, 0x6d, 0x2d, 0xea, 0x3d, 0x94, 0x35, 0x56, 0x85, 0x4b, 0xad, 0xd3,
  0xb5, 0x19, 0xcb, 0x6e, 0x3f, 0xeb, 0x4c, 0x31, 0x85, 0xb5, 0xf5, 0x6c,
  0x5c, 0xd1, 0x71, 0x05, 0xef, 0x39, 0xf5, 0x0a, 0xca, 0x73, 0x0d, 0x4e,
  0xdc, 0x76, 0x29, 0xa3, 0xc7, 0x0d, 0xb7, 0x96, 0x83, 0x38, 0xaa, 0x49,
  0x93, 0xc9, 0x17, 0xe7, 0x13, 0xb6, 0xd3, 0xb5, 0xc0, 0xe4, 0x27, 0xd0,
  0x4f, 0x4a, 0x82, 0xe4, 0x79, 0x7e, 0xcc, 0xf5, 0x25, 0xb9, 0x2c, 0xe3,
  0xcd, 0xf1, 0x8b, 0xc3, 0x5a, 0x37, 0x5d, 0xe7, 0x34, 0xef, 0x9e, 0xd0,
  0xb9, 0x5a, 0x0c, 0xdc, 0x30, 0x13, 0xdf, 0x02, 0x03, 0x01, 0x00, 0x01,
  0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
  0x0b, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x87, 0x53, 0xea, 0x99, 0xbc,
  0x6d, 0xc4, 0xd3, 0x7f, 0xb2, 0xca, 0xe7, 0x19, 0x44, 0xc5, 0xcf, 0xdf,
  0xcb, 0x41, 0xee, 0x3b, 0xf6, 0x4f, 0x2a, 0x48, 0x5f, 0x32, 0xca, 0x11,
  0xae, 0x21, 0x46, 0x5d, 0xb4, 0xb0, 0x8a, 0x6b, 0x43, 0x4a, 0xc1, 0x49,
  0xc9, 0x83, 0x61, 0xce, 0x3f, 0x90, 0x7d, 0xc5, 0x0b, 0x5c, 0x93, 0xb7,
  0x76, 0x2b, 0xe5, 0x2f, 0xac, 0xb2, 0xc6, 0x3d, 0x82, 0xee, 0x70, 0x4a,
  0x0a, 0x62, 0x5e, 0xb2, 0x33, 0xe0, 0xed, 0xcc, 0x83, 0xbd, 0x45, 0x27,
  0x94, 0xc1, 0x98, 0x84, 0x9e, 0x22, 0x00, 0xa8, 0xfe, 0x18, 0x0a, 0xe7,
  0xaa, 0x23, 0xaf, 0x6e, 0xaa, 0xe5, 0x03, 0x55, 0x37, 0x5a, 0x98, 0x08,
  0x7b, 0xab, 0x4c, 0xba, 0x46, 0x27, 0xf1, 0xd3, 0x63, 0x16, 0x20, 0x2f,
  0xe8, 0x58, 0xd6, 0x34, 0x3f, 0x83, 0xe5, 0x33, 0x5b, 0xf5, 0x6e, 0x6a,
  0x25, 0x9f, 0x16
};

//
// Message Hash for Signing & Verification Validation.
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8  MsgHash[] = {
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09
};

//
// Payload for PKCS#7 Signing & Verification Validation.
//
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8  *Payload = "Payload Data for PKCS#7 Signing";

UNIT_TEST_STATUS
EFIAPI
TestVerifyRsaCertPkcs1SignVerify (
  IN UNIT_TEST_CONTEXT  Context
  )
{
  BOOLEAN           Status;
  VOID              *RsaPrivKey;
  VOID              *RsaPubKey;
  UINT8             *Signature;
  UINTN             SigSize;
  UINT8             *Subject;
  UINTN             SubjectSize;
  RETURN_STATUS     ReturnStatus;
  CHAR8             CommonName[64];
  UINTN             CommonNameSize;
  CHAR8             OrgName[64];
  UINTN             OrgNameSize;
  UNIT_TEST_STATUS  TestStatus;

  RsaPrivKey = NULL;
  RsaPubKey  = NULL;
  Signature  = NULL;
  Subject    = NULL;

  TestStatus = UNIT_TEST_ERROR_TEST_FAILED;

  //
  // Retrieve RSA private key from encrypted PEM data.
  //
  Status = RsaGetPrivateKeyFromPem (TestKeyPem, sizeof (TestKeyPem), PemPass, &RsaPrivKey);
  UT_ASSERT_TRUE (Status);

  //
  // Retrieve RSA public key from X509 Certificate.
  //
  RsaPubKey = NULL;
  Status    = RsaGetPublicKeyFromX509 (TestCert, sizeof (TestCert), &RsaPubKey);
  UT_ASSERT_TRUE (Status);

  //
  // Generate RSA PKCS#1 Signature.
  //
  SigSize = 0;
  Status  = RsaPkcs1Sign (RsaPrivKey, MsgHash, SHA1_DIGEST_SIZE, NULL, &SigSize);
  UT_ASSERT_FALSE (Status);
  UT_ASSERT_NOT_EQUAL (SigSize, 0);

  Signature = AllocatePool (SigSize);
  if (Signature == NULL) {
    UT_LOG_ERROR ("Failed to allocate memory for Signature.\n");
    goto Exit;
  }

  Status = RsaPkcs1Sign (RsaPrivKey, MsgHash, SHA1_DIGEST_SIZE, Signature, &SigSize);
  UT_ASSERT_TRUE (Status);

  //
  // Verify RSA PKCS#1-encoded Signature.
  //
  Status = RsaPkcs1Verify (RsaPubKey, MsgHash, SHA1_DIGEST_SIZE, Signature, SigSize);
  UT_ASSERT_TRUE (Status);

  //
  // X509 Certificate Subject Retrieving.
  //
  SubjectSize = 0;
  Status      = X509GetSubjectName (TestCert, sizeof (TestCert), NULL, &SubjectSize);
  Subject     = (UINT8 *)AllocatePool (SubjectSize);
  if (Subject == NULL) {
    UT_LOG_ERROR ("Failed to allocate memory for Subject.\n");
    goto Exit;
  }

  Status = X509GetSubjectName (TestCert, sizeof (TestCert), Subject, &SubjectSize);
  UT_ASSERT_TRUE (Status);

  //
  // Get CommonName from X509 Certificate Subject
  //
  CommonNameSize = 64;
  ZeroMem (CommonName, CommonNameSize);
  ReturnStatus = X509GetCommonName (TestCert, sizeof (TestCert), CommonName, &CommonNameSize);
  UT_ASSERT_NOT_EFI_ERROR (ReturnStatus);

  UT_ASSERT_EQUAL (CommonNameSize, 5);
  UT_ASSERT_MEM_EQUAL (CommonName, "UEFI", 5);

  OrgNameSize = 64;
  ZeroMem (OrgName, OrgNameSize);
  ReturnStatus = X509GetOrganizationName (TestCert, sizeof (TestCert), OrgName, &OrgNameSize);
  UT_ASSERT_NOT_EFI_ERROR (ReturnStatus);

  UT_ASSERT_EQUAL (OrgNameSize, 10);
  UT_ASSERT_MEM_EQUAL (OrgName, "Tianocore", 10);

  //
  // X509 Certificate Verification.
  //
  Status = X509VerifyCert (TestCert, sizeof (TestCert), TestCACert, sizeof (TestCACert));
  UT_ASSERT_TRUE (Status);

  TestStatus = UNIT_TEST_PASSED;
Exit:
  //
  // Release Resources.
  //
  if (Subject != NULL) {
    FreePool (Subject);
  }

  if (Signature != NULL) {
    FreePool (Signature);
  }

  if (RsaPubKey != NULL) {
    RsaFree (RsaPubKey);
  }

  if (RsaPrivKey != NULL) {
    RsaFree (RsaPrivKey);
  }

  return TestStatus;
}

UNIT_TEST_STATUS
EFIAPI
TestVerifyPkcs7SignVerify (
  IN UNIT_TEST_CONTEXT  Context
  )
{
  BOOLEAN  Status;
  UINT8    *P7SignedData;
  UINTN    P7SignedDataSize;
  UINT8    *SignCert;

  P7SignedData = NULL;
  SignCert     = NULL;

  //
  // Construct Signer Certificate from RAW data.
  //
  Status = X509ConstructCertificate (TestCert, sizeof (TestCert), (UINT8 **)&SignCert);
  UT_ASSERT_TRUE (Status);
  UT_ASSERT_NOT_NULL (SignCert);

  //
  // Create PKCS#7 signedData on Payload.
  // Note: Caller should release P7SignedData manually.
  //
  Status = Pkcs7Sign (
             TestKeyPem,
             sizeof (TestKeyPem),
             (CONST UINT8 *)PemPass,
             (UINT8 *)Payload,
             AsciiStrLen (Payload),
             SignCert,
             NULL,
             &P7SignedData,
             &P7SignedDataSize
             );
  UT_ASSERT_TRUE (Status);
  UT_ASSERT_NOT_EQUAL (P7SignedDataSize, 0);

  Status = Pkcs7Verify (
             P7SignedData,
             P7SignedDataSize,
             TestCACert,
             sizeof (TestCACert),
             (UINT8 *)Payload,
             AsciiStrLen (Payload)
             );
  UT_ASSERT_TRUE (Status);

  if (P7SignedData != NULL) {
    FreePool (P7SignedData);
  }

  if (SignCert != NULL) {
    X509Free (SignCert);
  }

  return UNIT_TEST_PASSED;
}

//
// TestCase2: Non self issued CA (partial certificate chains)
// This case uses a non-self-issued certificate as the signing certificate and CA.
// BaseCryptLib can pass this case (with X509_V_FLAG_PARTIAL_CHAIN enabled).
// BaseCryptLibMbedTls cannot, because Mbedtls certificate chain validation lacks support for partial certificate chains currently .
//
UNIT_TEST_STATUS
EFIAPI
TestVerifyPkcs7SignVerifyNonSelfIssued (
  IN UNIT_TEST_CONTEXT  Context
  )
{
  BOOLEAN  Status;
  UINT8    *P7SignedData;
  UINTN    P7SignedDataSize;
  UINT8    *SignCert;

  P7SignedData = NULL;
  SignCert     = NULL;

  //
  // Construct Signer Certificate from RAW data.
  //
  Status = X509ConstructCertificate (TestCert2, sizeof (TestCert2), (UINT8 **)&SignCert);
  UT_ASSERT_TRUE (Status);
  UT_ASSERT_NOT_NULL (SignCert);

  //
  // Create PKCS#7 signedData on Payload.
  // Note: Caller should release P7SignedData manually.
  //
  Status = Pkcs7Sign (
             TestKeyCert2Pem,
             sizeof (TestKeyCert2Pem),
             (CONST UINT8 *)TestKeyCert2PemPass,
             (UINT8 *)Payload,
             AsciiStrLen (Payload),
             SignCert,
             NULL,
             &P7SignedData,
             &P7SignedDataSize
             );
  UT_ASSERT_TRUE (Status);
  UT_ASSERT_NOT_EQUAL (P7SignedDataSize, 0);

  Status = Pkcs7Verify (
             P7SignedData,
             P7SignedDataSize,
             TestCert2,
             sizeof (TestCert2),
             (UINT8 *)Payload,
             AsciiStrLen (Payload)
             );
  UT_ASSERT_TRUE (Status);

  if (P7SignedData != NULL) {
    FreePool (P7SignedData);
  }

  if (SignCert != NULL) {
    X509Free (SignCert);
  }

  return UNIT_TEST_PASSED;
}

TEST_DESC  mRsaCertTest[] = {
  //
  // -----Description--------------------------------------Class----------------------Function-----------------Pre---Post--Context
  //
  { "TestVerifyRsaCertPkcs1SignVerify()", "CryptoPkg.BaseCryptLib.RsaCert", TestVerifyRsaCertPkcs1SignVerify, NULL, NULL, NULL },
};

UINTN  mRsaCertTestNum = ARRAY_SIZE (mRsaCertTest);

TEST_DESC  mPkcs7Test[] = {
  //
  // -----Description--------------------------------------Class----------------------Function-----------------Pre---Post--Context
  //
  { "TestVerifyPkcs7SignVerify()",              "CryptoPkg.BaseCryptLib.Pkcs7", TestVerifyPkcs7SignVerify,              NULL, NULL, NULL },
  { "TestVerifyPkcs7SignVerifyNonSelfIssued()", "CryptoPkg.BaseCryptLib.Pkcs7", TestVerifyPkcs7SignVerifyNonSelfIssued, NULL, NULL, NULL },
};

UINTN  mPkcs7TestNum = ARRAY_SIZE (mPkcs7Test);