From 984d6c6052169bcae8010de33f7796e455536d61 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 11 Sep 2015 14:56:32 -0400 Subject: Fix no-stdio build Much related/similar work also done by Ivan Nestlerode +Replace FILE BIO's with dummy ops that fail. +Include for sscanf() even with no-stdio (since the declaration is there). We rely on sscanf() to parse the OPENSSL_ia32cap environment variable, since it can be larger than a 'long'. And we don't rely on the availability of strtoull(). +Remove OPENSSL_stderr(); not used. +Make OPENSSL_showfatal() do nothing (currently without stdio there's nothing we can do). +Remove file-based functionality from ssl/. The function prototypes were already gone, but not the functions themselves. +Remove unviable conf functionality via SYS_UEFI +Add fallback definition of BUFSIZ. +Remove functions taking FILE * from header files. +Add missing DECLARE_PEM_write_fp_const +Disable X509_LOOKUP_hash_dir(). X509_LOOKUP_file() was already compiled out, so remove its prototype. +Use OPENSSL_showfatal() in CRYPTO_destroy_dynlockid(). +Eliminate SRP_VBASE_init() and supporting functions. Users will need to build the verifier manually instead. +Eliminate compiler warning for unused do_pk8pkey_fp(). +Disable TEST_ENG_OPENSSL_PKEY. +Disable GOST engine as is uses [f]printf all over the place. +Eliminate compiler warning for unused send_fp_chars(). Signed-off-by: Rich Salz Reviewed-by: Tim Hudson --- crypto/asn1/Makefile | 8 +++--- crypto/asn1/a_strex.c | 2 ++ crypto/asn1/tasn_utl.c | 1 + crypto/bio/bss_file.c | 54 ++++++++++++++++++++++++++++++++++++++ crypto/conf/conf_sap.c | 2 ++ crypto/cryptlib.c | 8 +++--- crypto/des/read2pwd.c | 4 +++ crypto/ec/Makefile | 17 ++++++------ crypto/ec/ec_key.c | 1 + crypto/engine/eng_openssl.c | 2 ++ crypto/include/internal/cryptlib.h | 1 - crypto/lock.c | 3 +-- crypto/pem/pem_pk8.c | 4 ++- crypto/ts/Makefile | 4 +-- crypto/ui/ui_util.c | 4 +++ crypto/x509/by_dir.c | 1 + crypto/x509/by_file.c | 4 --- crypto/x509/x509_d2.c | 3 --- 18 files changed, 94 insertions(+), 29 deletions(-) (limited to 'crypto') diff --git a/crypto/asn1/Makefile b/crypto/asn1/Makefile index b0d4e14ec4..a6f1bac313 100644 --- a/crypto/asn1/Makefile +++ b/crypto/asn1/Makefile @@ -668,14 +668,16 @@ tasn_typ.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h tasn_typ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h tasn_typ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h tasn_typ.o: ../../include/openssl/symhacks.h tasn_typ.c -tasn_utl.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h -tasn_utl.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h +tasn_utl.o: ../../e_os.h ../../include/openssl/asn1.h +tasn_utl.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h +tasn_utl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h tasn_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h tasn_utl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h tasn_utl.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h tasn_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h tasn_utl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -tasn_utl.o: ../../include/openssl/symhacks.h asn1_locl.h tasn_utl.c +tasn_utl.o: ../../include/openssl/symhacks.h ../include/internal/cryptlib.h +tasn_utl.o: asn1_locl.h tasn_utl.c x_algor.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h x_algor.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h x_algor.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c index 2f233a2608..c9d3cea036 100644 --- a/crypto/asn1/a_strex.c +++ b/crypto/asn1/a_strex.c @@ -92,6 +92,7 @@ static int send_bio_chars(void *arg, const void *buf, int len) return 1; } +#ifndef OPENSSL_NO_STDIO static int send_fp_chars(void *arg, const void *buf, int len) { if (!arg) @@ -100,6 +101,7 @@ static int send_fp_chars(void *arg, const void *buf, int len) return 0; return 1; } +#endif typedef int char_io (void *arg, const void *buf, int len); diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c index 76e96051bf..8b62341b9b 100644 --- a/crypto/asn1/tasn_utl.c +++ b/crypto/asn1/tasn_utl.c @@ -59,6 +59,7 @@ #include #include +#include #include #include #include diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c index 8f22ef7f9f..7692ee293c 100644 --- a/crypto/bio/bss_file.c +++ b/crypto/bio/bss_file.c @@ -467,6 +467,60 @@ static int file_puts(BIO *bp, const char *str) return (ret); } +#else + +static int file_write(BIO *b, const char *in, int inl) +{ + return -1; +} +static int file_read(BIO *b, char *out, int outl) +{ + return -1; +} +static int file_puts(BIO *bp, const char *str) +{ + return -1; +} +static int file_gets(BIO *bp, char *buf, int size) +{ + return 0; +} +static long file_ctrl(BIO *b, int cmd, long num, void *ptr) +{ + return 0; +} +static int file_new(BIO *bi) +{ + return 0; +} +static int file_free(BIO *a) +{ + return 0; +} + +static BIO_METHOD methods_filep = { + BIO_TYPE_FILE, + "FILE pointer", + file_write, + file_read, + file_puts, + file_gets, + file_ctrl, + file_new, + file_free, + NULL, +}; + +BIO_METHOD *BIO_s_file(void) +{ + return (&methods_filep); +} + +BIO *BIO_new_file(const char *filename, const char *mode) +{ + return NULL; +} + # endif /* OPENSSL_NO_STDIO */ #endif /* HEADER_BSS_FILE_C */ diff --git a/crypto/conf/conf_sap.c b/crypto/conf/conf_sap.c index e99a38ef63..308989b451 100644 --- a/crypto/conf/conf_sap.c +++ b/crypto/conf/conf_sap.c @@ -87,9 +87,11 @@ void OPENSSL_config(const char *config_name) ENGINE_load_builtin_engines(); #endif ERR_clear_error(); +#ifndef OPENSSL_SYS_UEFI CONF_modules_load_file(NULL, config_name, CONF_MFLAGS_DEFAULT_SECTION | CONF_MFLAGS_IGNORE_MISSING_FILE); +#endif } void OPENSSL_no_config() diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index f0aaae6893..a9f9697c70 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -129,6 +129,7 @@ unsigned int *OPENSSL_ia32cap_loc(void) } # if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY) +#include # define OPENSSL_CPUID_SETUP typedef uint64_t IA32CAP; void OPENSSL_cpuid_setup(void) @@ -432,11 +433,13 @@ void OPENSSL_showfatal(const char *fmta, ...) #else void OPENSSL_showfatal(const char *fmta, ...) { +#ifndef OPENSSL_NO_STDIO va_list ap; va_start(ap, fmta); vfprintf(stderr, fmta, ap); va_end(ap); +#endif } int OPENSSL_isservice(void) @@ -463,11 +466,6 @@ void OpenSSLDie(const char *file, int line, const char *assertion) #endif } -void *OPENSSL_stderr(void) -{ - return stderr; -} - int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) { size_t i; diff --git a/crypto/des/read2pwd.c b/crypto/des/read2pwd.c index 01e275f331..7633139604 100644 --- a/crypto/des/read2pwd.c +++ b/crypto/des/read2pwd.c @@ -114,6 +114,10 @@ #include #include +#ifndef BUFSIZ +#define BUFSIZ 256 +#endif + int DES_read_password(DES_cblock *key, const char *prompt, int verify) { int ok; diff --git a/crypto/ec/Makefile b/crypto/ec/Makefile index 9ad71f6ee1..18e9610180 100644 --- a/crypto/ec/Makefile +++ b/crypto/ec/Makefile @@ -169,14 +169,15 @@ ec_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h ec_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h ec_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h ec_err.o: ../../include/openssl/symhacks.h ec_err.c -ec_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h -ec_key.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h -ec_key.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h -ec_key.o: ../../include/openssl/err.h ../../include/openssl/lhash.h -ec_key.o: ../../include/openssl/obj_mac.h ../../include/openssl/opensslconf.h -ec_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h -ec_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -ec_key.o: ../../include/openssl/symhacks.h ec_key.c ec_lcl.h +ec_key.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h +ec_key.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h +ec_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h +ec_key.o: ../../include/openssl/ec.h ../../include/openssl/err.h +ec_key.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h +ec_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +ec_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h +ec_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +ec_key.o: ../include/internal/cryptlib.h ec_key.c ec_lcl.h ec_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h ec_lib.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h ec_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 238009788a..ddb3257d77 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -61,6 +61,7 @@ * contributed to the OpenSSL project. */ +#include #include #include "ec_lcl.h" #include diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c index 4bc9b2ec69..095b5a02fb 100644 --- a/crypto/engine/eng_openssl.c +++ b/crypto/engine/eng_openssl.c @@ -89,7 +89,9 @@ * this is no longer automatic in ENGINE_load_builtin_engines(). */ #define TEST_ENG_OPENSSL_RC4 +#ifndef OPENSSL_NO_STDIO #define TEST_ENG_OPENSSL_PKEY +#endif /* #define TEST_ENG_OPENSSL_HMAC */ /* #define TEST_ENG_OPENSSL_HMAC_INIT */ /* #define TEST_ENG_OPENSSL_RC4_OTHERS */ diff --git a/crypto/include/internal/cryptlib.h b/crypto/include/internal/cryptlib.h index fba180a6b2..d7018b61e7 100644 --- a/crypto/include/internal/cryptlib.h +++ b/crypto/include/internal/cryptlib.h @@ -101,7 +101,6 @@ extern "C" { void OPENSSL_cpuid_setup(void); extern unsigned int OPENSSL_ia32cap_P[]; void OPENSSL_showfatal(const char *fmta, ...); -void *OPENSSL_stderr(void); extern int OPENSSL_NONPIC_relocated; #ifdef __cplusplus diff --git a/crypto/lock.c b/crypto/lock.c index d7d672d70d..12e4323110 100644 --- a/crypto/lock.c +++ b/crypto/lock.c @@ -309,8 +309,7 @@ void CRYPTO_destroy_dynlockid(int i) --pointer->references; #ifdef REF_CHECK if (pointer->references < 0) { - fprintf(stderr, - "CRYPTO_destroy_dynlockid, bad reference count\n"); + OPENSSL_showfatal("CRYPTO_destroy_dynlockid, bad reference count\n"); abort(); } else #endif diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c index ef5131fa29..e238b95865 100644 --- a/crypto/pem/pem_pk8.c +++ b/crypto/pem/pem_pk8.c @@ -69,10 +69,12 @@ static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); + +#ifndef OPENSSL_NO_STDIO static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder, int nid, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u); - +#endif /* * These functions write a private key in PKCS#8 format: it is a "drop in" * replacement for PEM_write_bio_PrivateKey() and friends. As usual if 'enc' diff --git a/crypto/ts/Makefile b/crypto/ts/Makefile index 754b89a617..76d1aeac72 100644 --- a/crypto/ts/Makefile +++ b/crypto/ts/Makefile @@ -207,7 +207,7 @@ ts_rsp_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h ts_rsp_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h ts_rsp_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h ts_rsp_sign.o: ../../include/openssl/x509v3.h ../include/internal/cryptlib.h -ts_rsp_sign.o: ../include/internal/x509_int.h ts_lcl.h ts_rsp_sign.c +ts_rsp_sign.o: ts_lcl.h ts_rsp_sign.c ts_rsp_utils.o: ../../e_os.h ../../include/openssl/asn1.h ts_rsp_utils.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h ts_rsp_utils.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h @@ -243,7 +243,7 @@ ts_rsp_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h ts_rsp_verify.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h ts_rsp_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h ts_rsp_verify.o: ../../include/openssl/x509v3.h ../include/internal/cryptlib.h -ts_rsp_verify.o: ../include/internal/x509_int.h ts_lcl.h ts_rsp_verify.c +ts_rsp_verify.o: ts_lcl.h ts_rsp_verify.c ts_verify_ctx.o: ../../e_os.h ../../include/openssl/asn1.h ts_verify_ctx.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h ts_verify_ctx.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c index f65f80d71d..b18e2a2a42 100644 --- a/crypto/ui/ui_util.c +++ b/crypto/ui/ui_util.c @@ -56,6 +56,10 @@ #include #include "ui_locl.h" +#ifndef BUFSIZ +#define BUFSIZ 256 +#endif + int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify) { diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index 5241cad639..3dd04d04aa 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -69,6 +69,7 @@ # include #endif + #include #include #include "internal/x509_int.h" diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c index 6fbffe11c1..7983b1527e 100644 --- a/crypto/x509/by_file.c +++ b/crypto/x509/by_file.c @@ -66,8 +66,6 @@ #include #include -#ifndef OPENSSL_NO_STDIO - static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); static X509_LOOKUP_METHOD x509_file_lookup = { @@ -269,5 +267,3 @@ int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) sk_X509_INFO_pop_free(inf, X509_INFO_free); return count; } - -#endif /* OPENSSL_NO_STDIO */ diff --git a/crypto/x509/x509_d2.c b/crypto/x509/x509_d2.c index 29bbf50a2c..e3d08630b9 100644 --- a/crypto/x509/x509_d2.c +++ b/crypto/x509/x509_d2.c @@ -61,7 +61,6 @@ #include #include -#ifndef OPENSSL_NO_STDIO int X509_STORE_set_default_paths(X509_STORE *ctx) { X509_LOOKUP *lookup; @@ -105,5 +104,3 @@ int X509_STORE_load_locations(X509_STORE *ctx, const char *file, return (0); return (1); } - -#endif -- cgit v1.2.3