signature-params: Add helper struct for signature scheme and parameters
[strongswan.git] / src / libstrongswan / tests / suites / test_signature_params.c
1 /*
2 * Copyright (C) 2017 Tobias Brunner
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "test_suite.h"
17
18 #include <asn1/oid.h>
19 #include <asn1/asn1.h>
20 #include <credentials/keys/signature_params.h>
21
22 static struct {
23 chunk_t aid;
24 rsa_pss_params_t params;
25 } rsa_pss_parse_tests[] = {
26 /* from RFC 7427, no parameters (empty sequence) */
27 { chunk_from_chars(0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x00),
28 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA1, }},
29 /* from RFC 7427, default parameters (SHA-1), would actually not be sent
30 * like this, as corrected in errata */
31 { chunk_from_chars(0x30,0x3e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x31,0xa0,
32 0x0b,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0xa1,0x18,0x30,0x16,
33 0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,0x09,0x06,0x05,0x2b,
34 0x0e,0x03,0x02,0x1a,0x05,0x00,0xa2,0x03,0x02,0x01,0x14,0xa3,0x03,0x02,0x01,0x01),
35 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA1, }},
36 /* from RFC 7427, SHA-256 */
37 { chunk_from_chars(0x30,0x46,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x39,0xa0,
38 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,
39 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,
40 0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0xa2,0x03,
41 0x02,0x01,0x20,0xa3,0x03,0x02,0x01,0x01),
42 { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA256, .salt_len = HASH_SIZE_SHA256, }},
43 /* from RFC 7427, SHA-256 (errata, without trailer, with len corrections) */
44 { chunk_from_chars(0x30,0x41,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x34,0xa0,
45 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,
46 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,
47 0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0xa2,0x03,
48 0x02,0x01,0x20),
49 { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA256, .salt_len = HASH_SIZE_SHA256, }},
50 /* SHA-512 */
51 { chunk_from_chars(0x30,0x41,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x34,0xa0,
52 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,
53 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,
54 0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0xa2,0x03,
55 0x02,0x01,0x40),
56 { .hash = HASH_SHA512, .mgf1_hash = HASH_SHA512, .salt_len = HASH_SIZE_SHA512, }},
57 /* SHA-256, no salt */
58 { chunk_from_chars(0x30,0x41,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x34,0xa0,
59 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,
60 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,
61 0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0xa2,0x03,
62 0x02,0x01,0x00),
63 { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA256, .salt_len = 0, }},
64 /* only hash specified */
65 { chunk_from_chars(0x30,0x1e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x11,
66 0xa0,0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,
67 0x05,0x00),
68 { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA1, }},
69 /* only mgf specified */
70 { chunk_from_chars(0x30,0x2b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x1e,
71 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,
72 0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00),
73 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA256, .salt_len = HASH_SIZE_SHA1, }},
74 /* only salt specified */
75 { chunk_from_chars(0x30,0x12,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x05,0xa2,
76 0x03,0x02,0x01,0x20),
77 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA256, }},
78 };
79
80 START_TEST(test_rsa_pss_params_parse)
81 {
82 rsa_pss_params_t parsed;
83 chunk_t params;
84 int oid;
85
86 oid = asn1_parse_algorithmIdentifier(rsa_pss_parse_tests[_i].aid, 0, &params);
87 ck_assert_int_eq(OID_RSASSA_PSS, oid);
88 ck_assert(rsa_pss_params_parse(params, 1, &parsed));
89 ck_assert_int_eq(rsa_pss_parse_tests[_i].params.hash, parsed.hash);
90 ck_assert_int_eq(rsa_pss_parse_tests[_i].params.mgf1_hash, parsed.mgf1_hash);
91 ck_assert_int_eq(rsa_pss_parse_tests[_i].params.salt_len, parsed.salt_len);
92 }
93 END_TEST
94
95 chunk_t rsa_pss_parse_invalid_tests[] = {
96 /* unknown hash */
97 chunk_from_chars(0x30,0x1e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x11,
98 0xa0,0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x00,
99 0x05,0x00),
100 /* unknown mgf */
101 chunk_from_chars(0x30,0x2b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x1e,
102 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x00,
103 0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00),
104 /* unknown mgf-1 hash */
105 chunk_from_chars(0x30,0x2b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x1e,
106 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,
107 0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x00,0x05,0x00),
108 /* incorrect trailer */
109 chunk_from_chars(0x30,0x12,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x05,
110 0xa3,0x03,0x02,0x01,0x02),
111 /* too long trailer */
112 chunk_from_chars(0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x06,
113 0xa3,0x04,0x02,0x02,0x01,0x01),
114 };
115
116 START_TEST(test_rsa_pss_params_parse_invalid)
117 {
118 rsa_pss_params_t parsed;
119 chunk_t params;
120 int oid;
121
122 oid = asn1_parse_algorithmIdentifier(rsa_pss_parse_invalid_tests[_i], 0, &params);
123 ck_assert_int_eq(OID_RSASSA_PSS, oid);
124 ck_assert(!rsa_pss_params_parse(params, 1, &parsed));
125 }
126 END_TEST
127
128 static struct {
129 chunk_t aid;
130 rsa_pss_params_t params;
131 } rsa_pss_build_tests[] = {
132 /* default parameters -> empty sequence */
133 { chunk_from_chars(0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x00),
134 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA1, }},
135 /* SHA-256 */
136 { chunk_from_chars(0x30,0x41,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x34,0xa0,
137 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,
138 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,
139 0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0xa2,0x03,
140 0x02,0x01,0x20),
141 { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA256, .salt_len = RSA_PSS_SALT_LEN_DEFAULT, }},
142 /* default salt length: SHA-1 */
143 { chunk_from_chars(0x30,0x0d,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x00),
144 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA1, .salt_len = RSA_PSS_SALT_LEN_DEFAULT, }},
145 /* default salt length: SHA-224 */
146 { chunk_from_chars(0x30,0x23,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x16,0xa0,
147 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,
148 0xa2,0x03,0x02,0x01,0x1c),
149 { .hash = HASH_SHA224, .mgf1_hash = HASH_SHA1, .salt_len = RSA_PSS_SALT_LEN_DEFAULT, }},
150 /* default salt length: SHA-384 */
151 { chunk_from_chars(0x30,0x23,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x16,0xa0,
152 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,
153 0xa2,0x03,0x02,0x01,0x30),
154 { .hash = HASH_SHA384, .mgf1_hash = HASH_SHA1, .salt_len = RSA_PSS_SALT_LEN_DEFAULT, }},
155 /* SHA-512 */
156 { chunk_from_chars(0x30,0x41,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x34,0xa0,
157 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,
158 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,
159 0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0xa2,0x03,
160 0x02,0x01,0x40),
161 { .hash = HASH_SHA512, .mgf1_hash = HASH_SHA512, .salt_len = RSA_PSS_SALT_LEN_DEFAULT, }},
162 /* SHA-256, no salt */
163 { chunk_from_chars(0x30,0x41,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x34,0xa0,
164 0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,
165 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,0x30,
166 0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0xa2,0x03,
167 0x02,0x01,0x00),
168 { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA256, .salt_len = 0, }},
169 /* SHA-256, rest default */
170 { chunk_from_chars(0x30,0x1e,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x11,
171 0xa0,0x0f,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,
172 0x05,0x00),
173 { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA1, }},
174 /* MGF1-SHA-256, rest default */
175 { chunk_from_chars(0x30,0x2b,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x1e,
176 0xa1,0x1c,0x30,0x1a,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x08,
177 0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00),
178 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA256, .salt_len = HASH_SIZE_SHA1, }},
179 /* only salt specified */
180 { chunk_from_chars(0x30,0x12,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01,0x01,0x0a,0x30,0x05,0xa2,
181 0x03,0x02,0x01,0x20),
182 { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA256, }},
183 };
184
185 START_TEST(test_rsa_pss_params_build)
186 {
187 chunk_t params, aid;
188
189 ck_assert(rsa_pss_params_build(&rsa_pss_build_tests[_i].params, &params));
190 aid = asn1_wrap(ASN1_SEQUENCE, "mm", asn1_build_known_oid(OID_RSASSA_PSS),
191 params);
192 ck_assert_chunk_eq(rsa_pss_build_tests[_i].aid, aid);
193 chunk_free(&aid);
194 }
195 END_TEST
196
197 rsa_pss_params_t rsa_pss_build_invalid_tests[] = {
198 /* unknown hash */
199 { .hash = HASH_UNKNOWN, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA1, },
200 /* invalid mgf */
201 { .hash = HASH_SHA256, .mgf1_hash = HASH_UNKNOWN, .salt_len = HASH_SIZE_SHA256, },
202 };
203
204 START_TEST(test_rsa_pss_params_build_invalid)
205 {
206 chunk_t params;
207
208 ck_assert(!rsa_pss_params_build(&rsa_pss_build_invalid_tests[_i], &params));
209 }
210 END_TEST
211
212 static rsa_pss_params_t rsa_pss_params_sha1 = { .hash = HASH_SHA1, .mgf1_hash = HASH_SHA1, .salt_len = HASH_SIZE_SHA1, };
213 static rsa_pss_params_t rsa_pss_params_sha256 = { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA256, .salt_len = HASH_SIZE_SHA256, };
214 static rsa_pss_params_t rsa_pss_params_sha256_mgf1 = { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA512, .salt_len = HASH_SIZE_SHA256, };
215 static rsa_pss_params_t rsa_pss_params_sha256_salt = { .hash = HASH_SHA256, .mgf1_hash = HASH_SHA256, .salt_len = 10, };
216
217 static struct {
218 bool equal;
219 bool complies;
220 signature_params_t a;
221 signature_params_t b;
222 } params_compare_tests[] = {
223 { TRUE, TRUE, { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, }, { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, }, },
224 { FALSE, FALSE, { .scheme = SIGN_RSA_EMSA_PKCS1_SHA1, }, { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, }, },
225 { TRUE, TRUE, { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 },
226 { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 }, },
227 { FALSE, FALSE, { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, .params = &rsa_pss_params_sha256 },
228 { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, .params = &rsa_pss_params_sha256 }, },
229 { FALSE, FALSE, { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 },
230 { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256_mgf1 }, },
231 { FALSE, TRUE, { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 },
232 { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256_salt }, },
233 { FALSE, FALSE, { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha1 },
234 { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 }, },
235 { FALSE, FALSE, { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 },
236 { .scheme = SIGN_RSA_EMSA_PSS, }, },
237 };
238
239 START_TEST(test_params_compare)
240 {
241 bool res;
242
243 res = signature_params_equal(&params_compare_tests[_i].a,
244 &params_compare_tests[_i].b);
245 ck_assert(res == params_compare_tests[_i].equal);
246 res = signature_params_comply(&params_compare_tests[_i].a,
247 &params_compare_tests[_i].b);
248 ck_assert(res == params_compare_tests[_i].complies);
249 res = signature_params_comply(&params_compare_tests[_i].b,
250 &params_compare_tests[_i].a);
251 ck_assert(res == params_compare_tests[_i].complies);
252 }
253 END_TEST
254
255 START_TEST(test_params_compare_null)
256 {
257 ck_assert(signature_params_equal(NULL, NULL));
258 ck_assert(!signature_params_equal(&params_compare_tests[0].a, NULL));
259 ck_assert(!signature_params_equal(NULL, &params_compare_tests[0].a));
260 }
261 END_TEST
262
263 static struct {
264 signature_params_t src;
265 signature_params_t res;
266 } params_clone_tests[] = {
267 { { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, }, { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, }, },
268 { { .scheme = SIGN_RSA_EMSA_PSS }, { .scheme = SIGN_RSA_EMSA_PSS }, },
269 { { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 },
270 { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256 }, },
271 { { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256_salt },
272 { .scheme = SIGN_RSA_EMSA_PSS, .params = &rsa_pss_params_sha256_salt }, },
273 { { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256, .params = &rsa_pss_params_sha256 },
274 { .scheme = SIGN_RSA_EMSA_PKCS1_SHA2_256 }, },
275 };
276
277 START_TEST(test_params_clone)
278 {
279 signature_params_t *clone = NULL;
280
281 clone = signature_params_clone(&params_clone_tests[_i].src);
282 ck_assert(signature_params_equal(clone, &params_clone_tests[_i].res));
283 signature_params_destroy(clone);
284 }
285 END_TEST
286
287 START_TEST(test_params_clone_null)
288 {
289 signature_params_t *clone = NULL;
290
291 clone = signature_params_clone(clone);
292 ck_assert(!clone);
293 signature_params_destroy(clone);
294 }
295 END_TEST
296
297 START_TEST(test_params_clear)
298 {
299 signature_params_t *clone;
300
301 clone = signature_params_clone(&params_clone_tests[_i].src);
302 signature_params_clear(clone);
303 ck_assert_int_eq(clone->scheme, SIGN_UNKNOWN);
304 ck_assert(!clone->params);
305 free(clone);
306 }
307 END_TEST
308
309 START_TEST(test_params_clear_null)
310 {
311 signature_params_t *clone = NULL;
312
313 signature_params_clear(clone);
314 }
315 END_TEST
316
317 Suite *signature_params_suite_create()
318 {
319 Suite *s;
320 TCase *tc;
321
322 s = suite_create("signature params");
323
324 tc = tcase_create("rsa/pss parse");
325 tcase_add_loop_test(tc, test_rsa_pss_params_parse, 0, countof(rsa_pss_parse_tests));
326 tcase_add_loop_test(tc, test_rsa_pss_params_parse_invalid, 0, countof(rsa_pss_parse_invalid_tests));
327 suite_add_tcase(s, tc);
328
329 tc = tcase_create("rsa/pss build");
330 tcase_add_loop_test(tc, test_rsa_pss_params_build, 0, countof(rsa_pss_build_tests));
331 tcase_add_loop_test(tc, test_rsa_pss_params_build_invalid, 0, countof(rsa_pss_build_invalid_tests));
332 suite_add_tcase(s, tc);
333
334 tc = tcase_create("params compare");
335 tcase_add_loop_test(tc, test_params_compare, 0, countof(params_compare_tests));
336 tcase_add_test(tc, test_params_compare_null);
337 suite_add_tcase(s, tc);
338
339 tc = tcase_create("params clone");
340 tcase_add_loop_test(tc, test_params_clone, 0, countof(params_clone_tests));
341 tcase_add_test(tc, test_params_clone_null);
342 suite_add_tcase(s, tc);
343
344 tc = tcase_create("params clear");
345 tcase_add_loop_test(tc, test_params_clear, 0, countof(params_clone_tests));
346 tcase_add_test(tc, test_params_clear_null);
347 suite_add_tcase(s, tc);
348
349 return s;
350 }