diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2020-09-18 10:18:27 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2020-09-18 10:18:27 +0000 |
commit | 2ff557bf94b4d88ae9590ffd0fbfd4a10f0fcd69 (patch) | |
tree | 19b3ec43df0cb5a2cddef182eef4d2c8fe6820b7 /regress/lib/libcrypto | |
parent | 479d861e65b26f1cb73e1a7939f546d5dcc0846b (diff) |
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 'regress/lib/libcrypto')
-rw-r--r-- | regress/lib/libcrypto/symbols/Makefile | 41 | ||||
-rw-r--r-- | regress/lib/libcrypto/symbols/symbols.awk | 141 |
2 files changed, 182 insertions, 0 deletions
diff --git a/regress/lib/libcrypto/symbols/Makefile b/regress/lib/libcrypto/symbols/Makefile new file mode 100644 index 00000000000..df4d1e3b2af --- /dev/null +++ b/regress/lib/libcrypto/symbols/Makefile @@ -0,0 +1,41 @@ +# $OpenBSD: Makefile,v 1.1 2020/09/18 10:18:25 tb Exp $ + +TESTS = \ + symbols + +PROG = ${TESTS} + +REGRESS_TARGETS= all_tests + +.include <bsd.own.mk> # for BSDSRCDIR + +# libcrypto's Makefile stomps on globals, so only include it when needed. +.ifmake include_headers.c +. include "${BSDSRCDIR}/lib/libcrypto/Makefile" # for HDRS + +include_headers.c: ${BSDSRCDIR}/lib/libcrypto/Symbols.list +. for h in ${HDRS:T} + @echo "#include <openssl/$h>" >> include_headers.c.tmp +. endfor + mv include_headers.c.tmp include_headers.c +.endif + +LDADD= -lcrypto +DPADD= ${LIBCRYPTO} ${LIBSSL} +LDFLAGS+= -lcrypto +CFLAGS+= -Wno-deprecated-declarations + +CLEANFILES+= include_headers.c symbols.c symbols.c.tmp + +symbols.c: symbols.awk ../../../../lib/libcrypto/Symbols.list + make -f ${.CURDIR}/Makefile include_headers.c + awk -f ${.CURDIR}/symbols.awk \ + < ${BSDSRCDIR}/lib/libcrypto/Symbols.list > symbols.c.tmp + mv symbols.c.tmp symbols.c + +all_tests: ${TESTS} + @for test in $>; do \ + ./$$test 2>/dev/null; \ + done + +.include <bsd.regress.mk> diff --git a/regress/lib/libcrypto/symbols/symbols.awk b/regress/lib/libcrypto/symbols/symbols.awk new file mode 100644 index 00000000000..f5585e3934f --- /dev/null +++ b/regress/lib/libcrypto/symbols/symbols.awk @@ -0,0 +1,141 @@ +# $OpenBSD: symbols.awk,v 1.1 2020/09/18 10:18:26 tb Exp $ + +# Copyright (c) 2018,2020 Theo Buehler <tb@openbsd.org> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# usage: awk -f symbols.awk < Symbols.list > symbols.c + +BEGIN { + printf("#include <openssl/pem.h> /* CMS special */\n") + printf("#include \"include_headers.c\"\n\n") +} + +/^DHparams_it$/ || +/^DSA_SIG_it$/ || +/^ECDSA_SIG_it$/ || +/^ECPARAMETERS_it$/ || +/^ECPKPARAMETERS_it$/ || +/^EC_PRIVATEKEY_it$/ || +/^ESS_CERT_ID_it$/ || +/^ESS_ISSUER_SERIAL_it$/ || +/^ESS_SIGNING_CERT_it$/ || +/^NETSCAPE_ENCRYPTED_PKEY_it$/ || +/^NETSCAPE_PKEY_it$/ || +/^TS_ACCURACY_it$/ || +/^TS_MSG_IMPRINT_it$/ || +/^TS_REQ_it$/ || +/^TS_RESP_it$/ || +/^TS_STATUS_INFO_it$/ || +/^TS_TST_INFO_it$/ || +/^X509_ATTRIBUTE_SET_it$/ || +/^X509_NAME_ENTRIES_it$/ || +/^X509_NAME_INTERNAL_it$/ || +/^X9_62_CHARACTERISTIC_TWO_it$/ || +/^X9_62_CURVE_it$/ || +/^X9_62_FIELDID_it$/ || +/^X9_62_PENTANOMIAL_it$/ { + printf("extern ASN1_ITEM %s;\n", $0) +} + +# internal function used in libtls +/^ASN1_time_tm_clamp_notafter$/ { + symbols[$0] = $0 + printf("extern int ASN1_time_tm_clamp_notafter(struct tm *);\n") +} + +# These are machdep (at least cpuid_setup and ia32cap_P are internal on amd64). +/^OPENSSL_cpuid_setup$/ || +/^OPENSSL_cpu_caps$/ || +/^OPENSSL_ia32cap_P$/ { + printf("/* skipped %s */\n", $0) + next +} + +/^OPENSSL_strcasecmp$/ { + printf("extern int OPENSSL_strcasecmp(const char *, const char *);\n") +} + +/^OPENSSL_strncasecmp$/ { + printf("extern int OPENSSL_strncasecmp(const char *, const char *, size_t);\n") +} + +/^BIO_CONNECT_free$/ || +/^ECPARAMETERS_free$/ || +/^ECPKPARAMETERS_free$/ || +/^EC_PRIVATEKEY_free$/ || +/^NETSCAPE_ENCRYPTED_PKEY_free$/ || +/^NETSCAPE_PKEY_free$/ || +/^X9_62_CHARACTERISTIC_TWO_free$/ || +/^X9_62_PENTANOMIAL_free$/ { + printf("extern void %s(void *);\n", $0) +} + +/^BIO_CONNECT_new$/ || +/^ECPARAMETERS_new$/ || +/^ECPKPARAMETERS_new$/ || +/^EC_PRIVATEKEY_new$/ || +/^NETSCAPE_ENCRYPTED_PKEY_new$/ || +/^NETSCAPE_PKEY_new$/ || +/^X9_62_CHARACTERISTIC_TWO_new$/ || +/^X9_62_PENTANOMIAL_new$/ { + printf("extern void *%s(void);\n", $0) +} + +/^d2i_DSAPrivateKey_fp$/ { + printf("extern void *%s(FILE *, void **);\n", $0) +} + +/^d2i_ECPKPARAMETERS$/ || +/^d2i_EC_PRIVATEKEY$/ || +/^d2i_NETSCAPE_ENCRYPTED_PKEY$/ || +/^d2i_NETSCAPE_PKEY$/ { + printf("extern void *%s", $0) + printf("(void *, const unsigned char *, const unsigned char *);\n", $0) +} + +/^i2d_ECPKPARAMETERS$/ || +/^i2d_EC_PRIVATEKEY$/ || +/^i2d_NETSCAPE_ENCRYPTED_PKEY$/ || +/^i2d_NETSCAPE_PKEY$/ { + printf("extern int %s", $0) + printf("(const void *, unsigned char **);\n") +} + +{ + symbols[$0] = $0 +} + +END { + printf("\nint\nmain(void)\n{\n") + printf("\tsize_t i;\n"); + + printf("\tstruct {\n") + printf("\t\tconst char *const name;\n") + printf("\t\tconst void *addr;\n") + printf("\t} symbols[] = {\n") + + for (symbol in symbols) { + printf("\t\t{\n") + printf("\t\t\t.name = \"%s\",\n", symbol) + printf("\t\t\t.addr = &%s,\n", symbol) + printf("\t\t},\n") + } + + printf("\t\};\n\n") + + printf("\tfor (i = 0; i < sizeof(symbols) / sizeof(symbols[0]); i++)\n") + printf("\t\tfprintf(stderr, \"%%s: %%p\\n\", symbols[i].name, symbols[i].addr);\n") + printf("\n\tprintf(\"OK\\n\");\n") + printf("\n\treturn 0;\n}\n") +} |