Latest update.

This commit is contained in:
2019-05-23 12:02:56 +09:00
parent a7bf77581f
commit 64d458de91
185 changed files with 5859 additions and 2853 deletions
+1
View File
@@ -640,6 +640,7 @@ int cms_main(int argc, char **argv)
goto opthelp;
}
} else if (!operation) {
BIO_printf(bio_err, "No operation option (-encrypt|-decrypt|-sign|-verify|...) specified.\n");
goto opthelp;
}
+16 -4
View File
@@ -25,12 +25,15 @@ NON_EMPTY_TRANSLATION_UNIT
# include <openssl/x509.h>
# include <openssl/pem.h>
static int verbose = 0;
static int dsa_cb(int p, int n, BN_GENCB *cb);
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C,
OPT_NOOUT, OPT_GENKEY, OPT_ENGINE, OPT_R_ENUM
OPT_NOOUT, OPT_GENKEY, OPT_ENGINE, OPT_VERBOSE,
OPT_R_ENUM
} OPTION_CHOICE;
const OPTIONS dsaparam_options[] = {
@@ -47,6 +50,7 @@ const OPTIONS dsaparam_options[] = {
# ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
# endif
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
{NULL}
};
@@ -107,6 +111,9 @@ int dsaparam_main(int argc, char **argv)
case OPT_NOOUT:
noout = 1;
break;
case OPT_VERBOSE:
verbose = 1;
break;
}
}
argc = opt_num_rest();
@@ -145,9 +152,11 @@ int dsaparam_main(int argc, char **argv)
BIO_printf(bio_err, "Error allocating DSA object\n");
goto end;
}
BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
num);
BIO_printf(bio_err, "This could take some time\n");
if (verbose) {
BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
num);
BIO_printf(bio_err, "This could take some time\n");
}
if (!DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL, cb)) {
ERR_print_errors(bio_err);
BIO_printf(bio_err, "Error, DSA key generation failed\n");
@@ -251,6 +260,9 @@ static int dsa_cb(int p, int n, BN_GENCB *cb)
static const char symbols[] = ".+*\n";
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
if (!verbose)
return 1;
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
(void)BIO_flush(BN_GENCB_get_arg(cb));
return 1;
+8 -3
View File
@@ -27,7 +27,7 @@ NON_EMPTY_TRANSLATION_UNIT
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_CIPHER,
OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_CIPHER, OPT_VERBOSE,
OPT_R_ENUM
} OPTION_CHOICE;
@@ -42,6 +42,7 @@ const OPTIONS gendsa_options[] = {
# ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
# endif
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
{NULL}
};
@@ -54,7 +55,7 @@ int gendsa_main(int argc, char **argv)
char *dsaparams = NULL;
char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
OPTION_CHOICE o;
int ret = 1, private = 0;
int ret = 1, private = 0, verbose = 0;
const BIGNUM *p = NULL;
prog = opt_init(argc, argv, gendsa_options);
@@ -86,6 +87,9 @@ int gendsa_main(int argc, char **argv)
if (!opt_cipher(opt_unknown(), &enc))
goto end;
break;
case OPT_VERBOSE:
verbose = 1;
break;
}
}
argc = opt_num_rest();
@@ -124,7 +128,8 @@ int gendsa_main(int argc, char **argv)
" Your key size is %d! Larger key size may behave not as expected.\n",
OPENSSL_DSA_MAX_MODULUS_BITS, BN_num_bits(p));
BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
if (verbose)
BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
if (!DSA_generate_key(dsa))
goto end;
+14 -4
View File
@@ -30,12 +30,14 @@ NON_EMPTY_TRANSLATION_UNIT
# define DEFBITS 2048
# define DEFPRIMES 2
static int verbose = 0;
static int genrsa_cb(int p, int n, BN_GENCB *cb);
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_3, OPT_F4, OPT_ENGINE,
OPT_OUT, OPT_PASSOUT, OPT_CIPHER, OPT_PRIMES,
OPT_OUT, OPT_PASSOUT, OPT_CIPHER, OPT_PRIMES, OPT_VERBOSE,
OPT_R_ENUM
} OPTION_CHOICE;
@@ -52,6 +54,7 @@ const OPTIONS genrsa_options[] = {
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
# endif
{"primes", OPT_PRIMES, 'p', "Specify number of primes"},
{"verbose", OPT_VERBOSE, '-', "Verbose output"},
{NULL}
};
@@ -115,6 +118,9 @@ opthelp:
if (!opt_int(opt_arg(), &primes))
goto end;
break;
case OPT_VERBOSE:
verbose = 1;
break;
}
}
argc = opt_num_rest();
@@ -143,8 +149,9 @@ opthelp:
if (out == NULL)
goto end;
BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus (%d primes)\n",
num, primes);
if (verbose)
BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus (%d primes)\n",
num, primes);
rsa = eng ? RSA_new_method(eng) : RSA_new();
if (rsa == NULL)
goto end;
@@ -156,7 +163,7 @@ opthelp:
RSA_get0_key(rsa, NULL, &e, NULL);
hexe = BN_bn2hex(e);
dece = BN_bn2dec(e);
if (hexe && dece) {
if (hexe && dece && verbose) {
BIO_printf(bio_err, "e is %s (0x%s)\n", dece, hexe);
}
OPENSSL_free(hexe);
@@ -186,6 +193,9 @@ static int genrsa_cb(int p, int n, BN_GENCB *cb)
{
char c = '*';
if (!verbose)
return 1;
if (p == 0)
c = '.';
if (p == 1)
+1 -2
View File
@@ -42,8 +42,7 @@ int info_main(int argc, char **argv)
prog = opt_init(argc, argv, info_options);
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
case OPT_EOF:
case OPT_ERR:
default:
opthelp:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
goto end;
+3 -3
View File
@@ -31,7 +31,7 @@ NON_EMPTY_TRANSLATION_UNIT
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_ENGINE, OPT_IN, OPT_OUT, OPT_ASN1PARSE, OPT_HEXDUMP,
OPT_RAW, OPT_OAEP, OPT_SSL, OPT_PKCS, OPT_X931,
OPT_RSA_RAW, OPT_OAEP, OPT_SSL, OPT_PKCS, OPT_X931,
OPT_SIGN, OPT_VERIFY, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT,
OPT_PUBIN, OPT_CERTIN, OPT_INKEY, OPT_PASSIN, OPT_KEYFORM,
OPT_R_ENUM
@@ -46,7 +46,7 @@ const OPTIONS rsautl_options[] = {
{"pubin", OPT_PUBIN, '-', "Input is an RSA public"},
{"certin", OPT_CERTIN, '-', "Input is a cert carrying an RSA public key"},
{"ssl", OPT_SSL, '-', "Use SSL v2 padding"},
{"raw", OPT_RAW, '-', "Use no padding"},
{"raw", OPT_RSA_RAW, '-', "Use no padding"},
{"pkcs", OPT_PKCS, '-', "Use PKCS#1 v1.5 padding (default)"},
{"oaep", OPT_OAEP, '-', "Use PKCS#1 OAEP"},
{"sign", OPT_SIGN, '-', "Sign with private key"},
@@ -112,7 +112,7 @@ int rsautl_main(int argc, char **argv)
case OPT_HEXDUMP:
hexdump = 1;
break;
case OPT_RAW:
case OPT_RSA_RAW:
pad = RSA_NO_PADDING;
break;
case OPT_OAEP:
+11 -2
View File
@@ -123,6 +123,8 @@ static SSL_SESSION *psksess = NULL;
static char *psk_identity = "Client_identity";
char *psk_key = NULL; /* by default PSK is not used */
static char http_server_binmode = 0; /* for now: 0/1 = default/binary */
#ifndef OPENSSL_NO_PSK
static unsigned int psk_server_cb(SSL *ssl, const char *identity,
unsigned char *psk,
@@ -752,6 +754,7 @@ typedef enum OPTION_choice {
OPT_SRTP_PROFILES, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN,
OPT_KEYLOG_FILE, OPT_MAX_EARLY, OPT_RECV_MAX_EARLY, OPT_EARLY_DATA,
OPT_S_NUM_TICKETS, OPT_ANTI_REPLAY, OPT_NO_ANTI_REPLAY, OPT_SCTP_LABEL_BUG,
OPT_HTTP_SERVER_BINMODE,
OPT_R_ENUM,
OPT_S_ENUM,
OPT_V_ENUM,
@@ -966,6 +969,7 @@ const OPTIONS s_server_options[] = {
"The number of TLSv1.3 session tickets that a server will automatically issue" },
{"anti_replay", OPT_ANTI_REPLAY, '-', "Switch on anti-replay protection (default)"},
{"no_anti_replay", OPT_NO_ANTI_REPLAY, '-', "Switch off anti-replay protection"},
{"http_server_binmode", OPT_HTTP_SERVER_BINMODE, '-', "opening files in binary mode when acting as http server (-WWW and -HTTP)"},
{NULL, OPT_EOF, 0, NULL}
};
@@ -1595,6 +1599,9 @@ int s_server_main(int argc, char *argv[])
if (max_early_data == -1)
max_early_data = SSL3_RT_MAX_PLAIN_LENGTH;
break;
case OPT_HTTP_SERVER_BINMODE:
http_server_binmode = 1;
break;
}
}
argc = opt_num_rest();
@@ -2956,6 +2963,7 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
#endif
int width;
fd_set readfds;
const char *opmode;
/* Set width for a select call if needed */
width = s + 1;
@@ -3249,9 +3257,10 @@ static int www_body(int s, int stype, int prot, unsigned char *context)
break;
}
if ((file = BIO_new_file(p, "r")) == NULL) {
opmode = (http_server_binmode == 1) ? "rb" : "r";
if ((file = BIO_new_file(p, opmode)) == NULL) {
BIO_puts(io, text);
BIO_printf(io, "Error opening '%s'\r\n", p);
BIO_printf(io, "Error opening '%s' mode='%s'\r\n", p, opmode);
ERR_print_errors(io);
break;
}
+10 -15
View File
@@ -122,35 +122,30 @@ opthelp:
if (!dirty)
version = 1;
if (version) {
if (strcmp(OpenSSL_version(OPENSSL_FULL_VERSION_STRING),
OPENSSL_FULL_VERSION_STR) == 0)
printf("%s\n", OpenSSL_version(OPENSSL_VERSION));
else
printf("%s (Library: %s)\n",
OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
}
if (version)
printf("%s (Library: %s)\n",
OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION));
if (date)
printf("%s\n", OpenSSL_version(OPENSSL_BUILT_ON));
if (platform)
printf("%s\n", OpenSSL_version(OPENSSL_PLATFORM));
if (options) {
printf("options: ");
printf("%s ", BN_options());
printf("options: ");
printf(" %s", BN_options());
#ifndef OPENSSL_NO_MD2
printf("%s ", MD2_options());
printf(" %s", MD2_options());
#endif
#ifndef OPENSSL_NO_RC4
printf("%s ", RC4_options());
printf(" %s", RC4_options());
#endif
#ifndef OPENSSL_NO_DES
printf("%s ", DES_options());
printf(" %s", DES_options());
#endif
#ifndef OPENSSL_NO_IDEA
printf("%s ", IDEA_options());
printf(" %s", IDEA_options());
#endif
#ifndef OPENSSL_NO_BF
printf("%s ", BF_options());
printf(" %s", BF_options());
#endif
printf("\n");
}