summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-12-01 22:31:59 +0000
committertb <>2022-12-01 22:31:59 +0000
commit598ea710f5e46dc832efc0723a6fcce970aa2cff (patch)
treed4f446c996ea871381feb6d05a6abc99e9921d44 /src
parent75f6297c3c06270e7bc9e304410f71eed918aa27 (diff)
downloadopenbsd-598ea710f5e46dc832efc0723a6fcce970aa2cff.tar.gz
openbsd-598ea710f5e46dc832efc0723a6fcce970aa2cff.tar.bz2
openbsd-598ea710f5e46dc832efc0723a6fcce970aa2cff.zip
Check that the bn_isqrt -C output isn't changed
bn_isqrt -C generates code included in lib/libcrypto/lib/bn_isqrt.c. The regress tests already ensure that the content of the tables don't change. Ensure further that the code generation doesn't get out of sync.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/bn/Makefile14
-rw-r--r--src/regress/lib/libcrypto/bn/bn_isqrt_tables.txt30
2 files changed, 43 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/bn/Makefile b/src/regress/lib/libcrypto/bn/Makefile
index b5d146c71b..7dc5ef75c8 100644
--- a/src/regress/lib/libcrypto/bn/Makefile
+++ b/src/regress/lib/libcrypto/bn/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.9 2022/12/01 21:21:51 tb Exp $ 1# $OpenBSD: Makefile,v 1.10 2022/12/01 22:31:59 tb Exp $
2 2
3PROGS += bn_add_sub 3PROGS += bn_add_sub
4PROGS += bn_cmp 4PROGS += bn_cmp
@@ -32,9 +32,21 @@ run-$p: $p
32 ./$p 32 ./$p
33.endfor 33.endfor
34 34
35# Verify that the bn_isqrt -C output isn't changed by accident.
35isqrt-print-tables: bn_isqrt 36isqrt-print-tables: bn_isqrt
36 @./bn_isqrt -C 37 @./bn_isqrt -C
37 38
39CLEANFILES += bn_isqrt_gen_tables.txt.tmp bn_isqrt_gen_tables.txt
40bn_isqrt_gen_tables.txt: bn_isqrt
41 ${.MAKE} -C ${.CURDIR} isqrt-print-tables > $@.tmp
42 mv -f $@.tmp $@
43
44REGRESS_TARGETS += run-bn_isqrt_check_tables
45.PHONY: run-bn_isqrt_check_tables
46run-bn_isqrt_check_tables: bn_isqrt_gen_tables.txt
47 diff -pu ${.CURDIR}/bn_isqrt_tables.txt bn_isqrt_gen_tables.txt
48
49
38# Keep bn_test last since it is special 50# Keep bn_test last since it is special
39PROGS += bn_test 51PROGS += bn_test
40STATIC_LINK += bn_test 52STATIC_LINK += bn_test
diff --git a/src/regress/lib/libcrypto/bn/bn_isqrt_tables.txt b/src/regress/lib/libcrypto/bn/bn_isqrt_tables.txt
new file mode 100644
index 0000000000..bc045a220e
--- /dev/null
+++ b/src/regress/lib/libcrypto/bn/bn_isqrt_tables.txt
@@ -0,0 +1,30 @@
1const uint8_t is_square_mod_11[] = {
2 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0,
3};
4CTASSERT(sizeof(is_square_mod_11) == 11);
5
6const uint8_t is_square_mod_63[] = {
7 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,
8 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0,
9 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
10 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
11};
12CTASSERT(sizeof(is_square_mod_63) == 63);
13
14const uint8_t is_square_mod_64[] = {
15 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
16 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
17 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
18 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
19};
20CTASSERT(sizeof(is_square_mod_64) == 64);
21
22const uint8_t is_square_mod_65[] = {
23 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0,
24 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0,
25 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
26 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0,
27 1,
28};
29CTASSERT(sizeof(is_square_mod_65) == 65);
30