xref: /qemu/tests/unit/test-crypto-akcipher.c (revision 689309c4ac40f01b93f29d66282d044c10d8e2e1)
1*689309c4SLei He /*
2*689309c4SLei He  * QEMU Crypto cipher algorithms
3*689309c4SLei He  *
4*689309c4SLei He  * Copyright (c) 2022 Bytedance
5*689309c4SLei He  * Author: lei he <helei.sig11@bytedance.com>
6*689309c4SLei He  *
7*689309c4SLei He  * This library is free software; you can redistribute it and/or
8*689309c4SLei He  * modify it under the terms of the GNU Lesser General Public
9*689309c4SLei He  * License as published by the Free Software Foundation; either
10*689309c4SLei He  * version 2.1 of the License, or (at your option) any later version.
11*689309c4SLei He  *
12*689309c4SLei He  * This library is distributed in the hope that it will be useful,
13*689309c4SLei He  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14*689309c4SLei He  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15*689309c4SLei He  * Lesser General Public License for more details.
16*689309c4SLei He  *
17*689309c4SLei He  * You should have received a copy of the GNU Lesser General Public
18*689309c4SLei He  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19*689309c4SLei He  *
20*689309c4SLei He  */
21*689309c4SLei He 
22*689309c4SLei He #include "qemu/osdep.h"
23*689309c4SLei He 
24*689309c4SLei He #include "crypto/init.h"
25*689309c4SLei He #include "crypto/akcipher.h"
26*689309c4SLei He #include "qapi/error.h"
27*689309c4SLei He 
28*689309c4SLei He static const uint8_t rsa1024_private_key[] = {
29*689309c4SLei He     0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02,
30*689309c4SLei He     0x81, 0x81, 0x00, 0xe6, 0x4d, 0x76, 0x4f, 0xb2,
31*689309c4SLei He     0x97, 0x09, 0xad, 0x9d, 0x17, 0x33, 0xf2, 0x30,
32*689309c4SLei He     0x42, 0x83, 0xa9, 0xcb, 0x49, 0xa4, 0x2e, 0x59,
33*689309c4SLei He     0x5e, 0x75, 0x51, 0xd1, 0xac, 0xc8, 0x86, 0x3e,
34*689309c4SLei He     0xdb, 0x72, 0x2e, 0xb2, 0xf7, 0xc3, 0x5b, 0xc7,
35*689309c4SLei He     0xea, 0xed, 0x30, 0xd1, 0xf7, 0x37, 0xee, 0x9d,
36*689309c4SLei He     0x36, 0x59, 0x6f, 0xf8, 0xce, 0xc0, 0x5c, 0x82,
37*689309c4SLei He     0x80, 0x37, 0x83, 0xd7, 0x45, 0x6a, 0xe9, 0xea,
38*689309c4SLei He     0xc5, 0x3a, 0x59, 0x6b, 0x34, 0x31, 0x44, 0x00,
39*689309c4SLei He     0x74, 0xa7, 0x29, 0xab, 0x79, 0x4a, 0xbd, 0xe8,
40*689309c4SLei He     0x25, 0x35, 0x01, 0x11, 0x40, 0xbf, 0x31, 0xbd,
41*689309c4SLei He     0xd3, 0xe0, 0x68, 0x1e, 0xd5, 0x5b, 0x2f, 0xe9,
42*689309c4SLei He     0x20, 0xf2, 0x9f, 0x46, 0x35, 0x30, 0xa8, 0xf1,
43*689309c4SLei He     0xfe, 0xef, 0xd8, 0x76, 0x23, 0x46, 0x34, 0x70,
44*689309c4SLei He     0xa1, 0xce, 0xc6, 0x65, 0x6d, 0xb0, 0x94, 0x7e,
45*689309c4SLei He     0xe5, 0x92, 0x45, 0x7b, 0xaa, 0xbb, 0x95, 0x97,
46*689309c4SLei He     0x77, 0xcd, 0xd3, 0x02, 0x03, 0x01, 0x00, 0x01,
47*689309c4SLei He     0x02, 0x81, 0x80, 0x30, 0x6a, 0xc4, 0x9e, 0xc8,
48*689309c4SLei He     0xba, 0xfc, 0x2b, 0xe5, 0xc4, 0xc5, 0x04, 0xfb,
49*689309c4SLei He     0xa4, 0x60, 0x2d, 0xc8, 0x31, 0x39, 0x35, 0x0d,
50*689309c4SLei He     0x50, 0xd0, 0x75, 0x5d, 0x11, 0x68, 0x2e, 0xe0,
51*689309c4SLei He     0xf4, 0x1d, 0xb3, 0x37, 0xa8, 0xe3, 0x07, 0x5e,
52*689309c4SLei He     0xa6, 0x43, 0x2b, 0x6a, 0x59, 0x01, 0x07, 0x47,
53*689309c4SLei He     0x41, 0xef, 0xd7, 0x9c, 0x85, 0x4a, 0xe7, 0xa7,
54*689309c4SLei He     0xff, 0xf0, 0xab, 0xe5, 0x0c, 0x11, 0x08, 0x10,
55*689309c4SLei He     0x75, 0x5a, 0x68, 0xa0, 0x08, 0x03, 0xc9, 0x40,
56*689309c4SLei He     0x79, 0x67, 0x1d, 0x65, 0x89, 0x2d, 0x08, 0xf9,
57*689309c4SLei He     0xb5, 0x1b, 0x7d, 0xd2, 0x41, 0x3b, 0x33, 0xf2,
58*689309c4SLei He     0x47, 0x2f, 0x9c, 0x0b, 0xd5, 0xaf, 0xcb, 0xdb,
59*689309c4SLei He     0xbb, 0x37, 0x63, 0x03, 0xf8, 0xe7, 0x2e, 0xc7,
60*689309c4SLei He     0x3c, 0x86, 0x9f, 0xc2, 0x9b, 0xb4, 0x70, 0x6a,
61*689309c4SLei He     0x4d, 0x7c, 0xe4, 0x1b, 0x3a, 0xa9, 0xae, 0xd7,
62*689309c4SLei He     0xce, 0x7f, 0x56, 0xc2, 0x73, 0x5e, 0x58, 0x63,
63*689309c4SLei He     0xd5, 0x86, 0x41, 0x02, 0x41, 0x00, 0xf6, 0x56,
64*689309c4SLei He     0x69, 0xec, 0xef, 0x65, 0x95, 0xdc, 0x25, 0x47,
65*689309c4SLei He     0xe0, 0x6f, 0xb0, 0x4f, 0x79, 0x77, 0x0a, 0x5e,
66*689309c4SLei He     0x46, 0xcb, 0xbd, 0x0b, 0x71, 0x51, 0x2a, 0xa4,
67*689309c4SLei He     0x65, 0x29, 0x18, 0xc6, 0x30, 0xa0, 0x95, 0x4c,
68*689309c4SLei He     0x4b, 0xbe, 0x8c, 0x40, 0xe3, 0x9c, 0x23, 0x02,
69*689309c4SLei He     0x14, 0x43, 0xe9, 0x64, 0xea, 0xe3, 0xa8, 0xe2,
70*689309c4SLei He     0x1a, 0xd5, 0xf9, 0x5c, 0xe0, 0x36, 0x2c, 0x97,
71*689309c4SLei He     0xda, 0xd5, 0xc7, 0x46, 0xce, 0x11, 0x02, 0x41,
72*689309c4SLei He     0x00, 0xef, 0x56, 0x08, 0xb8, 0x29, 0xa5, 0xa6,
73*689309c4SLei He     0x7c, 0xf7, 0x5f, 0xb4, 0xf5, 0x63, 0xe7, 0xeb,
74*689309c4SLei He     0x45, 0xfd, 0x89, 0xaa, 0x94, 0xa6, 0x3d, 0x0b,
75*689309c4SLei He     0xd9, 0x04, 0x6f, 0x78, 0xe0, 0xbb, 0xa2, 0xd4,
76*689309c4SLei He     0x29, 0x83, 0x17, 0x95, 0x6f, 0x50, 0x3d, 0x40,
77*689309c4SLei He     0x5d, 0xe5, 0x24, 0xda, 0xc2, 0x23, 0x50, 0x86,
78*689309c4SLei He     0xa8, 0x34, 0xc8, 0x6f, 0xec, 0x7f, 0xb6, 0x45,
79*689309c4SLei He     0x3a, 0xdd, 0x78, 0x9b, 0xee, 0xa1, 0xe4, 0x09,
80*689309c4SLei He     0xa3, 0x02, 0x40, 0x5c, 0xd6, 0x66, 0x67, 0x58,
81*689309c4SLei He     0x35, 0xc5, 0xcb, 0xc8, 0xf5, 0x14, 0xbd, 0xa3,
82*689309c4SLei He     0x09, 0xe0, 0xb2, 0x1f, 0x63, 0x36, 0x75, 0x34,
83*689309c4SLei He     0x52, 0xea, 0xaa, 0xf7, 0x52, 0x2b, 0x99, 0xd8,
84*689309c4SLei He     0x6f, 0x61, 0x06, 0x34, 0x1e, 0x23, 0xf1, 0xb5,
85*689309c4SLei He     0x34, 0x03, 0x53, 0xe5, 0xd1, 0xb3, 0xc7, 0x80,
86*689309c4SLei He     0x5f, 0x7b, 0x32, 0xbf, 0x84, 0x2f, 0x2e, 0xf3,
87*689309c4SLei He     0x22, 0xb0, 0x91, 0x5a, 0x2f, 0x04, 0xd7, 0x4a,
88*689309c4SLei He     0x9a, 0x01, 0xb1, 0x02, 0x40, 0x34, 0x0b, 0x26,
89*689309c4SLei He     0x4c, 0x3d, 0xaa, 0x2a, 0xc0, 0xe3, 0xdd, 0xe8,
90*689309c4SLei He     0xf0, 0xaf, 0x6f, 0xe0, 0x06, 0x51, 0x32, 0x9d,
91*689309c4SLei He     0x68, 0x43, 0x99, 0xe4, 0xb8, 0xa5, 0x31, 0x44,
92*689309c4SLei He     0x3c, 0xc2, 0x30, 0x8f, 0x28, 0x13, 0xbc, 0x8e,
93*689309c4SLei He     0x1f, 0x2d, 0x78, 0x94, 0x45, 0x96, 0xad, 0x63,
94*689309c4SLei He     0xf0, 0x71, 0x53, 0x72, 0x64, 0xa3, 0x4d, 0xae,
95*689309c4SLei He     0xa0, 0xe3, 0xc8, 0x93, 0xd7, 0x50, 0x0f, 0x89,
96*689309c4SLei He     0x00, 0xe4, 0x2d, 0x3d, 0x37, 0x02, 0x41, 0x00,
97*689309c4SLei He     0xbe, 0xa6, 0x08, 0xe0, 0xc8, 0x15, 0x2a, 0x47,
98*689309c4SLei He     0xcb, 0xd5, 0xec, 0x93, 0xd3, 0xaa, 0x12, 0x82,
99*689309c4SLei He     0xaf, 0xac, 0x51, 0x5a, 0x5b, 0xa7, 0x93, 0x4b,
100*689309c4SLei He     0xb9, 0xab, 0x00, 0xfa, 0x5a, 0xea, 0x34, 0xe4,
101*689309c4SLei He     0x80, 0xf1, 0x44, 0x6a, 0x65, 0xe4, 0x33, 0x99,
102*689309c4SLei He     0xfb, 0x54, 0xd7, 0x89, 0x5a, 0x1b, 0xd6, 0x2b,
103*689309c4SLei He     0xcc, 0x6e, 0x4b, 0x19, 0xa0, 0x6d, 0x93, 0x9f,
104*689309c4SLei He     0xc3, 0x91, 0x7a, 0xa5, 0xd8, 0x59, 0x0e, 0x9e,
105*689309c4SLei He };
106*689309c4SLei He 
107*689309c4SLei He static const uint8_t rsa1024_public_key[] = {
108*689309c4SLei He     0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xe6,
109*689309c4SLei He     0x4d, 0x76, 0x4f, 0xb2, 0x97, 0x09, 0xad, 0x9d,
110*689309c4SLei He     0x17, 0x33, 0xf2, 0x30, 0x42, 0x83, 0xa9, 0xcb,
111*689309c4SLei He     0x49, 0xa4, 0x2e, 0x59, 0x5e, 0x75, 0x51, 0xd1,
112*689309c4SLei He     0xac, 0xc8, 0x86, 0x3e, 0xdb, 0x72, 0x2e, 0xb2,
113*689309c4SLei He     0xf7, 0xc3, 0x5b, 0xc7, 0xea, 0xed, 0x30, 0xd1,
114*689309c4SLei He     0xf7, 0x37, 0xee, 0x9d, 0x36, 0x59, 0x6f, 0xf8,
115*689309c4SLei He     0xce, 0xc0, 0x5c, 0x82, 0x80, 0x37, 0x83, 0xd7,
116*689309c4SLei He     0x45, 0x6a, 0xe9, 0xea, 0xc5, 0x3a, 0x59, 0x6b,
117*689309c4SLei He     0x34, 0x31, 0x44, 0x00, 0x74, 0xa7, 0x29, 0xab,
118*689309c4SLei He     0x79, 0x4a, 0xbd, 0xe8, 0x25, 0x35, 0x01, 0x11,
119*689309c4SLei He     0x40, 0xbf, 0x31, 0xbd, 0xd3, 0xe0, 0x68, 0x1e,
120*689309c4SLei He     0xd5, 0x5b, 0x2f, 0xe9, 0x20, 0xf2, 0x9f, 0x46,
121*689309c4SLei He     0x35, 0x30, 0xa8, 0xf1, 0xfe, 0xef, 0xd8, 0x76,
122*689309c4SLei He     0x23, 0x46, 0x34, 0x70, 0xa1, 0xce, 0xc6, 0x65,
123*689309c4SLei He     0x6d, 0xb0, 0x94, 0x7e, 0xe5, 0x92, 0x45, 0x7b,
124*689309c4SLei He     0xaa, 0xbb, 0x95, 0x97, 0x77, 0xcd, 0xd3, 0x02,
125*689309c4SLei He     0x03, 0x01, 0x00, 0x01,
126*689309c4SLei He };
127*689309c4SLei He 
128*689309c4SLei He static const uint8_t rsa2048_private_key[] = {
129*689309c4SLei He     0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02,
130*689309c4SLei He     0x82, 0x01, 0x01, 0x00, 0xbd, 0x9c, 0x83, 0x6b,
131*689309c4SLei He     0x0e, 0x8e, 0xcf, 0xfa, 0xaa, 0x4f, 0x6a, 0xf4,
132*689309c4SLei He     0xe3, 0x52, 0x0f, 0xa5, 0xd0, 0xbe, 0x5e, 0x7f,
133*689309c4SLei He     0x08, 0x24, 0xba, 0x87, 0x46, 0xfb, 0x28, 0x93,
134*689309c4SLei He     0xe5, 0xe5, 0x81, 0x42, 0xc0, 0xf9, 0x17, 0xc7,
135*689309c4SLei He     0x81, 0x01, 0xf4, 0x18, 0x6a, 0x17, 0xf5, 0x57,
136*689309c4SLei He     0x20, 0x37, 0xcf, 0xf9, 0x74, 0x5e, 0xe1, 0x48,
137*689309c4SLei He     0x6a, 0x71, 0x0a, 0x0f, 0x79, 0x72, 0x2b, 0x46,
138*689309c4SLei He     0x10, 0x53, 0xdc, 0x14, 0x43, 0xbd, 0xbc, 0x6d,
139*689309c4SLei He     0x15, 0x6f, 0x15, 0x4e, 0xf0, 0x0d, 0x89, 0x39,
140*689309c4SLei He     0x02, 0xc3, 0x68, 0x5c, 0xa8, 0xfc, 0xed, 0x64,
141*689309c4SLei He     0x9d, 0x98, 0xb7, 0xcd, 0x83, 0x66, 0x93, 0xc3,
142*689309c4SLei He     0xd9, 0x57, 0xa0, 0x21, 0x93, 0xad, 0x5c, 0x75,
143*689309c4SLei He     0x69, 0x88, 0x9e, 0x81, 0xdc, 0x7f, 0x1d, 0xd5,
144*689309c4SLei He     0xbd, 0x1c, 0xc1, 0x30, 0x56, 0xa5, 0xda, 0x99,
145*689309c4SLei He     0x46, 0xa6, 0x6d, 0x0e, 0x6f, 0x5e, 0x51, 0x34,
146*689309c4SLei He     0x49, 0x73, 0xc3, 0x67, 0x49, 0x7e, 0x21, 0x2a,
147*689309c4SLei He     0x20, 0xa7, 0x2b, 0x92, 0x73, 0x1d, 0xa5, 0x25,
148*689309c4SLei He     0x2a, 0xd0, 0x3a, 0x89, 0x75, 0xb2, 0xbb, 0x19,
149*689309c4SLei He     0x37, 0x78, 0x48, 0xd2, 0xf2, 0x2a, 0x6d, 0x9e,
150*689309c4SLei He     0xc6, 0x26, 0xca, 0x46, 0x8c, 0xf1, 0x42, 0x2a,
151*689309c4SLei He     0x31, 0xb2, 0xfc, 0xe7, 0x55, 0x51, 0xff, 0x07,
152*689309c4SLei He     0x13, 0x5b, 0x36, 0x59, 0x2b, 0x43, 0x30, 0x4b,
153*689309c4SLei He     0x05, 0x5c, 0xd2, 0x45, 0xa0, 0xa0, 0x7c, 0x17,
154*689309c4SLei He     0x5b, 0x07, 0xbb, 0x5d, 0x83, 0x80, 0x92, 0x6d,
155*689309c4SLei He     0x87, 0x1a, 0x43, 0xac, 0xc7, 0x6b, 0x8d, 0x11,
156*689309c4SLei He     0x60, 0x27, 0xd2, 0xdf, 0xdb, 0x71, 0x02, 0x55,
157*689309c4SLei He     0x6e, 0xb5, 0xca, 0x4d, 0xda, 0x59, 0x0d, 0xb8,
158*689309c4SLei He     0x8c, 0xcd, 0xd3, 0x0e, 0x55, 0xa0, 0xa4, 0x8d,
159*689309c4SLei He     0xa0, 0x14, 0x10, 0x48, 0x42, 0x35, 0x56, 0x08,
160*689309c4SLei He     0xf7, 0x29, 0x5f, 0xa2, 0xea, 0xa4, 0x5e, 0x8e,
161*689309c4SLei He     0x99, 0x56, 0xaa, 0x5a, 0x8c, 0x23, 0x8f, 0x35,
162*689309c4SLei He     0x22, 0x8a, 0xff, 0xed, 0x02, 0x03, 0x01, 0x00,
163*689309c4SLei He     0x01, 0x02, 0x82, 0x01, 0x00, 0x4e, 0x4a, 0xf3,
164*689309c4SLei He     0x44, 0xe0, 0x64, 0xfd, 0xe1, 0xde, 0x33, 0x1e,
165*689309c4SLei He     0xd1, 0xf1, 0x8f, 0x6f, 0xe0, 0xa2, 0xfa, 0x08,
166*689309c4SLei He     0x60, 0xe1, 0xc6, 0xf0, 0xb2, 0x6d, 0x0f, 0xc6,
167*689309c4SLei He     0x28, 0x93, 0xb4, 0x19, 0x94, 0xab, 0xc3, 0xef,
168*689309c4SLei He     0x1a, 0xb4, 0xdd, 0x4e, 0xa2, 0x4a, 0x24, 0x8c,
169*689309c4SLei He     0x6c, 0xa6, 0x64, 0x05, 0x5f, 0x56, 0xba, 0xda,
170*689309c4SLei He     0xc1, 0x21, 0x1a, 0x7d, 0xf1, 0xf7, 0xce, 0xb9,
171*689309c4SLei He     0xa9, 0x9b, 0x92, 0x54, 0xfc, 0x95, 0x20, 0x22,
172*689309c4SLei He     0x4e, 0xd4, 0x9b, 0xe2, 0xab, 0x8e, 0x99, 0xb8,
173*689309c4SLei He     0x40, 0xaf, 0x30, 0x6a, 0xc6, 0x60, 0x0c, 0xd8,
174*689309c4SLei He     0x25, 0x44, 0xa1, 0xcb, 0xbb, 0x73, 0x77, 0x86,
175*689309c4SLei He     0xaa, 0x46, 0xf3, 0x54, 0xae, 0xa8, 0xa0, 0xdb,
176*689309c4SLei He     0xdd, 0xab, 0x6e, 0xfb, 0x2c, 0x5a, 0x14, 0xaf,
177*689309c4SLei He     0x08, 0x13, 0xa7, 0x6c, 0xe9, 0xfd, 0xcd, 0x4c,
178*689309c4SLei He     0x1f, 0x20, 0x3a, 0x16, 0x2b, 0xf0, 0xb6, 0x7c,
179*689309c4SLei He     0x47, 0x5f, 0xd1, 0x0a, 0x2c, 0xc4, 0xa5, 0x68,
180*689309c4SLei He     0xd0, 0x43, 0x75, 0x6b, 0x65, 0xaa, 0x32, 0xc6,
181*689309c4SLei He     0x99, 0x06, 0xcb, 0x8f, 0xe6, 0x8d, 0xce, 0xbf,
182*689309c4SLei He     0x4d, 0x0d, 0x7b, 0x22, 0x2a, 0x8a, 0xcb, 0x7d,
183*689309c4SLei He     0x7f, 0x16, 0x48, 0x85, 0xf1, 0x86, 0xcb, 0x54,
184*689309c4SLei He     0xb9, 0x39, 0xd4, 0xbc, 0xe3, 0x2d, 0x27, 0x59,
185*689309c4SLei He     0xf6, 0x81, 0x5e, 0x94, 0x45, 0xdf, 0xb9, 0x22,
186*689309c4SLei He     0xaf, 0x64, 0x0d, 0x14, 0xec, 0x8c, 0xeb, 0x71,
187*689309c4SLei He     0xac, 0xee, 0x09, 0x4c, 0xbf, 0x34, 0xf9, 0xf4,
188*689309c4SLei He     0x66, 0x77, 0x36, 0x3b, 0x41, 0x74, 0x01, 0x4f,
189*689309c4SLei He     0xfc, 0x56, 0x83, 0xba, 0x14, 0xb0, 0x2f, 0xdd,
190*689309c4SLei He     0x4d, 0xb9, 0x3f, 0xdf, 0x71, 0xbe, 0x7b, 0xba,
191*689309c4SLei He     0x66, 0xc8, 0xc5, 0x42, 0xc9, 0xba, 0x18, 0x63,
192*689309c4SLei He     0x45, 0x07, 0x2f, 0x84, 0x3e, 0xc3, 0xfb, 0x47,
193*689309c4SLei He     0xda, 0xd4, 0x1d, 0x0e, 0x9d, 0x96, 0xc0, 0xea,
194*689309c4SLei He     0xee, 0x45, 0x2f, 0xe1, 0x62, 0x23, 0xee, 0xef,
195*689309c4SLei He     0x3d, 0x5e, 0x55, 0xa1, 0x0d, 0x02, 0x81, 0x81,
196*689309c4SLei He     0x00, 0xeb, 0x76, 0x88, 0xd3, 0xae, 0x3f, 0x1d,
197*689309c4SLei He     0xf2, 0x49, 0xe0, 0x37, 0x49, 0x83, 0x82, 0x6c,
198*689309c4SLei He     0xf7, 0xf1, 0x17, 0x30, 0x75, 0x2e, 0x89, 0x06,
199*689309c4SLei He     0x88, 0x56, 0x32, 0xf6, 0xfa, 0x58, 0xcb, 0x3c,
200*689309c4SLei He     0x98, 0x67, 0xc3, 0xde, 0x10, 0x82, 0xe5, 0xfa,
201*689309c4SLei He     0xfa, 0x52, 0x47, 0x8d, 0xd7, 0x00, 0xc6, 0xcb,
202*689309c4SLei He     0xf7, 0xf6, 0x57, 0x9b, 0x6e, 0x0c, 0xac, 0xe8,
203*689309c4SLei He     0x3b, 0xd1, 0xde, 0xb5, 0x34, 0xaf, 0x8b, 0x2a,
204*689309c4SLei He     0xb0, 0x2d, 0x01, 0xeb, 0x7c, 0xa0, 0x42, 0x26,
205*689309c4SLei He     0xbb, 0x2b, 0x43, 0x0e, 0x1d, 0xe2, 0x4e, 0xc9,
206*689309c4SLei He     0xc1, 0x0a, 0x67, 0x1d, 0xfc, 0x83, 0x25, 0xce,
207*689309c4SLei He     0xb2, 0x18, 0xd9, 0x0d, 0x70, 0xf5, 0xa3, 0x5a,
208*689309c4SLei He     0x9c, 0x99, 0xdd, 0x47, 0xa1, 0x57, 0xe7, 0x20,
209*689309c4SLei He     0xde, 0xa1, 0x29, 0x8d, 0x96, 0x62, 0xf9, 0x26,
210*689309c4SLei He     0x95, 0x51, 0xa6, 0xe7, 0x09, 0x8b, 0xba, 0x16,
211*689309c4SLei He     0x8b, 0x19, 0x5b, 0xf9, 0x27, 0x0d, 0xc5, 0xd6,
212*689309c4SLei He     0x5f, 0x02, 0x81, 0x81, 0x00, 0xce, 0x26, 0x31,
213*689309c4SLei He     0xb5, 0x43, 0x53, 0x95, 0x39, 0xdd, 0x01, 0x98,
214*689309c4SLei He     0x8b, 0x3d, 0x27, 0xeb, 0x0b, 0x87, 0x1c, 0x95,
215*689309c4SLei He     0xfc, 0x3e, 0x36, 0x51, 0x31, 0xb5, 0xea, 0x59,
216*689309c4SLei He     0x56, 0xc0, 0x97, 0x62, 0xf0, 0x63, 0x2b, 0xb6,
217*689309c4SLei He     0x30, 0x9b, 0xdf, 0x19, 0x10, 0xe9, 0xa0, 0x3d,
218*689309c4SLei He     0xea, 0x54, 0x5a, 0xe6, 0xc6, 0x9e, 0x7e, 0xb5,
219*689309c4SLei He     0xf0, 0xb0, 0x54, 0xef, 0xc3, 0xe1, 0x47, 0xa6,
220*689309c4SLei He     0x95, 0xc7, 0xe4, 0xa3, 0x4a, 0x30, 0x68, 0x24,
221*689309c4SLei He     0x98, 0x7d, 0xc1, 0x34, 0xa9, 0xcb, 0xbc, 0x3c,
222*689309c4SLei He     0x08, 0x9c, 0x7d, 0x0c, 0xa2, 0xb7, 0x60, 0xaa,
223*689309c4SLei He     0x38, 0x08, 0x16, 0xa6, 0x7f, 0xdb, 0xd2, 0xb1,
224*689309c4SLei He     0x67, 0xe7, 0x93, 0x8e, 0xbb, 0x7e, 0xb9, 0xb5,
225*689309c4SLei He     0xd0, 0xd0, 0x9f, 0x7b, 0xcc, 0x46, 0xe6, 0x74,
226*689309c4SLei He     0x78, 0x1a, 0x96, 0xd6, 0xd7, 0x74, 0x34, 0x54,
227*689309c4SLei He     0x3b, 0x54, 0x55, 0x7f, 0x89, 0x81, 0xbc, 0x40,
228*689309c4SLei He     0x55, 0x87, 0x24, 0x95, 0x33, 0x02, 0x81, 0x81,
229*689309c4SLei He     0x00, 0xb0, 0x18, 0x5d, 0x2a, 0x1a, 0x95, 0x9f,
230*689309c4SLei He     0x9a, 0xd5, 0x3f, 0x37, 0x79, 0xe6, 0x3d, 0x83,
231*689309c4SLei He     0xab, 0x46, 0x86, 0x36, 0x3a, 0x5d, 0x0c, 0x23,
232*689309c4SLei He     0x73, 0x91, 0x2b, 0xda, 0x63, 0xce, 0x46, 0x68,
233*689309c4SLei He     0xd1, 0xfe, 0x40, 0x90, 0xf2, 0x3e, 0x43, 0x2b,
234*689309c4SLei He     0x19, 0x4c, 0xb1, 0xb0, 0xd5, 0x8c, 0x02, 0x21,
235*689309c4SLei He     0x07, 0x18, 0x17, 0xda, 0xe9, 0x49, 0xd7, 0x82,
236*689309c4SLei He     0x73, 0x42, 0x78, 0xd1, 0x82, 0x4e, 0x8a, 0xc0,
237*689309c4SLei He     0xe9, 0x33, 0x2f, 0xcd, 0x62, 0xce, 0x23, 0xca,
238*689309c4SLei He     0xfd, 0x8d, 0xd4, 0x3f, 0x59, 0x80, 0x27, 0xb6,
239*689309c4SLei He     0x61, 0x85, 0x9b, 0x2a, 0xe4, 0xef, 0x5c, 0x36,
240*689309c4SLei He     0x22, 0x21, 0xcd, 0x2a, 0x6d, 0x41, 0x77, 0xe2,
241*689309c4SLei He     0xcb, 0x5d, 0x93, 0x0d, 0x00, 0x10, 0x52, 0x8d,
242*689309c4SLei He     0xd5, 0x92, 0x28, 0x16, 0x78, 0xd3, 0x1a, 0x4c,
243*689309c4SLei He     0x8d, 0xbd, 0x9c, 0x1a, 0x0b, 0x9c, 0x91, 0x16,
244*689309c4SLei He     0x4c, 0xff, 0x31, 0x36, 0xbb, 0xcb, 0x64, 0x1a,
245*689309c4SLei He     0xf7, 0x02, 0x81, 0x80, 0x32, 0x65, 0x09, 0xdf,
246*689309c4SLei He     0xca, 0xee, 0xa2, 0xdb, 0x3b, 0x58, 0xc9, 0x86,
247*689309c4SLei He     0xb8, 0x53, 0x8a, 0xd5, 0x0d, 0x99, 0x82, 0x5c,
248*689309c4SLei He     0xe0, 0x84, 0x7c, 0xc2, 0xcf, 0x3a, 0xd3, 0xce,
249*689309c4SLei He     0x2e, 0x54, 0x93, 0xbe, 0x3a, 0x30, 0x14, 0x60,
250*689309c4SLei He     0xbb, 0xaa, 0x05, 0x41, 0xaa, 0x2b, 0x1f, 0x17,
251*689309c4SLei He     0xaa, 0xb9, 0x72, 0x12, 0xf9, 0xe9, 0xf5, 0xe6,
252*689309c4SLei He     0x39, 0xe4, 0xf9, 0x9c, 0x03, 0xf5, 0x75, 0x16,
253*689309c4SLei He     0xc6, 0x7f, 0xf1, 0x1f, 0x10, 0xc8, 0x54, 0xb1,
254*689309c4SLei He     0xe6, 0x84, 0x15, 0xb0, 0xb0, 0x7a, 0x7a, 0x9e,
255*689309c4SLei He     0x8c, 0x4a, 0xd1, 0x8c, 0xf1, 0x91, 0x32, 0xeb,
256*689309c4SLei He     0x71, 0xa6, 0xbf, 0xdb, 0x1f, 0xcc, 0xd8, 0xcb,
257*689309c4SLei He     0x92, 0xc3, 0xf2, 0xaf, 0x89, 0x22, 0x32, 0xfd,
258*689309c4SLei He     0x32, 0x12, 0xda, 0xbb, 0xac, 0x55, 0x68, 0x01,
259*689309c4SLei He     0x78, 0x56, 0x89, 0x7c, 0xb0, 0x0e, 0x9e, 0xcc,
260*689309c4SLei He     0xc6, 0x28, 0x04, 0x7e, 0x83, 0xf5, 0x96, 0x30,
261*689309c4SLei He     0x92, 0x51, 0xf2, 0x1b, 0x02, 0x81, 0x81, 0x00,
262*689309c4SLei He     0x83, 0x6d, 0xd1, 0x98, 0x90, 0x41, 0x8c, 0xa7,
263*689309c4SLei He     0x92, 0x83, 0xac, 0x89, 0x05, 0x0c, 0x79, 0x67,
264*689309c4SLei He     0x90, 0xb6, 0xa1, 0xf3, 0x2f, 0xca, 0xf0, 0x15,
265*689309c4SLei He     0xe0, 0x30, 0x58, 0xe9, 0x4f, 0xcb, 0x4c, 0x56,
266*689309c4SLei He     0x56, 0x56, 0x14, 0x3f, 0x1b, 0x79, 0xb6, 0xef,
267*689309c4SLei He     0x57, 0x4b, 0x28, 0xbd, 0xb0, 0xe6, 0x0c, 0x49,
268*689309c4SLei He     0x4b, 0xbe, 0xe1, 0x57, 0x28, 0x2a, 0x23, 0x5e,
269*689309c4SLei He     0xc4, 0xa2, 0x19, 0x4b, 0x00, 0x67, 0x78, 0xd9,
270*689309c4SLei He     0x26, 0x6e, 0x17, 0x25, 0xce, 0xe4, 0xfd, 0xde,
271*689309c4SLei He     0x86, 0xa8, 0x5a, 0x67, 0x47, 0x6b, 0x15, 0x09,
272*689309c4SLei He     0xe1, 0xec, 0x8e, 0x62, 0x98, 0x91, 0x6f, 0xc0,
273*689309c4SLei He     0x98, 0x0c, 0x70, 0x0e, 0x7d, 0xbe, 0x63, 0xbd,
274*689309c4SLei He     0x12, 0x5a, 0x98, 0x1c, 0xe3, 0x0c, 0xfb, 0xc7,
275*689309c4SLei He     0xfb, 0x1b, 0xbd, 0x02, 0x87, 0xcc, 0x0c, 0xbb,
276*689309c4SLei He     0xc2, 0xd4, 0xb6, 0xc1, 0xa1, 0x23, 0xd3, 0x1e,
277*689309c4SLei He     0x21, 0x6f, 0x48, 0xba, 0x0e, 0x2e, 0xc7, 0x42
278*689309c4SLei He };
279*689309c4SLei He 
280*689309c4SLei He static const uint8_t rsa2048_public_key[] = {
281*689309c4SLei He     0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01,
282*689309c4SLei He     0x00, 0xbd, 0x9c, 0x83, 0x6b, 0x0e, 0x8e, 0xcf,
283*689309c4SLei He     0xfa, 0xaa, 0x4f, 0x6a, 0xf4, 0xe3, 0x52, 0x0f,
284*689309c4SLei He     0xa5, 0xd0, 0xbe, 0x5e, 0x7f, 0x08, 0x24, 0xba,
285*689309c4SLei He     0x87, 0x46, 0xfb, 0x28, 0x93, 0xe5, 0xe5, 0x81,
286*689309c4SLei He     0x42, 0xc0, 0xf9, 0x17, 0xc7, 0x81, 0x01, 0xf4,
287*689309c4SLei He     0x18, 0x6a, 0x17, 0xf5, 0x57, 0x20, 0x37, 0xcf,
288*689309c4SLei He     0xf9, 0x74, 0x5e, 0xe1, 0x48, 0x6a, 0x71, 0x0a,
289*689309c4SLei He     0x0f, 0x79, 0x72, 0x2b, 0x46, 0x10, 0x53, 0xdc,
290*689309c4SLei He     0x14, 0x43, 0xbd, 0xbc, 0x6d, 0x15, 0x6f, 0x15,
291*689309c4SLei He     0x4e, 0xf0, 0x0d, 0x89, 0x39, 0x02, 0xc3, 0x68,
292*689309c4SLei He     0x5c, 0xa8, 0xfc, 0xed, 0x64, 0x9d, 0x98, 0xb7,
293*689309c4SLei He     0xcd, 0x83, 0x66, 0x93, 0xc3, 0xd9, 0x57, 0xa0,
294*689309c4SLei He     0x21, 0x93, 0xad, 0x5c, 0x75, 0x69, 0x88, 0x9e,
295*689309c4SLei He     0x81, 0xdc, 0x7f, 0x1d, 0xd5, 0xbd, 0x1c, 0xc1,
296*689309c4SLei He     0x30, 0x56, 0xa5, 0xda, 0x99, 0x46, 0xa6, 0x6d,
297*689309c4SLei He     0x0e, 0x6f, 0x5e, 0x51, 0x34, 0x49, 0x73, 0xc3,
298*689309c4SLei He     0x67, 0x49, 0x7e, 0x21, 0x2a, 0x20, 0xa7, 0x2b,
299*689309c4SLei He     0x92, 0x73, 0x1d, 0xa5, 0x25, 0x2a, 0xd0, 0x3a,
300*689309c4SLei He     0x89, 0x75, 0xb2, 0xbb, 0x19, 0x37, 0x78, 0x48,
301*689309c4SLei He     0xd2, 0xf2, 0x2a, 0x6d, 0x9e, 0xc6, 0x26, 0xca,
302*689309c4SLei He     0x46, 0x8c, 0xf1, 0x42, 0x2a, 0x31, 0xb2, 0xfc,
303*689309c4SLei He     0xe7, 0x55, 0x51, 0xff, 0x07, 0x13, 0x5b, 0x36,
304*689309c4SLei He     0x59, 0x2b, 0x43, 0x30, 0x4b, 0x05, 0x5c, 0xd2,
305*689309c4SLei He     0x45, 0xa0, 0xa0, 0x7c, 0x17, 0x5b, 0x07, 0xbb,
306*689309c4SLei He     0x5d, 0x83, 0x80, 0x92, 0x6d, 0x87, 0x1a, 0x43,
307*689309c4SLei He     0xac, 0xc7, 0x6b, 0x8d, 0x11, 0x60, 0x27, 0xd2,
308*689309c4SLei He     0xdf, 0xdb, 0x71, 0x02, 0x55, 0x6e, 0xb5, 0xca,
309*689309c4SLei He     0x4d, 0xda, 0x59, 0x0d, 0xb8, 0x8c, 0xcd, 0xd3,
310*689309c4SLei He     0x0e, 0x55, 0xa0, 0xa4, 0x8d, 0xa0, 0x14, 0x10,
311*689309c4SLei He     0x48, 0x42, 0x35, 0x56, 0x08, 0xf7, 0x29, 0x5f,
312*689309c4SLei He     0xa2, 0xea, 0xa4, 0x5e, 0x8e, 0x99, 0x56, 0xaa,
313*689309c4SLei He     0x5a, 0x8c, 0x23, 0x8f, 0x35, 0x22, 0x8a, 0xff,
314*689309c4SLei He     0xed, 0x02, 0x03, 0x01, 0x00, 0x01
315*689309c4SLei He };
316*689309c4SLei He 
317*689309c4SLei He static const uint8_t test_sha1_dgst[] = {
318*689309c4SLei He     0x3c, 0x05, 0x19, 0x34, 0x29, 0x19, 0xc7, 0xe0,
319*689309c4SLei He     0x87, 0xb6, 0x24, 0xf9, 0x58, 0xac, 0xa4, 0xd4,
320*689309c4SLei He     0xb2, 0xd9, 0x03, 0x9e,
321*689309c4SLei He };
322*689309c4SLei He 
323*689309c4SLei He static const uint8_t exp_signature_rsa2048_pkcs1[] = {
324*689309c4SLei He     0x4e, 0x82, 0x56, 0x4c, 0x84, 0x66, 0xca, 0x1e,
325*689309c4SLei He     0xc6, 0x92, 0x46, 0x20, 0x02, 0x6b, 0x64, 0x46,
326*689309c4SLei He     0x15, 0x6b, 0x24, 0xf2, 0xbb, 0xfa, 0x44, 0x3c,
327*689309c4SLei He     0xaf, 0x42, 0xc8, 0x41, 0xfd, 0xce, 0xed, 0x95,
328*689309c4SLei He     0x34, 0xaf, 0x25, 0x09, 0xd1, 0x06, 0x94, 0xaa,
329*689309c4SLei He     0x52, 0xd4, 0x29, 0xc8, 0x52, 0x34, 0x67, 0x59,
330*689309c4SLei He     0x4f, 0x5a, 0xfd, 0x23, 0x30, 0x5e, 0xc7, 0x1e,
331*689309c4SLei He     0xa6, 0xe0, 0x1b, 0x23, 0xca, 0x82, 0x47, 0x9a,
332*689309c4SLei He     0x2e, 0x2c, 0x66, 0x45, 0x5a, 0x12, 0xa9, 0x15,
333*689309c4SLei He     0xbf, 0xd6, 0xd6, 0xfa, 0x8d, 0x60, 0x99, 0x89,
334*689309c4SLei He     0x91, 0x39, 0x06, 0xb7, 0xd3, 0x9a, 0xef, 0x15,
335*689309c4SLei He     0x7b, 0x95, 0x87, 0x77, 0x2c, 0x41, 0xd4, 0x71,
336*689309c4SLei He     0xd5, 0xdf, 0x22, 0x7b, 0x01, 0xe2, 0xc1, 0xfb,
337*689309c4SLei He     0xb9, 0x4e, 0x0c, 0x9b, 0xd5, 0x04, 0xed, 0x2b,
338*689309c4SLei He     0x7e, 0x73, 0x53, 0xaa, 0x33, 0x89, 0x9d, 0x95,
339*689309c4SLei He     0x28, 0x8f, 0x8b, 0x80, 0x34, 0x7a, 0xea, 0xe3,
340*689309c4SLei He     0x66, 0x8a, 0xa8, 0xad, 0xed, 0x91, 0x43, 0xdd,
341*689309c4SLei He     0x77, 0xe5, 0xd7, 0x16, 0xda, 0xa8, 0x00, 0x29,
342*689309c4SLei He     0x3f, 0x9f, 0xe0, 0x1d, 0x42, 0x9d, 0x35, 0x5d,
343*689309c4SLei He     0x0f, 0xf3, 0x90, 0x27, 0x3a, 0x8c, 0x46, 0x13,
344*689309c4SLei He     0x53, 0x3e, 0x3b, 0x38, 0x77, 0xf8, 0x57, 0x61,
345*689309c4SLei He     0xbc, 0xc4, 0x54, 0x68, 0x48, 0xae, 0x58, 0x03,
346*689309c4SLei He     0x33, 0x94, 0x3f, 0x18, 0x1e, 0xb3, 0x3f, 0x79,
347*689309c4SLei He     0xa7, 0x26, 0x92, 0x5d, 0x32, 0x2a, 0xdb, 0xe6,
348*689309c4SLei He     0x3a, 0xe8, 0xd7, 0xaa, 0x91, 0xfe, 0x9f, 0x06,
349*689309c4SLei He     0x26, 0x68, 0x8c, 0x27, 0x31, 0xb0, 0x04, 0x9e,
350*689309c4SLei He     0x94, 0x79, 0x63, 0xa1, 0xc7, 0xe8, 0x5b, 0x8c,
351*689309c4SLei He     0xd3, 0xf1, 0x88, 0x58, 0x31, 0x2f, 0x4e, 0x11,
352*689309c4SLei He     0x00, 0xfe, 0x29, 0xad, 0x2c, 0xa9, 0x8e, 0x63,
353*689309c4SLei He     0xd8, 0x7d, 0xc5, 0xa1, 0x71, 0xfa, 0x08, 0x29,
354*689309c4SLei He     0xea, 0xd6, 0x6c, 0x53, 0x00, 0x52, 0xa0, 0xed,
355*689309c4SLei He     0x6b, 0x7c, 0x67, 0x50, 0x71, 0x2d, 0x96, 0x7a,
356*689309c4SLei He };
357*689309c4SLei He 
358*689309c4SLei He static const uint8_t exp_signature_rsa1024_pkcs1[] = {
359*689309c4SLei He     0x6b, 0x5b, 0xbb, 0x3b, 0x1f, 0x08, 0xd8, 0xc0,
360*689309c4SLei He     0x4a, 0xf1, 0x5a, 0x12, 0xc2, 0x39, 0x14, 0x65,
361*689309c4SLei He     0x4f, 0xda, 0x79, 0x67, 0xf2, 0x89, 0x25, 0xad,
362*689309c4SLei He     0x9e, 0x7e, 0xba, 0xa8, 0x34, 0x15, 0x03, 0xdd,
363*689309c4SLei He     0x80, 0x6b, 0x01, 0xd7, 0x4a, 0xf3, 0xd6, 0xef,
364*689309c4SLei He     0x1e, 0x48, 0xf3, 0xbc, 0x75, 0x1a, 0xc4, 0x2c,
365*689309c4SLei He     0x90, 0x15, 0x9f, 0x21, 0x24, 0x98, 0x21, 0xef,
366*689309c4SLei He     0x6d, 0x3b, 0xf3, 0x82, 0x8f, 0x8d, 0xd8, 0x48,
367*689309c4SLei He     0x37, 0x16, 0x19, 0x8e, 0x3c, 0x64, 0xa0, 0x9e,
368*689309c4SLei He     0xf7, 0x0c, 0xd9, 0x5c, 0xc6, 0x13, 0xc4, 0x5f,
369*689309c4SLei He     0xf8, 0xf3, 0x59, 0x5b, 0xd0, 0x33, 0x95, 0x98,
370*689309c4SLei He     0xde, 0x67, 0x25, 0x58, 0x46, 0xba, 0xee, 0x0f,
371*689309c4SLei He     0x47, 0x7a, 0x7f, 0xd0, 0xe4, 0x77, 0x09, 0x17,
372*689309c4SLei He     0xe9, 0x81, 0x6e, 0x2d, 0x33, 0x9b, 0x13, 0x0b,
373*689309c4SLei He     0xc9, 0xb2, 0x0c, 0x2c, 0xb5, 0xdf, 0x52, 0x8f,
374*689309c4SLei He     0xab, 0x0d, 0xc6, 0x59, 0x1d, 0xc7, 0x33, 0x7b,
375*689309c4SLei He };
376*689309c4SLei He 
377*689309c4SLei He static const uint8_t test_plaintext[] = {
378*689309c4SLei He     0x00, 0x44, 0xbc, 0x6f, 0x77, 0xfb, 0xe2, 0xa4,
379*689309c4SLei He     0x98, 0x9e, 0xf5, 0x33, 0xa0, 0xbd, 0x81, 0xb9,
380*689309c4SLei He     0xf1, 0x44, 0x7f, 0x79, 0x89, 0x23, 0xe5, 0x46,
381*689309c4SLei He     0x66, 0x9f, 0x98, 0x95, 0x6f, 0x56, 0x78, 0xf6,
382*689309c4SLei He     0xf5, 0xac, 0x9c, 0xda, 0xc2, 0x79, 0x59, 0xf0,
383*689309c4SLei He     0x1b, 0x03, 0xfa, 0x46, 0x1c, 0x1f, 0x18, 0x07,
384*689309c4SLei He     0xce, 0xad, 0xed, 0x3d, 0x11, 0xf9, 0x1b, 0x26,
385*689309c4SLei He     0x4a, 0x97, 0x28, 0x71, 0x5f, 0x2c, 0x5e, 0x58,
386*689309c4SLei He     0xf0, 0xd6, 0xbf, 0xa4, 0x12, 0xd0, 0x1d, 0x07,
387*689309c4SLei He     0xcb, 0x73, 0x66, 0xb6, 0xa4, 0x09, 0xaf, 0x5d,
388*689309c4SLei He     0xe9, 0x14, 0x14, 0xaf, 0x69, 0xd6, 0xee, 0x0a,
389*689309c4SLei He     0xfc, 0xca, 0xac, 0x94, 0x47, 0xd5, 0x9d, 0x5b,
390*689309c4SLei He     0x2b, 0xfb, 0xce, 0x9d, 0x04, 0xc1, 0xaf, 0xa5,
391*689309c4SLei He     0xa1, 0x8d, 0xa9, 0x48, 0xa8, 0x65, 0xe6, 0x9f,
392*689309c4SLei He     0x74, 0x78, 0x16, 0x32, 0x93, 0xb5, 0x21, 0xb9,
393*689309c4SLei He     0x9f, 0x3f, 0xc1, 0xe5, 0xa2, 0x50, 0x8b, 0x12,
394*689309c4SLei He     0xfb, 0x3e, 0xb0, 0x8a, 0x00, 0xc7, 0x20, 0x56,
395*689309c4SLei He     0xb3, 0xb1, 0x29, 0x95, 0x89, 0xd6, 0x50, 0xf5,
396*689309c4SLei He     0x37, 0x38, 0x8e, 0x12, 0xf1, 0xba, 0x82, 0x37,
397*689309c4SLei He     0x34, 0x68, 0x4b, 0xe8, 0xe3, 0x11, 0x1c, 0x46,
398*689309c4SLei He     0xf9, 0x63, 0x3a, 0xd6, 0xf3, 0x3f, 0x55, 0xa6,
399*689309c4SLei He     0xbd, 0x89, 0xf1, 0x2d, 0x38, 0x91, 0x7c, 0xc2,
400*689309c4SLei He     0x4d, 0xf1, 0x69, 0x82, 0x6d, 0x71, 0x77, 0xf4,
401*689309c4SLei He     0xfc, 0x43, 0x20, 0x6f, 0x43, 0xb9, 0x43, 0xd1,
402*689309c4SLei He     0x65, 0xbd, 0xca, 0xb1, 0x43, 0x87, 0xf8, 0xc8,
403*689309c4SLei He     0x76, 0x21, 0xa9, 0xeb, 0x3e, 0x9a, 0xef, 0xc9,
404*689309c4SLei He     0x0e, 0x79, 0xbc, 0xf0, 0xf8, 0xc8, 0xe2, 0xbc,
405*689309c4SLei He     0x33, 0x35, 0x3e, 0xfc, 0xf9, 0x44, 0x69, 0x06,
406*689309c4SLei He     0x7c, 0x7f, 0x5d, 0xa2, 0x9e, 0xab, 0xc2, 0x82,
407*689309c4SLei He     0xa0, 0xfb, 0xc5, 0x79, 0x57, 0x8c, 0xf1, 0x1c,
408*689309c4SLei He     0x51, 0x64, 0x4c, 0x56, 0x08, 0x80, 0x32, 0xf4,
409*689309c4SLei He     0x97, 0x8f, 0x6f, 0xb2, 0x16, 0xa6, 0x9d, 0x71,
410*689309c4SLei He };
411*689309c4SLei He 
412*689309c4SLei He static const uint8_t exp_ciphertext_rsa1024_raw[] = {
413*689309c4SLei He     0x01, 0xa0, 0xc2, 0x94, 0x9f, 0xd6, 0xbe, 0x8d,
414*689309c4SLei He     0xe9, 0x24, 0xaa, 0x9c, 0x67, 0xd7, 0xe3, 0x04,
415*689309c4SLei He     0x34, 0xbf, 0xd3, 0x27, 0xa1, 0x43, 0xeb, 0x60,
416*689309c4SLei He     0x6b, 0x5b, 0x64, 0x15, 0x55, 0x16, 0x98, 0x35,
417*689309c4SLei He     0xc2, 0x59, 0xa7, 0xf7, 0x24, 0xf7, 0x05, 0xb9,
418*689309c4SLei He     0xe8, 0x56, 0x6f, 0xf2, 0x7d, 0x8b, 0x3c, 0xcb,
419*689309c4SLei He     0xa6, 0xc2, 0xac, 0x0c, 0x37, 0x8c, 0x70, 0x70,
420*689309c4SLei He     0x55, 0x05, 0x07, 0x0d, 0x63, 0x6b, 0x7d, 0x5f,
421*689309c4SLei He     0xae, 0x03, 0x1e, 0x55, 0x05, 0xbb, 0xa8, 0xe7,
422*689309c4SLei He     0xff, 0xa0, 0x8c, 0x5b, 0x6b, 0x01, 0x48, 0x2e,
423*689309c4SLei He     0x4f, 0x7f, 0xe2, 0x74, 0xc6, 0x32, 0xa7, 0x2d,
424*689309c4SLei He     0xdb, 0x91, 0x9b, 0x67, 0x4d, 0x71, 0xf9, 0x8c,
425*689309c4SLei He     0x42, 0x43, 0x75, 0x4e, 0xd0, 0x0e, 0x7c, 0xa0,
426*689309c4SLei He     0x97, 0x1a, 0x5f, 0x8e, 0x6f, 0xe4, 0xfa, 0x16,
427*689309c4SLei He     0x1d, 0x59, 0x0e, 0x0b, 0x11, 0x12, 0xa3, 0x0c,
428*689309c4SLei He     0xa6, 0x55, 0xe6, 0xdb, 0xa7, 0x71, 0xa6, 0xff,
429*689309c4SLei He };
430*689309c4SLei He 
431*689309c4SLei He static const uint8_t exp_ciphertext_rsa1024_pkcs1[] = {
432*689309c4SLei He     0x93, 0x78, 0x6a, 0x76, 0xb8, 0x94, 0xea, 0xe4,
433*689309c4SLei He     0x32, 0x79, 0x01, 0x8b, 0xc1, 0xcb, 0x2e, 0x2d,
434*689309c4SLei He     0xfe, 0xdc, 0x9b, 0xe3, 0xe9, 0x23, 0xe4, 0x0a,
435*689309c4SLei He     0xb0, 0x6b, 0x9f, 0x6b, 0x62, 0xf5, 0x3d, 0xf0,
436*689309c4SLei He     0x78, 0x84, 0x77, 0x21, 0xad, 0x0b, 0x30, 0x30,
437*689309c4SLei He     0x94, 0xe2, 0x18, 0xc4, 0x9b, 0x12, 0x06, 0xc8,
438*689309c4SLei He     0xaa, 0xf7, 0x30, 0xe4, 0xc8, 0x64, 0xe7, 0x51,
439*689309c4SLei He     0xf1, 0x6a, 0xe1, 0xa2, 0x58, 0x7a, 0x02, 0x9c,
440*689309c4SLei He     0x8e, 0xf0, 0x2d, 0x25, 0x6b, 0xb7, 0x25, 0x5e,
441*689309c4SLei He     0x05, 0xaf, 0x38, 0xb2, 0x69, 0x5e, 0x6c, 0x75,
442*689309c4SLei He     0x6e, 0x27, 0xba, 0x5d, 0x7d, 0x35, 0x72, 0xb7,
443*689309c4SLei He     0x25, 0xd4, 0xaa, 0xb2, 0x4b, 0x9e, 0x6b, 0x82,
444*689309c4SLei He     0xb2, 0x32, 0xe2, 0x13, 0x1d, 0x00, 0x21, 0x08,
445*689309c4SLei He     0xae, 0x14, 0xbb, 0xc0, 0x40, 0xb7, 0x0d, 0xd5,
446*689309c4SLei He     0x0e, 0x4d, 0x6d, 0x9a, 0x70, 0x86, 0xe9, 0xfc,
447*689309c4SLei He     0x67, 0x2b, 0xa4, 0x11, 0x45, 0xb6, 0xc4, 0x2f,
448*689309c4SLei He };
449*689309c4SLei He 
450*689309c4SLei He static const uint8_t exp_ciphertext_rsa2048_raw[] = {
451*689309c4SLei He     0x09, 0x7b, 0x9e, 0x7c, 0x10, 0x1f, 0x73, 0xb4,
452*689309c4SLei He     0x5f, 0xdb, 0x4f, 0x05, 0xe7, 0xfc, 0x9e, 0x35,
453*689309c4SLei He     0x48, 0xd8, 0xc8, 0xf5, 0xac, 0x6d, 0xb4, 0xb0,
454*689309c4SLei He     0xd4, 0xf7, 0x69, 0x0f, 0x30, 0x78, 0xbb, 0x55,
455*689309c4SLei He     0x67, 0x66, 0x66, 0x05, 0xf4, 0x77, 0xe2, 0x30,
456*689309c4SLei He     0xa5, 0x94, 0x10, 0xa3, 0xcb, 0xee, 0x13, 0x9f,
457*689309c4SLei He     0x47, 0x1b, 0x2e, 0xf9, 0xfd, 0x94, 0x09, 0xbd,
458*689309c4SLei He     0x26, 0x6e, 0x84, 0xc7, 0x5c, 0x42, 0x20, 0x76,
459*689309c4SLei He     0x72, 0x83, 0x75, 0x68, 0xa4, 0x18, 0x2d, 0x76,
460*689309c4SLei He     0x62, 0xc3, 0xab, 0xc0, 0xc9, 0x36, 0x59, 0xe0,
461*689309c4SLei He     0xa9, 0x70, 0x1f, 0xff, 0x97, 0x07, 0x0d, 0x88,
462*689309c4SLei He     0xc2, 0xd8, 0x51, 0x35, 0xf7, 0xb0, 0x50, 0xe4,
463*689309c4SLei He     0x9f, 0x3d, 0xd4, 0x71, 0x8b, 0x40, 0x89, 0x71,
464*689309c4SLei He     0x6c, 0xd8, 0xc2, 0x63, 0xb6, 0x3a, 0xce, 0xb1,
465*689309c4SLei He     0x32, 0xf1, 0xc6, 0x11, 0x31, 0x25, 0x48, 0xcf,
466*689309c4SLei He     0xeb, 0xbc, 0xd3, 0x9b, 0xc5, 0xbd, 0xd2, 0x57,
467*689309c4SLei He     0x73, 0x9b, 0x20, 0xb8, 0xdf, 0xbe, 0xb8, 0x40,
468*689309c4SLei He     0xb6, 0xac, 0x24, 0xdb, 0x94, 0x6a, 0x93, 0x43,
469*689309c4SLei He     0x4a, 0xa8, 0xa3, 0xcf, 0xd5, 0x61, 0x1b, 0x46,
470*689309c4SLei He     0x1d, 0x6f, 0x57, 0xec, 0xa6, 0xd0, 0x44, 0x05,
471*689309c4SLei He     0x48, 0xb8, 0x90, 0x80, 0x23, 0x8e, 0x5f, 0xb0,
472*689309c4SLei He     0x4b, 0x6f, 0xe3, 0xf9, 0xb0, 0x04, 0x60, 0xae,
473*689309c4SLei He     0x80, 0xcf, 0xa5, 0x5c, 0x11, 0xe4, 0xce, 0x57,
474*689309c4SLei He     0x5b, 0xbb, 0xde, 0x92, 0xfc, 0xe7, 0x3f, 0xe0,
475*689309c4SLei He     0xfc, 0x06, 0xc8, 0xf3, 0x8c, 0xac, 0x86, 0x09,
476*689309c4SLei He     0x31, 0xe5, 0x7e, 0xfb, 0x5d, 0xa7, 0x57, 0xf8,
477*689309c4SLei He     0x1d, 0x23, 0x9d, 0xa3, 0xeb, 0x53, 0x28, 0xde,
478*689309c4SLei He     0xbf, 0x53, 0xef, 0x35, 0x3c, 0x7e, 0x3c, 0x1b,
479*689309c4SLei He     0x76, 0x9d, 0x09, 0x25, 0x43, 0xd4, 0x8b, 0xca,
480*689309c4SLei He     0xda, 0x45, 0x5b, 0xdc, 0x9f, 0x57, 0x5a, 0x30,
481*689309c4SLei He     0x2e, 0xe9, 0x73, 0x68, 0x28, 0xfa, 0x40, 0xb0,
482*689309c4SLei He     0x7c, 0x31, 0xd7, 0x8b, 0x4e, 0x99, 0x94, 0xf1,
483*689309c4SLei He };
484*689309c4SLei He 
485*689309c4SLei He static const uint8_t exp_ciphertext_rsa2048_pkcs1[] = {
486*689309c4SLei He     0xa5, 0x19, 0x19, 0x34, 0xad, 0xf6, 0xd2, 0xbe,
487*689309c4SLei He     0xed, 0x8f, 0xe5, 0xfe, 0xa2, 0xa5, 0x20, 0x08,
488*689309c4SLei He     0x15, 0x53, 0x7c, 0x68, 0x28, 0xae, 0x07, 0xb2,
489*689309c4SLei He     0x4c, 0x5d, 0xee, 0xc1, 0xc6, 0xdc, 0xd6, 0x8b,
490*689309c4SLei He     0xc6, 0xba, 0x46, 0xe1, 0x16, 0xa9, 0x04, 0x72,
491*689309c4SLei He     0xdf, 0x8f, 0x1e, 0x97, 0x2a, 0x55, 0xe7, 0xac,
492*689309c4SLei He     0x08, 0x0d, 0x61, 0xe8, 0x64, 0x8b, 0x6f, 0x96,
493*689309c4SLei He     0x0e, 0xbb, 0x8a, 0x30, 0xb3, 0x73, 0x28, 0x61,
494*689309c4SLei He     0x16, 0x89, 0x90, 0x88, 0x8e, 0xda, 0x22, 0xe6,
495*689309c4SLei He     0x42, 0x16, 0xc7, 0xe8, 0x30, 0x0d, 0x7f, 0x44,
496*689309c4SLei He     0x1e, 0xef, 0xe6, 0xdb, 0x78, 0x54, 0x89, 0xa5,
497*689309c4SLei He     0x60, 0x67, 0xb3, 0x35, 0x2d, 0x79, 0x49, 0xcf,
498*689309c4SLei He     0xe6, 0x8f, 0xf3, 0x64, 0x52, 0x1c, 0x6c, 0x43,
499*689309c4SLei He     0x7e, 0xb0, 0xde, 0x55, 0xdf, 0xbe, 0xb7, 0xb1,
500*689309c4SLei He     0xdb, 0x02, 0xee, 0x76, 0x96, 0xcc, 0x0b, 0x97,
501*689309c4SLei He     0x8c, 0x23, 0xaa, 0x7d, 0x4c, 0x47, 0x28, 0x41,
502*689309c4SLei He     0x7a, 0x20, 0x39, 0x1f, 0x64, 0x0b, 0xf1, 0x74,
503*689309c4SLei He     0xf1, 0x29, 0xda, 0xe9, 0x3a, 0x36, 0xa6, 0x88,
504*689309c4SLei He     0xb8, 0xc0, 0x21, 0xb8, 0x9b, 0x5d, 0x90, 0x85,
505*689309c4SLei He     0xa3, 0x30, 0x61, 0x17, 0x8c, 0x74, 0x63, 0xd5,
506*689309c4SLei He     0x0f, 0x95, 0xdc, 0xc8, 0x4f, 0xa7, 0x24, 0x55,
507*689309c4SLei He     0x40, 0xe2, 0x84, 0x57, 0x65, 0x06, 0x11, 0x30,
508*689309c4SLei He     0x2b, 0x9e, 0x32, 0x95, 0x39, 0xf2, 0x1a, 0x3f,
509*689309c4SLei He     0xab, 0xcd, 0x7b, 0x7f, 0x9c, 0xf0, 0x00, 0x50,
510*689309c4SLei He     0x7c, 0xf4, 0xbe, 0xcb, 0x80, 0xea, 0x66, 0xba,
511*689309c4SLei He     0x0e, 0x7b, 0x46, 0x0b, 0x25, 0xe0, 0xc1, 0x03,
512*689309c4SLei He     0x29, 0x11, 0x2d, 0x69, 0x4f, 0x21, 0xa2, 0x58,
513*689309c4SLei He     0x37, 0x4b, 0x84, 0x15, 0xb3, 0x65, 0x3a, 0xac,
514*689309c4SLei He     0xd4, 0xd0, 0xf6, 0xdf, 0x4b, 0x82, 0xca, 0x9e,
515*689309c4SLei He     0xbb, 0xbe, 0x3c, 0x4d, 0xd5, 0xbf, 0x00, 0xd6,
516*689309c4SLei He     0x12, 0x48, 0x72, 0x0b, 0xc7, 0xf8, 0xe1, 0xcd,
517*689309c4SLei He     0xd0, 0x28, 0x03, 0x19, 0xa6, 0x06, 0x13, 0x45,
518*689309c4SLei He };
519*689309c4SLei He 
520*689309c4SLei He typedef struct QCryptoAkCipherTestData QCryptoAkCipherTestData;
521*689309c4SLei He struct QCryptoAkCipherTestData {
522*689309c4SLei He     const char *path;
523*689309c4SLei He     QCryptoAkCipherOptions opt;
524*689309c4SLei He 
525*689309c4SLei He     const uint8_t *priv_key;
526*689309c4SLei He     size_t priv_key_len;
527*689309c4SLei He     const uint8_t *pub_key;
528*689309c4SLei He     size_t pub_key_len;
529*689309c4SLei He 
530*689309c4SLei He     const uint8_t *plaintext;
531*689309c4SLei He     size_t plen;
532*689309c4SLei He     const uint8_t *ciphertext;
533*689309c4SLei He     size_t clen;
534*689309c4SLei He     const uint8_t *dgst;
535*689309c4SLei He     size_t dlen;
536*689309c4SLei He     const uint8_t *signature;
537*689309c4SLei He     size_t slen;
538*689309c4SLei He };
539*689309c4SLei He 
540*689309c4SLei He static QCryptoAkCipherTestData test_data[] = {
541*689309c4SLei He     /* rsa1024 with raw padding */
542*689309c4SLei He     {
543*689309c4SLei He         .path = "/crypto/akcipher/rsa1024-raw",
544*689309c4SLei He         .opt = {
545*689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
546*689309c4SLei He             .u.rsa = {
547*689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
548*689309c4SLei He             },
549*689309c4SLei He         },
550*689309c4SLei He         .pub_key = rsa1024_public_key,
551*689309c4SLei He         .pub_key_len = sizeof(rsa1024_public_key),
552*689309c4SLei He         .priv_key = rsa1024_private_key,
553*689309c4SLei He         .priv_key_len = sizeof(rsa1024_private_key),
554*689309c4SLei He 
555*689309c4SLei He         .plaintext = test_plaintext,
556*689309c4SLei He         .plen = 128,
557*689309c4SLei He         .ciphertext = exp_ciphertext_rsa1024_raw,
558*689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa1024_raw),
559*689309c4SLei He     },
560*689309c4SLei He 
561*689309c4SLei He     /* rsa1024 with pkcs1 padding */
562*689309c4SLei He     {
563*689309c4SLei He         .path = "/crypto/akcipher/rsa1024-pkcs1",
564*689309c4SLei He         .opt = {
565*689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
566*689309c4SLei He             .u.rsa = {
567*689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
568*689309c4SLei He                 .hash_alg = QCRYPTO_HASH_ALG_SHA1,
569*689309c4SLei He             },
570*689309c4SLei He         },
571*689309c4SLei He         .pub_key = rsa1024_public_key,
572*689309c4SLei He         .pub_key_len = sizeof(rsa1024_public_key),
573*689309c4SLei He         .priv_key = rsa1024_private_key,
574*689309c4SLei He         .priv_key_len = sizeof(rsa1024_private_key),
575*689309c4SLei He 
576*689309c4SLei He         .plaintext = test_plaintext,
577*689309c4SLei He         .plen = 64,
578*689309c4SLei He         .ciphertext = exp_ciphertext_rsa1024_pkcs1,
579*689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa1024_pkcs1),
580*689309c4SLei He         .dgst = test_sha1_dgst,
581*689309c4SLei He         .dlen = sizeof(test_sha1_dgst),
582*689309c4SLei He         .signature = exp_signature_rsa1024_pkcs1,
583*689309c4SLei He         .slen = sizeof(exp_signature_rsa1024_pkcs1),
584*689309c4SLei He     },
585*689309c4SLei He 
586*689309c4SLei He     /* rsa2048 with raw padding */
587*689309c4SLei He     {
588*689309c4SLei He         .path = "/crypto/akcipher/rsa2048-raw",
589*689309c4SLei He         .opt = {
590*689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
591*689309c4SLei He             .u.rsa = {
592*689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW,
593*689309c4SLei He             },
594*689309c4SLei He         },
595*689309c4SLei He         .pub_key = rsa2048_public_key,
596*689309c4SLei He         .pub_key_len = sizeof(rsa2048_public_key),
597*689309c4SLei He         .priv_key = rsa2048_private_key,
598*689309c4SLei He         .priv_key_len = sizeof(rsa2048_private_key),
599*689309c4SLei He 
600*689309c4SLei He         .plaintext = test_plaintext,
601*689309c4SLei He         .plen = 256,
602*689309c4SLei He         .ciphertext = exp_ciphertext_rsa2048_raw,
603*689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa2048_raw),
604*689309c4SLei He     },
605*689309c4SLei He 
606*689309c4SLei He     /* rsa2048 with pkcs1 padding */
607*689309c4SLei He     {
608*689309c4SLei He         .path = "/crypto/akcipher/rsa2048-pkcs1",
609*689309c4SLei He         .opt = {
610*689309c4SLei He             .alg = QCRYPTO_AKCIPHER_ALG_RSA,
611*689309c4SLei He             .u.rsa = {
612*689309c4SLei He                 .padding_alg = QCRYPTO_RSA_PADDING_ALG_PKCS1,
613*689309c4SLei He                 .hash_alg = QCRYPTO_HASH_ALG_SHA1,
614*689309c4SLei He             },
615*689309c4SLei He         },
616*689309c4SLei He         .pub_key = rsa2048_public_key,
617*689309c4SLei He         .pub_key_len = sizeof(rsa2048_public_key),
618*689309c4SLei He         .priv_key = rsa2048_private_key,
619*689309c4SLei He         .priv_key_len = sizeof(rsa2048_private_key),
620*689309c4SLei He 
621*689309c4SLei He         .plaintext = test_plaintext,
622*689309c4SLei He         .plen = 128,
623*689309c4SLei He         .ciphertext = exp_ciphertext_rsa2048_pkcs1,
624*689309c4SLei He         .clen = sizeof(exp_ciphertext_rsa2048_pkcs1),
625*689309c4SLei He         .dgst = test_sha1_dgst,
626*689309c4SLei He         .dlen = sizeof(test_sha1_dgst),
627*689309c4SLei He         .signature = exp_signature_rsa2048_pkcs1,
628*689309c4SLei He         .slen = sizeof(exp_signature_rsa2048_pkcs1),
629*689309c4SLei He     },
630*689309c4SLei He 
631*689309c4SLei He };
632*689309c4SLei He 
633*689309c4SLei He static void test_akcipher(const void *opaque)
634*689309c4SLei He {
635*689309c4SLei He     const QCryptoAkCipherTestData *data = opaque;
636*689309c4SLei He     g_autofree uint8_t *plaintext = NULL;
637*689309c4SLei He     g_autofree uint8_t *ciphertext = NULL;
638*689309c4SLei He     g_autofree uint8_t *signature = NULL;
639*689309c4SLei He     QCryptoAkCipher *pub_key, *priv_key;
640*689309c4SLei He 
641*689309c4SLei He     if (!qcrypto_akcipher_supports((QCryptoAkCipherOptions *)&data->opt)) {
642*689309c4SLei He         return;
643*689309c4SLei He     }
644*689309c4SLei He     pub_key = qcrypto_akcipher_new(&data->opt,
645*689309c4SLei He                                    QCRYPTO_AKCIPHER_KEY_TYPE_PUBLIC,
646*689309c4SLei He                                    data->pub_key, data->pub_key_len,
647*689309c4SLei He                                    &error_abort);
648*689309c4SLei He     g_assert(pub_key != NULL);
649*689309c4SLei He     priv_key = qcrypto_akcipher_new(&data->opt,
650*689309c4SLei He                                     QCRYPTO_AKCIPHER_KEY_TYPE_PRIVATE,
651*689309c4SLei He                                     data->priv_key, data->priv_key_len,
652*689309c4SLei He                                     &error_abort);
653*689309c4SLei He     g_assert(priv_key != NULL);
654*689309c4SLei He 
655*689309c4SLei He     if (data->plaintext != NULL) {
656*689309c4SLei He 
657*689309c4SLei He         ciphertext = g_new0(uint8_t, data->clen);
658*689309c4SLei He         g_assert(qcrypto_akcipher_encrypt(pub_key, data->plaintext, data->plen,
659*689309c4SLei He                                           ciphertext, data->clen,
660*689309c4SLei He                                           &error_abort) > 0);
661*689309c4SLei He 
662*689309c4SLei He         /**
663*689309c4SLei He          * In the asymmetric encryption algorithms, the ciphertext generated
664*689309c4SLei He          * each time may be different, here only compare the decrypted
665*689309c4SLei He          * plaintext
666*689309c4SLei He          */
667*689309c4SLei He         plaintext = g_new0(uint8_t, data->clen);
668*689309c4SLei He         g_assert(qcrypto_akcipher_decrypt(priv_key, ciphertext,
669*689309c4SLei He                                           data->clen, plaintext,
670*689309c4SLei He                                           data->plen,
671*689309c4SLei He                                           &error_abort) == data->plen);
672*689309c4SLei He         g_assert(!memcmp(plaintext, data->plaintext, data->plen));
673*689309c4SLei He     }
674*689309c4SLei He 
675*689309c4SLei He     if (data->signature != NULL) {
676*689309c4SLei He         signature = g_new(uint8_t, data->slen);
677*689309c4SLei He         g_assert(qcrypto_akcipher_sign(priv_key, data->dgst, data->dlen,
678*689309c4SLei He                                        signature, data->slen,
679*689309c4SLei He                                        &error_abort) > 0);
680*689309c4SLei He         /**
681*689309c4SLei He          * The signature generated each time may be different, here only check
682*689309c4SLei He          * the verification.
683*689309c4SLei He          */
684*689309c4SLei He         g_assert(qcrypto_akcipher_verify(pub_key, data->signature, data->slen,
685*689309c4SLei He                                          data->dgst, data->dlen,
686*689309c4SLei He                                          &error_abort) == 0);
687*689309c4SLei He         g_assert(qcrypto_akcipher_verify(pub_key, signature, data->slen,
688*689309c4SLei He                                          data->dgst, data->dlen,
689*689309c4SLei He                                          &error_abort) == 0);
690*689309c4SLei He         ++signature[0];
691*689309c4SLei He         /* Here error should be ignored */
692*689309c4SLei He         g_assert(qcrypto_akcipher_verify(pub_key, signature, data->slen,
693*689309c4SLei He                                          data->dgst, data->dlen, NULL) != 0);
694*689309c4SLei He     }
695*689309c4SLei He 
696*689309c4SLei He     qcrypto_akcipher_free(pub_key);
697*689309c4SLei He     qcrypto_akcipher_free(priv_key);
698*689309c4SLei He }
699*689309c4SLei He 
700*689309c4SLei He int main(int argc, char **argv)
701*689309c4SLei He {
702*689309c4SLei He     size_t i;
703*689309c4SLei He     g_test_init(&argc, &argv, NULL);
704*689309c4SLei He     g_assert(qcrypto_init(NULL) == 0);
705*689309c4SLei He 
706*689309c4SLei He     for (i = 0; i < G_N_ELEMENTS(test_data); i++) {
707*689309c4SLei He         g_test_add_data_func(test_data[i].path, &test_data[i], test_akcipher);
708*689309c4SLei He     }
709*689309c4SLei He 
710*689309c4SLei He     return g_test_run();
711*689309c4SLei He }
712