diff options
author | tb <> | 2020-09-18 10:18:26 +0000 |
---|---|---|
committer | tb <> | 2020-09-18 10:18:26 +0000 |
commit | d69772a4d7336813a88117684aef29f528d0ca37 (patch) | |
tree | 4dd6c62a0ac48af5a9320e2de99412d98d09ab6e /src | |
parent | 5ab1a4db10bf4cb7507852b60baf6f13caca0187 (diff) | |
download | openbsd-d69772a4d7336813a88117684aef29f528d0ca37.tar.gz openbsd-d69772a4d7336813a88117684aef29f528d0ca37.tar.bz2 openbsd-d69772a4d7336813a88117684aef29f528d0ca37.zip |
Check availability of the symbols in Symbols.list
This regress parses Symbols.list and pulls all public headers out of
libcrypto's Makefile to generate a simple program that uses all public
symbols. A number of symbols need to be declared extern since they are
unavailable in public headers and a handful must be skipped since they
are apparently architecture dependent.
This would have caught the recent breakage due to the accidental removal
of the NAME_CONSTRAINTS_check() function and points out a number of
places where cleanup may happen in the future.
discussed with beck
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/symbols/Makefile | 41 | ||||
-rw-r--r-- | src/regress/lib/libcrypto/symbols/symbols.awk | 141 |
2 files changed, 182 insertions, 0 deletions
diff --git a/src/regress/lib/libcrypto/symbols/Makefile b/src/regress/lib/libcrypto/symbols/Makefile new file mode 100644 index 0000000000..df4d1e3b2a --- /dev/null +++ b/src/regress/lib/libcrypto/symbols/Makefile | |||
@@ -0,0 +1,41 @@ | |||
1 | # $OpenBSD: Makefile,v 1.1 2020/09/18 10:18:25 tb Exp $ | ||
2 | |||
3 | TESTS = \ | ||
4 | symbols | ||
5 | |||
6 | PROG = ${TESTS} | ||
7 | |||
8 | REGRESS_TARGETS= all_tests | ||
9 | |||
10 | .include <bsd.own.mk> # for BSDSRCDIR | ||
11 | |||
12 | # libcrypto's Makefile stomps on globals, so only include it when needed. | ||
13 | .ifmake include_headers.c | ||
14 | . include "${BSDSRCDIR}/lib/libcrypto/Makefile" # for HDRS | ||
15 | |||
16 | include_headers.c: ${BSDSRCDIR}/lib/libcrypto/Symbols.list | ||
17 | . for h in ${HDRS:T} | ||
18 | @echo "#include <openssl/$h>" >> include_headers.c.tmp | ||
19 | . endfor | ||
20 | mv include_headers.c.tmp include_headers.c | ||
21 | .endif | ||
22 | |||
23 | LDADD= -lcrypto | ||
24 | DPADD= ${LIBCRYPTO} ${LIBSSL} | ||
25 | LDFLAGS+= -lcrypto | ||
26 | CFLAGS+= -Wno-deprecated-declarations | ||
27 | |||
28 | CLEANFILES+= include_headers.c symbols.c symbols.c.tmp | ||
29 | |||
30 | symbols.c: symbols.awk ../../../../lib/libcrypto/Symbols.list | ||
31 | make -f ${.CURDIR}/Makefile include_headers.c | ||
32 | awk -f ${.CURDIR}/symbols.awk \ | ||
33 | < ${BSDSRCDIR}/lib/libcrypto/Symbols.list > symbols.c.tmp | ||
34 | mv symbols.c.tmp symbols.c | ||
35 | |||
36 | all_tests: ${TESTS} | ||
37 | @for test in $>; do \ | ||
38 | ./$$test 2>/dev/null; \ | ||
39 | done | ||
40 | |||
41 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libcrypto/symbols/symbols.awk b/src/regress/lib/libcrypto/symbols/symbols.awk new file mode 100644 index 0000000000..f5585e3934 --- /dev/null +++ b/src/regress/lib/libcrypto/symbols/symbols.awk | |||
@@ -0,0 +1,141 @@ | |||
1 | # $OpenBSD: symbols.awk,v 1.1 2020/09/18 10:18:26 tb Exp $ | ||
2 | |||
3 | # Copyright (c) 2018,2020 Theo Buehler <tb@openbsd.org> | ||
4 | # | ||
5 | # Permission to use, copy, modify, and distribute this software for any | ||
6 | # purpose with or without fee is hereby granted, provided that the above | ||
7 | # copyright notice and this permission notice appear in all copies. | ||
8 | # | ||
9 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | |||
17 | # usage: awk -f symbols.awk < Symbols.list > symbols.c | ||
18 | |||
19 | BEGIN { | ||
20 | printf("#include <openssl/pem.h> /* CMS special */\n") | ||
21 | printf("#include \"include_headers.c\"\n\n") | ||
22 | } | ||
23 | |||
24 | /^DHparams_it$/ || | ||
25 | /^DSA_SIG_it$/ || | ||
26 | /^ECDSA_SIG_it$/ || | ||
27 | /^ECPARAMETERS_it$/ || | ||
28 | /^ECPKPARAMETERS_it$/ || | ||
29 | /^EC_PRIVATEKEY_it$/ || | ||
30 | /^ESS_CERT_ID_it$/ || | ||
31 | /^ESS_ISSUER_SERIAL_it$/ || | ||
32 | /^ESS_SIGNING_CERT_it$/ || | ||
33 | /^NETSCAPE_ENCRYPTED_PKEY_it$/ || | ||
34 | /^NETSCAPE_PKEY_it$/ || | ||
35 | /^TS_ACCURACY_it$/ || | ||
36 | /^TS_MSG_IMPRINT_it$/ || | ||
37 | /^TS_REQ_it$/ || | ||
38 | /^TS_RESP_it$/ || | ||
39 | /^TS_STATUS_INFO_it$/ || | ||
40 | /^TS_TST_INFO_it$/ || | ||
41 | /^X509_ATTRIBUTE_SET_it$/ || | ||
42 | /^X509_NAME_ENTRIES_it$/ || | ||
43 | /^X509_NAME_INTERNAL_it$/ || | ||
44 | /^X9_62_CHARACTERISTIC_TWO_it$/ || | ||
45 | /^X9_62_CURVE_it$/ || | ||
46 | /^X9_62_FIELDID_it$/ || | ||
47 | /^X9_62_PENTANOMIAL_it$/ { | ||
48 | printf("extern ASN1_ITEM %s;\n", $0) | ||
49 | } | ||
50 | |||
51 | # internal function used in libtls | ||
52 | /^ASN1_time_tm_clamp_notafter$/ { | ||
53 | symbols[$0] = $0 | ||
54 | printf("extern int ASN1_time_tm_clamp_notafter(struct tm *);\n") | ||
55 | } | ||
56 | |||
57 | # These are machdep (at least cpuid_setup and ia32cap_P are internal on amd64). | ||
58 | /^OPENSSL_cpuid_setup$/ || | ||
59 | /^OPENSSL_cpu_caps$/ || | ||
60 | /^OPENSSL_ia32cap_P$/ { | ||
61 | printf("/* skipped %s */\n", $0) | ||
62 | next | ||
63 | } | ||
64 | |||
65 | /^OPENSSL_strcasecmp$/ { | ||
66 | printf("extern int OPENSSL_strcasecmp(const char *, const char *);\n") | ||
67 | } | ||
68 | |||
69 | /^OPENSSL_strncasecmp$/ { | ||
70 | printf("extern int OPENSSL_strncasecmp(const char *, const char *, size_t);\n") | ||
71 | } | ||
72 | |||
73 | /^BIO_CONNECT_free$/ || | ||
74 | /^ECPARAMETERS_free$/ || | ||
75 | /^ECPKPARAMETERS_free$/ || | ||
76 | /^EC_PRIVATEKEY_free$/ || | ||
77 | /^NETSCAPE_ENCRYPTED_PKEY_free$/ || | ||
78 | /^NETSCAPE_PKEY_free$/ || | ||
79 | /^X9_62_CHARACTERISTIC_TWO_free$/ || | ||
80 | /^X9_62_PENTANOMIAL_free$/ { | ||
81 | printf("extern void %s(void *);\n", $0) | ||
82 | } | ||
83 | |||
84 | /^BIO_CONNECT_new$/ || | ||
85 | /^ECPARAMETERS_new$/ || | ||
86 | /^ECPKPARAMETERS_new$/ || | ||
87 | /^EC_PRIVATEKEY_new$/ || | ||
88 | /^NETSCAPE_ENCRYPTED_PKEY_new$/ || | ||
89 | /^NETSCAPE_PKEY_new$/ || | ||
90 | /^X9_62_CHARACTERISTIC_TWO_new$/ || | ||
91 | /^X9_62_PENTANOMIAL_new$/ { | ||
92 | printf("extern void *%s(void);\n", $0) | ||
93 | } | ||
94 | |||
95 | /^d2i_DSAPrivateKey_fp$/ { | ||
96 | printf("extern void *%s(FILE *, void **);\n", $0) | ||
97 | } | ||
98 | |||
99 | /^d2i_ECPKPARAMETERS$/ || | ||
100 | /^d2i_EC_PRIVATEKEY$/ || | ||
101 | /^d2i_NETSCAPE_ENCRYPTED_PKEY$/ || | ||
102 | /^d2i_NETSCAPE_PKEY$/ { | ||
103 | printf("extern void *%s", $0) | ||
104 | printf("(void *, const unsigned char *, const unsigned char *);\n", $0) | ||
105 | } | ||
106 | |||
107 | /^i2d_ECPKPARAMETERS$/ || | ||
108 | /^i2d_EC_PRIVATEKEY$/ || | ||
109 | /^i2d_NETSCAPE_ENCRYPTED_PKEY$/ || | ||
110 | /^i2d_NETSCAPE_PKEY$/ { | ||
111 | printf("extern int %s", $0) | ||
112 | printf("(const void *, unsigned char **);\n") | ||
113 | } | ||
114 | |||
115 | { | ||
116 | symbols[$0] = $0 | ||
117 | } | ||
118 | |||
119 | END { | ||
120 | printf("\nint\nmain(void)\n{\n") | ||
121 | printf("\tsize_t i;\n"); | ||
122 | |||
123 | printf("\tstruct {\n") | ||
124 | printf("\t\tconst char *const name;\n") | ||
125 | printf("\t\tconst void *addr;\n") | ||
126 | printf("\t} symbols[] = {\n") | ||
127 | |||
128 | for (symbol in symbols) { | ||
129 | printf("\t\t{\n") | ||
130 | printf("\t\t\t.name = \"%s\",\n", symbol) | ||
131 | printf("\t\t\t.addr = &%s,\n", symbol) | ||
132 | printf("\t\t},\n") | ||
133 | } | ||
134 | |||
135 | printf("\t\};\n\n") | ||
136 | |||
137 | printf("\tfor (i = 0; i < sizeof(symbols) / sizeof(symbols[0]); i++)\n") | ||
138 | printf("\t\tfprintf(stderr, \"%%s: %%p\\n\", symbols[i].name, symbols[i].addr);\n") | ||
139 | printf("\n\tprintf(\"OK\\n\");\n") | ||
140 | printf("\n\treturn 0;\n}\n") | ||
141 | } | ||