xref: /qemu/tests/unit/test-crypto-akcipher.c (revision f0cfb761)
1689309c4SLei He /*
2689309c4SLei He  * QEMU Crypto cipher algorithms
3689309c4SLei He  *
4689309c4SLei He  * Copyright (c) 2022 Bytedance
5689309c4SLei He  * Author: lei he <helei.sig11@bytedance.com>
6689309c4SLei He  *
7689309c4SLei He  * This library is free software; you can redistribute it and/or
8689309c4SLei He  * modify it under the terms of the GNU Lesser General Public
9689309c4SLei He  * License as published by the Free Software Foundation; either
10689309c4SLei He  * version 2.1 of the License, or (at your option) any later version.
11689309c4SLei He  *
12689309c4SLei He  * This library is distributed in the hope that it will be useful,
13689309c4SLei He  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14689309c4SLei He  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15689309c4SLei He  * Lesser General Public License for more details.
16689309c4SLei He  *
17689309c4SLei He  * You should have received a copy of the GNU Lesser General Public
18689309c4SLei He  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19689309c4SLei He  *
20689309c4SLei He  */
21689309c4SLei He 
22689309c4SLei He #include "qemu/osdep.h"
23689309c4SLei He 
24689309c4SLei He #include "crypto/init.h"
25689309c4SLei He #include "crypto/akcipher.h"
26689309c4SLei He #include "qapi/error.h"
27689309c4SLei He 
28689309c4SLei He static const uint8_t rsa1024_private_key[] = {
29689309c4SLei He     0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02,
30689309c4SLei He     0x81, 0x81, 0x00, 0xe6, 0x4d, 0x76, 0x4f, 0xb2,
31689309c4SLei He     0x97, 0x09, 0xad, 0x9d, 0x17, 0x33, 0xf2, 0x30,
32689309c4SLei He     0x42, 0x83, 0xa9, 0xcb, 0x49, 0xa4, 0x2e, 0x59,
33689309c4SLei He     0x5e, 0x75, 0x51, 0xd1, 0xac, 0xc8, 0x86, 0x3e,
34689309c4SLei He     0xdb, 0x72, 0x2e, 0xb2, 0xf7, 0xc3, 0x5b, 0xc7,
35689309c4SLei He     0xea, 0xed, 0x30, 0xd1, 0xf7, 0x37, 0xee, 0x9d,
36689309c4SLei He     0x36, 0x59, 0x6f, 0xf8, 0xce, 0xc0, 0x5c, 0x82,
37689309c4SLei He     0x80, 0x37, 0x83, 0xd7, 0x45, 0x6a, 0xe9, 0xea,
38689309c4SLei He     0xc5, 0x3a, 0x59, 0x6b, 0x34, 0x31, 0x44, 0x00,
39689309c4SLei He     0x74, 0xa7, 0x29, 0xab, 0x79, 0x4a, 0xbd, 0xe8,
40689309c4SLei He     0x25, 0x35, 0x01, 0x11, 0x40, 0xbf, 0x31, 0xbd,
41689309c4SLei He     0xd3, 0xe0, 0x68, 0x1e, 0xd5, 0x5b, 0x2f, 0xe9,
42689309c4SLei He     0x20, 0xf2, 0x9f, 0x46, 0x35, 0x30, 0xa8, 0xf1,
43689309c4SLei He     0xfe, 0xef, 0xd8, 0x76, 0x23, 0x46, 0x34, 0x70,
44689309c4SLei He     0xa1, 0xce, 0xc6, 0x65, 0x6d, 0xb0, 0x94, 0x7e,
45689309c4SLei He     0xe5, 0x92, 0x45, 0x7b, 0xaa, 0xbb, 0x95, 0x97,
46689309c4SLei He     0x77, 0xcd, 0xd3, 0x02, 0x03, 0x01, 0x00, 0x01,
47689309c4SLei He     0x02, 0x81, 0x80, 0x30, 0x6a, 0xc4, 0x9e, 0xc8,
48689309c4SLei He     0xba, 0xfc, 0x2b, 0xe5, 0xc4, 0xc5, 0x04, 0xfb,
49689309c4SLei He     0xa4, 0x60, 0x2d, 0xc8, 0x31, 0x39, 0x35, 0x0d,
50689309c4SLei He     0x50, 0xd0, 0x75, 0x5d, 0x11, 0x68, 0x2e, 0xe0,
51689309c4SLei He     0xf4, 0x1d, 0xb3, 0x37, 0xa8, 0xe3, 0x07, 0x5e,
52689309c4SLei He     0xa6, 0x43, 0x2b, 0x6a, 0x59, 0x01, 0x07, 0x47,
53689309c4SLei He     0x41, 0xef, 0xd7, 0x9c, 0x85, 0x4a, 0xe7, 0xa7,
54689309c4SLei He     0xff, 0xf0, 0xab, 0xe5, 0x0c, 0x11, 0x08, 0x10,
55689309c4SLei He     0x75, 0x5a, 0x68, 0xa0, 0x08, 0x03, 0xc9, 0x40,
56689309c4SLei He     0x79, 0x67, 0x1d, 0x65, 0x89, 0x2d, 0x08, 0xf9,
57689309c4SLei He     0xb5, 0x1b, 0x7d, 0xd2, 0x41, 0x3b, 0x33, 0xf2,
58689309c4SLei He     0x47, 0x2f, 0x9c, 0x0b, 0xd5, 0xaf, 0xcb, 0xdb,
59689309c4SLei He     0xbb, 0x37, 0x63, 0x03, 0xf8, 0xe7, 0x2e, 0xc7,
60689309c4SLei He     0x3c, 0x86, 0x9f, 0xc2, 0x9b, 0xb4, 0x70, 0x6a,
61689309c4SLei He     0x4d, 0x7c, 0xe4, 0x1b, 0x3a, 0xa9, 0xae, 0xd7,
62689309c4SLei He     0xce, 0x7f, 0x56, 0xc2, 0x73, 0x5e, 0x58, 0x63,
63689309c4SLei He     0xd5, 0x86, 0x41, 0x02, 0x41, 0x00, 0xf6, 0x56,
64689309c4SLei He     0x69, 0xec, 0xef, 0x65, 0x95, 0xdc, 0x25, 0x47,
65689309c4SLei He     0xe0, 0x6f, 0xb0, 0x4f, 0x79, 0x77, 0x0a, 0x5e,
66689309c4SLei He     0x46, 0xcb, 0xbd, 0x0b, 0x71, 0x51, 0x2a, 0xa4,
67689309c4SLei He     0x65, 0x29, 0x18, 0xc6, 0x30, 0xa0, 0x95, 0x4c,
68689309c4SLei He     0x4b, 0xbe, 0x8c, 0x40, 0xe3, 0x9c, 0x23, 0x02,
69689309c4SLei He     0x14, 0x43, 0xe9, 0x64, 0xea, 0xe3, 0xa8, 0xe2,
70689309c4SLei He     0x1a, 0xd5, 0xf9, 0x5c, 0xe0, 0x36, 0x2c, 0x97,
71689309c4SLei He     0xda, 0xd5, 0xc7, 0x46, 0xce, 0x11, 0x02, 0x41,
72689309c4SLei He     0x00, 0xef, 0x56, 0x08, 0xb8, 0x29, 0xa5, 0xa6,
73689309c4SLei He     0x7c, 0xf7, 0x5f, 0xb4, 0xf5, 0x63, 0xe7, 0xeb,
74689309c4SLei He     0x45, 0xfd, 0x89, 0xaa, 0x94, 0xa6, 0x3d, 0x0b,
75689309c4SLei He     0xd9, 0x04, 0x6f, 0x78, 0xe0, 0xbb, 0xa2, 0xd4,
76689309c4SLei He     0x29, 0x83, 0x17, 0x95, 0x6f, 0x50, 0x3d, 0x40,
77689309c4SLei He     0x5d, 0xe5, 0x24, 0xda, 0xc2, 0x23, 0x50, 0x86,
78689309c4SLei He     0xa8, 0x34, 0xc8, 0x6f, 0xec, 0x7f, 0xb6, 0x45,
79689309c4SLei He     0x3a, 0xdd, 0x78, 0x9b, 0xee, 0xa1, 0xe4, 0x09,
80689309c4SLei He     0xa3, 0x02, 0x40, 0x5c, 0xd6, 0x66, 0x67, 0x58,
81689309c4SLei He     0x35, 0xc5, 0xcb, 0xc8, 0xf5, 0x14, 0xbd, 0xa3,
82689309c4SLei He     0x09, 0xe0, 0xb2, 0x1f, 0x63, 0x36, 0x75, 0x34,
83689309c4SLei He     0x52, 0xea, 0xaa, 0xf7, 0x52, 0x2b, 0x99, 0xd8,
84689309c4SLei He     0x6f, 0x61, 0x06, 0x34, 0x1e, 0x23, 0xf1, 0xb5,
85689309c4SLei He     0x34, 0x03, 0x53, 0xe5, 0xd1, 0xb3, 0xc7, 0x80,
86689309c4SLei He     0x5f, 0x7b, 0x32, 0xbf, 0x84, 0x2f, 0x2e, 0xf3,
87689309c4SLei He     0x22, 0xb0, 0x91, 0x5a, 0x2f, 0x04, 0xd7, 0x4a,
88689309c4SLei He     0x9a, 0x01, 0xb1, 0x02, 0x40, 0x34, 0x0b, 0x26,
89689309c4SLei He     0x4c, 0x3d, 0xaa, 0x2a, 0xc0, 0xe3, 0xdd, 0xe8,
90689309c4SLei He     0xf0, 0xaf, 0x6f, 0xe0, 0x06, 0x51, 0x32, 0x9d,
91689309c4SLei He     0x68, 0x43, 0x99, 0xe4, 0xb8, 0xa5, 0x31, 0x44,
92689309c4SLei He     0x3c, 0xc2, 0x30, 0x8f, 0x28, 0x13, 0xbc, 0x8e,
93689309c4SLei He     0x1f, 0x2d, 0x78, 0x94, 0x45, 0x96, 0xad, 0x63,
94689309c4SLei He     0xf0, 0x71, 0x53, 0x72, 0x64, 0xa3, 0x4d, 0xae,
95689309c4SLei He     0xa0, 0xe3, 0xc8, 0x93, 0xd7, 0x50, 0x0f, 0x89,
96689309c4SLei He     0x00, 0xe4, 0x2d, 0x3d, 0x37, 0x02, 0x41, 0x00,
97689309c4SLei He     0xbe, 0xa6, 0x08, 0xe0, 0xc8, 0x15, 0x2a, 0x47,
98689309c4SLei He     0xcb, 0xd5, 0xec, 0x93, 0xd3, 0xaa, 0x12, 0x82,
99689309c4SLei He     0xaf, 0xac, 0x51, 0x5a, 0x5b, 0xa7, 0x93, 0x4b,
100689309c4SLei He     0xb9, 0xab, 0x00, 0xfa, 0x5a, 0xea, 0x34, 0xe4,
101689309c4SLei He     0x80, 0xf1, 0x44, 0x6a, 0x65, 0xe4, 0x33, 0x99,
102689309c4SLei He     0xfb, 0x54, 0xd7, 0x89, 0x5a, 0x1b, 0xd6, 0x2b,
103689309c4SLei He     0xcc, 0x6e, 0x4b, 0x19, 0xa0, 0x6d, 0x93, 0x9f,
104689309c4SLei He     0xc3, 0x91, 0x7a, 0xa5, 0xd8, 0x59, 0x0e, 0x9e,
105689309c4SLei He };
106689309c4SLei He 
107689309c4SLei He static const uint8_t rsa1024_public_key[] = {
108689309c4SLei He     0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xe6,
109689309c4SLei He     0x4d, 0x76, 0x4f, 0xb2, 0x97, 0x09, 0xad, 0x9d,
110689309c4SLei He     0x17, 0x33, 0xf2, 0x30, 0x42, 0x83, 0xa9, 0xcb,
111689309c4SLei He     0x49, 0xa4, 0x2e, 0x59, 0x5e, 0x75, 0x51, 0xd1,
112689309c4SLei He     0xac, 0xc8, 0x86, 0x3e, 0xdb, 0x72, 0x2e, 0xb2,
113689309c4SLei He     0xf7, 0xc3, 0x5b, 0xc7, 0xea, 0xed, 0x30, 0xd1,
114689309c4SLei He     0xf7, 0x37, 0xee, 0x9d, 0x36, 0x59, 0x6f, 0xf8,
115689309c4SLei He     0xce, 0xc0, 0x5c, 0x82, 0x80, 0x37, 0x83, 0xd7,
116689309c4SLei He     0x45, 0x6a, 0xe9, 0xea, 0xc5, 0x3a, 0x59, 0x6b,
117689309c4SLei He     0x34, 0x31, 0x44, 0x00, 0x74, 0xa7, 0x29, 0xab,
118689309c4SLei He     0x79, 0x4a, 0xbd, 0xe8, 0x25, 0x35, 0x01, 0x11,
119689309c4SLei He     0x40, 0xbf, 0x31, 0xbd, 0xd3, 0xe0, 0x68, 0x1e,
120689309c4SLei He     0xd5, 0x5b, 0x2f, 0xe9, 0x20, 0xf2, 0x9f, 0x46,
121689309c4SLei He     0x35, 0x30, 0xa8, 0xf1, 0xfe, 0xef, 0xd8, 0x76,
122689309c4SLei He     0x23, 0x46, 0x34, 0x70, 0xa1, 0xce, 0xc6, 0x65,
123689309c4SLei He     0x6d, 0xb0, 0x94, 0x7e, 0xe5, 0x92, 0x45, 0x7b,
124689309c4SLei He     0xaa, 0xbb, 0x95, 0x97, 0x77, 0xcd, 0xd3, 0x02,
125689309c4SLei He     0x03, 0x01, 0x00, 0x01,
126689309c4SLei He };
127689309c4SLei He 
128689309c4SLei He static const uint8_t rsa2048_private_key[] = {
129689309c4SLei He     0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02,
130689309c4SLei He     0x82, 0x01, 0x01, 0x00, 0xbd, 0x9c, 0x83, 0x6b,
131689309c4SLei He     0x0e, 0x8e, 0xcf, 0xfa, 0xaa, 0x4f, 0x6a, 0xf4,
132689309c4SLei He     0xe3, 0x52, 0x0f, 0xa5, 0xd0, 0xbe, 0x5e, 0x7f,
133689309c4SLei He     0x08, 0x24, 0xba, 0x87, 0x46, 0xfb, 0x28, 0x93,
134689309c4SLei He     0xe5, 0xe5, 0x81, 0x42, 0xc0, 0xf9, 0x17, 0xc7,
135689309c4SLei He     0x81, 0x01, 0xf4, 0x18, 0x6a, 0x17, 0xf5, 0x57,
136689309c4SLei He     0x20, 0x37, 0xcf, 0xf9, 0x74, 0x5e, 0xe1, 0x48,
137689309c4SLei He     0x6a, 0x71, 0x0a, 0x0f, 0x79, 0x72, 0x2b, 0x46,
138689309c4SLei He     0x10, 0x53, 0xdc, 0x14, 0x43, 0xbd, 0xbc, 0x6d,
139689309c4SLei He     0x15, 0x6f, 0x15, 0x4e, 0xf0, 0x0d, 0x89, 0x39,
140689309c4SLei He     0x02, 0xc3, 0x68, 0x5c, 0xa8, 0xfc, 0xed, 0x64,
141689309c4SLei He     0x9d, 0x98, 0xb7, 0xcd, 0x83, 0x66, 0x93, 0xc3,
142689309c4SLei He     0xd9, 0x57, 0xa0, 0x21, 0x93, 0xad, 0x5c, 0x75,
143689309c4SLei He     0x69, 0x88, 0x9e, 0x81, 0xdc, 0x7f, 0x1d, 0xd5,
144689309c4SLei He     0xbd, 0x1c, 0xc1, 0x30, 0x56, 0xa5, 0xda, 0x99,
145689309c4SLei He     0x46, 0xa6, 0x6d, 0x0e, 0x6f, 0x5e, 0x51, 0x34,
146689309c4SLei He     0x49, 0x73, 0xc3, 0x67, 0x49, 0x7e, 0x21, 0x2a,
147689309c4SLei He     0x20, 0xa7, 0x2b, 0x92, 0x73, 0x1d, 0xa5, 0x25,
148689309c4SLei He     0x2a, 0xd0, 0x3a, 0x89, 0x75, 0xb2, 0xbb, 0x19,
149689309c4SLei He     0x37, 0x78, 0x48, 0xd2, 0xf2, 0x2a, 0x6d, 0x9e,
150689309c4SLei He     0xc6, 0x26, 0xca, 0x46, 0x8c, 0xf1, 0x42, 0x2a,
151689309c4SLei He     0x31, 0xb2, 0xfc, 0xe7, 0x55, 0x51, 0xff, 0x07,
152689309c4SLei He     0x13, 0x5b, 0x36, 0x59, 0x2b, 0x43, 0x30, 0x4b,
153689309c4SLei He     0x05, 0x5c, 0xd2, 0x45, 0xa0, 0xa0, 0x7c, 0x17,
154689309c4SLei He     0x5b, 0x07, 0xbb, 0x5d, 0x83, 0x80, 0x92, 0x6d,
155689309c4SLei He     0x87, 0x1a, 0x43, 0xac, 0xc7, 0x6b, 0x8d, 0x11,
156689309c4SLei He     0x60, 0x27, 0xd2, 0xdf, 0xdb, 0x71, 0x02, 0x55,
157689309c4SLei He     0x6e, 0xb5, 0xca, 0x4d, 0xda, 0x59, 0x0d, 0xb8,
158689309c4SLei He     0x8c, 0xcd, 0xd3, 0x0e, 0x55, 0xa0, 0xa4, 0x8d,
159689309c4SLei He     0xa0, 0x14, 0x10, 0x48, 0x42, 0x35, 0x56, 0x08,
160689309c4SLei He     0xf7, 0x29, 0x5f, 0xa2, 0xea, 0xa4, 0x5e, 0x8e,
161689309c4SLei He     0x99, 0x56, 0xaa, 0x5a, 0x8c, 0x23, 0x8f, 0x35,
162689309c4SLei He     0x22, 0x8a, 0xff, 0xed, 0x02, 0x03, 0x01, 0x00,
163689309c4SLei He     0x01, 0x02, 0x82, 0x01, 0x00, 0x4e, 0x4a, 0xf3,
164689309c4SLei He     0x44, 0xe0, 0x64, 0xfd, 0xe1, 0xde, 0x33, 0x1e,
165689309c4SLei He     0xd1, 0xf1, 0x8f, 0x6f, 0xe0, 0xa2, 0xfa, 0x08,
166689309c4SLei He     0x60, 0xe1, 0xc6, 0xf0, 0xb2, 0x6d, 0x0f, 0xc6,
167689309c4SLei He     0x28, 0x93, 0xb4, 0x19, 0x94, 0xab, 0xc3, 0xef,
168689309c4SLei He     0x1a, 0xb4, 0xdd, 0x4e, 0xa2, 0x4a, 0x24, 0x8c,
169689309c4SLei He     0x6c, 0xa6, 0x64, 0x05, 0x5f, 0x56, 0xba, 0xda,
170689309c4SLei He     0xc1, 0x21, 0x1a, 0x7d, 0xf1, 0xf7, 0xce, 0xb9,
171689309c4SLei He     0xa9, 0x9b, 0x92, 0x54, 0xfc, 0x95, 0x20, 0x22,
172689309c4SLei He     0x4e, 0xd4, 0x9b, 0xe2, 0xab, 0x8e, 0x99, 0xb8,
173689309c4SLei He     0x40, 0xaf, 0x30, 0x6a, 0xc6, 0x60, 0x0c, 0xd8,
174689309c4SLei He     0x25, 0x44, 0xa1, 0xcb, 0xbb, 0x73, 0x77, 0x86,
175689309c4SLei He     0xaa, 0x46, 0xf3, 0x54, 0xae, 0xa8, 0xa0, 0xdb,
176689309c4SLei He     0xdd, 0xab, 0x6e, 0xfb, 0x2c, 0x5a, 0x14, 0xaf,
177689309c4SLei He     0x08, 0x13, 0xa7, 0x6c, 0xe9, 0xfd, 0xcd, 0x4c,
178689309c4SLei He     0x1f, 0x20, 0x3a, 0x16, 0x2b, 0xf0, 0xb6, 0x7c,
179689309c4SLei He     0x47, 0x5f, 0xd1, 0x0a, 0x2c, 0xc4, 0xa5, 0x68,
180689309c4SLei He     0xd0, 0x43, 0x75, 0x6b, 0x65, 0xaa, 0x32, 0xc6,
181689309c4SLei He     0x99, 0x06, 0xcb, 0x8f, 0xe6, 0x8d, 0xce, 0xbf,
182689309c4SLei He     0x4d, 0x0d, 0x7b, 0x22, 0x2a, 0x8a, 0xcb, 0x7d,
183689309c4SLei He     0x7f, 0x16, 0x48, 0x85, 0xf1, 0x86, 0xcb, 0x54,
184689309c4SLei He     0xb9, 0x39, 0xd4, 0xbc, 0xe3, 0x2d, 0x27, 0x59,
185689309c4SLei He     0xf6, 0x81, 0x5e, 0x94, 0x45, 0xdf, 0xb9, 0x22,
186689309c4SLei He     0xaf, 0x64, 0x0d, 0x14, 0xec, 0x8c, 0xeb, 0x71,
187689309c4SLei He     0xac, 0xee, 0x09, 0x4c, 0xbf, 0x34, 0xf9, 0xf4,
188689309c4SLei He     0x66, 0x77, 0x36, 0x3b, 0x41, 0x74, 0x01, 0x4f,
189689309c4SLei He     0xfc, 0x56, 0x83, 0xba, 0x14, 0xb0, 0x2f, 0xdd,
190689309c4SLei He     0x4d, 0xb9, 0x3f, 0xdf, 0x71, 0xbe, 0x7b, 0xba,
191689309c4SLei He     0x66, 0xc8, 0xc5, 0x42, 0xc9, 0xba, 0x18, 0x63,
192689309c4SLei He     0x45, 0x07, 0x2f, 0x84, 0x3e, 0xc3, 0xfb, 0x47,
193689309c4SLei He     0xda, 0xd4, 0x1d, 0x0e, 0x9d, 0x96, 0xc0, 0xea,
194689309c4SLei He     0xee, 0x45, 0x2f, 0xe1, 0x62, 0x23, 0xee, 0xef,
195689309c4SLei He     0x3d, 0x5e, 0x55, 0xa1, 0x0d, 0x02, 0x81, 0x81,
196689309c4SLei He     0x00, 0xeb, 0x76, 0x88, 0xd3, 0xae, 0x3f, 0x1d,
197689309c4SLei He     0xf2, 0x49, 0xe0, 0x37, 0x49, 0x83, 0x82, 0x6c,
198689309c4SLei He     0xf7, 0xf1, 0x17, 0x30, 0x75, 0x2e, 0x89, 0x06,
199689309c4SLei He     0x88, 0x56, 0x32, 0xf6, 0xfa, 0x58, 0xcb, 0x3c,
200689309c4SLei He     0x98, 0x67, 0xc3, 0xde, 0x10, 0x82, 0xe5, 0xfa,
201689309c4SLei He     0xfa, 0x52, 0x47, 0x8d, 0xd7, 0x00, 0xc6, 0xcb,
202689309c4SLei He     0xf7, 0xf6, 0x57, 0x9b, 0x6e, 0x0c, 0xac, 0xe8,
203689309c4SLei He     0x3b, 0xd1, 0xde, 0xb5, 0x34, 0xaf, 0x8b, 0x2a,
204689309c4SLei He     0xb0, 0x2d, 0x01, 0xeb, 0x7c, 0xa0, 0x42, 0x26,
205689309c4SLei He     0xbb, 0x2b, 0x43, 0x0e, 0x1d, 0xe2, 0x4e, 0xc9,
206689309c4SLei He     0xc1, 0x0a, 0x67, 0x1d, 0xfc, 0x83, 0x25, 0xce,
207689309c4SLei He     0xb2, 0x18, 0xd9, 0x0d, 0x70, 0xf5, 0xa3, 0x5a,
208689309c4SLei He     0x9c, 0x99, 0xdd, 0x47, 0xa1, 0x57, 0xe7, 0x20,
209689309c4SLei He     0xde, 0xa1, 0x29, 0x8d, 0x96, 0x62, 0xf9, 0x26,
210689309c4SLei He     0x95, 0x51, 0xa6, 0xe7, 0x09, 0x8b, 0xba, 0x16,
211689309c4SLei He     0x8b, 0x19, 0x5b, 0xf9, 0x27, 0x0d, 0xc5, 0xd6,
212689309c4SLei He     0x5f, 0x02, 0x81, 0x81, 0x00, 0xce, 0x26, 0x31,
213689309c4SLei He     0xb5, 0x43, 0x53, 0x95, 0x39, 0xdd, 0x01, 0x98,
214689309c4SLei He     0x8b, 0x3d, 0x27, 0xeb, 0x0b, 0x87, 0x1c, 0x95,
215689309c4SLei He     0xfc, 0x3e, 0x36, 0x51, 0x31, 0xb5, 0xea, 0x59,
216689309c4SLei He     0x56, 0xc0, 0x97, 0x62, 0xf0, 0x63, 0x2b, 0xb6,
217689309c4SLei He     0x30, 0x9b, 0xdf, 0x19, 0x10, 0xe9, 0xa0, 0x3d,
218689309c4SLei He     0xea, 0x54, 0x5a, 0xe6, 0xc6, 0x9e, 0x7e, 0xb5,
219689309c4SLei He     0xf0, 0xb0, 0x54, 0xef, 0xc3, 0xe1, 0x47, 0xa6,
220689309c4SLei He     0x95, 0xc7, 0xe4, 0xa3, 0x4a, 0x30, 0x68, 0x24,
221689309c4SLei He     0x98, 0x7d, 0xc1, 0x34, 0xa9, 0xcb, 0xbc, 0x3c,
222689309c4SLei He     0x08, 0x9c, 0x7d, 0x0c, 0xa2, 0xb7, 0x60, 0xaa,
223689309c4SLei He     0x38, 0x08, 0x16, 0xa6, 0x7f, 0xdb, 0xd2, 0xb1,
224689309c4SLei He     0x67, 0xe7, 0x93, 0x8e, 0xbb, 0x7e, 0xb9, 0xb5,
225689309c4SLei He     0xd0, 0xd0, 0x9f, 0x7b, 0xcc, 0x46, 0xe6, 0x74,
226689309c4SLei He     0x78, 0x1a, 0x96, 0xd6, 0xd7, 0x74, 0x34, 0x54,
227689309c4SLei He     0x3b, 0x54, 0x55, 0x7f, 0x89, 0x81, 0xbc, 0x40,
228689309c4SLei He     0x55, 0x87, 0x24, 0x95, 0x33, 0x02, 0x81, 0x81,
229689309c4SLei He     0x00, 0xb0, 0x18, 0x5d, 0x2a, 0x1a, 0x95, 0x9f,
230689309c4SLei He     0x9a, 0xd5, 0x3f, 0x37, 0x79, 0xe6, 0x3d, 0x83,
231689309c4SLei He     0xab, 0x46, 0x86, 0x36, 0x3a, 0x5d, 0x0c, 0x23,
232689309c4SLei He     0x73, 0x91, 0x2b, 0xda, 0x63, 0xce, 0x46, 0x68,
233689309c4SLei He     0xd1, 0xfe, 0x40, 0x90, 0xf2, 0x3e, 0x43, 0x2b,
234689309c4SLei He     0x19, 0x4c, 0xb1, 0xb0, 0xd5, 0x8c, 0x02, 0x21,
235689309c4SLei He     0x07, 0x18, 0x17, 0xda, 0xe9, 0x49, 0xd7, 0x82,
236689309c4SLei He     0x73, 0x42, 0x78, 0xd1, 0x82, 0x4e, 0x8a, 0xc0,
237689309c4SLei He     0xe9, 0x33, 0x2f, 0xcd, 0x62, 0xce, 0x23, 0xca,
238689309c4SLei He     0xfd, 0x8d, 0xd4, 0x3f, 0x59, 0x80, 0x27, 0xb6,
239689309c4SLei He     0x61, 0x85, 0x9b, 0x2a, 0xe4, 0xef, 0x5c, 0x36,
240689309c4SLei He     0x22, 0x21, 0xcd, 0x2a, 0x6d, 0x41, 0x77, 0xe2,
241689309c4SLei He     0xcb, 0x5d, 0x93, 0x0d, 0x00, 0x10, 0x52, 0x8d,
242689309c4SLei He     0xd5, 0x92, 0x28, 0x16, 0x78, 0xd3, 0x1a, 0x4c,
243689309c4SLei He     0x8d, 0xbd, 0x9c, 0x1a, 0x0b, 0x9c, 0x91, 0x16,
244689309c4SLei He     0x4c, 0xff, 0x31, 0x36, 0xbb, 0xcb, 0x64, 0x1a,
245689309c4SLei He     0xf7, 0x02, 0x81, 0x80, 0x32, 0x65, 0x09, 0xdf,
246689309c4SLei He     0xca, 0xee, 0xa2, 0xdb, 0x3b, 0x58, 0xc9, 0x86,
247689309c4SLei He     0xb8, 0x53, 0x8a, 0xd5, 0x0d, 0x99, 0x82, 0x5c,
248689309c4SLei He     0xe0, 0x84, 0x7c, 0xc2, 0xcf, 0x3a, 0xd3, 0xce,
249689309c4SLei He     0x2e, 0x54, 0x93, 0xbe, 0x3a, 0x30, 0x14, 0x60,
250689309c4SLei He     0xbb, 0xaa, 0x05, 0x41, 0xaa, 0x2b, 0x1f, 0x17,
251689309c4SLei He     0xaa, 0xb9, 0x72, 0x12, 0xf9, 0xe9, 0xf5, 0xe6,
252689309c4SLei He     0x39, 0xe4, 0xf9, 0x9c, 0x03, 0xf5, 0x75, 0x16,
253689309c4SLei He     0xc6, 0x7f, 0xf1, 0x1f, 0x10, 0xc8, 0x54, 0xb1,
254689309c4SLei He     0xe6, 0x84, 0x15, 0xb0, 0xb0, 0x7a, 0x7a, 0x9e,
255689309c4SLei He     0x8c, 0x4a, 0xd1, 0x8c, 0xf1, 0x91, 0x32, 0xeb,
256689309c4SLei He     0x71, 0xa6, 0xbf, 0xdb, 0x1f, 0xcc, 0xd8, 0xcb,
257689309c4SLei He     0x92, 0xc3, 0xf2, 0xaf, 0x89, 0x22, 0x32, 0xfd,
258689309c4SLei He     0x32, 0x12, 0xda, 0xbb, 0xac, 0x55, 0x68, 0x01,
259689309c4SLei He     0x78, 0x56, 0x89, 0x7c, 0xb0, 0x0e, 0x9e, 0xcc,
260689309c4SLei He     0xc6, 0x28, 0x04, 0x7e, 0x83, 0xf5, 0x96, 0x30,
261689309c4SLei He     0x92, 0x51, 0xf2, 0x1b, 0x02, 0x81, 0x81, 0x00,
262689309c4SLei He     0x83, 0x6d, 0xd1, 0x98, 0x90, 0x41, 0x8c, 0xa7,
263689309c4SLei He     0x92, 0x83, 0xac, 0x89, 0x05, 0x0c, 0x79, 0x67,
264689309c4SLei He     0x90, 0xb6, 0xa1, 0xf3, 0x2f, 0xca, 0xf0, 0x15,
265689309c4SLei He     0xe0, 0x30, 0x58, 0xe9, 0x4f, 0xcb, 0x4c, 0x56,
266689309c4SLei He     0x56, 0x56, 0x14, 0x3f, 0x1b, 0x79, 0xb6, 0xef,
267689309c4SLei He     0x57, 0x4b, 0x28, 0xbd, 0xb0, 0xe6, 0x0c, 0x49,
268689309c4SLei He     0x4b, 0xbe, 0xe1, 0x57, 0x28, 0x2a, 0x23, 0x5e,
269689309c4SLei He     0xc4, 0xa2, 0x19, 0x4b, 0x00, 0x67, 0x78, 0xd9,
270689309c4SLei He     0x26, 0x6e, 0x17, 0x25, 0xce, 0xe4, 0xfd, 0xde,
271689309c4SLei He     0x86, 0xa8, 0x5a, 0x67, 0x47, 0x6b, 0x15, 0x09,
272689309c4SLei He     0xe1, 0xec, 0x8e, 0x62, 0x98, 0x91, 0x6f, 0xc0,
273689309c4SLei He     0x98, 0x0c, 0x70, 0x0e, 0x7d, 0xbe, 0x63, 0xbd,
274689309c4SLei He     0x12, 0x5a, 0x98, 0x1c, 0xe3, 0x0c, 0xfb, 0xc7,
275689309c4SLei He     0xfb, 0x1b, 0xbd, 0x02, 0x87, 0xcc, 0x0c, 0xbb,
276689309c4SLei He     0xc2, 0xd4, 0xb6, 0xc1, 0xa1, 0x23, 0xd3, 0x1e,
277689309c4SLei He     0x21, 0x6f, 0x48, 0xba, 0x0e, 0x2e, 0xc7, 0x42
278689309c4SLei He };
279689309c4SLei He 
280689309c4SLei He static const uint8_t rsa2048_public_key[] = {
281689309c4SLei He     0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01,
282689309c4SLei He     0x00, 0xbd, 0x9c, 0x83, 0x6b, 0x0e, 0x8e, 0xcf,
283689309c4SLei He     0xfa, 0xaa, 0x4f, 0x6a, 0xf4, 0xe3, 0x52, 0x0f,
284689309c4SLei He     0xa5, 0xd0, 0xbe, 0x5e, 0x7f, 0x08, 0x24, 0xba,
285689309c4SLei He     0x87, 0x46, 0xfb, 0x28, 0x93, 0xe5, 0xe5, 0x81,
286689309c4SLei He     0x42, 0xc0, 0xf9, 0x17, 0xc7, 0x81, 0x01, 0xf4,
287689309c4SLei He     0x18, 0x6a, 0x17, 0xf5, 0x57, 0x20, 0x37, 0xcf,
288689309c4SLei He     0xf9, 0x74, 0x5e, 0xe1, 0x48, 0x6a, 0x71, 0x0a,
289689309c4SLei He     0x0f, 0x79, 0x72, 0x2b, 0x46, 0x10, 0x53, 0xdc,
290689309c4SLei He     0x14, 0x43, 0xbd, 0xbc, 0x6d, 0x15, 0x6f, 0x15,
291689309c4SLei He     0x4e, 0xf0, 0x0d, 0x89, 0x39, 0x02, 0xc3, 0x68,
292689309c4SLei He     0x5c, 0xa8, 0xfc, 0xed, 0x64, 0x9d, 0x98, 0xb7,
293689309c4SLei He     0xcd, 0x83, 0x66, 0x93, 0xc3, 0xd9, 0x57, 0xa0,
294689309c4SLei He     0x21, 0x93, 0xad, 0x5c, 0x75, 0x69, 0x88, 0x9e,
295689309c4SLei He     0x81, 0xdc, 0x7f, 0x1d, 0xd5, 0xbd, 0x1c, 0xc1,
296689309c4SLei He     0x30, 0x56, 0xa5, 0xda, 0x99, 0x46, 0xa6, 0x6d,
297689309c4SLei He     0x0e, 0x6f, 0x5e, 0x51, 0x34, 0x49, 0x73, 0xc3,
298689309c4SLei He     0x67, 0x49, 0x7e, 0x21, 0x2a, 0x20, 0xa7, 0x2b,
299689309c4SLei He     0x92, 0x73, 0x1d, 0xa5, 0x25, 0x2a, 0xd0, 0x3a,
300689309c4SLei He     0x89, 0x75, 0xb2, 0xbb, 0x19, 0x37, 0x78, 0x48,
301689309c4SLei He     0xd2, 0xf2, 0x2a, 0x6d, 0x9e, 0xc6, 0x26, 0xca,
302689309c4SLei He     0x46, 0x8c, 0xf1, 0x42, 0x2a, 0x31, 0xb2, 0xfc,
303689309c4SLei He     0xe7, 0x55, 0x51, 0xff, 0x07, 0x13, 0x5b, 0x36,
304689309c4SLei He     0x59, 0x2b, 0x43, 0x30, 0x4b, 0x05, 0x5c, 0xd2,
305689309c4SLei He     0x45, 0xa0, 0xa0, 0x7c, 0x17, 0x5b, 0x07, 0xbb,
306689309c4SLei He     0x5d, 0x83, 0x80, 0x92, 0x6d, 0x87, 0x1a, 0x43,
307689309c4SLei He     0xac, 0xc7, 0x6b, 0x8d, 0x11, 0x60, 0x27, 0xd2,
308689309c4SLei He     0xdf, 0xdb, 0x71, 0x02, 0x55, 0x6e, 0xb5, 0xca,
309689309c4SLei He     0x4d, 0xda, 0x59, 0x0d, 0xb8, 0x8c, 0xcd, 0xd3,
310689309c4SLei He     0x0e, 0x55, 0xa0, 0xa4, 0x8d, 0xa0, 0x14, 0x10,
311689309c4SLei He     0x48, 0x42, 0x35, 0x56, 0x08, 0xf7, 0x29, 0x5f,
312689309c4SLei He     0xa2, 0xea, 0xa4, 0x5e, 0x8e, 0x99, 0x56, 0xaa,
313689309c4SLei He     0x5a, 0x8c, 0x23, 0x8f, 0x35, 0x22, 0x8a, 0xff,
314689309c4SLei He     0xed, 0x02, 0x03, 0x01, 0x00, 0x01
315689309c4SLei He };
316689309c4SLei He 
317689309c4SLei He static const uint8_t test_sha1_dgst[] = {
318689309c4SLei He     0x3c, 0x05, 0x19, 0x34, 0x29, 0x19, 0xc7, 0xe0,
319689309c4SLei He     0x87, 0xb6, 0x24, 0xf9, 0x58, 0xac, 0xa4, 0xd4,
320689309c4SLei He     0xb2, 0xd9, 0x03, 0x9e,
321689309c4SLei He };
322689309c4SLei He 
323689309c4SLei He static const uint8_t exp_signature_rsa2048_pkcs1[] = {
324689309c4SLei He     0x4e, 0x82, 0x56, 0x4c, 0x84, 0x66, 0xca, 0x1e,
325689309c4SLei He     0xc6, 0x92, 0x46, 0x20, 0x02, 0x6b, 0x64, 0x46,
326689309c4SLei He     0x15, 0x6b, 0x24, 0xf2, 0xbb, 0xfa, 0x44, 0x3c,
327689309c4SLei He     0xaf, 0x42, 0xc8, 0x41, 0xfd, 0xce, 0xed, 0x95,
328689309c4SLei He     0x34, 0xaf, 0x25, 0x09, 0xd1, 0x06, 0x94, 0xaa,
329689309c4SLei He     0x52, 0xd4, 0x29, 0xc8, 0x52, 0x34, 0x67, 0x59,
330689309c4SLei He     0x4f, 0x5a, 0xfd, 0x23, 0x30, 0x5e, 0xc7, 0x1e,
331689309c4SLei He     0xa6, 0xe0, 0x1b, 0x23, 0xca, 0x82, 0x47, 0x9a,
332689309c4SLei He     0x2e, 0x2c, 0x66, 0x45, 0x5a, 0x12, 0xa9, 0x15,
333689309c4SLei He     0xbf, 0xd6, 0xd6, 0xfa, 0x8d, 0x60, 0x99, 0x89,
334689309c4SLei He     0x91, 0x39, 0x06, 0xb7, 0xd3, 0x9a, 0xef, 0x15,
335689309c4SLei He     0x7b, 0x95, 0x87, 0x77, 0x2c, 0x41, 0xd4, 0x71,
336689309c4SLei He     0xd5, 0xdf, 0x22, 0x7b, 0x01, 0xe2, 0xc1, 0xfb,
337689309c4SLei He     0xb9, 0x4e, 0x0c, 0x9b, 0xd5, 0x04, 0xed, 0x2b,
338689309c4SLei He     0x7e, 0x73, 0x53, 0xaa, 0x33, 0x89, 0x9d, 0x95,
339689309c4SLei He     0x28, 0x8f, 0x8b, 0x80, 0x34, 0x7a, 0xea, 0xe3,
340689309c4SLei He     0x66, 0x8a, 0xa8, 0xad, 0xed, 0x91, 0x43, 0xdd,
341689309c4SLei He     0x77, 0xe5, 0xd7, 0x16, 0xda, 0xa8, 0x00, 0x29,
342689309c4SLei He     0x3f, 0x9f, 0xe0, 0x1d, 0x42, 0x9d, 0x35, 0x5d,
343689309c4SLei He     0x0f, 0xf3, 0x90, 0x27, 0x3a, 0x8c, 0x46, 0x13,
344689309c4SLei He     0x53, 0x3e, 0x3b, 0x38, 0x77, 0xf8, 0x57, 0x61,
345689309c4SLei He     0xbc, 0xc4, 0x54, 0x68, 0x48, 0xae, 0x58, 0x03,
346689309c4SLei He     0x33, 0x94, 0x3f, 0x18, 0x1e, 0xb3, 0x3f, 0x79,
347689309c4SLei He     0xa7, 0x26, 0x92, 0x5d, 0x32, 0x2a, 0xdb, 0xe6,
348689309c4SLei He     0x3a, 0xe8, 0xd7, 0xaa, 0x91, 0xfe, 0x9f, 0x06,
349689309c4SLei He     0x26, 0x68, 0x8c, 0x27, 0x31, 0xb0, 0x04, 0x9e,
350689309c4SLei He     0x94, 0x79, 0x63, 0xa1, 0xc7, 0xe8, 0x5b, 0x8c,
351689309c4SLei He     0xd3, 0xf1, 0x88, 0x58, 0x31, 0x2f, 0x4e, 0x11,
352689309c4SLei He     0x00, 0xfe, 0x29, 0xad, 0x2c, 0xa9, 0x8e, 0x63,
353689309c4SLei He     0xd8, 0x7d, 0xc5, 0xa1, 0x71, 0xfa, 0x08, 0x29,
354689309c4SLei He     0xea, 0xd6, 0x6c, 0x53, 0x00, 0x52, 0xa0, 0xed,
355689309c4SLei He     0x6b, 0x7c, 0x67, 0x50, 0x71, 0x2d, 0x96, 0x7a,
356689309c4SLei He };
357689309c4SLei He 
358689309c4SLei He static const uint8_t exp_signature_rsa1024_pkcs1[] = {
359689309c4SLei He     0x6b, 0x5b, 0xbb, 0x3b, 0x1f, 0x08, 0xd8, 0xc0,
360689309c4SLei He     0x4a, 0xf1, 0x5a, 0x12, 0xc2, 0x39, 0x14, 0x65,
361689309c4SLei He     0x4f, 0xda, 0x79, 0x67, 0xf2, 0x89, 0x25, 0xad,
362689309c4SLei He     0x9e, 0x7e, 0xba, 0xa8, 0x34, 0x15, 0x03, 0xdd,
363689309c4SLei He     0x80, 0x6b, 0x01, 0xd7, 0x4a, 0xf3, 0xd6, 0xef,
364689309c4SLei He     0x1e, 0x48, 0xf3, 0xbc, 0x75, 0x1a, 0xc4, 0x2c,
365689309c4SLei He     0x90, 0x15, 0x9f, 0x21, 0x24, 0x98, 0x21, 0xef,
366689309c4SLei He     0x6d, 0x3b, 0xf3, 0x82, 0x8f, 0x8d, 0xd8, 0x48,
367689309c4SLei He     0x37, 0x16, 0x19, 0x8e, 0x3c, 0x64, 0xa0, 0x9e,
368689309c4SLei He     0xf7, 0x0c, 0xd9, 0x5c, 0xc6, 0x13, 0xc4, 0x5f,
369689309c4SLei He     0xf8, 0xf3, 0x59, 0x5b, 0xd0, 0x33, 0x95, 0x98,
370689309c4SLei He     0xde, 0x67, 0x25, 0x58, 0x46, 0xba, 0xee, 0x0f,
371689309c4SLei He     0x47, 0x7a, 0x7f, 0xd0, 0xe4, 0x77, 0x09, 0x17,
372689309c4SLei He     0xe9, 0x81, 0x6e, 0x2d, 0x33, 0x9b, 0x13, 0x0b,
373689309c4SLei He     0xc9, 0xb2, 0x0c, 0x2c, 0xb5, 0xdf, 0x52, 0x8f,
374689309c4SLei He     0xab, 0x0d, 0xc6, 0x59, 0x1d, 0xc7, 0x33, 0x7b,
375689309c4SLei He };
376689309c4SLei He 
377689309c4SLei He static const uint8_t test_plaintext[] = {
378689309c4SLei He     0x00, 0x44, 0xbc, 0x6f, 0x77, 0xfb, 0xe2, 0xa4,
379689309c4SLei He     0x98, 0x9e, 0xf5, 0x33, 0xa0, 0xbd, 0x81, 0xb9,
380689309c4SLei He     0xf1, 0x44, 0x7f, 0x79, 0x89, 0x23, 0xe5, 0x46,
381689309c4SLei He     0x66, 0x9f, 0x98, 0x95, 0x6f, 0x56, 0x78, 0xf6,
382689309c4SLei He     0xf5, 0xac, 0x9c, 0xda, 0xc2, 0x79, 0x59, 0xf0,
383689309c4SLei He     0x1b, 0x03, 0xfa, 0x46, 0x1c, 0x1f, 0x18, 0x07,
384689309c4SLei He     0xce, 0xad, 0xed, 0x3d, 0x11, 0xf9, 0x1b, 0x26,
385689309c4SLei He     0x4a, 0x97, 0x28, 0x71, 0x5f, 0x2c, 0x5e, 0x58,
386689309c4SLei He     0xf0, 0xd6, 0xbf, 0xa4, 0x12, 0xd0, 0x1d, 0x07,
387689309c4SLei He     0xcb, 0x73, 0x66, 0xb6, 0xa4, 0x09, 0xaf, 0x5d,
388689309c4SLei He     0xe9, 0x14, 0x14, 0xaf, 0x69, 0xd6, 0xee, 0x0a,
389689309c4SLei He     0xfc, 0xca, 0xac, 0x94, 0x47, 0xd5, 0x9d, 0x5b,
390689309c4SLei He     0x2b, 0xfb, 0xce, 0x9d, 0x04, 0xc1, 0xaf, 0xa5,
391689309c4SLei He     0xa1, 0x8d, 0xa9, 0x48, 0xa8, 0x65, 0xe6, 0x9f,
392689309c4SLei He     0x74, 0x78, 0x16, 0x32, 0x93, 0xb5, 0x21, 0xb9,
393689309c4SLei He     0x9f, 0x3f, 0xc1, 0xe5, 0xa2, 0x50, 0x8b, 0x12,
394689309c4SLei He     0xfb, 0x3e, 0xb0, 0x8a, 0x00, 0xc7, 0x20, 0x56,
395689309c4SLei He     0xb3, 0xb1, 0x29, 0x95, 0x89, 0xd6, 0x50, 0xf5,
396689309c4SLei He     0x37, 0x38, 0x8e, 0x12, 0xf1, 0xba, 0x82, 0x37,
397689309c4SLei He     0x34, 0x68, 0x4b, 0xe8, 0xe3, 0x11, 0x1c, 0x46,
398689309c4SLei He     0xf9, 0x63, 0x3a, 0xd6, 0xf3, 0x3f, 0x55, 0xa6,
399689309c4SLei He     0xbd, 0x89, 0xf1, 0x2d, 0x38, 0x91, 0x7c, 0xc2,
400689309c4SLei He     0x4d, 0xf1, 0x69, 0x82, 0x6d, 0x71, 0x77, 0xf4,
401689309c4SLei He     0xfc, 0x43, 0x20, 0x6f, 0x43, 0xb9, 0x43, 0xd1,
402689309c4SLei He     0x65, 0xbd, 0xca, 0xb1, 0x43, 0x87, 0xf8, 0xc8,
403689309c4SLei He     0x76, 0x21, 0xa9, 0xeb, 0x3e, 0x9a, 0xef, 0xc9,
404689309c4SLei He     0x0e, 0x79, 0xbc, 0xf0, 0xf8, 0xc8, 0xe2, 0xbc,
405689309c4SLei He     0x33, 0x35, 0x3e, 0xfc, 0xf9, 0x44, 0x69, 0x06,
406689309c4SLei He     0x7c, 0x7f, 0x5d, 0xa2, 0x9e, 0xab, 0xc2, 0x82,
407689309c4SLei He     0xa0, 0xfb, 0xc5, 0x79, 0x57, 0x8c, 0xf1, 0x1c,
408689309c4SLei He     0x51, 0x64, 0x4c, 0x56, 0x08, 0x80, 0x32, 0xf4,
409689309c4SLei He     0x97, 0x8f, 0x6f, 0xb2, 0x16, 0xa6, 0x9d, 0x71,
410689309c4SLei He };
411689309c4SLei He 
412689309c4SLei He static const uint8_t exp_ciphertext_rsa1024_raw[] = {
413689309c4SLei He     0x01, 0xa0, 0xc2, 0x94, 0x9f, 0xd6, 0xbe, 0x8d,
414689309c4SLei He     0xe9, 0x24, 0xaa, 0x9c, 0x67, 0xd7, 0xe3, 0x04,
415689309c4SLei He     0x34, 0xbf, 0xd3, 0x27, 0xa1, 0x43, 0xeb, 0x60,
416689309c4SLei He     0x6b, 0x5b, 0x64, 0x15, 0x55, 0x16, 0x98, 0x35,
417689309c4SLei He     0xc2, 0x59, 0xa7, 0xf7, 0x24, 0xf7, 0x05, 0xb9,
418689309c4SLei He     0xe8, 0x56, 0x6f, 0xf2, 0x7d, 0x8b, 0x3c, 0xcb,
419689309c4SLei He     0xa6, 0xc2, 0xac, 0x0c, 0x37, 0x8c, 0x70, 0x70,
420689309c4SLei He     0x55, 0x05, 0x07, 0x0d, 0x63, 0x6b, 0x7d, 0x5f,
421689309c4SLei He     0xae, 0x03, 0x1e, 0x55, 0x05, 0xbb, 0xa8, 0xe7,
422689309c4SLei He     0xff, 0xa0, 0x8c, 0x5b, 0x6b, 0x01, 0x48, 0x2e,
423689309c4SLei He     0x4f, 0x7f, 0xe2, 0x74, 0xc6, 0x32, 0xa7, 0x2d,
424689309c4SLei He     0xdb, 0x91, 0x9b, 0x67, 0x4d, 0x71, 0xf9, 0x8c,
425689309c4SLei He     0x42, 0x43, 0x75, 0x4e, 0xd0, 0x0e, 0x7c, 0xa0,
426689309c4SLei He     0x97, 0x1a, 0x5f, 0x8e, 0x6f, 0xe4, 0xfa, 0x16,
427689309c4SLei He     0x1d, 0x59, 0x0e, 0x0b, 0x11, 0x12, 0xa3, 0x0c,
428689309c4SLei He     0xa6, 0x55, 0xe6, 0xdb, 0xa7, 0x71, 0xa6, 0xff,
429689309c4SLei He };
430689309c4SLei He 
431689309c4SLei He static const uint8_t exp_ciphertext_rsa1024_pkcs1[] = {
432689309c4SLei He     0x93, 0x78, 0x6a, 0x76, 0xb8, 0x94, 0xea, 0xe4,
433689309c4SLei He     0x32, 0x79, 0x01, 0x8b, 0xc1, 0xcb, 0x2e, 0x2d,
434689309c4SLei He     0xfe, 0xdc, 0x9b, 0xe3, 0xe9, 0x23, 0xe4, 0x0a,
435689309c4SLei He     0xb0, 0x6b, 0x9f, 0x6b, 0x62, 0xf5, 0x3d, 0xf0,
436689309c4SLei He     0x78, 0x84, 0x77, 0x21, 0xad, 0x0b, 0x30, 0x30,
437689309c4SLei He     0x94, 0xe2, 0x18, 0xc4, 0x9b, 0x12, 0x06, 0xc8,
438689309c4SLei He     0xaa, 0xf7, 0x30, 0xe4, 0xc8, 0x64, 0xe7, 0x51,
439689309c4SLei He     0xf1, 0x6a, 0xe1, 0xa2, 0x58, 0x7a, 0x02, 0x9c,
440689309c4SLei He     0x8e, 0xf0, 0x2d, 0x25, 0x6b, 0xb7, 0x25, 0x5e,
441689309c4SLei He     0x05, 0xaf, 0x38, 0xb2, 0x69, 0x5e, 0x6c, 0x75,
442689309c4SLei He     0x6e, 0x27, 0xba, 0x5d, 0x7d, 0x35, 0x72, 0xb7,
443689309c4SLei He     0x25, 0xd4, 0xaa, 0xb2, 0x4b, 0x9e, 0x6b, 0x82,
444689309c4SLei He     0xb2, 0x32, 0xe2, 0x13, 0x1d, 0x00, 0x21, 0x08,
445689309c4SLei He     0xae, 0x14, 0xbb, 0xc0, 0x40, 0xb7, 0x0d, 0xd5,
446689309c4SLei He     0x0e, 0x4d, 0x6d, 0x9a, 0x70, 0x86, 0xe9, 0xfc,
447689309c4SLei He     0x67, 0x2b, 0xa4, 0x11, 0x45, 0xb6, 0xc4, 0x2f,
448689309c4SLei He };
449689309c4SLei He 
450689309c4SLei He static const uint8_t exp_ciphertext_rsa2048_raw[] = {
451689309c4SLei He     0x09, 0x7b, 0x9e, 0x7c, 0x10, 0x1f, 0x73, 0xb4,
452689309c4SLei He     0x5f, 0xdb, 0x4f, 0x05, 0xe7, 0xfc, 0x9e, 0x35,
453689309c4SLei He     0x48, 0xd8, 0xc8, 0xf5, 0xac, 0x6d, 0xb4, 0xb0,
454689309c4SLei He     0xd4, 0xf7, 0x69, 0x0f, 0x30, 0x78, 0xbb, 0x55,
455689309c4SLei He     0x67, 0x66, 0x66, 0x05, 0xf4, 0x77, 0xe2, 0x30,
456689309c4SLei He     0xa5, 0x94, 0x10, 0xa3, 0xcb, 0xee, 0x13, 0x9f,
457689309c4SLei He     0x47, 0x1b, 0x2e, 0xf9, 0xfd, 0x94, 0x09, 0xbd,
458689309c4SLei He     0x26, 0x6e, 0x84, 0xc7, 0x5c, 0x42, 0x20, 0x76,
459689309c4SLei He     0x72, 0x83, 0x75, 0x68, 0xa4, 0x18, 0x2d, 0x76,
460689309c4SLei He     0x62, 0xc3, 0xab, 0xc0, 0xc9, 0x36, 0x59, 0xe0,
461689309c4SLei He     0xa9, 0x70, 0x1f, 0xff, 0x97, 0x07, 0x0d, 0x88,
462689309c4SLei He     0xc2, 0xd8, 0x51, 0x35, 0xf7, 0xb0, 0x50, 0xe4,
463689309c4SLei He     0x9f, 0x3d, 0xd4, 0x71, 0x8b, 0x40, 0x89, 0x71,
464689309c4SLei He     0x6c, 0xd8, 0xc2, 0x63, 0xb6, 0x3a, 0xce, 0xb1,
465689309c4SLei He     0x32, 0xf1, 0xc6, 0x11, 0x31, 0x25, 0x48, 0xcf,
466689309c4SLei He     0xeb, 0xbc, 0xd3, 0x9b, 0xc5, 0xbd, 0xd2, 0x57,
467689309c4SLei He     0x73, 0x9b, 0x20, 0xb8, 0xdf, 0xbe, 0xb8, 0x40,
468689309c4SLei He     0xb6, 0xac, 0x24, 0xdb, 0x94, 0x6a, 0x93, 0x43,
469689309c4SLei He     0x4a, 0xa8, 0xa3, 0xcf, 0xd5, 0x61, 0x1b, 0x46,
470689309c4SLei He     0x1d, 0x6f, 0x57, 0xec, 0xa6, 0xd0, 0x44, 0x05,
471689309c4SLei He     0x48, 0xb8, 0x90, 0x80, 0x23, 0x8e, 0x5f, 0xb0,
472689309c4SLei He     0x4b, 0x6f, 0xe3, 0xf9, 0xb0, 0x04, 0x60, 0xae,
473689309c4SLei He     0x80, 0xcf, 0xa5, 0x5c, 0x11, 0xe4, 0xce, 0x57,
474689309c4SLei He     0x5b, 0xbb, 0xde, 0x92, 0xfc, 0xe7, 0x3f, 0xe0,
475689309c4SLei He     0xfc, 0x06, 0xc8, 0xf3, 0x8c, 0xac, 0x86, 0x09,
476689309c4SLei He     0x31, 0xe5, 0x7e, 0xfb, 0x5d, 0xa7, 0x57, 0xf8,
477689309c4SLei He     0x1d, 0x23, 0x9d, 0xa3, 0xeb, 0x53, 0x28, 0xde,
478689309c4SLei He     0xbf, 0x53, 0xef, 0x35, 0x3c, 0x7e, 0x3c, 0x1b,
479689309c4SLei He     0x76, 0x9d, 0x09, 0x25, 0x43, 0xd4, 0x8b, 0xca,
480689309c4SLei He     0xda, 0x45, 0x5b, 0xdc, 0x9f, 0x57, 0x5a, 0x30,
481689309c4SLei He     0x2e, 0xe9, 0x73, 0x68, 0x28, 0xfa, 0x40, 0xb0,
482689309c4SLei He     0x7c, 0x31, 0xd7, 0x8b, 0x4e, 0x99, 0x94, 0xf1,
483689309c4SLei He };
484689309c4SLei He 
485689309c4SLei He static const uint8_t exp_ciphertext_rsa2048_pkcs1[] = {
486689309c4SLei He     0xa5, 0x19, 0x19, 0x34, 0xad, 0xf6, 0xd2, 0xbe,
487689309c4SLei He     0xed, 0x8f, 0xe5, 0xfe, 0xa2, 0xa5, 0x20, 0x08,
488689309c4SLei He     0x15, 0x53, 0x7c, 0x68, 0x28, 0xae, 0x07, 0xb2,
489689309c4SLei He     0x4c, 0x5d, 0xee, 0xc1, 0xc6, 0xdc, 0xd6, 0x8b,
490689309c4SLei He     0xc6, 0xba, 0x46, 0xe1, 0x16, 0xa9, 0x04, 0x72,
491689309c4SLei He     0xdf, 0x8f, 0x1e, 0x97, 0x2a, 0x55, 0xe7, 0xac,
492689309c4SLei He     0x08, 0x0d, 0x61, 0xe8, 0x64, 0x8b, 0x6f, 0x96,
493689309c4SLei He     0x0e, 0xbb, 0x8a, 0x30, 0xb3, 0x73, 0x28, 0x61,
494689309c4SLei He     0x16, 0x89, 0x90, 0x88, 0x8e, 0xda, 0x22, 0xe6,
495689309c4SLei He     0x42, 0x16, 0xc7, 0xe8, 0x30, 0x0d, 0x7f, 0x44,
496689309c4SLei He     0x1e, 0xef, 0xe6, 0xdb, 0x78, 0x54, 0x89, 0xa5,
497689309c4SLei He     0x60, 0x67, 0xb3, 0x35, 0x2d, 0x79, 0x49, 0xcf,
498689309c4SLei He     0xe6, 0x8f, 0xf3, 0x64, 0x52, 0x1c, 0x6c, 0x43,
499689309c4SLei He     0x7e, 0xb0, 0xde, 0x55, 0xdf, 0xbe, 0xb7, 0xb1,
500689309c4SLei He     0xdb, 0x02, 0xee, 0x76, 0x96, 0xcc, 0x0b, 0x97,
501689309c4SLei He     0x8c, 0x23, 0xaa, 0x7d, 0x4c, 0x47, 0x28, 0x41,
502689309c4SLei He     0x7a, 0x20, 0x39, 0x1f, 0x64, 0x0b, 0xf1, 0x74,
503689309c4SLei He     0xf1, 0x29, 0xda, 0xe9, 0x3a, 0x36, 0xa6, 0x88,
504689309c4SLei He     0xb8, 0xc0, 0x21, 0xb8, 0x9b, 0x5d, 0x90, 0x85,
505689309c4SLei He     0xa3, 0x30, 0x61, 0x17, 0x8c, 0x74, 0x63, 0xd5,
506689309c4SLei He     0x0f, 0x95, 0xdc, 0xc8, 0x4f, 0xa7, 0x24, 0x55,
507689309c4SLei He     0x40, 0xe2, 0x84, 0x57, 0x65, 0x06, 0x11, 0x30,
508689309c4SLei He     0x2b, 0x9e, 0x32, 0x95, 0x39, 0xf2, 0x1a, 0x3f,
509689309c4SLei He     0xab, 0xcd, 0x7b, 0x7f, 0x9c, 0xf0, 0x00, 0x50,
510689309c4SLei He     0x7c, 0xf4, 0xbe, 0xcb, 0x80, 0xea, 0x66, 0xba,
511689309c4SLei He     0x0e, 0x7b, 0x46, 0x0b, 0x25, 0xe0, 0xc1, 0x03,
512689309c4SLei He     0x29, 0x11, 0x2d, 0x69, 0x4f, 0x21, 0xa2, 0x58,
513689309c4SLei He     0x37, 0x4b, 0x84, 0x15, 0xb3, 0x65, 0x3a, 0xac,
514689309c4SLei He     0xd4, 0xd0, 0xf6, 0xdf, 0x4b, 0x82, 0xca, 0x9e,
515689309c4SLei He     0xbb, 0xbe, 0x3c, 0x4d, 0xd5, 0xbf, 0x00, 0xd6,
516689309c4SLei He     0x12, 0x48, 0x72, 0x0b, 0xc7, 0xf8, 0xe1, 0xcd,
517689309c4SLei He     0xd0, 0x28, 0x03, 0x19, 0xa6, 0x06, 0x13, 0x45,
518689309c4SLei He };
519689309c4SLei He 
520f0cfb761SLei He static const uint8_t rsa_private_key_lack_element[] = {
521f0cfb761SLei He     /* RSAPrivateKey, offset: 0, length: 176 */
522f0cfb761SLei He     0x30, 0x81, 0xb0,
523f0cfb761SLei He     /* version, offset: 4, length: 1 */
524f0cfb761SLei He     0x02, 0x01, 0x00,
525f0cfb761SLei He     /* n, offset: 7, length: 65 */
526f0cfb761SLei He     0x02, 0x41,
527f0cfb761SLei He     0x00, 0xb9, 0xe1, 0x22, 0xdb, 0x56, 0x2f, 0xb6,
528f0cfb761SLei He     0xf7, 0xf0, 0x0a, 0x87, 0x43, 0x07, 0x12, 0xdb,
529f0cfb761SLei He     0x6d, 0xb6, 0x2b, 0x41, 0x8d, 0x2c, 0x3c, 0xa5,
530f0cfb761SLei He     0xdd, 0x78, 0x9a, 0x8f, 0xab, 0x8e, 0xf2, 0x4a,
531f0cfb761SLei He     0xc8, 0x34, 0x0c, 0x12, 0x4f, 0x11, 0x90, 0xc6,
532f0cfb761SLei He     0xc2, 0xa5, 0xd0, 0xcd, 0xfb, 0xfc, 0x2c, 0x95,
533f0cfb761SLei He     0x56, 0x82, 0xdf, 0x39, 0xf3, 0x3b, 0x1d, 0x62,
534f0cfb761SLei He     0x26, 0x97, 0xb7, 0x93, 0x25, 0xc7, 0xec, 0x7e,
535f0cfb761SLei He     0xf7,
536f0cfb761SLei He     /* e, offset: 74, length: 3 */
537f0cfb761SLei He     0x02, 0x03, 0x01, 0x00, 0x01,
538f0cfb761SLei He     /* d, offset: 79, length: 64 */
539f0cfb761SLei He     0x02, 0x40,
540f0cfb761SLei He     0x1e, 0x80, 0xfe, 0xda, 0x65, 0xdb, 0x70, 0xb8,
541f0cfb761SLei He     0x61, 0x91, 0x28, 0xbf, 0x6c, 0x32, 0xc1, 0x05,
542f0cfb761SLei He     0xd1, 0x26, 0x6a, 0x1c, 0x83, 0xcc, 0xf4, 0x1f,
543f0cfb761SLei He     0x53, 0x42, 0x72, 0x1f, 0x62, 0x57, 0x0a, 0xc4,
544f0cfb761SLei He     0x66, 0x76, 0x30, 0x87, 0xb9, 0xb1, 0xb9, 0x6a,
545f0cfb761SLei He     0x63, 0xfd, 0x8f, 0x3e, 0xfc, 0x35, 0x3f, 0xd6,
546f0cfb761SLei He     0x2e, 0x6c, 0xc8, 0x70, 0x8a, 0x17, 0xc1, 0x28,
547f0cfb761SLei He     0x6a, 0xfe, 0x51, 0x56, 0xb3, 0x92, 0x6f, 0x09,
548f0cfb761SLei He     /* p, offset: 145, length: 33 */
549f0cfb761SLei He     0x02, 0x21,
550f0cfb761SLei He     0x00, 0xe3, 0x2e, 0x2d, 0x8d, 0xba, 0x1c, 0x34,
551f0cfb761SLei He     0x4c, 0x49, 0x9f, 0xc1, 0xa6, 0xdd, 0xd7, 0x13,
552f0cfb761SLei He     0x8d, 0x05, 0x48, 0xdd, 0xff, 0x5c, 0x30, 0xbc,
553f0cfb761SLei He     0x6b, 0xc4, 0x18, 0x9d, 0xfc, 0xa2, 0xd0, 0x9b,
554f0cfb761SLei He     0x4d,
555f0cfb761SLei He     /* q, offset: 180, length: 33 */
556f0cfb761SLei He     0x02, 0x21,
557f0cfb761SLei He     0x00, 0xd1, 0x75, 0xaf, 0x4b, 0xc6, 0x1a, 0xb0,
558f0cfb761SLei He     0x98, 0x14, 0x42, 0xae, 0x33, 0xf3, 0x44, 0xde,
559f0cfb761SLei He     0x21, 0xcb, 0x04, 0xda, 0xfb, 0x1e, 0x35, 0x92,
560f0cfb761SLei He     0xcd, 0x69, 0xc0, 0x83, 0x06, 0x83, 0x8e, 0x39,
561f0cfb761SLei He     0x53,
562f0cfb761SLei He     /* lack element: dp, dq, u */
563f0cfb761SLei He };
564f0cfb761SLei He 
565f0cfb761SLei He static const uint8_t rsa_public_key_lack_element[] = {
566f0cfb761SLei He     /* RSAPublicKey, offset: 0, length: 67 */
567f0cfb761SLei He     0x30, 0x81, 0x43,
568f0cfb761SLei He     /* n, offset: 7, length: 65 */
569f0cfb761SLei He     0x02, 0x41,
570f0cfb761SLei He     0x00, 0xb9, 0xe1, 0x22, 0xdb, 0x56, 0x2f, 0xb6,
571f0cfb761SLei He     0xf7, 0xf0, 0x0a, 0x87, 0x43, 0x07, 0x12, 0xdb,
572f0cfb761SLei He     0x6d, 0xb6, 0x2b, 0x41, 0x8d, 0x2c, 0x3c, 0xa5,
573f0cfb761SLei He     0xdd, 0x78, 0x9a, 0x8f, 0xab, 0x8e, 0xf2, 0x4a,
574f0cfb761SLei He     0xc8, 0x34, 0x0c, 0x12, 0x4f, 0x11, 0x90, 0xc6,
575f0cfb761SLei He     0xc2, 0xa5, 0xd0, 0xcd, 0xfb, 0xfc, 0x2c, 0x95,
576f0cfb761SLei He     0x56, 0x82, 0xdf, 0x39, 0xf3, 0x3b, 0x1d, 0x62,
577f0cfb761SLei He     0x26, 0x97, 0xb7, 0x93, 0x25, 0xc7, 0xec, 0x7e,
578f0cfb761SLei He     0xf7,
579f0cfb761SLei He     /* lack element: e */
580f0cfb761SLei He };
581f0cfb761SLei He 
582f0cfb761SLei He static const uint8_t rsa_public_key_empty_element[] = {
583f0cfb761SLei He     /* RSAPublicKey, offset: 0, length: 69 */
584f0cfb761SLei He     0x30, 0x81, 0x45,
585f0cfb761SLei He     /* n, offset: 7, length: 65 */
586f0cfb761SLei He     0x02, 0x41,
587f0cfb761SLei He     0x00, 0xb9, 0xe1, 0x22, 0xdb, 0x56, 0x2f, 0xb6,
588f0cfb761SLei He     0xf7, 0xf0, 0x0a, 0x87, 0x43, 0x07, 0x12, 0xdb,
589f0cfb761SLei He     0x6d, 0xb6, 0x2b, 0x41, 0x8d, 0x2c, 0x3c, 0xa5,
590f0cfb761SLei He     0xdd, 0x78, 0x9a, 0x8f, 0xab, 0x8e, 0xf2, 0x4a,
591f0cfb761SLei He     0xc8, 0x34, 0x0c, 0x12, 0x4f, 0x11, 0x90, 0xc6,
592f0cfb761SLei He     0xc2, 0xa5, 0xd0, 0xcd, 0xfb, 0xfc, 0x2c, 0x95,
593f0cfb761SLei He     0x56, 0x82, 0xdf, 0x39, 0xf3, 0x3b, 0x1d, 0x62,
594f0cfb761SLei He     0x26, 0x97, 0xb7, 0x93, 0x25, 0xc7, 0xec, 0x7e,
595f0cfb761SLei He     0xf7,
596f0cfb761SLei He     /* e: empty element */
597f0cfb761SLei He     0x02, 0x00,
598f0cfb761SLei He };
599f0cfb761SLei He 
600f0cfb761SLei He static const uint8_t rsa_private_key_empty_element[] = {
601f0cfb761SLei He     /* RSAPrivateKey, offset: 0, length: 19 */
602f0cfb761SLei He     0x30, 0x81, 0x13,
603f0cfb761SLei He     /* version, offset: 4, length: 1 */
604f0cfb761SLei He     0x02, 0x01, 0x00,
605f0cfb761SLei He     /* n: empty element */
606f0cfb761SLei He     0x02, 0x00,
607f0cfb761SLei He     /* e: empty element */
608f0cfb761SLei He     0x02, 0x00,
609f0cfb761SLei He     /* d: empty element */
610f0cfb761SLei He     0x02, 0x00,
611f0cfb761SLei He     /* p: empty element */
612f0cfb761SLei He     0x02, 0x00,
613f0cfb761SLei He     /* q: empty element */
614f0cfb761SLei He     0x02, 0x00,
615f0cfb761SLei He     /* dp: empty element */
616f0cfb761SLei He     0x02, 0x00,
617f0cfb761SLei He     /* dq: empty element */
618f0cfb761SLei He     0x02, 0x00,
619f0cfb761SLei He     /* u: empty element */
620f0cfb761SLei He     0x02, 0x00,
621f0cfb761SLei He };
622f0cfb761SLei He 
623f0cfb761SLei He static const uint8_t rsa_public_key_invalid_length_val[] = {
624f0cfb761SLei He     /* RSAPublicKey, INVALID length: 313 */
625f0cfb761SLei He     0x30, 0x82, 0x01, 0x39,
626f0cfb761SLei He     /* n, offset: 7, length: 65 */
627f0cfb761SLei He     0x02, 0x41,
628f0cfb761SLei He     0x00, 0xb9, 0xe1, 0x22, 0xdb, 0x56, 0x2f, 0xb6,
629f0cfb761SLei He     0xf7, 0xf0, 0x0a, 0x87, 0x43, 0x07, 0x12, 0xdb,
630f0cfb761SLei He     0x6d, 0xb6, 0x2b, 0x41, 0x8d, 0x2c, 0x3c, 0xa5,
631f0cfb761SLei He     0xdd, 0x78, 0x9a, 0x8f, 0xab, 0x8e, 0xf2, 0x4a,
632f0cfb761SLei He     0xc8, 0x34, 0x0c, 0x12, 0x4f, 0x11, 0x90, 0xc6,
633f0cfb761SLei He     0xc2, 0xa5, 0xd0, 0xcd, 0xfb, 0xfc, 0x2c, 0x95,
634f0cfb761SLei He     0x56, 0x82, 0xdf, 0x39, 0xf3, 0x3b, 0x1d, 0x62,
635f0cfb761SLei He     0x26, 0x97, 0xb7, 0x93, 0x25, 0xc7, 0xec, 0x7e,
636f0cfb761SLei He     0xf7,
637f0cfb761SLei He     /* e, */
638f0cfb761SLei He     0x02, 0x03, 0x01, 0x00, 0x01,  /* INTEGER, offset: 74, length: 3 */
639f0cfb761SLei He };
640f0cfb761SLei He 
641f0cfb761SLei He static const uint8_t rsa_public_key_extra_elem[] = {
642f0cfb761SLei He     /* RSAPublicKey, length: 80 */
643f0cfb761SLei He     0x30, 0x81, 0x50,
644f0cfb761SLei He     /* n, offset: 7, length: 65 */
645f0cfb761SLei He     0x02, 0x41,
646f0cfb761SLei He     0x00, 0xb9, 0xe1, 0x22, 0xdb, 0x56, 0x2f, 0xb6,
647f0cfb761SLei He     0xf7, 0xf0, 0x0a, 0x87, 0x43, 0x07, 0x12, 0xdb,
648f0cfb761SLei He     0x6d, 0xb6, 0x2b, 0x41, 0x8d, 0x2c, 0x3c, 0xa5,
649f0cfb761SLei He     0xdd, 0x78, 0x9a, 0x8f, 0xab, 0x8e, 0xf2, 0x4a,
650f0cfb761SLei He     0xc8, 0x34, 0x0c, 0x12, 0x4f, 0x11, 0x90, 0xc6,
651f0cfb761SLei He     0xc2, 0xa5, 0xd0, 0xcd, 0xfb, 0xfc, 0x2c, 0x95,
652f0cfb761SLei He     0x56, 0x82, 0xdf, 0x39, 0xf3, 0x3b, 0x1d, 0x62,
653f0cfb761SLei He     0x26, 0x97, 0xb7, 0x93, 0x25, 0xc7, 0xec, 0x7e,
654f0cfb761SLei He     0xf7,
655f0cfb761SLei He     /* e, offset: 74, length: 3 */
656f0cfb761SLei He     0x02, 0x03, 0x01, 0x00, 0x01,
657f0cfb761SLei He     /* Additional integer field, length 3 */
658f0cfb761SLei He     0x02, 0x06, 0xe1, 0x22, 0xdb, 0xe1, 0x22, 0xdb,
659f0cfb761SLei He };
660f0cfb761SLei He 
661f0cfb761SLei He typedef struct QCryptoRSAKeyTestData QCryptoRSAKeyTestData;
662f0cfb761SLei He struct QCryptoRSAKeyTestData {
663f0cfb761SLei He     const char *path;
664f0cfb761SLei He     QCryptoAkCipherKeyType key_type;
665f0cfb761SLei He     QCryptoAkCipherOptions opt;
666f0cfb761SLei He     const uint8_t *key;
667f0cfb761SLei He     size_t keylen;
668f0cfb761SLei He     bool is_valid_key;
669f0cfb761SLei He     size_t exp_key_len;
670f0cfb761SLei He };
671f0cfb761SLei He 
672689309c4SLei He typedef struct QCryptoAkCipherTestData QCryptoAkCipherTestData;
673689309c4SLei He struct QCryptoAkCipherTestData {
674689309c4SLei He     const char *path;
675689309c4SLei He     QCryptoAkCipherOptions opt;
676689309c4SLei He 
677689309c4SLei He     const uint8_t *priv_key;
678689309c4SLei He     size_t priv_key_len;
679689309c4SLei He     const uint8_t *pub_key;
680689309c4SLei He     size_t pub_key_len;
681689309c4SLei He 
682689309c4SLei He     const uint8_t *plaintext;
683689309c4SLei He     size_t plen;
684689309c4SLei He     const uint8_t *ciphertext;
685689309c4SLei He     size_t clen;
686689309c4SLei He     const uint8_t *dgst;
687689309c4SLei He     size_t dlen;
688689309c4SLei He     const uint8_t *signature;
689689309c4SLei He     size_t slen;
690689309c4SLei He };
691689309c4SLei He 
692f0cfb761SLei He static QCryptoRSAKeyTestData rsakey_test_data[] = {
693f0cfb761SLei He     {
694f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-1024-public",
695f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
696f0cfb761SLei He         .key = rsa1024_public_key,
697f0cfb761SLei He         .keylen = sizeof(rsa1024_public_key),
698f0cfb761SLei He         .is_valid_key = true,
699f0cfb761SLei He         .exp_key_len = 128,
700f0cfb761SLei He     },
701f0cfb761SLei He     {
702f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-1024-private",
703f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
704f0cfb761SLei He         .key = rsa1024_private_key,
705f0cfb761SLei He         .keylen = sizeof(rsa1024_private_key),
706f0cfb761SLei He         .is_valid_key = true,
707f0cfb761SLei He         .exp_key_len = 128,
708f0cfb761SLei He     },
709f0cfb761SLei He     {
710f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-2048-public",
711f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
712f0cfb761SLei He         .key = rsa2048_public_key,
713f0cfb761SLei He         .keylen = sizeof(rsa2048_public_key),
714f0cfb761SLei He         .is_valid_key = true,
715f0cfb761SLei He         .exp_key_len = 256,
716f0cfb761SLei He     },
717f0cfb761SLei He     {
718f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-2048-private",
719f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
720f0cfb761SLei He         .key = rsa2048_private_key,
721f0cfb761SLei He         .keylen = sizeof(rsa2048_private_key),
722f0cfb761SLei He         .is_valid_key = true,
723f0cfb761SLei He         .exp_key_len = 256,
724f0cfb761SLei He     },
725f0cfb761SLei He     {
726f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-public-lack-elem",
727f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
728f0cfb761SLei He         .key = rsa_public_key_lack_element,
729f0cfb761SLei He         .keylen = sizeof(rsa_public_key_lack_element),
730f0cfb761SLei He         .is_valid_key = false,
731f0cfb761SLei He     },
732f0cfb761SLei He     {
733f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-private-lack-elem",
734f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
735f0cfb761SLei He         .key = rsa_private_key_lack_element,
736f0cfb761SLei He         .keylen = sizeof(rsa_private_key_lack_element),
737f0cfb761SLei He         .is_valid_key = false,
738f0cfb761SLei He     },
739f0cfb761SLei He     {
740f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-public-empty-elem",
741f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
742f0cfb761SLei He         .key = rsa_public_key_empty_element,
743f0cfb761SLei He         .keylen = sizeof(rsa_public_key_empty_element),
744f0cfb761SLei He         .is_valid_key = false,
745f0cfb761SLei He     },
746f0cfb761SLei He     {
747f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-private-empty-elem",
748f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
749f0cfb761SLei He         .key = rsa_private_key_empty_element,
750f0cfb761SLei He         .keylen = sizeof(rsa_private_key_empty_element),
751f0cfb761SLei He         .is_valid_key = false,
752f0cfb761SLei He     },
753f0cfb761SLei He     {
754f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-public-empty-key",
755f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
756f0cfb761SLei He         .key = NULL,
757f0cfb761SLei He         .keylen = 0,
758f0cfb761SLei He         .is_valid_key = false,
759f0cfb761SLei He     },
760f0cfb761SLei He     {
761f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-private-empty-key",
762f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
763f0cfb761SLei He         .key = NULL,
764f0cfb761SLei He         .keylen = 0,
765f0cfb761SLei He         .is_valid_key = false,
766f0cfb761SLei He     },
767f0cfb761SLei He     {
768f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-public-invalid-length-val",
769f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
770f0cfb761SLei He         .key = rsa_public_key_invalid_length_val,
771f0cfb761SLei He         .keylen = sizeof(rsa_public_key_invalid_length_val),
772f0cfb761SLei He         .is_valid_key = false,
773f0cfb761SLei He     },
774f0cfb761SLei He     {
775f0cfb761SLei He         .path = "/crypto/akcipher/rsakey-public-extra-elem",
776f0cfb761SLei He         .key_type = QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
777f0cfb761SLei He         .key = rsa_public_key_extra_elem,
778f0cfb761SLei He         .keylen = sizeof(rsa_public_key_extra_elem),
779f0cfb761SLei He         .is_valid_key = false,
780f0cfb761SLei He     },
781f0cfb761SLei He };
782f0cfb761SLei He 
783f0cfb761SLei He static QCryptoAkCipherTestData akcipher_test_data[] = {
784689309c4SLei He     /* rsa1024 with raw padding */
785689309c4SLei He     {
786689309c4SLei He         .path = "/crypto/akcipher/rsa1024-raw",
787689309c4SLei He         .opt = {
788689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
789689309c4SLei He             .u.rsa = {
790689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
791689309c4SLei He             },
792689309c4SLei He         },
793689309c4SLei He         .pub_key = rsa1024_public_key,
794689309c4SLei He         .pub_key_len = sizeof(rsa1024_public_key),
795689309c4SLei He         .priv_key = rsa1024_private_key,
796689309c4SLei He         .priv_key_len = sizeof(rsa1024_private_key),
797689309c4SLei He 
798689309c4SLei He         .plaintext = test_plaintext,
799689309c4SLei He         .plen = 128,
800689309c4SLei He         .ciphertext = exp_ciphertext_rsa1024_raw,
801689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa1024_raw),
802689309c4SLei He     },
803689309c4SLei He 
804689309c4SLei He     /* rsa1024 with pkcs1 padding */
805689309c4SLei He     {
806689309c4SLei He         .path = "/crypto/akcipher/rsa1024-pkcs1",
807689309c4SLei He         .opt = {
808689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
809689309c4SLei He             .u.rsa = {
810689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
811689309c4SLei He                 .hash_alg = QCRYPTO_HASH_ALG_SHA1,
812689309c4SLei He             },
813689309c4SLei He         },
814689309c4SLei He         .pub_key = rsa1024_public_key,
815689309c4SLei He         .pub_key_len = sizeof(rsa1024_public_key),
816689309c4SLei He         .priv_key = rsa1024_private_key,
817689309c4SLei He         .priv_key_len = sizeof(rsa1024_private_key),
818689309c4SLei He 
819689309c4SLei He         .plaintext = test_plaintext,
820689309c4SLei He         .plen = 64,
821689309c4SLei He         .ciphertext = exp_ciphertext_rsa1024_pkcs1,
822689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa1024_pkcs1),
823689309c4SLei He         .dgst = test_sha1_dgst,
824689309c4SLei He         .dlen = sizeof(test_sha1_dgst),
825689309c4SLei He         .signature = exp_signature_rsa1024_pkcs1,
826689309c4SLei He         .slen = sizeof(exp_signature_rsa1024_pkcs1),
827689309c4SLei He     },
828689309c4SLei He 
829689309c4SLei He     /* rsa2048 with raw padding */
830689309c4SLei He     {
831689309c4SLei He         .path = "/crypto/akcipher/rsa2048-raw",
832689309c4SLei He         .opt = {
833689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
834689309c4SLei He             .u.rsa = {
835689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
836689309c4SLei He             },
837689309c4SLei He         },
838689309c4SLei He         .pub_key = rsa2048_public_key,
839689309c4SLei He         .pub_key_len = sizeof(rsa2048_public_key),
840689309c4SLei He         .priv_key = rsa2048_private_key,
841689309c4SLei He         .priv_key_len = sizeof(rsa2048_private_key),
842689309c4SLei He 
843689309c4SLei He         .plaintext = test_plaintext,
844689309c4SLei He         .plen = 256,
845689309c4SLei He         .ciphertext = exp_ciphertext_rsa2048_raw,
846689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa2048_raw),
847689309c4SLei He     },
848689309c4SLei He 
849689309c4SLei He     /* rsa2048 with pkcs1 padding */
850689309c4SLei He     {
851689309c4SLei He         .path = "/crypto/akcipher/rsa2048-pkcs1",
852689309c4SLei He         .opt = {
853689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
854689309c4SLei He             .u.rsa = {
855689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
856689309c4SLei He                 .hash_alg = QCRYPTO_HASH_ALG_SHA1,
857689309c4SLei He             },
858689309c4SLei He         },
859689309c4SLei He         .pub_key = rsa2048_public_key,
860689309c4SLei He         .pub_key_len = sizeof(rsa2048_public_key),
861689309c4SLei He         .priv_key = rsa2048_private_key,
862689309c4SLei He         .priv_key_len = sizeof(rsa2048_private_key),
863689309c4SLei He 
864689309c4SLei He         .plaintext = test_plaintext,
865689309c4SLei He         .plen = 128,
866689309c4SLei He         .ciphertext = exp_ciphertext_rsa2048_pkcs1,
867689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa2048_pkcs1),
868689309c4SLei He         .dgst = test_sha1_dgst,
869689309c4SLei He         .dlen = sizeof(test_sha1_dgst),
870689309c4SLei He         .signature = exp_signature_rsa2048_pkcs1,
871689309c4SLei He         .slen = sizeof(exp_signature_rsa2048_pkcs1),
872689309c4SLei He     },
873689309c4SLei He 
874689309c4SLei He };
875689309c4SLei He 
test_akcipher(const void * opaque)876689309c4SLei He static void test_akcipher(const void *opaque)
877689309c4SLei He {
878689309c4SLei He     const QCryptoAkCipherTestData *data = opaque;
879689309c4SLei He     g_autofree uint8_t *plaintext = NULL;
880689309c4SLei He     g_autofree uint8_t *ciphertext = NULL;
881689309c4SLei He     g_autofree uint8_t *signature = NULL;
882689309c4SLei He     QCryptoAkCipher *pub_key, *priv_key;
883689309c4SLei He 
884689309c4SLei He     if (!qcrypto_akcipher_supports((QCryptoAkCipherOptions *)&data->opt)) {
885689309c4SLei He         return;
886689309c4SLei He     }
887689309c4SLei He     pub_key = qcrypto_akcipher_new(&data->opt,
888689309c4SLei He                                    QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
889689309c4SLei He                                    data->pub_key, data->pub_key_len,
890689309c4SLei He                                    &error_abort);
891689309c4SLei He     g_assert(pub_key != NULL);
892689309c4SLei He     priv_key = qcrypto_akcipher_new(&data->opt,
893689309c4SLei He                                     QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
894689309c4SLei He                                     data->priv_key, data->priv_key_len,
895689309c4SLei He                                     &error_abort);
896689309c4SLei He     g_assert(priv_key != NULL);
897689309c4SLei He 
898689309c4SLei He     if (data->plaintext != NULL) {
899689309c4SLei He 
900689309c4SLei He         ciphertext = g_new0(uint8_t, data->clen);
901689309c4SLei He         g_assert(qcrypto_akcipher_encrypt(pub_key, data->plaintext, data->plen,
902689309c4SLei He                                           ciphertext, data->clen,
903689309c4SLei He                                           &error_abort) > 0);
904689309c4SLei He 
905689309c4SLei He         /**
906689309c4SLei He          * In the asymmetric encryption algorithms, the ciphertext generated
907689309c4SLei He          * each time may be different, here only compare the decrypted
908689309c4SLei He          * plaintext
909689309c4SLei He          */
910689309c4SLei He         plaintext = g_new0(uint8_t, data->clen);
911689309c4SLei He         g_assert(qcrypto_akcipher_decrypt(priv_key, ciphertext,
912689309c4SLei He                                           data->clen, plaintext,
913689309c4SLei He                                           data->plen,
914689309c4SLei He                                           &error_abort) == data->plen);
915689309c4SLei He         g_assert(!memcmp(plaintext, data->plaintext, data->plen));
916689309c4SLei He     }
917689309c4SLei He 
918689309c4SLei He     if (data->signature != NULL) {
919689309c4SLei He         signature = g_new(uint8_t, data->slen);
920689309c4SLei He         g_assert(qcrypto_akcipher_sign(priv_key, data->dgst, data->dlen,
921689309c4SLei He                                        signature, data->slen,
922689309c4SLei He                                        &error_abort) > 0);
923689309c4SLei He         /**
924689309c4SLei He          * The signature generated each time may be different, here only check
925689309c4SLei He          * the verification.
926689309c4SLei He          */
927689309c4SLei He         g_assert(qcrypto_akcipher_verify(pub_key, data->signature, data->slen,
928689309c4SLei He                                          data->dgst, data->dlen,
929689309c4SLei He                                          &error_abort) == 0);
930689309c4SLei He         g_assert(qcrypto_akcipher_verify(pub_key, signature, data->slen,
931689309c4SLei He                                          data->dgst, data->dlen,
932689309c4SLei He                                          &error_abort) == 0);
933689309c4SLei He         ++signature[0];
934689309c4SLei He         /* Here error should be ignored */
935689309c4SLei He         g_assert(qcrypto_akcipher_verify(pub_key, signature, data->slen,
936689309c4SLei He                                          data->dgst, data->dlen, NULL) != 0);
937689309c4SLei He     }
938689309c4SLei He 
939689309c4SLei He     qcrypto_akcipher_free(pub_key);
940689309c4SLei He     qcrypto_akcipher_free(priv_key);
941689309c4SLei He }
942689309c4SLei He 
test_rsakey(const void * opaque)943f0cfb761SLei He static void test_rsakey(const void *opaque)
944f0cfb761SLei He {
945f0cfb761SLei He     const QCryptoRSAKeyTestData *data = (const QCryptoRSAKeyTestData *)opaque;
946f0cfb761SLei He     QCryptoAkCipherOptions opt = {
947f0cfb761SLei He         .alg = QCRYPTO_AKCIPHER_ALG_RSA,
948f0cfb761SLei He         .u.rsa = {
949f0cfb761SLei He             .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
950f0cfb761SLei He             .hash_alg = QCRYPTO_HASH_ALG_SHA1,
951f0cfb761SLei He         }
952f0cfb761SLei He     };
953f0cfb761SLei He     g_autoptr(QCryptoAkCipher) key = qcrypto_akcipher_new(
954f0cfb761SLei He         &opt, data->key_type, data->key, data->keylen, NULL);
955f0cfb761SLei He 
956f0cfb761SLei He     if (!qcrypto_akcipher_supports(&opt)) {
957f0cfb761SLei He         return;
958f0cfb761SLei He     }
959f0cfb761SLei He 
960f0cfb761SLei He     if (!data->is_valid_key) {
961f0cfb761SLei He         g_assert(key == NULL);
962f0cfb761SLei He         return;
963f0cfb761SLei He     }
964f0cfb761SLei He 
965f0cfb761SLei He     g_assert(key != NULL);
966f0cfb761SLei He     g_assert(qcrypto_akcipher_max_ciphertext_len(key) == data->exp_key_len);
967f0cfb761SLei He     g_assert(qcrypto_akcipher_max_plaintext_len(key) == data->exp_key_len);
968f0cfb761SLei He     g_assert(qcrypto_akcipher_max_signature_len(key) == data->exp_key_len);
969f0cfb761SLei He     g_assert(qcrypto_akcipher_max_dgst_len(key) == data->exp_key_len);
970f0cfb761SLei He }
971f0cfb761SLei He 
main(int argc,char ** argv)972689309c4SLei He int main(int argc, char **argv)
973689309c4SLei He {
974689309c4SLei He     size_t i;
975689309c4SLei He     g_test_init(&argc, &argv, NULL);
976689309c4SLei He     g_assert(qcrypto_init(NULL) == 0);
977689309c4SLei He 
978f0cfb761SLei He     for (i = 0; i < G_N_ELEMENTS(akcipher_test_data); i++) {
979f0cfb761SLei He         g_test_add_data_func(akcipher_test_data[i].path,
980f0cfb761SLei He                              &akcipher_test_data[i],
981f0cfb761SLei He                              test_akcipher);
982f0cfb761SLei He     }
983f0cfb761SLei He     for (i = 0; i < G_N_ELEMENTS(rsakey_test_data); i++) {
984f0cfb761SLei He         g_test_add_data_func(rsakey_test_data[i].path,
985f0cfb761SLei He                              &rsakey_test_data[i],
986f0cfb761SLei He                              test_rsakey);
987689309c4SLei He     }
988689309c4SLei He 
989689309c4SLei He     return g_test_run();
990689309c4SLei He }
991