X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fapps.c;h=be7a80acb8cf99d457fecf851086ce6cb6ae6f6c;hp=40faa02f9076f79822662f599d0ebff34c967157;hb=5c6bf03117a26942327f43d02e9113e9870f7aba;hpb=9335a5f7c07cf16d3d167edee078b33c8dab725d diff --git a/apps/apps.c b/apps/apps.c index 40faa02f90..be7a80acb8 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -114,9 +114,7 @@ #include #include #include -#define NON_MAIN -#include "apps.h" -#undef NON_MAIN +#include #include #include #include @@ -136,6 +134,10 @@ # endif /* NO_STRINGS_H */ #endif +#define NON_MAIN +#include "apps.h" +#undef NON_MAIN + #ifdef OPENSSL_SYS_WINDOWS # include "bss_file.c" #endif @@ -354,6 +356,22 @@ int WIN32_rename(char *from, char *to) } #endif +#ifdef OPENSSL_SYS_VMS +int VMS_strcasecmp(const char *str1, const char *str2) + { + while (*str1 && *str2) + { + int res = toupper(*str1) - toupper(*str2); + if (res) return res < 0 ? -1 : 1; + } + if (*str1) + return 1; + if (*str2) + return -1; + return 0; + } +#endif + int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]) { int num,len,i; @@ -798,7 +816,7 @@ end: return(x); } -EVP_PKEY *load_key(BIO *err, const char *file, int format, +EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, const char *pass, ENGINE *e, const char *key_descrip) { BIO *key=NULL; @@ -808,7 +826,7 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, cb_data.password = pass; cb_data.prompt_info = file; - if (file == NULL) + if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) { BIO_printf(err,"no keyfile specified\n"); goto end; @@ -828,12 +846,19 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, ERR_print_errors(err); goto end; } - if (BIO_read_filename(key,file) <= 0) + if (file == NULL && maybe_stdin) { - BIO_printf(err, "Error opening %s %s\n", key_descrip, file); - ERR_print_errors(err); - goto end; + setvbuf(stdin, NULL, _IONBF, 0); + BIO_set_fp(key,stdin,BIO_NOCLOSE); } + else + if (BIO_read_filename(key,file) <= 0) + { + BIO_printf(err, "Error opening %s %s\n", + key_descrip, file); + ERR_print_errors(err); + goto end; + } if (format == FORMAT_ASN1) { pkey=d2i_PrivateKey_bio(key, NULL); @@ -867,7 +892,7 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, return(pkey); } -EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, +EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin, const char *pass, ENGINE *e, const char *key_descrip) { BIO *key=NULL; @@ -877,7 +902,7 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, cb_data.password = pass; cb_data.prompt_info = file; - if (file == NULL) + if (file == NULL && (!maybe_stdin || format == FORMAT_ENGINE)) { BIO_printf(err,"no keyfile specified\n"); goto end; @@ -897,11 +922,18 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, ERR_print_errors(err); goto end; } - if (BIO_read_filename(key,file) <= 0) + if (file == NULL && maybe_stdin) { - BIO_printf(err, "Error opening %s %s\n", key_descrip, file); - ERR_print_errors(err); - goto end; + setvbuf(stdin, NULL, _IONBF, 0); + BIO_set_fp(key,stdin,BIO_NOCLOSE); + } + else + if (BIO_read_filename(key,file) <= 0) + { + BIO_printf(err, "Error opening %s %s\n", + key_descrip, file); + ERR_print_errors(err); + goto end; } if (format == FORMAT_ASN1) { @@ -1074,6 +1106,7 @@ int set_cert_ex(unsigned long *flags, const char *arg) { "no_extensions", X509_FLAG_NO_EXTENSIONS, 0}, { "no_sigdump", X509_FLAG_NO_SIGDUMP, 0}, { "no_aux", X509_FLAG_NO_AUX, 0}, + { "no_attributes", X509_FLAG_NO_ATTRIBUTES, 0}, { "ext_default", X509V3_EXT_DEFAULT, X509V3_EXT_UNKNOWN_MASK}, { "ext_error", X509V3_EXT_ERROR_UNKNOWN, X509V3_EXT_UNKNOWN_MASK}, { "ext_parse", X509V3_EXT_PARSE_UNKNOWN, X509V3_EXT_UNKNOWN_MASK}, @@ -1217,7 +1250,7 @@ static int set_table_opts(unsigned long *flags, const char *arg, const NAME_EX_T void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags) { - char buf[256]; + char *buf; char mline = 0; int indent = 0; if(title) BIO_puts(out, title); @@ -1226,9 +1259,10 @@ void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags) indent = 4; } if(lflags == XN_FLAG_COMPAT) { - X509_NAME_oneline(nm,buf,256); - BIO_puts(out,buf); + buf = X509_NAME_oneline(nm, 0, 0); + BIO_puts(out, buf); BIO_puts(out, "\n"); + OPENSSL_free(buf); } else { if(mline) BIO_puts(out, "\n"); X509_NAME_print_ex(out, nm, indent, lflags);