X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fopenssl.c;h=21ddeb3c54a602d2d00e59359ab01f69c439c500;hp=9a152f54e361b363b27674dcbfc618354e987c22;hb=66b14bab0a7cfbf58d5df342e26e57f474592a8e;hpb=45d051c82563a75b07ec54b63e3a5bbad388ab67 diff --git a/apps/openssl.c b/apps/openssl.c index 9a152f54e3..21ddeb3c54 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -122,13 +122,16 @@ #ifndef OPENSSL_NO_ENGINE # include #endif -/* needed for the _O_BINARY defs in the MS world */ -#define USE_SOCKETS -#include "s_apps.h" #include #ifdef OPENSSL_FIPS # include #endif +#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */ +#include "s_apps.h" +/* Needed to get the other O_xxx flags. */ +#ifdef OPENSSL_SYS_VMS +# include +#endif #define INCLUDE_FUNCTION_TABLE #include "apps.h" @@ -155,9 +158,10 @@ static LHASH_OF(FUNCTION) *prog_init(void); static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]); static void list_pkey(void); static void list_type(FUNC_TYPE ft); +static void list_disabled(void); char *default_config_file = NULL; -CONF *config = NULL; +static CONF *config = NULL; BIO *bio_in = NULL; BIO *bio_out = NULL; BIO *bio_err = NULL; @@ -264,70 +268,10 @@ static void lock_dbg_cb(int mode, int type, const char *file, int line) err: if (errstr) { - /* we cannot use bio_err here */ - fprintf(stderr, - "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", - errstr, mode, type, file, line); - } -} - -BIO *dup_bio_in(void) -{ - return BIO_new_fp(stdin, BIO_NOCLOSE | BIO_FP_TEXT); -} - -BIO *dup_bio_out(void) -{ - BIO *b = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT); -#ifdef OPENSSL_SYS_VMS - b = BIO_push(BIO_new(BIO_f_linebuffer()), b); -#endif - return b; -} - -void unbuffer(FILE *fp) -{ - setbuf(fp, NULL); -} - -static BIO *bio_open_default_(const char *filename, const char *mode, int quiet) -{ - BIO *ret; - - if (filename == NULL || strcmp(filename, "-") == 0) { - ret = *mode == 'r' ? dup_bio_in() : dup_bio_out(); - if (quiet) { - ERR_clear_error(); - return ret; - } - if (ret != NULL) - return ret; - BIO_printf(bio_err, - "Can't open %s, %s\n", - *mode == 'r' ? "stdin" : "stdout", strerror(errno)); - } else { - ret = BIO_new_file(filename, mode); - if (quiet) { - ERR_clear_error(); - return ret; - } - if (ret != NULL) - return ret; BIO_printf(bio_err, - "Can't open %s for %s, %s\n", - filename, - *mode == 'r' ? "reading" : "writing", strerror(errno)); + "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n", + errstr, mode, type, file, line); } - ERR_print_errors(bio_err); - return NULL; -} -BIO *bio_open_default(const char *filename, const char *mode) -{ - return bio_open_default_(filename, mode, 0); -} -BIO *bio_open_default_quiet(const char *filename, const char *mode) -{ - return bio_open_default_(filename, mode, 1); } #if defined( OPENSSL_SYS_VMS) @@ -348,6 +292,12 @@ int main(int argc, char *argv[]) arg.argv = NULL; arg.size = 0; + /* Set up some of the environment. */ + default_config_file = make_config_name(); + bio_in = dup_bio_in(FORMAT_TEXT); + bio_out = dup_bio_out(FORMAT_TEXT); + bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); + #if defined( OPENSSL_SYS_VMS) copied_argv = argv = copy_argv(&argc, argv); #endif @@ -369,12 +319,12 @@ int main(int argc, char *argv[]) #ifdef OPENSSL_FIPS if (!FIPS_mode_set(1)) { ERR_load_crypto_strings(); - ERR_print_errors(BIO_new_fp(stderr, BIO_NOCLOSE)); - EXIT(1); + ERR_print_errors(bio_err); + return 1; } #else - fprintf(stderr, "FIPS mode not supported.\n"); - EXIT(1); + BIO_printf(bio_err, "FIPS mode not supported.\n"); + return 1; #endif } @@ -393,12 +343,6 @@ int main(int argc, char *argv[]) prog = prog_init(); pname = opt_progname(argv[0]); - /* Lets load up our environment a little */ - default_config_file = make_config_name(); - bio_in = dup_bio_in(); - bio_out = dup_bio_out(); - bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT); - /* first check the program name */ f.name = pname; fp = lh_FUNCTION_retrieve(prog, &f); @@ -536,7 +480,7 @@ typedef enum HELPLIST_CHOICE { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS, - OPT_PK_ALGORITHMS + OPT_PK_ALGORITHMS, OPT_DISABLED } HELPLIST_CHOICE; OPTIONS list_options[] = { @@ -551,6 +495,8 @@ OPTIONS list_options[] = { "List of cipher algorithms"}, {"public-key-algorithms", OPT_PK_ALGORITHMS, '-', "List of public key algorithms"}, + {"disabled", OPT_DISABLED, '-', + "List of disabled features"}, {NULL} }; @@ -587,6 +533,9 @@ int list_main(int argc, char **argv) case OPT_PK_ALGORITHMS: list_pkey(); break; + case OPT_DISABLED: + list_disabled(); + break; } } @@ -771,6 +720,116 @@ static int SortFnByName(const void *_f1, const void *_f2) return strcmp(f1->name, f2->name); } +static void list_disabled(void) +{ + BIO_puts(bio_out, "Disabled algorithms:\n"); +#ifdef OPENSSL_NO_AES + BIO_puts(bio_out, "AES\n"); +#endif +#ifdef OPENSSL_NO_BF + BIO_puts(bio_out, "BF\n"); +#endif +#ifdef OPENSSL_NO_CAMELLIA + BIO_puts(bio_out, "CAMELLIA\n"); +#endif +#ifdef OPENSSL_NO_CAST + BIO_puts(bio_out, "CAST\n"); +#endif +#ifdef OPENSSL_NO_CMS + BIO_puts(bio_out, "CMS\n"); +#endif +#ifdef OPENSSL_NO_COMP + BIO_puts(bio_out, "COMP\n"); +#endif +#ifdef OPENSSL_NO_DES + BIO_puts(bio_out, "DES\n"); +#endif +#ifdef OPENSSL_NO_DH + BIO_puts(bio_out, "DH\n"); +#endif +#ifdef OPENSSL_NO_DSA + BIO_puts(bio_out, "DSA\n"); +#endif +#ifdef OPENSSL_NO_DTLS1 + BIO_puts(bio_out, "DTLS1\n"); +#endif +#ifdef OPENSSL_NO_EC + BIO_puts(bio_out, "EC\n"); +#endif +#ifdef OPENSSL_NO_EC2M + BIO_puts(bio_out, "EC2M\n"); +#endif +#ifdef OPENSSL_NO_ENGINE + BIO_puts(bio_out, "ENGINE\n"); +#endif +#ifdef OPENSSL_NO_IDEA + BIO_puts(bio_out, "IDEA\n"); +#endif +#ifdef OPENSSL_NO_JPAKE + BIO_puts(bio_out, "JPAKE\n"); +#endif +#ifdef OPENSSL_NO_MD2 + BIO_puts(bio_out, "MD2\n"); +#endif +#ifdef OPENSSL_NO_MD4 + BIO_puts(bio_out, "MD4\n"); +#endif +#ifdef OPENSSL_NO_MD5 + BIO_puts(bio_out, "MD5\n"); +#endif +#ifdef OPENSSL_NO_MDC2 + BIO_puts(bio_out, "MDC2\n"); +#endif +#ifdef OPENSSL_NO_MD_GHOST94 + BIO_puts(bio_out, "MD_GHOST94\n"); +#endif +#ifdef OPENSSL_NO_OCSP + BIO_puts(bio_out, "OCSP\n"); +#endif +#ifdef OPENSSL_NO_PSK + BIO_puts(bio_out, "PSK\n"); +#endif +#ifdef OPENSSL_NO_RC2 + BIO_puts(bio_out, "RC2\n"); +#endif +#ifdef OPENSSL_NO_RC4 + BIO_puts(bio_out, "RC4\n"); +#endif +#ifdef OPENSSL_NO_RC5 + BIO_puts(bio_out, "RC5\n"); +#endif +#ifdef OPENSSL_NO_RMD160 + BIO_puts(bio_out, "RMD160\n"); +#endif +#ifdef OPENSSL_NO_RSA + BIO_puts(bio_out, "RSA\n"); +#endif +#ifdef OPENSSL_NO_SCRYPT + BIO_puts(bio_out, "SCRYPT\n"); +#endif +#ifdef OPENSSL_NO_SEED + BIO_puts(bio_out, "SEED\n"); +#endif +#ifdef OPENSSL_NO_SOCK + BIO_puts(bio_out, "SOCK\n"); +#endif +#ifdef OPENSSL_NO_SRP + BIO_puts(bio_out, "SRP\n"); +#endif +#ifdef OPENSSL_NO_SRTP + BIO_puts(bio_out, "SRTP\n"); +#endif +#ifdef OPENSSL_NO_SSL3 + BIO_puts(bio_out, "SSL3\n"); +#endif +#ifdef OPENSSL_NO_WHIRLPOOL + BIO_puts(bio_out, "WHIRLPOOL\n"); +#endif +#ifndef ZLIB + BIO_puts(bio_out, "ZLIB\n"); +#endif +} + static LHASH_OF(FUNCTION) *prog_init(void) { LHASH_OF(FUNCTION) *ret;