1ab7c5947Schristos /*
2e0ea3921Schristos * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
3ab7c5947Schristos *
4*8fbed61eSchristos * Licensed under the Apache License 2.0 (the "License"). You may not use
5ab7c5947Schristos * this file except in compliance with the License. You can obtain a copy
6ab7c5947Schristos * in the file LICENSE in the source distribution or at
7ab7c5947Schristos * https://www.openssl.org/source/license.html
8ab7c5947Schristos */
9ab7c5947Schristos
10ab7c5947Schristos #include <stdio.h>
11ab7c5947Schristos #include <stdlib.h>
12ab7c5947Schristos
13e0ea3921Schristos #include "internal/nelem.h"
1452629741Schristos #include "internal/constant_time.h"
15e0ea3921Schristos #include "testutil.h"
16e0ea3921Schristos #include "internal/numbers.h"
17e0ea3921Schristos
18ab7c5947Schristos static const unsigned int CONSTTIME_TRUE = (unsigned)(~0);
19ab7c5947Schristos static const unsigned int CONSTTIME_FALSE = 0;
20ab7c5947Schristos static const unsigned char CONSTTIME_TRUE_8 = 0xff;
21ab7c5947Schristos static const unsigned char CONSTTIME_FALSE_8 = 0;
22e0ea3921Schristos static const size_t CONSTTIME_TRUE_S = ~((size_t)0);
23e0ea3921Schristos static const size_t CONSTTIME_FALSE_S = 0;
24e0ea3921Schristos static uint32_t CONSTTIME_TRUE_32 = (uint32_t)(~(uint32_t)0);
25e0ea3921Schristos static uint32_t CONSTTIME_FALSE_32 = 0;
26e0ea3921Schristos static uint64_t CONSTTIME_TRUE_64 = (uint64_t)(~(uint64_t)0);
27e0ea3921Schristos static uint64_t CONSTTIME_FALSE_64 = 0;
28e0ea3921Schristos
29e0ea3921Schristos static unsigned int test_values[] = {
30e0ea3921Schristos 0, 1, 1024, 12345, 32000, UINT_MAX / 2 - 1,
31e0ea3921Schristos UINT_MAX / 2, UINT_MAX / 2 + 1, UINT_MAX - 1,
32e0ea3921Schristos UINT_MAX
33e0ea3921Schristos };
34e0ea3921Schristos
35e0ea3921Schristos static unsigned char test_values_8[] = {
36e0ea3921Schristos 0, 1, 2, 20, 32, 127, 128, 129, 255
37e0ea3921Schristos };
38e0ea3921Schristos
39e0ea3921Schristos static int signed_test_values[] = {
40e0ea3921Schristos 0, 1, -1, 1024, -1024, 12345, -12345,
41e0ea3921Schristos 32000, -32000, INT_MAX, INT_MIN, INT_MAX - 1,
42e0ea3921Schristos INT_MIN + 1
43e0ea3921Schristos };
44e0ea3921Schristos
45e0ea3921Schristos static size_t test_values_s[] = {
46e0ea3921Schristos 0, 1, 1024, 12345, 32000, SIZE_MAX / 2 - 1,
47e0ea3921Schristos SIZE_MAX / 2, SIZE_MAX / 2 + 1, SIZE_MAX - 1,
48e0ea3921Schristos SIZE_MAX
49e0ea3921Schristos };
50e0ea3921Schristos
51e0ea3921Schristos static uint32_t test_values_32[] = {
52e0ea3921Schristos 0, 1, 1024, 12345, 32000, UINT32_MAX / 2, UINT32_MAX / 2 + 1,
53e0ea3921Schristos UINT32_MAX - 1, UINT32_MAX
54e0ea3921Schristos };
55e0ea3921Schristos
56e0ea3921Schristos static uint64_t test_values_64[] = {
57e0ea3921Schristos 0, 1, 1024, 12345, 32000, 32000000, 32000000001, UINT64_MAX / 2,
58e0ea3921Schristos UINT64_MAX / 2 + 1, UINT64_MAX - 1, UINT64_MAX
59e0ea3921Schristos };
60ab7c5947Schristos
test_binary_op(unsigned int (* op)(unsigned int a,unsigned int b),const char * op_name,unsigned int a,unsigned int b,int is_true)61ab7c5947Schristos static int test_binary_op(unsigned int (*op) (unsigned int a, unsigned int b),
62ab7c5947Schristos const char *op_name, unsigned int a, unsigned int b,
63ab7c5947Schristos int is_true)
64ab7c5947Schristos {
65e0ea3921Schristos if (is_true && !TEST_uint_eq(op(a, b), CONSTTIME_TRUE))
66ab7c5947Schristos return 0;
67e0ea3921Schristos if (!is_true && !TEST_uint_eq(op(a, b), CONSTTIME_FALSE))
68e0ea3921Schristos return 0;
69e0ea3921Schristos return 1;
70ab7c5947Schristos }
71ab7c5947Schristos
test_binary_op_8(unsigned char (* op)(unsigned int a,unsigned int b),const char * op_name,unsigned int a,unsigned int b,int is_true)72ab7c5947Schristos static int test_binary_op_8(unsigned
73ab7c5947Schristos char (*op) (unsigned int a, unsigned int b),
74ab7c5947Schristos const char *op_name, unsigned int a,
75ab7c5947Schristos unsigned int b, int is_true)
76ab7c5947Schristos {
77e0ea3921Schristos if (is_true && !TEST_uint_eq(op(a, b), CONSTTIME_TRUE_8))
78ab7c5947Schristos return 0;
79e0ea3921Schristos if (!is_true && !TEST_uint_eq(op(a, b), CONSTTIME_FALSE_8))
80e0ea3921Schristos return 0;
81e0ea3921Schristos return 1;
82ab7c5947Schristos }
83ab7c5947Schristos
test_binary_op_s(size_t (* op)(size_t a,size_t b),const char * op_name,size_t a,size_t b,int is_true)84e0ea3921Schristos static int test_binary_op_s(size_t (*op) (size_t a, size_t b),
85e0ea3921Schristos const char *op_name, size_t a, size_t b,
86e0ea3921Schristos int is_true)
87ab7c5947Schristos {
88e0ea3921Schristos if (is_true && !TEST_size_t_eq(op(a,b), CONSTTIME_TRUE_S))
89ab7c5947Schristos return 0;
90e0ea3921Schristos if (!is_true && !TEST_uint_eq(op(a,b), CONSTTIME_FALSE_S))
91e0ea3921Schristos return 0;
92e0ea3921Schristos return 1;
93ab7c5947Schristos }
94ab7c5947Schristos
test_binary_op_64(uint64_t (* op)(uint64_t a,uint64_t b),const char * op_name,uint64_t a,uint64_t b,int is_true)95e0ea3921Schristos static int test_binary_op_64(uint64_t (*op)(uint64_t a, uint64_t b),
96e0ea3921Schristos const char *op_name, uint64_t a, uint64_t b,
97e0ea3921Schristos int is_true)
98ab7c5947Schristos {
99e0ea3921Schristos uint64_t c = op(a, b);
100e0ea3921Schristos
101e0ea3921Schristos if (is_true && c != CONSTTIME_TRUE_64) {
102e0ea3921Schristos TEST_error("TRUE %s op failed", op_name);
103e0ea3921Schristos BIO_printf(bio_err, "a=%jx b=%jx\n", a, b);
104e0ea3921Schristos return 0;
105e0ea3921Schristos } else if (!is_true && c != CONSTTIME_FALSE_64) {
106e0ea3921Schristos TEST_error("FALSE %s op failed", op_name);
107e0ea3921Schristos BIO_printf(bio_err, "a=%jx b=%jx\n", a, b);
108e0ea3921Schristos return 0;
109e0ea3921Schristos }
110ab7c5947Schristos return 1;
111ab7c5947Schristos }
112e0ea3921Schristos
test_is_zero(int i)113e0ea3921Schristos static int test_is_zero(int i)
114e0ea3921Schristos {
115e0ea3921Schristos unsigned int a = test_values[i];
116e0ea3921Schristos
117e0ea3921Schristos if (a == 0 && !TEST_uint_eq(constant_time_is_zero(a), CONSTTIME_TRUE))
118ab7c5947Schristos return 0;
119e0ea3921Schristos if (a != 0 && !TEST_uint_eq(constant_time_is_zero(a), CONSTTIME_FALSE))
120e0ea3921Schristos return 0;
121e0ea3921Schristos return 1;
122e0ea3921Schristos }
123e0ea3921Schristos
test_is_zero_8(int i)124e0ea3921Schristos static int test_is_zero_8(int i)
125e0ea3921Schristos {
126e0ea3921Schristos unsigned int a = test_values_8[i];
127e0ea3921Schristos
128e0ea3921Schristos if (a == 0 && !TEST_uint_eq(constant_time_is_zero_8(a), CONSTTIME_TRUE_8))
129e0ea3921Schristos return 0;
130e0ea3921Schristos if (a != 0 && !TEST_uint_eq(constant_time_is_zero_8(a), CONSTTIME_FALSE_8))
131e0ea3921Schristos return 0;
132e0ea3921Schristos return 1;
133e0ea3921Schristos }
134e0ea3921Schristos
test_is_zero_32(int i)135e0ea3921Schristos static int test_is_zero_32(int i)
136e0ea3921Schristos {
137e0ea3921Schristos uint32_t a = test_values_32[i];
138e0ea3921Schristos
139e0ea3921Schristos if (a == 0 && !TEST_true(constant_time_is_zero_32(a) == CONSTTIME_TRUE_32))
140e0ea3921Schristos return 0;
141e0ea3921Schristos if (a != 0 && !TEST_true(constant_time_is_zero_32(a) == CONSTTIME_FALSE_32))
142e0ea3921Schristos return 0;
143e0ea3921Schristos return 1;
144e0ea3921Schristos }
145e0ea3921Schristos
test_is_zero_s(int i)146e0ea3921Schristos static int test_is_zero_s(int i)
147e0ea3921Schristos {
148e0ea3921Schristos size_t a = test_values_s[i];
149e0ea3921Schristos
150e0ea3921Schristos if (a == 0 && !TEST_size_t_eq(constant_time_is_zero_s(a), CONSTTIME_TRUE_S))
151e0ea3921Schristos return 0;
152e0ea3921Schristos if (a != 0 && !TEST_uint_eq(constant_time_is_zero_s(a), CONSTTIME_FALSE_S))
153e0ea3921Schristos return 0;
154e0ea3921Schristos return 1;
155ab7c5947Schristos }
156ab7c5947Schristos
test_select(unsigned int a,unsigned int b)157ab7c5947Schristos static int test_select(unsigned int a, unsigned int b)
158ab7c5947Schristos {
159e0ea3921Schristos if (!TEST_uint_eq(constant_time_select(CONSTTIME_TRUE, a, b), a))
160ab7c5947Schristos return 0;
161e0ea3921Schristos if (!TEST_uint_eq(constant_time_select(CONSTTIME_FALSE, a, b), b))
162e0ea3921Schristos return 0;
163e0ea3921Schristos return 1;
164ab7c5947Schristos }
165ab7c5947Schristos
test_select_8(unsigned char a,unsigned char b)166ab7c5947Schristos static int test_select_8(unsigned char a, unsigned char b)
167ab7c5947Schristos {
168e0ea3921Schristos if (!TEST_uint_eq(constant_time_select_8(CONSTTIME_TRUE_8, a, b), a))
169ab7c5947Schristos return 0;
170e0ea3921Schristos if (!TEST_uint_eq(constant_time_select_8(CONSTTIME_FALSE_8, a, b), b))
171e0ea3921Schristos return 0;
172e0ea3921Schristos return 1;
173e0ea3921Schristos }
174e0ea3921Schristos
test_select_32(uint32_t a,uint32_t b)175e0ea3921Schristos static int test_select_32(uint32_t a, uint32_t b)
176e0ea3921Schristos {
177e0ea3921Schristos if (!TEST_true(constant_time_select_32(CONSTTIME_TRUE_32, a, b) == a))
178e0ea3921Schristos return 0;
179e0ea3921Schristos if (!TEST_true(constant_time_select_32(CONSTTIME_FALSE_32, a, b) == b))
180e0ea3921Schristos return 0;
181e0ea3921Schristos return 1;
182e0ea3921Schristos }
183e0ea3921Schristos
test_select_s(size_t a,size_t b)184e0ea3921Schristos static int test_select_s(size_t a, size_t b)
185e0ea3921Schristos {
186e0ea3921Schristos if (!TEST_uint_eq(constant_time_select_s(CONSTTIME_TRUE_S, a, b), a))
187e0ea3921Schristos return 0;
188e0ea3921Schristos if (!TEST_uint_eq(constant_time_select_s(CONSTTIME_FALSE_S, a, b), b))
189e0ea3921Schristos return 0;
190e0ea3921Schristos return 1;
191e0ea3921Schristos }
192e0ea3921Schristos
test_select_64(uint64_t a,uint64_t b)193e0ea3921Schristos static int test_select_64(uint64_t a, uint64_t b)
194e0ea3921Schristos {
195e0ea3921Schristos uint64_t selected = constant_time_select_64(CONSTTIME_TRUE_64, a, b);
196e0ea3921Schristos
197e0ea3921Schristos if (selected != a) {
198e0ea3921Schristos TEST_error("test_select_64 TRUE failed");
199e0ea3921Schristos BIO_printf(bio_err, "a=%jx b=%jx got %jx wanted a\n", a, b, selected);
200e0ea3921Schristos return 0;
201e0ea3921Schristos }
202e0ea3921Schristos selected = constant_time_select_64(CONSTTIME_FALSE_64, a, b);
203e0ea3921Schristos if (selected != b) {
204e0ea3921Schristos BIO_printf(bio_err, "a=%jx b=%jx got %jx wanted b\n", a, b, selected);
205e0ea3921Schristos return 0;
206e0ea3921Schristos }
207e0ea3921Schristos return 1;
208ab7c5947Schristos }
209ab7c5947Schristos
test_select_int(int a,int b)210ab7c5947Schristos static int test_select_int(int a, int b)
211ab7c5947Schristos {
212e0ea3921Schristos if (!TEST_int_eq(constant_time_select_int(CONSTTIME_TRUE, a, b), a))
213ab7c5947Schristos return 0;
214e0ea3921Schristos if (!TEST_int_eq(constant_time_select_int(CONSTTIME_FALSE, a, b), b))
215ab7c5947Schristos return 0;
216e0ea3921Schristos return 1;
217ab7c5947Schristos }
218ab7c5947Schristos
test_eq_int_8(int a,int b)219ab7c5947Schristos static int test_eq_int_8(int a, int b)
220ab7c5947Schristos {
221e0ea3921Schristos if (a == b && !TEST_int_eq(constant_time_eq_int_8(a, b), CONSTTIME_TRUE_8))
222ab7c5947Schristos return 0;
223e0ea3921Schristos if (a != b && !TEST_int_eq(constant_time_eq_int_8(a, b), CONSTTIME_FALSE_8))
224e0ea3921Schristos return 0;
225e0ea3921Schristos return 1;
226ab7c5947Schristos }
227ab7c5947Schristos
test_eq_s(size_t a,size_t b)228e0ea3921Schristos static int test_eq_s(size_t a, size_t b)
229ab7c5947Schristos {
230e0ea3921Schristos if (a == b && !TEST_size_t_eq(constant_time_eq_s(a, b), CONSTTIME_TRUE_S))
231e0ea3921Schristos return 0;
232e0ea3921Schristos if (a != b && !TEST_int_eq(constant_time_eq_s(a, b), CONSTTIME_FALSE_S))
233e0ea3921Schristos return 0;
234e0ea3921Schristos return 1;
235ab7c5947Schristos }
236ab7c5947Schristos
test_eq_int(int a,int b)237e0ea3921Schristos static int test_eq_int(int a, int b)
238e0ea3921Schristos {
239e0ea3921Schristos if (a == b && !TEST_uint_eq(constant_time_eq_int(a, b), CONSTTIME_TRUE))
240e0ea3921Schristos return 0;
241e0ea3921Schristos if (a != b && !TEST_uint_eq(constant_time_eq_int(a, b), CONSTTIME_FALSE))
242e0ea3921Schristos return 0;
243e0ea3921Schristos return 1;
244e0ea3921Schristos }
245e0ea3921Schristos
test_sizeofs(void)246e0ea3921Schristos static int test_sizeofs(void)
247e0ea3921Schristos {
248e0ea3921Schristos if (!TEST_uint_eq(OSSL_NELEM(test_values), OSSL_NELEM(test_values_s)))
249e0ea3921Schristos return 0;
250e0ea3921Schristos return 1;
251e0ea3921Schristos }
252e0ea3921Schristos
test_binops(int i)253e0ea3921Schristos static int test_binops(int i)
254e0ea3921Schristos {
255e0ea3921Schristos unsigned int a = test_values[i];
256e0ea3921Schristos int j;
257e0ea3921Schristos int ret = 1;
258e0ea3921Schristos
259e0ea3921Schristos for (j = 0; j < (int)OSSL_NELEM(test_values); ++j) {
260e0ea3921Schristos unsigned int b = test_values[j];
261e0ea3921Schristos
262e0ea3921Schristos if (!test_select(a, b)
263e0ea3921Schristos || !test_binary_op(&constant_time_lt, "ct_lt",
264e0ea3921Schristos a, b, a < b)
265e0ea3921Schristos || !test_binary_op(&constant_time_lt, "constant_time_lt",
266e0ea3921Schristos b, a, b < a)
267e0ea3921Schristos || !test_binary_op(&constant_time_ge, "constant_time_ge",
268e0ea3921Schristos a, b, a >= b)
269e0ea3921Schristos || !test_binary_op(&constant_time_ge, "constant_time_ge",
270e0ea3921Schristos b, a, b >= a)
271e0ea3921Schristos || !test_binary_op(&constant_time_eq, "constant_time_eq",
272e0ea3921Schristos a, b, a == b)
273e0ea3921Schristos || !test_binary_op(&constant_time_eq, "constant_time_eq",
274e0ea3921Schristos b, a, b == a))
275e0ea3921Schristos ret = 0;
276e0ea3921Schristos }
277e0ea3921Schristos return ret;
278e0ea3921Schristos }
279e0ea3921Schristos
test_binops_8(int i)280e0ea3921Schristos static int test_binops_8(int i)
281e0ea3921Schristos {
282e0ea3921Schristos unsigned int a = test_values_8[i];
283e0ea3921Schristos int j;
284e0ea3921Schristos int ret = 1;
285e0ea3921Schristos
286e0ea3921Schristos for (j = 0; j < (int)OSSL_NELEM(test_values_8); ++j) {
287e0ea3921Schristos unsigned int b = test_values_8[j];
288e0ea3921Schristos
289e0ea3921Schristos if (!test_binary_op_8(&constant_time_lt_8, "constant_time_lt_8",
290e0ea3921Schristos a, b, a < b)
291e0ea3921Schristos || !test_binary_op_8(&constant_time_lt_8, "constant_time_lt_8",
292e0ea3921Schristos b, a, b < a)
293e0ea3921Schristos || !test_binary_op_8(&constant_time_ge_8, "constant_time_ge_8",
294e0ea3921Schristos a, b, a >= b)
295e0ea3921Schristos || !test_binary_op_8(&constant_time_ge_8, "constant_time_ge_8",
296e0ea3921Schristos b, a, b >= a)
297e0ea3921Schristos || !test_binary_op_8(&constant_time_eq_8, "constant_time_eq_8",
298e0ea3921Schristos a, b, a == b)
299e0ea3921Schristos || !test_binary_op_8(&constant_time_eq_8, "constant_time_eq_8",
300e0ea3921Schristos b, a, b == a))
301e0ea3921Schristos ret = 0;
302e0ea3921Schristos }
303e0ea3921Schristos return ret;
304e0ea3921Schristos }
305e0ea3921Schristos
test_binops_s(int i)306e0ea3921Schristos static int test_binops_s(int i)
307e0ea3921Schristos {
308e0ea3921Schristos size_t a = test_values_s[i];
309e0ea3921Schristos int j;
310e0ea3921Schristos int ret = 1;
311e0ea3921Schristos
312e0ea3921Schristos for (j = 0; j < (int)OSSL_NELEM(test_values_s); ++j) {
313e0ea3921Schristos size_t b = test_values_s[j];
314e0ea3921Schristos
315e0ea3921Schristos if (!test_select_s(a, b)
316e0ea3921Schristos || !test_eq_s(a, b)
317e0ea3921Schristos || !test_binary_op_s(&constant_time_lt_s, "constant_time_lt_s",
318e0ea3921Schristos a, b, a < b)
319e0ea3921Schristos || !test_binary_op_s(&constant_time_lt_s, "constant_time_lt_s",
320e0ea3921Schristos b, a, b < a)
321e0ea3921Schristos || !test_binary_op_s(&constant_time_ge_s, "constant_time_ge_s",
322e0ea3921Schristos a, b, a >= b)
323e0ea3921Schristos || !test_binary_op_s(&constant_time_ge_s, "constant_time_ge_s",
324e0ea3921Schristos b, a, b >= a)
325e0ea3921Schristos || !test_binary_op_s(&constant_time_eq_s, "constant_time_eq_s",
326e0ea3921Schristos a, b, a == b)
327e0ea3921Schristos || !test_binary_op_s(&constant_time_eq_s, "constant_time_eq_s",
328e0ea3921Schristos b, a, b == a))
329e0ea3921Schristos ret = 0;
330e0ea3921Schristos }
331e0ea3921Schristos return ret;
332e0ea3921Schristos }
333e0ea3921Schristos
test_signed(int i)334e0ea3921Schristos static int test_signed(int i)
335e0ea3921Schristos {
336e0ea3921Schristos int c = signed_test_values[i];
337e0ea3921Schristos unsigned int j;
338e0ea3921Schristos int ret = 1;
339e0ea3921Schristos
340ab7c5947Schristos for (j = 0; j < OSSL_NELEM(signed_test_values); ++j) {
341e0ea3921Schristos int d = signed_test_values[j];
342e0ea3921Schristos
343e0ea3921Schristos if (!test_select_int(c, d)
344e0ea3921Schristos || !test_eq_int(c, d)
345e0ea3921Schristos || !test_eq_int_8(c, d))
346e0ea3921Schristos ret = 0;
347ab7c5947Schristos }
348e0ea3921Schristos return ret;
349ab7c5947Schristos }
350ab7c5947Schristos
test_8values(int i)351e0ea3921Schristos static int test_8values(int i)
352e0ea3921Schristos {
353e0ea3921Schristos unsigned char e = test_values_8[i];
354e0ea3921Schristos unsigned int j;
355e0ea3921Schristos int ret = 1;
356e0ea3921Schristos
357ab7c5947Schristos for (j = 0; j < sizeof(test_values_8); ++j) {
358e0ea3921Schristos unsigned char f = test_values_8[j];
359e0ea3921Schristos
360e0ea3921Schristos if (!test_select_8(e, f))
361e0ea3921Schristos ret = 0;
362ab7c5947Schristos }
363e0ea3921Schristos return ret;
364ab7c5947Schristos }
365ab7c5947Schristos
test_32values(int i)366e0ea3921Schristos static int test_32values(int i)
367e0ea3921Schristos {
368e0ea3921Schristos uint32_t e = test_values_32[i];
369e0ea3921Schristos size_t j;
370e0ea3921Schristos int ret = 1;
371e0ea3921Schristos
372e0ea3921Schristos for (j = 0; j < OSSL_NELEM(test_values_32); j++) {
373e0ea3921Schristos uint32_t f = test_values_32[j];
374e0ea3921Schristos
375e0ea3921Schristos if (!test_select_32(e, f))
376e0ea3921Schristos ret = 0;
377ab7c5947Schristos }
378e0ea3921Schristos return ret;
379e0ea3921Schristos }
380e0ea3921Schristos
test_64values(int i)381e0ea3921Schristos static int test_64values(int i)
382e0ea3921Schristos {
383e0ea3921Schristos uint64_t g = test_values_64[i];
384e0ea3921Schristos int j, ret = 1;
385e0ea3921Schristos
386e0ea3921Schristos for (j = i + 1; j < (int)OSSL_NELEM(test_values_64); j++) {
387e0ea3921Schristos uint64_t h = test_values_64[j];
388e0ea3921Schristos
389e0ea3921Schristos if (!test_binary_op_64(&constant_time_lt_64, "constant_time_lt_64",
390e0ea3921Schristos g, h, g < h)
391e0ea3921Schristos || !test_select_64(g, h)) {
392e0ea3921Schristos TEST_info("test_64values failed i=%d j=%d", i, j);
393e0ea3921Schristos ret = 0;
394e0ea3921Schristos }
395e0ea3921Schristos }
396e0ea3921Schristos return ret;
397e0ea3921Schristos }
398e0ea3921Schristos
setup_tests(void)399e0ea3921Schristos int setup_tests(void)
400e0ea3921Schristos {
401e0ea3921Schristos ADD_TEST(test_sizeofs);
402e0ea3921Schristos ADD_ALL_TESTS(test_is_zero, OSSL_NELEM(test_values));
403e0ea3921Schristos ADD_ALL_TESTS(test_is_zero_8, OSSL_NELEM(test_values_8));
404e0ea3921Schristos ADD_ALL_TESTS(test_is_zero_32, OSSL_NELEM(test_values_32));
405e0ea3921Schristos ADD_ALL_TESTS(test_is_zero_s, OSSL_NELEM(test_values_s));
406e0ea3921Schristos ADD_ALL_TESTS(test_binops, OSSL_NELEM(test_values));
407e0ea3921Schristos ADD_ALL_TESTS(test_binops_8, OSSL_NELEM(test_values_8));
408e0ea3921Schristos ADD_ALL_TESTS(test_binops_s, OSSL_NELEM(test_values_s));
409e0ea3921Schristos ADD_ALL_TESTS(test_signed, OSSL_NELEM(signed_test_values));
410e0ea3921Schristos ADD_ALL_TESTS(test_8values, OSSL_NELEM(test_values_8));
411e0ea3921Schristos ADD_ALL_TESTS(test_32values, OSSL_NELEM(test_values_32));
412e0ea3921Schristos ADD_ALL_TESTS(test_64values, OSSL_NELEM(test_values_64));
413e0ea3921Schristos return 1;
414ab7c5947Schristos }
415