Update to OpenSSL 1.0.2.o
This commit is contained in:
@@ -128,7 +128,7 @@ int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
|
||||
#endif
|
||||
|
||||
if (file == NULL)
|
||||
file = RAND_file_name(buffer, sizeof buffer);
|
||||
file = RAND_file_name(buffer, sizeof(buffer));
|
||||
else if (RAND_egd(file) > 0) {
|
||||
/*
|
||||
* we try if the given filename is an EGD socket. if it is, we don't
|
||||
@@ -203,7 +203,7 @@ int app_RAND_write_file(const char *file, BIO *bio_e)
|
||||
return 0;
|
||||
|
||||
if (file == NULL)
|
||||
file = RAND_file_name(buffer, sizeof buffer);
|
||||
file = RAND_file_name(buffer, sizeof(buffer));
|
||||
if (file == NULL || !RAND_write_file(file)) {
|
||||
BIO_printf(bio_e, "unable to write 'random state'\n");
|
||||
return 0;
|
||||
|
||||
70
apps/apps.c
70
apps/apps.c
@@ -148,6 +148,10 @@
|
||||
#ifdef _WIN32
|
||||
static int WIN32_rename(const char *from, const char *to);
|
||||
# define rename(from,to) WIN32_rename((from),(to))
|
||||
# ifdef fileno
|
||||
# undef fileno
|
||||
# endif
|
||||
# define fileno(a) (int)_fileno(a)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
@@ -1734,9 +1738,9 @@ int save_serial(char *serialfile, char *suffix, BIGNUM *serial,
|
||||
BUF_strlcpy(buf[0], serialfile, BSIZE);
|
||||
else {
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", serialfile, suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", serialfile, suffix);
|
||||
#endif
|
||||
}
|
||||
#ifdef RL_DEBUG
|
||||
@@ -1785,14 +1789,14 @@ int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix)
|
||||
goto err;
|
||||
}
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, new_suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", serialfile, new_suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", serialfile, new_suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", serialfile, new_suffix);
|
||||
#endif
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", serialfile, old_suffix);
|
||||
j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", serialfile, old_suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", serialfile, old_suffix);
|
||||
j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", serialfile, old_suffix);
|
||||
#endif
|
||||
#ifdef RL_DEBUG
|
||||
BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n",
|
||||
@@ -1873,9 +1877,9 @@ CA_DB *load_index(char *dbfile, DB_ATTR *db_attr)
|
||||
goto err;
|
||||
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
BIO_snprintf(buf[0], sizeof buf[0], "%s.attr", dbfile);
|
||||
BIO_snprintf(buf[0], sizeof(buf[0]), "%s.attr", dbfile);
|
||||
#else
|
||||
BIO_snprintf(buf[0], sizeof buf[0], "%s-attr", dbfile);
|
||||
BIO_snprintf(buf[0], sizeof(buf[0]), "%s-attr", dbfile);
|
||||
#endif
|
||||
dbattr_conf = NCONF_new(NULL);
|
||||
if (NCONF_load(dbattr_conf, buf[0], &errorline) <= 0) {
|
||||
@@ -1963,19 +1967,19 @@ int save_index(const char *dbfile, const char *suffix, CA_DB *db)
|
||||
goto err;
|
||||
}
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr", dbfile);
|
||||
j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s.attr", dbfile);
|
||||
#else
|
||||
j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr", dbfile);
|
||||
j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr", dbfile);
|
||||
#endif
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[1], sizeof buf[1], "%s.attr.%s", dbfile, suffix);
|
||||
j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.attr.%s", dbfile, suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[1], sizeof buf[1], "%s-attr-%s", dbfile, suffix);
|
||||
j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-attr-%s", dbfile, suffix);
|
||||
#endif
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, suffix);
|
||||
#endif
|
||||
#ifdef RL_DEBUG
|
||||
BIO_printf(bio_err, "DEBUG: writing \"%s\"\n", buf[0]);
|
||||
@@ -2024,29 +2028,29 @@ int rotate_index(const char *dbfile, const char *new_suffix,
|
||||
goto err;
|
||||
}
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[4], sizeof buf[4], "%s.attr", dbfile);
|
||||
j = BIO_snprintf(buf[4], sizeof(buf[4]), "%s.attr", dbfile);
|
||||
#else
|
||||
j = BIO_snprintf(buf[4], sizeof buf[4], "%s-attr", dbfile);
|
||||
j = BIO_snprintf(buf[4], sizeof(buf[4]), "%s-attr", dbfile);
|
||||
#endif
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[2], sizeof buf[2], "%s.attr.%s", dbfile, new_suffix);
|
||||
j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s.attr.%s", dbfile, new_suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[2], sizeof buf[2], "%s-attr-%s", dbfile, new_suffix);
|
||||
j = BIO_snprintf(buf[2], sizeof(buf[2]), "%s-attr-%s", dbfile, new_suffix);
|
||||
#endif
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", dbfile, new_suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s.%s", dbfile, new_suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[0], sizeof buf[0], "%s-%s", dbfile, new_suffix);
|
||||
j = BIO_snprintf(buf[0], sizeof(buf[0]), "%s-%s", dbfile, new_suffix);
|
||||
#endif
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[1], sizeof buf[1], "%s.%s", dbfile, old_suffix);
|
||||
j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s.%s", dbfile, old_suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[1], sizeof buf[1], "%s-%s", dbfile, old_suffix);
|
||||
j = BIO_snprintf(buf[1], sizeof(buf[1]), "%s-%s", dbfile, old_suffix);
|
||||
#endif
|
||||
#ifndef OPENSSL_SYS_VMS
|
||||
j = BIO_snprintf(buf[3], sizeof buf[3], "%s.attr.%s", dbfile, old_suffix);
|
||||
j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s.attr.%s", dbfile, old_suffix);
|
||||
#else
|
||||
j = BIO_snprintf(buf[3], sizeof buf[3], "%s-attr-%s", dbfile, old_suffix);
|
||||
j = BIO_snprintf(buf[3], sizeof(buf[3]), "%s-attr-%s", dbfile, old_suffix);
|
||||
#endif
|
||||
#ifdef RL_DEBUG
|
||||
BIO_printf(bio_err, "DEBUG: renaming \"%s\" to \"%s\"\n", dbfile, buf[1]);
|
||||
@@ -2600,7 +2604,7 @@ static void jpake_send_step3a(BIO *bconn, JPAKE_CTX *ctx)
|
||||
|
||||
JPAKE_STEP3A_init(&s3a);
|
||||
JPAKE_STEP3A_generate(&s3a, ctx);
|
||||
BIO_write(bconn, s3a.hhk, sizeof s3a.hhk);
|
||||
BIO_write(bconn, s3a.hhk, sizeof(s3a.hhk));
|
||||
(void)BIO_flush(bconn);
|
||||
JPAKE_STEP3A_release(&s3a);
|
||||
}
|
||||
@@ -2611,7 +2615,7 @@ static void jpake_send_step3b(BIO *bconn, JPAKE_CTX *ctx)
|
||||
|
||||
JPAKE_STEP3B_init(&s3b);
|
||||
JPAKE_STEP3B_generate(&s3b, ctx);
|
||||
BIO_write(bconn, s3b.hk, sizeof s3b.hk);
|
||||
BIO_write(bconn, s3b.hk, sizeof(s3b.hk));
|
||||
(void)BIO_flush(bconn);
|
||||
JPAKE_STEP3B_release(&s3b);
|
||||
}
|
||||
@@ -2621,7 +2625,7 @@ static void readbn(BIGNUM **bn, BIO *bconn)
|
||||
char buf[10240];
|
||||
int l;
|
||||
|
||||
l = BIO_gets(bconn, buf, sizeof buf);
|
||||
l = BIO_gets(bconn, buf, sizeof(buf));
|
||||
assert(l > 0);
|
||||
assert(buf[l - 1] == '\n');
|
||||
buf[l - 1] = '\0';
|
||||
@@ -2668,8 +2672,8 @@ static void jpake_receive_step3a(JPAKE_CTX *ctx, BIO *bconn)
|
||||
int l;
|
||||
|
||||
JPAKE_STEP3A_init(&s3a);
|
||||
l = BIO_read(bconn, s3a.hhk, sizeof s3a.hhk);
|
||||
assert(l == sizeof s3a.hhk);
|
||||
l = BIO_read(bconn, s3a.hhk, sizeof(s3a.hhk));
|
||||
assert(l == sizeof(s3a.hhk));
|
||||
if (!JPAKE_STEP3A_process(ctx, &s3a)) {
|
||||
ERR_print_errors(bio_err);
|
||||
exit(1);
|
||||
@@ -2683,8 +2687,8 @@ static void jpake_receive_step3b(JPAKE_CTX *ctx, BIO *bconn)
|
||||
int l;
|
||||
|
||||
JPAKE_STEP3B_init(&s3b);
|
||||
l = BIO_read(bconn, s3b.hk, sizeof s3b.hk);
|
||||
assert(l == sizeof s3b.hk);
|
||||
l = BIO_read(bconn, s3b.hk, sizeof(s3b.hk));
|
||||
assert(l == sizeof(s3b.hk));
|
||||
if (!JPAKE_STEP3B_process(ctx, &s3b)) {
|
||||
ERR_print_errors(bio_err);
|
||||
exit(1);
|
||||
@@ -2788,13 +2792,13 @@ unsigned char *next_protos_parse(unsigned short *outlen, const char *in)
|
||||
OPENSSL_free(out);
|
||||
return NULL;
|
||||
}
|
||||
out[start] = i - start;
|
||||
out[start] = (unsigned char)(i - start);
|
||||
start = i + 1;
|
||||
} else
|
||||
out[i + 1] = in[i];
|
||||
}
|
||||
|
||||
*outlen = len + 1;
|
||||
*outlen = (unsigned char)(len + 1);
|
||||
return out;
|
||||
}
|
||||
#endif /* ndef OPENSSL_NO_TLSEXT */
|
||||
|
||||
265
apps/ca.c
265
apps/ca.c
@@ -1628,8 +1628,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
CONF *lconf, unsigned long certopt, unsigned long nameopt,
|
||||
int default_op, int ext_copy, int selfsign)
|
||||
{
|
||||
X509_NAME *name = NULL, *CAname = NULL, *subject = NULL, *dn_subject =
|
||||
NULL;
|
||||
X509_NAME *name = NULL, *CAname = NULL, *subject = NULL;
|
||||
ASN1_UTCTIME *tm, *tmptm;
|
||||
ASN1_STRING *str, *str2;
|
||||
ASN1_OBJECT *obj;
|
||||
@@ -1817,8 +1816,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
|
||||
if (push != NULL) {
|
||||
if (!X509_NAME_add_entry(subject, push, -1, 0)) {
|
||||
if (push != NULL)
|
||||
X509_NAME_ENTRY_free(push);
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
@@ -1836,104 +1833,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
BIO_printf(bio_err,
|
||||
"The subject name appears to be ok, checking data base for clashes\n");
|
||||
|
||||
/* Build the correct Subject if no e-mail is wanted in the subject */
|
||||
/*
|
||||
* and add it later on because of the method extensions are added
|
||||
* (altName)
|
||||
*/
|
||||
|
||||
if (email_dn)
|
||||
dn_subject = subject;
|
||||
else {
|
||||
X509_NAME_ENTRY *tmpne;
|
||||
/*
|
||||
* Its best to dup the subject DN and then delete any email addresses
|
||||
* because this retains its structure.
|
||||
*/
|
||||
if (!(dn_subject = X509_NAME_dup(subject))) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
while ((i = X509_NAME_get_index_by_NID(dn_subject,
|
||||
NID_pkcs9_emailAddress,
|
||||
-1)) >= 0) {
|
||||
tmpne = X509_NAME_get_entry(dn_subject, i);
|
||||
X509_NAME_delete_entry(dn_subject, i);
|
||||
X509_NAME_ENTRY_free(tmpne);
|
||||
}
|
||||
}
|
||||
|
||||
if (BN_is_zero(serial))
|
||||
row[DB_serial] = BUF_strdup("00");
|
||||
else
|
||||
row[DB_serial] = BN_bn2hex(serial);
|
||||
if (row[DB_serial] == NULL) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (db->attributes.unique_subject) {
|
||||
OPENSSL_STRING *crow = row;
|
||||
|
||||
rrow = TXT_DB_get_by_index(db->db, DB_name, crow);
|
||||
if (rrow != NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"ERROR:There is already a certificate for %s\n",
|
||||
row[DB_name]);
|
||||
}
|
||||
}
|
||||
if (rrow == NULL) {
|
||||
rrow = TXT_DB_get_by_index(db->db, DB_serial, row);
|
||||
if (rrow != NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"ERROR:Serial number %s has already been issued,\n",
|
||||
row[DB_serial]);
|
||||
BIO_printf(bio_err,
|
||||
" check the database/serial_file for corruption\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (rrow != NULL) {
|
||||
BIO_printf(bio_err, "The matching entry has the following details\n");
|
||||
if (rrow[DB_type][0] == 'E')
|
||||
p = "Expired";
|
||||
else if (rrow[DB_type][0] == 'R')
|
||||
p = "Revoked";
|
||||
else if (rrow[DB_type][0] == 'V')
|
||||
p = "Valid";
|
||||
else
|
||||
p = "\ninvalid type, Data base error\n";
|
||||
BIO_printf(bio_err, "Type :%s\n", p);;
|
||||
if (rrow[DB_type][0] == 'R') {
|
||||
p = rrow[DB_exp_date];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Was revoked on:%s\n", p);
|
||||
}
|
||||
p = rrow[DB_exp_date];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Expires on :%s\n", p);
|
||||
p = rrow[DB_serial];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Serial Number :%s\n", p);
|
||||
p = rrow[DB_file];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "File name :%s\n", p);
|
||||
p = rrow[DB_name];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Subject Name :%s\n", p);
|
||||
ok = -1; /* This is now a 'bad' error. */
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* We are now totally happy, lets make and sign the certificate */
|
||||
if (verbose)
|
||||
BIO_printf(bio_err,
|
||||
@@ -1985,10 +1884,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
/* Lets add the extensions, if there are any */
|
||||
if (ext_sect) {
|
||||
X509V3_CTX ctx;
|
||||
if (ci->version == NULL)
|
||||
if ((ci->version = ASN1_INTEGER_new()) == NULL)
|
||||
goto err;
|
||||
ASN1_INTEGER_set(ci->version, 2); /* version 3 certificate */
|
||||
|
||||
/*
|
||||
* Free the current entries if any, there should not be any I believe
|
||||
@@ -2051,10 +1946,133 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Set the right value for the noemailDN option */
|
||||
if (email_dn == 0) {
|
||||
if (!X509_set_subject_name(ret, dn_subject))
|
||||
{
|
||||
STACK_OF(X509_EXTENSION) *exts = ci->extensions;
|
||||
|
||||
if (exts != NULL && sk_X509_EXTENSION_num(exts) > 0)
|
||||
/* Make it an X509 v3 certificate. */
|
||||
if (!X509_set_version(ret, 2))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
BIO_printf(bio_err,
|
||||
"The subject name appears to be ok, checking data base for clashes\n");
|
||||
|
||||
/* Build the correct Subject if no e-mail is wanted in the subject */
|
||||
|
||||
if (!email_dn) {
|
||||
X509_NAME_ENTRY *tmpne;
|
||||
X509_NAME *dn_subject;
|
||||
|
||||
/*
|
||||
* Its best to dup the subject DN and then delete any email addresses
|
||||
* because this retains its structure.
|
||||
*/
|
||||
if (!(dn_subject = X509_NAME_dup(subject))) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
while ((i = X509_NAME_get_index_by_NID(dn_subject,
|
||||
NID_pkcs9_emailAddress,
|
||||
-1)) >= 0) {
|
||||
tmpne = X509_NAME_get_entry(dn_subject, i);
|
||||
X509_NAME_delete_entry(dn_subject, i);
|
||||
X509_NAME_ENTRY_free(tmpne);
|
||||
}
|
||||
|
||||
if (!X509_set_subject_name(ret, dn_subject)) {
|
||||
X509_NAME_free(dn_subject);
|
||||
goto err;
|
||||
}
|
||||
X509_NAME_free(dn_subject);
|
||||
}
|
||||
|
||||
row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
|
||||
if (row[DB_name] == NULL) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (BN_is_zero(serial))
|
||||
row[DB_serial] = BUF_strdup("00");
|
||||
else
|
||||
row[DB_serial] = BN_bn2hex(serial);
|
||||
if (row[DB_serial] == NULL) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (row[DB_name][0] == '\0') {
|
||||
/*
|
||||
* An empty subject! We'll use the serial number instead. If
|
||||
* unique_subject is in use then we don't want different entries with
|
||||
* empty subjects matching each other.
|
||||
*/
|
||||
OPENSSL_free(row[DB_name]);
|
||||
row[DB_name] = OPENSSL_strdup(row[DB_serial]);
|
||||
if (row[DB_name] == NULL) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (db->attributes.unique_subject) {
|
||||
OPENSSL_STRING *crow = row;
|
||||
|
||||
rrow = TXT_DB_get_by_index(db->db, DB_name, crow);
|
||||
if (rrow != NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"ERROR:There is already a certificate for %s\n",
|
||||
row[DB_name]);
|
||||
}
|
||||
}
|
||||
if (rrow == NULL) {
|
||||
rrow = TXT_DB_get_by_index(db->db, DB_serial, row);
|
||||
if (rrow != NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"ERROR:Serial number %s has already been issued,\n",
|
||||
row[DB_serial]);
|
||||
BIO_printf(bio_err,
|
||||
" check the database/serial_file for corruption\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (rrow != NULL) {
|
||||
BIO_printf(bio_err, "The matching entry has the following details\n");
|
||||
if (rrow[DB_type][0] == 'E')
|
||||
p = "Expired";
|
||||
else if (rrow[DB_type][0] == 'R')
|
||||
p = "Revoked";
|
||||
else if (rrow[DB_type][0] == 'V')
|
||||
p = "Valid";
|
||||
else
|
||||
p = "\ninvalid type, Data base error\n";
|
||||
BIO_printf(bio_err, "Type :%s\n", p);;
|
||||
if (rrow[DB_type][0] == 'R') {
|
||||
p = rrow[DB_exp_date];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Was revoked on:%s\n", p);
|
||||
}
|
||||
p = rrow[DB_exp_date];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Expires on :%s\n", p);
|
||||
p = rrow[DB_serial];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Serial Number :%s\n", p);
|
||||
p = rrow[DB_file];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "File name :%s\n", p);
|
||||
p = rrow[DB_name];
|
||||
if (p == NULL)
|
||||
p = "undef";
|
||||
BIO_printf(bio_err, "Subject Name :%s\n", p);
|
||||
ok = -1; /* This is now a 'bad' error. */
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!default_op) {
|
||||
@@ -2105,10 +2123,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
row[DB_exp_date] = OPENSSL_malloc(tm->length + 1);
|
||||
row[DB_rev_date] = OPENSSL_malloc(1);
|
||||
row[DB_file] = OPENSSL_malloc(8);
|
||||
row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
|
||||
if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
|
||||
(row[DB_rev_date] == NULL) ||
|
||||
(row[DB_file] == NULL) || (row[DB_name] == NULL)) {
|
||||
(row[DB_file] == NULL)) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
@@ -2126,10 +2143,8 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i = 0; i < DB_NUMBER; i++) {
|
||||
for (i = 0; i < DB_NUMBER; i++)
|
||||
irow[i] = row[i];
|
||||
row[i] = NULL;
|
||||
}
|
||||
irow[DB_NUMBER] = NULL;
|
||||
|
||||
if (!TXT_DB_insert(db->db, irow)) {
|
||||
@@ -2137,18 +2152,19 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
BIO_printf(bio_err, "TXT_DB error number %ld\n", db->db->error);
|
||||
goto err;
|
||||
}
|
||||
irow = NULL;
|
||||
ok = 1;
|
||||
err:
|
||||
for (i = 0; i < DB_NUMBER; i++)
|
||||
if (row[i] != NULL)
|
||||
if (ok != 1) {
|
||||
for (i = 0; i < DB_NUMBER; i++)
|
||||
OPENSSL_free(row[i]);
|
||||
}
|
||||
OPENSSL_free(irow);
|
||||
|
||||
if (CAname != NULL)
|
||||
X509_NAME_free(CAname);
|
||||
if (subject != NULL)
|
||||
X509_NAME_free(subject);
|
||||
if ((dn_subject != NULL) && !email_dn)
|
||||
X509_NAME_free(dn_subject);
|
||||
if (tmptm != NULL)
|
||||
ASN1_UTCTIME_free(tmptm);
|
||||
if (ok <= 0) {
|
||||
@@ -2351,6 +2367,11 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
|
||||
else
|
||||
row[DB_serial] = BN_bn2hex(bn);
|
||||
BN_free(bn);
|
||||
if (row[DB_name] != NULL && row[DB_name][0] == '\0') {
|
||||
/* Entries with empty Subjects actually use the serial number instead */
|
||||
OPENSSL_free(row[DB_name]);
|
||||
row[DB_name] = OPENSSL_strdup(row[DB_serial]);
|
||||
}
|
||||
if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
@@ -2396,18 +2417,20 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i = 0; i < DB_NUMBER; i++) {
|
||||
for (i = 0; i < DB_NUMBER; i++)
|
||||
irow[i] = row[i];
|
||||
row[i] = NULL;
|
||||
}
|
||||
irow[DB_NUMBER] = NULL;
|
||||
|
||||
if (!TXT_DB_insert(db->db, irow)) {
|
||||
BIO_printf(bio_err, "failed to update database\n");
|
||||
BIO_printf(bio_err, "TXT_DB error number %ld\n", db->db->error);
|
||||
OPENSSL_free(irow);
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i = 0; i < DB_NUMBER; i++)
|
||||
row[i] = NULL;
|
||||
|
||||
/* Revoke Certificate */
|
||||
if (type == -1)
|
||||
ok = 1;
|
||||
|
||||
@@ -217,7 +217,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(STDout, "%s - ", nm);
|
||||
}
|
||||
#endif
|
||||
BIO_puts(STDout, SSL_CIPHER_description(c, buf, sizeof buf));
|
||||
BIO_puts(STDout, SSL_CIPHER_description(c, buf, sizeof(buf)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
apps/cms.c
10
apps/cms.c
@@ -4,7 +4,7 @@
|
||||
* project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2008 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 2008-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -977,12 +977,16 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
signer = load_cert(bio_err, signerfile, FORMAT_PEM, NULL,
|
||||
e, "signer certificate");
|
||||
if (!signer)
|
||||
if (!signer) {
|
||||
ret = 2;
|
||||
goto end;
|
||||
}
|
||||
key = load_key(bio_err, keyfile, keyform, 0, passin, e,
|
||||
"signing key file");
|
||||
if (!key)
|
||||
if (!key) {
|
||||
ret = 2;
|
||||
goto end;
|
||||
}
|
||||
for (kparam = key_first; kparam; kparam = kparam->next) {
|
||||
if (kparam->idx == i) {
|
||||
tflags |= CMS_KEY_PARAM;
|
||||
|
||||
@@ -145,7 +145,7 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
/* first check the program name */
|
||||
program_name(argv[0], pname, sizeof pname);
|
||||
program_name(argv[0], pname, sizeof(pname));
|
||||
|
||||
md = EVP_get_digestbyname(pname);
|
||||
|
||||
|
||||
@@ -381,10 +381,19 @@ int MAIN(int argc, char **argv)
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
if (informat == FORMAT_ASN1)
|
||||
if (informat == FORMAT_ASN1) {
|
||||
/*
|
||||
* We have no PEM header to determine what type of DH params it
|
||||
* is. We'll just try both.
|
||||
*/
|
||||
dh = d2i_DHparams_bio(in, NULL);
|
||||
else /* informat == FORMAT_PEM */
|
||||
/* BIO_reset() returns 0 for success for file BIOs only!!! */
|
||||
if (dh == NULL && BIO_reset(in) == 0)
|
||||
dh = d2i_DHxparams_bio(in, NULL);
|
||||
} else {
|
||||
/* informat == FORMAT_PEM */
|
||||
dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (dh == NULL) {
|
||||
BIO_printf(bio_err, "unable to load DH parameters\n");
|
||||
@@ -484,10 +493,13 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!noout) {
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_DHparams_bio(out, dh);
|
||||
else if (outformat == FORMAT_PEM) {
|
||||
if (dh->q)
|
||||
if (outformat == FORMAT_ASN1) {
|
||||
if (dh->q != NULL)
|
||||
i = i2d_DHxparams_bio(out, dh);
|
||||
else
|
||||
i = i2d_DHparams_bio(out, dh);
|
||||
} else if (outformat == FORMAT_PEM) {
|
||||
if (dh->q != NULL)
|
||||
i = PEM_write_bio_DHxparams(out, dh);
|
||||
else
|
||||
i = PEM_write_bio_DHparams(out, dh);
|
||||
|
||||
@@ -327,6 +327,9 @@ int MAIN(int argc, char **argv)
|
||||
} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
|
||||
EVP_PKEY *pk;
|
||||
pk = EVP_PKEY_new();
|
||||
if (pk == NULL)
|
||||
goto end;
|
||||
|
||||
EVP_PKEY_set1_DSA(pk, dsa);
|
||||
if (outformat == FORMAT_PVK)
|
||||
i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout);
|
||||
|
||||
@@ -382,6 +382,9 @@ int MAIN(int argc, char **argv)
|
||||
printf("\treturn(dsa);\n\t}\n");
|
||||
}
|
||||
|
||||
if (outformat == FORMAT_ASN1 && genkey)
|
||||
noout = 1;
|
||||
|
||||
if (!noout) {
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_DSAparams_bio(out, dsa);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -546,6 +546,9 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(out, "\treturn(group);\n\t}\n");
|
||||
}
|
||||
|
||||
if (outformat == FORMAT_ASN1 && genkey)
|
||||
noout = 1;
|
||||
|
||||
if (!noout) {
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_ECPKParameters_bio(out, group);
|
||||
@@ -582,6 +585,9 @@ int MAIN(int argc, char **argv)
|
||||
if (EC_KEY_set_group(eckey, group) == 0)
|
||||
goto end;
|
||||
|
||||
if (new_form)
|
||||
EC_KEY_set_conv_form(eckey, form);
|
||||
|
||||
if (!EC_KEY_generate_key(eckey)) {
|
||||
EC_KEY_free(eckey);
|
||||
goto end;
|
||||
|
||||
57
apps/enc.c
57
apps/enc.c
@@ -81,20 +81,32 @@ int set_hex(char *in, unsigned char *out, int size);
|
||||
#define BSIZE (8*1024)
|
||||
#define PROG enc_main
|
||||
|
||||
static void show_ciphers(const OBJ_NAME *name, void *bio_)
|
||||
struct doall_enc_ciphers {
|
||||
BIO *bio;
|
||||
int n;
|
||||
};
|
||||
|
||||
static void show_ciphers(const OBJ_NAME *name, void *arg)
|
||||
{
|
||||
BIO *bio = bio_;
|
||||
static int n;
|
||||
struct doall_enc_ciphers *dec = (struct doall_enc_ciphers *)arg;
|
||||
const EVP_CIPHER *cipher;
|
||||
|
||||
if (!islower((unsigned char)*name->name))
|
||||
return;
|
||||
|
||||
BIO_printf(bio, "-%-25s", name->name);
|
||||
if (++n == 3) {
|
||||
BIO_printf(bio, "\n");
|
||||
n = 0;
|
||||
/* Filter out ciphers that we cannot use */
|
||||
cipher = EVP_get_cipherbyname(name->name);
|
||||
if (cipher == NULL ||
|
||||
(EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) != 0 ||
|
||||
EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE)
|
||||
return;
|
||||
|
||||
BIO_printf(dec->bio, "-%-25s", name->name);
|
||||
if (++dec->n == 3) {
|
||||
BIO_printf(dec->bio, "\n");
|
||||
dec->n = 0;
|
||||
} else
|
||||
BIO_printf(bio, " ");
|
||||
BIO_printf(dec->bio, " ");
|
||||
}
|
||||
|
||||
int MAIN(int, char **);
|
||||
@@ -102,7 +114,7 @@ int MAIN(int, char **);
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
static const char magic[] = "Salted__";
|
||||
char mbuf[sizeof magic - 1];
|
||||
char mbuf[sizeof(magic) - 1];
|
||||
char *strbuf = NULL;
|
||||
unsigned char *buff = NULL, *bufsize = NULL;
|
||||
int bsize = BSIZE, verbose = 0;
|
||||
@@ -130,6 +142,7 @@ int MAIN(int argc, char **argv)
|
||||
ENGINE *e = NULL;
|
||||
const EVP_MD *dgst = NULL;
|
||||
int non_fips_allow = 0;
|
||||
struct doall_enc_ciphers dec;
|
||||
|
||||
apps_startup();
|
||||
|
||||
@@ -141,7 +154,7 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
/* first check the program name */
|
||||
program_name(argv[0], pname, sizeof pname);
|
||||
program_name(argv[0], pname, sizeof(pname));
|
||||
if (strcmp(pname, "base64") == 0)
|
||||
base64 = 1;
|
||||
#ifdef ZLIB
|
||||
@@ -234,7 +247,7 @@ int MAIN(int argc, char **argv)
|
||||
goto bad;
|
||||
}
|
||||
buf[0] = '\0';
|
||||
if (!fgets(buf, sizeof buf, infile)) {
|
||||
if (!fgets(buf, sizeof(buf), infile)) {
|
||||
BIO_printf(bio_err, "unable to read key from '%s'\n", file);
|
||||
goto bad;
|
||||
}
|
||||
@@ -311,8 +324,10 @@ int MAIN(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
BIO_printf(bio_err, "Cipher Types\n");
|
||||
dec.n = 0;
|
||||
dec.bio = bio_err;
|
||||
OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
|
||||
show_ciphers, bio_err);
|
||||
show_ciphers, &dec);
|
||||
BIO_printf(bio_err, "\n");
|
||||
|
||||
goto end;
|
||||
@@ -417,7 +432,7 @@ int MAIN(int argc, char **argv)
|
||||
for (;;) {
|
||||
char buf[200];
|
||||
|
||||
BIO_snprintf(buf, sizeof buf, "enter %s %s password:",
|
||||
BIO_snprintf(buf, sizeof(buf), "enter %s %s password:",
|
||||
OBJ_nid2ln(EVP_CIPHER_nid(cipher)),
|
||||
(enc) ? "encryption" : "decryption");
|
||||
strbuf[0] = '\0';
|
||||
@@ -502,31 +517,31 @@ int MAIN(int argc, char **argv)
|
||||
else {
|
||||
if (enc) {
|
||||
if (hsalt) {
|
||||
if (!set_hex(hsalt, salt, sizeof salt)) {
|
||||
if (!set_hex(hsalt, salt, sizeof(salt))) {
|
||||
BIO_printf(bio_err, "invalid hex salt value\n");
|
||||
goto end;
|
||||
}
|
||||
} else if (RAND_bytes(salt, sizeof salt) <= 0)
|
||||
} else if (RAND_bytes(salt, sizeof(salt)) <= 0)
|
||||
goto end;
|
||||
/*
|
||||
* If -P option then don't bother writing
|
||||
*/
|
||||
if ((printkey != 2)
|
||||
&& (BIO_write(wbio, magic,
|
||||
sizeof magic - 1) != sizeof magic - 1
|
||||
sizeof(magic) - 1) != sizeof(magic) - 1
|
||||
|| BIO_write(wbio,
|
||||
(char *)salt,
|
||||
sizeof salt) != sizeof salt)) {
|
||||
sizeof(salt)) != sizeof(salt))) {
|
||||
BIO_printf(bio_err, "error writing output file\n");
|
||||
goto end;
|
||||
}
|
||||
} else if (BIO_read(rbio, mbuf, sizeof mbuf) != sizeof mbuf
|
||||
} else if (BIO_read(rbio, mbuf, sizeof(mbuf)) != sizeof(mbuf)
|
||||
|| BIO_read(rbio,
|
||||
(unsigned char *)salt,
|
||||
sizeof salt) != sizeof salt) {
|
||||
sizeof(salt)) != sizeof(salt)) {
|
||||
BIO_printf(bio_err, "error reading input file\n");
|
||||
goto end;
|
||||
} else if (memcmp(mbuf, magic, sizeof magic - 1)) {
|
||||
} else if (memcmp(mbuf, magic, sizeof(magic) - 1)) {
|
||||
BIO_printf(bio_err, "bad magic number\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -549,7 +564,7 @@ int MAIN(int argc, char **argv)
|
||||
int siz = EVP_CIPHER_iv_length(cipher);
|
||||
if (siz == 0) {
|
||||
BIO_printf(bio_err, "warning: iv not use by this cipher\n");
|
||||
} else if (!set_hex(hiv, iv, sizeof iv)) {
|
||||
} else if (!set_hex(hiv, iv, sizeof(iv))) {
|
||||
BIO_printf(bio_err, "invalid hex iv value\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -108,13 +108,16 @@ static int append_buf(char **buf, const char *s, int *size, int step)
|
||||
}
|
||||
|
||||
if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
|
||||
char *p = *buf;
|
||||
|
||||
*size += step;
|
||||
*buf = OPENSSL_realloc(*buf, *size);
|
||||
if (*buf == NULL) {
|
||||
OPENSSL_free(p);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (*buf == NULL)
|
||||
return 0;
|
||||
|
||||
if (**buf != '\0')
|
||||
BUF_strlcat(*buf, ", ", *size);
|
||||
BUF_strlcat(*buf, s, *size);
|
||||
|
||||
@@ -108,7 +108,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (sscanf(argv[i], "%lx", &l)) {
|
||||
ERR_error_string_n(l, buf, sizeof buf);
|
||||
ERR_error_string_n(l, buf, sizeof(buf));
|
||||
printf("%s\n", buf);
|
||||
} else {
|
||||
printf("%s: bad error code\n", argv[i]);
|
||||
|
||||
@@ -1195,7 +1195,7 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio,
|
||||
*pcbio = cbio;
|
||||
|
||||
for (;;) {
|
||||
len = BIO_gets(cbio, inbuf, sizeof inbuf);
|
||||
len = BIO_gets(cbio, inbuf, sizeof(inbuf));
|
||||
if (len <= 0)
|
||||
return 1;
|
||||
/* Look for "POST" signalling start of query */
|
||||
|
||||
@@ -351,7 +351,7 @@ int main(int Argc, char *ARGV[])
|
||||
prog = prog_init();
|
||||
|
||||
/* first check the program name */
|
||||
program_name(Argv[0], pname, sizeof pname);
|
||||
program_name(Argv[0], pname, sizeof(pname));
|
||||
|
||||
f.name = pname;
|
||||
fp = lh_FUNCTION_retrieve(prog, &f);
|
||||
@@ -379,7 +379,7 @@ int main(int Argc, char *ARGV[])
|
||||
for (;;) {
|
||||
ret = 0;
|
||||
p = buf;
|
||||
n = sizeof buf;
|
||||
n = sizeof(buf);
|
||||
i = 0;
|
||||
for (;;) {
|
||||
p[0] = '\0';
|
||||
@@ -685,7 +685,7 @@ static LHASH_OF(FUNCTION) *prog_init(void)
|
||||
|
||||
/* Purely so it looks nice when the user hits ? */
|
||||
for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
|
||||
qsort(functions, i, sizeof *functions, SortFnByName);
|
||||
qsort(functions, i, sizeof(*functions), SortFnByName);
|
||||
|
||||
if ((ret = lh_FUNCTION_new()) == NULL)
|
||||
return (NULL);
|
||||
|
||||
@@ -252,7 +252,7 @@ int MAIN(int argc, char **argv)
|
||||
/* ignore rest of line */
|
||||
char trash[BUFSIZ];
|
||||
do
|
||||
r = BIO_gets(in, trash, sizeof trash);
|
||||
r = BIO_gets(in, trash, sizeof(trash));
|
||||
while ((r > 0) && (!strchr(trash, '\n')));
|
||||
}
|
||||
|
||||
@@ -329,8 +329,8 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|
||||
EVP_DigestUpdate(&md2, passwd, passwd_len);
|
||||
EVP_DigestFinal_ex(&md2, buf, NULL);
|
||||
|
||||
for (i = passwd_len; i > sizeof buf; i -= sizeof buf)
|
||||
EVP_DigestUpdate(&md, buf, sizeof buf);
|
||||
for (i = passwd_len; i > sizeof(buf); i -= sizeof(buf))
|
||||
EVP_DigestUpdate(&md, buf, sizeof(buf));
|
||||
EVP_DigestUpdate(&md, buf, i);
|
||||
|
||||
n = passwd_len;
|
||||
@@ -343,13 +343,13 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|
||||
for (i = 0; i < 1000; i++) {
|
||||
EVP_DigestInit_ex(&md2, EVP_md5(), NULL);
|
||||
EVP_DigestUpdate(&md2, (i & 1) ? (unsigned const char *)passwd : buf,
|
||||
(i & 1) ? passwd_len : sizeof buf);
|
||||
(i & 1) ? passwd_len : sizeof(buf));
|
||||
if (i % 3)
|
||||
EVP_DigestUpdate(&md2, salt_out, salt_len);
|
||||
if (i % 7)
|
||||
EVP_DigestUpdate(&md2, passwd, passwd_len);
|
||||
EVP_DigestUpdate(&md2, (i & 1) ? buf : (unsigned const char *)passwd,
|
||||
(i & 1) ? sizeof buf : passwd_len);
|
||||
(i & 1) ? sizeof(buf) : passwd_len);
|
||||
EVP_DigestFinal_ex(&md2, buf, NULL);
|
||||
}
|
||||
EVP_MD_CTX_cleanup(&md2);
|
||||
@@ -357,7 +357,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|
||||
{
|
||||
/* transform buf into output string */
|
||||
|
||||
unsigned char buf_perm[sizeof buf];
|
||||
unsigned char buf_perm[sizeof(buf)];
|
||||
int dest, source;
|
||||
char *output;
|
||||
|
||||
@@ -369,7 +369,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|
||||
buf_perm[15] = buf[11];
|
||||
# ifndef PEDANTIC /* Unfortunately, this generates a "no
|
||||
* effect" warning */
|
||||
assert(16 == sizeof buf_perm);
|
||||
assert(16 == sizeof(buf_perm));
|
||||
# endif
|
||||
|
||||
output = salt_out + salt_len;
|
||||
|
||||
@@ -481,7 +481,7 @@ int MAIN(int argc, char **argv)
|
||||
CRYPTO_push_info("read MAC password");
|
||||
# endif
|
||||
if (EVP_read_pw_string
|
||||
(macpass, sizeof macpass, "Enter MAC Password:", export_cert)) {
|
||||
(macpass, sizeof(macpass), "Enter MAC Password:", export_cert)) {
|
||||
BIO_printf(bio_err, "Can't read Password\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -629,13 +629,13 @@ int MAIN(int argc, char **argv)
|
||||
# endif
|
||||
|
||||
if (!noprompt &&
|
||||
EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:",
|
||||
EVP_read_pw_string(pass, sizeof(pass), "Enter Export Password:",
|
||||
1)) {
|
||||
BIO_printf(bio_err, "Can't read Password\n");
|
||||
goto export_end;
|
||||
}
|
||||
if (!twopass)
|
||||
BUF_strlcpy(macpass, pass, sizeof macpass);
|
||||
BUF_strlcpy(macpass, pass, sizeof(macpass));
|
||||
|
||||
# ifdef CRYPTO_MDEBUG
|
||||
CRYPTO_pop_info();
|
||||
@@ -698,7 +698,7 @@ int MAIN(int argc, char **argv)
|
||||
CRYPTO_push_info("read import password");
|
||||
# endif
|
||||
if (!noprompt
|
||||
&& EVP_read_pw_string(pass, sizeof pass, "Enter Import Password:",
|
||||
&& EVP_read_pw_string(pass, sizeof(pass), "Enter Import Password:",
|
||||
0)) {
|
||||
BIO_printf(bio_err, "Can't read Password\n");
|
||||
goto end;
|
||||
@@ -708,7 +708,7 @@ int MAIN(int argc, char **argv)
|
||||
# endif
|
||||
|
||||
if (!twopass)
|
||||
BUF_strlcpy(macpass, pass, sizeof macpass);
|
||||
BUF_strlcpy(macpass, pass, sizeof(macpass));
|
||||
|
||||
if ((options & INFO) && p12->mac)
|
||||
BIO_printf(bio_err, "MAC Iteration %ld\n",
|
||||
|
||||
@@ -277,7 +277,7 @@ int MAIN(int argc, char **argv)
|
||||
else {
|
||||
p8pass = pass;
|
||||
if (EVP_read_pw_string
|
||||
(pass, sizeof pass, "Enter Encryption Password:", 1))
|
||||
(pass, sizeof(pass), "Enter Encryption Password:", 1))
|
||||
goto end;
|
||||
}
|
||||
app_RAND_load_file(NULL, bio_err, 0);
|
||||
@@ -331,7 +331,7 @@ int MAIN(int argc, char **argv)
|
||||
p8pass = passin;
|
||||
else {
|
||||
p8pass = pass;
|
||||
EVP_read_pw_string(pass, sizeof pass, "Enter Password:", 0);
|
||||
EVP_read_pw_string(pass, sizeof(pass), "Enter Password:", 0);
|
||||
}
|
||||
p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass));
|
||||
}
|
||||
|
||||
@@ -322,8 +322,10 @@ int MAIN(int argc, char **argv)
|
||||
buf_in, (size_t)buf_inlen);
|
||||
if (rv == 0)
|
||||
BIO_puts(out, "Signature Verification Failure\n");
|
||||
else if (rv == 1)
|
||||
else if (rv == 1) {
|
||||
BIO_puts(out, "Signature Verified Successfully\n");
|
||||
ret = 0;
|
||||
}
|
||||
if (rv >= 0)
|
||||
goto end;
|
||||
} else {
|
||||
|
||||
@@ -155,5 +155,8 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err, "options are\n");
|
||||
BIO_printf(bio_err, "%-14s hex\n", "-hex");
|
||||
BIO_printf(bio_err, "%-14s number of checks\n", "-checks <n>");
|
||||
BIO_printf(bio_err, "%-14s generate prime\n", "-generate");
|
||||
BIO_printf(bio_err, "%-14s number of bits\n", "-bits <n>");
|
||||
BIO_printf(bio_err, "%-14s safe prime\n", "-safe");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ extern int srp_main(int argc, char *argv[]);
|
||||
typedef struct {
|
||||
int type;
|
||||
const char *name;
|
||||
int (*func) (int argc, char *argv[]);
|
||||
int (*func)(int argc, char *argv[]);
|
||||
} FUNCTION;
|
||||
DECLARE_LHASH_OF(FUNCTION);
|
||||
|
||||
|
||||
@@ -6,22 +6,22 @@ print "/* automatically generated by progs.pl for openssl.c */\n\n";
|
||||
grep(s/^asn1pars$/asn1parse/,@ARGV);
|
||||
|
||||
foreach (@ARGV)
|
||||
{ printf "extern int %s_main(int argc,char *argv[]);\n",$_; }
|
||||
{ printf "extern int %s_main(int argc, char *argv[]);\n",$_; }
|
||||
|
||||
print <<'EOF';
|
||||
|
||||
#define FUNC_TYPE_GENERAL 1
|
||||
#define FUNC_TYPE_MD 2
|
||||
#define FUNC_TYPE_CIPHER 3
|
||||
#define FUNC_TYPE_PKEY 4
|
||||
#define FUNC_TYPE_MD_ALG 5
|
||||
#define FUNC_TYPE_CIPHER_ALG 6
|
||||
#define FUNC_TYPE_GENERAL 1
|
||||
#define FUNC_TYPE_MD 2
|
||||
#define FUNC_TYPE_CIPHER 3
|
||||
#define FUNC_TYPE_PKEY 4
|
||||
#define FUNC_TYPE_MD_ALG 5
|
||||
#define FUNC_TYPE_CIPHER_ALG 6
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
const char *name;
|
||||
int (*func)(int argc,char *argv[]);
|
||||
} FUNCTION;
|
||||
int type;
|
||||
const char *name;
|
||||
int (*func)(int argc, char *argv[]);
|
||||
} FUNCTION;
|
||||
DECLARE_LHASH_OF(FUNCTION);
|
||||
|
||||
FUNCTION functions[] = {
|
||||
@@ -30,7 +30,7 @@ EOF
|
||||
foreach (@ARGV)
|
||||
{
|
||||
push(@files,$_);
|
||||
$str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
|
||||
$str=" {FUNC_TYPE_GENERAL, \"$_\", ${_}_main},\n";
|
||||
if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
|
||||
{ print "#if !defined(OPENSSL_NO_SOCK)\n${str}#endif\n"; }
|
||||
elsif ( ($_ =~ /^speed$/))
|
||||
@@ -60,7 +60,7 @@ foreach (@ARGV)
|
||||
foreach ("md2","md4","md5","sha","sha1","mdc2","rmd160")
|
||||
{
|
||||
push(@files,$_);
|
||||
printf "#ifndef OPENSSL_NO_".uc($_)."\n\t{FUNC_TYPE_MD,\"".$_."\",dgst_main},\n#endif\n";
|
||||
printf "#ifndef OPENSSL_NO_".uc($_)."\n {FUNC_TYPE_MD, \"".$_."\", dgst_main},\n#endif\n";
|
||||
}
|
||||
|
||||
foreach (
|
||||
@@ -86,7 +86,7 @@ foreach (
|
||||
{
|
||||
push(@files,$_);
|
||||
|
||||
$t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
|
||||
$t=sprintf(" {FUNC_TYPE_CIPHER, \"%s\", enc_main},\n",$_);
|
||||
if ($_ =~ /des/) { $t="#ifndef OPENSSL_NO_DES\n${t}#endif\n"; }
|
||||
elsif ($_ =~ /aes/) { $t="#ifndef OPENSSL_NO_AES\n${t}#endif\n"; }
|
||||
elsif ($_ =~ /camellia/) { $t="#ifndef OPENSSL_NO_CAMELLIA\n${t}#endif\n"; }
|
||||
@@ -101,4 +101,4 @@ foreach (
|
||||
print $t;
|
||||
}
|
||||
|
||||
print "\t{0,NULL,NULL}\n\t};\n";
|
||||
print " {0, NULL, NULL}\n};\n";
|
||||
|
||||
@@ -198,7 +198,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
chunk = num;
|
||||
if (chunk > (int)sizeof(buf))
|
||||
chunk = sizeof buf;
|
||||
chunk = sizeof(buf);
|
||||
r = RAND_bytes(buf, chunk);
|
||||
if (r <= 0)
|
||||
goto err;
|
||||
|
||||
42
apps/req.c
42
apps/req.c
@@ -331,7 +331,6 @@ int MAIN(int argc, char **argv)
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-x509") == 0) {
|
||||
newreq = 1;
|
||||
x509 = 1;
|
||||
} else if (strcmp(*argv, "-asn1-kludge") == 0)
|
||||
kludge = 1;
|
||||
@@ -447,6 +446,9 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (x509 && infile == NULL)
|
||||
newreq = 1;
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
|
||||
BIO_printf(bio_err, "Error getting passwords\n");
|
||||
@@ -753,7 +755,7 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (newreq) {
|
||||
if (newreq || x509) {
|
||||
if (pkey == NULL) {
|
||||
BIO_printf(bio_err, "you need to specify a private key\n");
|
||||
goto end;
|
||||
@@ -1191,7 +1193,7 @@ static int prompt_info(X509_REQ *req,
|
||||
/* If OBJ not recognised ignore it */
|
||||
if ((nid = OBJ_txt2nid(type)) == NID_undef)
|
||||
goto start;
|
||||
if (BIO_snprintf(buf, sizeof buf, "%s_default", v->name)
|
||||
if (BIO_snprintf(buf, sizeof(buf), "%s_default", v->name)
|
||||
>= (int)sizeof(buf)) {
|
||||
BIO_printf(bio_err, "Name '%s' too long\n", v->name);
|
||||
return 0;
|
||||
@@ -1202,19 +1204,19 @@ static int prompt_info(X509_REQ *req,
|
||||
def = "";
|
||||
}
|
||||
|
||||
BIO_snprintf(buf, sizeof buf, "%s_value", v->name);
|
||||
BIO_snprintf(buf, sizeof(buf), "%s_value", v->name);
|
||||
if ((value = NCONF_get_string(req_conf, dn_sect, buf)) == NULL) {
|
||||
ERR_clear_error();
|
||||
value = NULL;
|
||||
}
|
||||
|
||||
BIO_snprintf(buf, sizeof buf, "%s_min", v->name);
|
||||
BIO_snprintf(buf, sizeof(buf), "%s_min", v->name);
|
||||
if (!NCONF_get_number(req_conf, dn_sect, buf, &n_min)) {
|
||||
ERR_clear_error();
|
||||
n_min = -1;
|
||||
}
|
||||
|
||||
BIO_snprintf(buf, sizeof buf, "%s_max", v->name);
|
||||
BIO_snprintf(buf, sizeof(buf), "%s_max", v->name);
|
||||
if (!NCONF_get_number(req_conf, dn_sect, buf, &n_max)) {
|
||||
ERR_clear_error();
|
||||
n_max = -1;
|
||||
@@ -1250,7 +1252,7 @@ static int prompt_info(X509_REQ *req,
|
||||
if ((nid = OBJ_txt2nid(type)) == NID_undef)
|
||||
goto start2;
|
||||
|
||||
if (BIO_snprintf(buf, sizeof buf, "%s_default", type)
|
||||
if (BIO_snprintf(buf, sizeof(buf), "%s_default", type)
|
||||
>= (int)sizeof(buf)) {
|
||||
BIO_printf(bio_err, "Name '%s' too long\n", v->name);
|
||||
return 0;
|
||||
@@ -1262,20 +1264,20 @@ static int prompt_info(X509_REQ *req,
|
||||
def = "";
|
||||
}
|
||||
|
||||
BIO_snprintf(buf, sizeof buf, "%s_value", type);
|
||||
BIO_snprintf(buf, sizeof(buf), "%s_value", type);
|
||||
if ((value = NCONF_get_string(req_conf, attr_sect, buf))
|
||||
== NULL) {
|
||||
ERR_clear_error();
|
||||
value = NULL;
|
||||
}
|
||||
|
||||
BIO_snprintf(buf, sizeof buf, "%s_min", type);
|
||||
BIO_snprintf(buf, sizeof(buf), "%s_min", type);
|
||||
if (!NCONF_get_number(req_conf, attr_sect, buf, &n_min)) {
|
||||
ERR_clear_error();
|
||||
n_min = -1;
|
||||
}
|
||||
|
||||
BIO_snprintf(buf, sizeof buf, "%s_max", type);
|
||||
BIO_snprintf(buf, sizeof(buf), "%s_max", type);
|
||||
if (!NCONF_get_number(req_conf, attr_sect, buf, &n_max)) {
|
||||
ERR_clear_error();
|
||||
n_max = -1;
|
||||
@@ -1370,13 +1372,13 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def,
|
||||
BIO_printf(bio_err, "%s [%s]:", text, def);
|
||||
(void)BIO_flush(bio_err);
|
||||
if (value != NULL) {
|
||||
BUF_strlcpy(buf, value, sizeof buf);
|
||||
BUF_strlcat(buf, "\n", sizeof buf);
|
||||
BUF_strlcpy(buf, value, sizeof(buf));
|
||||
BUF_strlcat(buf, "\n", sizeof(buf));
|
||||
BIO_printf(bio_err, "%s\n", value);
|
||||
} else {
|
||||
buf[0] = '\0';
|
||||
if (!batch) {
|
||||
if (!fgets(buf, sizeof buf, stdin))
|
||||
if (!fgets(buf, sizeof(buf), stdin))
|
||||
return 0;
|
||||
} else {
|
||||
buf[0] = '\n';
|
||||
@@ -1389,8 +1391,8 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def,
|
||||
else if (buf[0] == '\n') {
|
||||
if ((def == NULL) || (def[0] == '\0'))
|
||||
return (1);
|
||||
BUF_strlcpy(buf, def, sizeof buf);
|
||||
BUF_strlcat(buf, "\n", sizeof buf);
|
||||
BUF_strlcpy(buf, def, sizeof(buf));
|
||||
BUF_strlcat(buf, "\n", sizeof(buf));
|
||||
} else if ((buf[0] == '.') && (buf[1] == '\n'))
|
||||
return (1);
|
||||
|
||||
@@ -1429,13 +1431,13 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def,
|
||||
BIO_printf(bio_err, "%s [%s]:", text, def);
|
||||
(void)BIO_flush(bio_err);
|
||||
if (value != NULL) {
|
||||
BUF_strlcpy(buf, value, sizeof buf);
|
||||
BUF_strlcat(buf, "\n", sizeof buf);
|
||||
BUF_strlcpy(buf, value, sizeof(buf));
|
||||
BUF_strlcat(buf, "\n", sizeof(buf));
|
||||
BIO_printf(bio_err, "%s\n", value);
|
||||
} else {
|
||||
buf[0] = '\0';
|
||||
if (!batch) {
|
||||
if (!fgets(buf, sizeof buf, stdin))
|
||||
if (!fgets(buf, sizeof(buf), stdin))
|
||||
return 0;
|
||||
} else {
|
||||
buf[0] = '\n';
|
||||
@@ -1448,8 +1450,8 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def,
|
||||
else if (buf[0] == '\n') {
|
||||
if ((def == NULL) || (def[0] == '\0'))
|
||||
return (1);
|
||||
BUF_strlcpy(buf, def, sizeof buf);
|
||||
BUF_strlcat(buf, "\n", sizeof buf);
|
||||
BUF_strlcpy(buf, def, sizeof(buf));
|
||||
BUF_strlcat(buf, "\n", sizeof(buf));
|
||||
} else if ((buf[0] == '.') && (buf[1] == '\n'))
|
||||
return (1);
|
||||
|
||||
|
||||
@@ -630,10 +630,11 @@ static int serverinfo_cli_parse_cb(SSL *s, unsigned int ext_type,
|
||||
unsigned char ext_buf[4 + 65536];
|
||||
|
||||
/* Reconstruct the type/len fields prior to extension data */
|
||||
ext_buf[0] = ext_type >> 8;
|
||||
ext_buf[1] = ext_type & 0xFF;
|
||||
ext_buf[2] = inlen >> 8;
|
||||
ext_buf[3] = inlen & 0xFF;
|
||||
inlen &= 0xffff; /* for formal memcpy correctness */
|
||||
ext_buf[0] = (unsigned char)(ext_type >> 8);
|
||||
ext_buf[1] = (unsigned char)(ext_type);
|
||||
ext_buf[2] = (unsigned char)(inlen >> 8);
|
||||
ext_buf[3] = (unsigned char)(inlen);
|
||||
memcpy(ext_buf + 4, in, inlen);
|
||||
|
||||
BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %d",
|
||||
@@ -1667,6 +1668,8 @@ int MAIN(int argc, char **argv)
|
||||
if (strstr(mbuf, "/stream:features>"))
|
||||
goto shut;
|
||||
seen = BIO_read(sbio, mbuf, BUFSIZZ);
|
||||
if (seen <= 0)
|
||||
goto shut;
|
||||
mbuf[seen] = 0;
|
||||
}
|
||||
BIO_printf(sbio,
|
||||
@@ -2132,6 +2135,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_free(bio_c_msg);
|
||||
bio_c_msg = NULL;
|
||||
}
|
||||
SSL_COMP_free_compression_methods();
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
@@ -2162,10 +2166,10 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
BIO_printf(bio, "---\nCertificate chain\n");
|
||||
for (i = 0; i < sk_X509_num(sk); i++) {
|
||||
X509_NAME_oneline(X509_get_subject_name(sk_X509_value(sk, i)),
|
||||
buf, sizeof buf);
|
||||
buf, sizeof(buf));
|
||||
BIO_printf(bio, "%2d s:%s\n", i, buf);
|
||||
X509_NAME_oneline(X509_get_issuer_name(sk_X509_value(sk, i)),
|
||||
buf, sizeof buf);
|
||||
buf, sizeof(buf));
|
||||
BIO_printf(bio, " i:%s\n", buf);
|
||||
if (c_showcerts)
|
||||
PEM_write_bio_X509(bio, sk_X509_value(sk, i));
|
||||
@@ -2180,9 +2184,9 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
/* Redundant if we showed the whole chain */
|
||||
if (!(c_showcerts && got_a_chain))
|
||||
PEM_write_bio_X509(bio, peer);
|
||||
X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf);
|
||||
X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof(buf));
|
||||
BIO_printf(bio, "subject=%s\n", buf);
|
||||
X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf);
|
||||
X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof(buf));
|
||||
BIO_printf(bio, "issuer=%s\n", buf);
|
||||
} else
|
||||
BIO_printf(bio, "no peer certificate available\n");
|
||||
@@ -2199,7 +2203,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
} else {
|
||||
BIO_printf(bio, "---\nNo client certificate CA names sent\n");
|
||||
}
|
||||
p = SSL_get_shared_ciphers(s, buf, sizeof buf);
|
||||
p = SSL_get_shared_ciphers(s, buf, sizeof(buf));
|
||||
if (p != NULL) {
|
||||
/*
|
||||
* This works only for SSL 2. In later protocol versions, the
|
||||
|
||||
@@ -2008,7 +2008,7 @@ int MAIN(int argc, char *argv[])
|
||||
|
||||
SSL_CTX_set_verify(ctx, s_server_verify, verify_callback);
|
||||
SSL_CTX_set_session_id_context(ctx, (void *)&s_server_session_id_context,
|
||||
sizeof s_server_session_id_context);
|
||||
sizeof(s_server_session_id_context));
|
||||
|
||||
/* Set DTLS cookie generation and verification callbacks */
|
||||
SSL_CTX_set_cookie_generate_cb(ctx, generate_cookie_callback);
|
||||
@@ -2019,7 +2019,7 @@ int MAIN(int argc, char *argv[])
|
||||
SSL_CTX_set_verify(ctx2, s_server_verify, verify_callback);
|
||||
SSL_CTX_set_session_id_context(ctx2,
|
||||
(void *)&s_server_session_id_context,
|
||||
sizeof s_server_session_id_context);
|
||||
sizeof(s_server_session_id_context));
|
||||
|
||||
tlsextcbp.biodebug = bio_s_out;
|
||||
SSL_CTX_set_tlsext_servername_callback(ctx2, ssl_servername_cb);
|
||||
@@ -2132,6 +2132,7 @@ int MAIN(int argc, char *argv[])
|
||||
BIO_free(bio_s_msg);
|
||||
bio_s_msg = NULL;
|
||||
}
|
||||
SSL_COMP_free_compression_methods();
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
@@ -2665,14 +2666,14 @@ static int init_ssl_connection(SSL *con)
|
||||
if (peer != NULL) {
|
||||
BIO_printf(bio_s_out, "Client certificate\n");
|
||||
PEM_write_bio_X509(bio_s_out, peer);
|
||||
X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof buf);
|
||||
X509_NAME_oneline(X509_get_subject_name(peer), buf, sizeof(buf));
|
||||
BIO_printf(bio_s_out, "subject=%s\n", buf);
|
||||
X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof buf);
|
||||
X509_NAME_oneline(X509_get_issuer_name(peer), buf, sizeof(buf));
|
||||
BIO_printf(bio_s_out, "issuer=%s\n", buf);
|
||||
X509_free(peer);
|
||||
}
|
||||
|
||||
if (SSL_get_shared_ciphers(con, buf, sizeof buf) != NULL)
|
||||
if (SSL_get_shared_ciphers(con, buf, sizeof(buf)) != NULL)
|
||||
BIO_printf(bio_s_out, "Shared ciphers:%s\n", buf);
|
||||
str = SSL_CIPHER_get_name(SSL_get_current_cipher(con));
|
||||
ssl_print_sigalgs(bio_s_out, con);
|
||||
@@ -3016,7 +3017,7 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
PEM_write_bio_X509(io, peer);
|
||||
} else
|
||||
BIO_puts(io, "no client certificate available\n");
|
||||
BIO_puts(io, "</BODY></HTML>\r\n\r\n");
|
||||
BIO_puts(io, "</pre></BODY></HTML>\r\n\r\n");
|
||||
break;
|
||||
} else if ((www == 2 || www == 3)
|
||||
&& (strncmp("GET /", buf, 5) == 0)) {
|
||||
|
||||
@@ -235,7 +235,7 @@ int init_client(int *sock, char *host, int port, int type)
|
||||
{
|
||||
unsigned char ip[4];
|
||||
|
||||
memset(ip, '\0', sizeof ip);
|
||||
memset(ip, '\0', sizeof(ip));
|
||||
if (!host_ip(host, &(ip[0])))
|
||||
return 0;
|
||||
return init_client_ip(sock, ip, port, type);
|
||||
@@ -360,7 +360,7 @@ static int init_server_long(int *sock, int port, char *ip, int type)
|
||||
# if defined SOL_SOCKET && defined SO_REUSEADDR
|
||||
{
|
||||
int j = 1;
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void *)&j, sizeof j);
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void *)&j, sizeof(j));
|
||||
}
|
||||
# endif
|
||||
if (bind(s, (struct sockaddr *)&server, sizeof(server)) == -1) {
|
||||
@@ -595,7 +595,7 @@ static struct hostent *GetHostByName(char *name)
|
||||
if (ret == NULL)
|
||||
return (NULL);
|
||||
/* else add to cache */
|
||||
if (strlen(name) < sizeof ghbn_cache[0].name) {
|
||||
if (strlen(name) < sizeof(ghbn_cache[0].name)) {
|
||||
strcpy(ghbn_cache[lowi].name, name);
|
||||
memcpy((char *)&(ghbn_cache[lowi].ent), ret,
|
||||
sizeof(struct hostent));
|
||||
|
||||
@@ -422,7 +422,7 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
if (s_www_path != NULL) {
|
||||
BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n",
|
||||
BIO_snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n",
|
||||
s_www_path);
|
||||
SSL_write(scon, buf, strlen(buf));
|
||||
while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)
|
||||
@@ -481,7 +481,7 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (s_www_path != NULL) {
|
||||
BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", s_www_path);
|
||||
BIO_snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n", s_www_path);
|
||||
SSL_write(scon, buf, strlen(buf));
|
||||
while (SSL_read(scon, buf, sizeof(buf)) > 0) ;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
if (s_www_path) {
|
||||
BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n",
|
||||
BIO_snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n",
|
||||
s_www_path);
|
||||
SSL_write(scon, buf, strlen(buf));
|
||||
while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)
|
||||
|
||||
20
apps/speed.c
20
apps/speed.c
@@ -307,7 +307,8 @@ static SIGRETTYPE sig_done(int sig)
|
||||
# if !defined(SIGALRM)
|
||||
# define SIGALRM
|
||||
# endif
|
||||
static unsigned int lapse, schlock;
|
||||
static volatile unsigned int lapse;
|
||||
static volatile unsigned int schlock;
|
||||
static void alarm_win32(unsigned int secs)
|
||||
{
|
||||
lapse = secs * 1000;
|
||||
@@ -725,6 +726,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err, "no EVP given\n");
|
||||
goto end;
|
||||
}
|
||||
evp_md = NULL;
|
||||
evp_cipher = EVP_get_cipherbyname(*argv);
|
||||
if (!evp_cipher) {
|
||||
evp_md = EVP_get_digestbyname(*argv);
|
||||
@@ -2089,7 +2091,7 @@ int MAIN(int argc, char **argv)
|
||||
RAND_pseudo_bytes(buf, 20);
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
if (RAND_status() != 1) {
|
||||
RAND_seed(rnd_seed, sizeof rnd_seed);
|
||||
RAND_seed(rnd_seed, sizeof(rnd_seed));
|
||||
rnd_fake = 1;
|
||||
}
|
||||
for (j = 0; j < DSA_NUM; j++) {
|
||||
@@ -2168,7 +2170,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
# ifndef OPENSSL_NO_ECDSA
|
||||
if (RAND_status() != 1) {
|
||||
RAND_seed(rnd_seed, sizeof rnd_seed);
|
||||
RAND_seed(rnd_seed, sizeof(rnd_seed));
|
||||
rnd_fake = 1;
|
||||
}
|
||||
for (j = 0; j < EC_NUM; j++) {
|
||||
@@ -2263,7 +2265,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
# ifndef OPENSSL_NO_ECDH
|
||||
if (RAND_status() != 1) {
|
||||
RAND_seed(rnd_seed, sizeof rnd_seed);
|
||||
RAND_seed(rnd_seed, sizeof(rnd_seed));
|
||||
rnd_fake = 1;
|
||||
}
|
||||
for (j = 0; j < EC_NUM; j++) {
|
||||
@@ -2586,7 +2588,7 @@ static char *sstrsep(char **string, const char *delim)
|
||||
if (**string == 0)
|
||||
return NULL;
|
||||
|
||||
memset(isdelim, 0, sizeof isdelim);
|
||||
memset(isdelim, 0, sizeof(isdelim));
|
||||
isdelim[0] = 1;
|
||||
|
||||
while (*delim) {
|
||||
@@ -2613,7 +2615,7 @@ static int do_multi(int multi)
|
||||
int *fds;
|
||||
static char sep[] = ":";
|
||||
|
||||
fds = malloc(multi * sizeof *fds);
|
||||
fds = malloc(multi * sizeof(*fds));
|
||||
if (fds == NULL) {
|
||||
fprintf(stderr, "Out of memory in speed (do_multi)\n");
|
||||
exit(1);
|
||||
@@ -2651,7 +2653,7 @@ static int do_multi(int multi)
|
||||
char *p;
|
||||
|
||||
f = fdopen(fds[n], "r");
|
||||
while (fgets(buf, sizeof buf, f)) {
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
p = strchr(buf, '\n');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
@@ -2827,8 +2829,8 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher)
|
||||
|
||||
RAND_bytes(out, 16);
|
||||
len += 16;
|
||||
aad[11] = len >> 8;
|
||||
aad[12] = len;
|
||||
aad[11] = (unsigned char)(len >> 8);
|
||||
aad[12] = (unsigned char)(len);
|
||||
pad = EVP_CIPHER_CTX_ctrl(&ctx,
|
||||
EVP_CTRL_AEAD_TLS1_AAD,
|
||||
EVP_AEAD_TLS1_AAD_LEN, aad);
|
||||
|
||||
19
apps/spkac.c
19
apps/spkac.c
@@ -5,7 +5,7 @@
|
||||
* 1999. Based on an original idea by Massimiliano Pala (madwolf@openca.org).
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2017 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -185,20 +185,23 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
|
||||
if (keyfile) {
|
||||
if (keyfile != NULL) {
|
||||
pkey = load_key(bio_err,
|
||||
strcmp(keyfile, "-") ? keyfile : NULL,
|
||||
FORMAT_PEM, 1, passin, e, "private key");
|
||||
if (!pkey) {
|
||||
if (pkey == NULL)
|
||||
goto end;
|
||||
}
|
||||
spki = NETSCAPE_SPKI_new();
|
||||
if (challenge)
|
||||
if (spki == NULL)
|
||||
goto end;
|
||||
if (challenge != NULL)
|
||||
ASN1_STRING_set(spki->spkac->challenge,
|
||||
challenge, (int)strlen(challenge));
|
||||
NETSCAPE_SPKI_set_pubkey(spki, pkey);
|
||||
NETSCAPE_SPKI_sign(spki, pkey, EVP_md5());
|
||||
spkstr = NETSCAPE_SPKI_b64_encode(spki);
|
||||
if (spkstr == NULL)
|
||||
goto end;
|
||||
|
||||
if (outfile)
|
||||
out = BIO_new_file(outfile, "w");
|
||||
@@ -253,7 +256,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
spki = NETSCAPE_SPKI_b64_decode(spkstr, -1);
|
||||
|
||||
if (!spki) {
|
||||
if (spki == NULL) {
|
||||
BIO_printf(bio_err, "Error loading SPKAC\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
@@ -282,9 +285,9 @@ int MAIN(int argc, char **argv)
|
||||
pkey = NETSCAPE_SPKI_get_pubkey(spki);
|
||||
if (verify) {
|
||||
i = NETSCAPE_SPKI_verify(spki, pkey);
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
BIO_printf(bio_err, "Signature OK\n");
|
||||
else {
|
||||
} else {
|
||||
BIO_printf(bio_err, "Signature Failure\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
|
||||
70
apps/srp.c
70
apps/srp.c
@@ -123,13 +123,14 @@ static int get_index(CA_DB *db, char *id, char type)
|
||||
int i;
|
||||
if (id == NULL)
|
||||
return -1;
|
||||
if (type == DB_SRP_INDEX)
|
||||
if (type == DB_SRP_INDEX) {
|
||||
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
|
||||
pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
|
||||
if (pp[DB_srptype][0] == DB_SRP_INDEX
|
||||
&& !strcmp(id, pp[DB_srpid]))
|
||||
return i;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++) {
|
||||
pp = sk_OPENSSL_PSTRING_value(db->db->data, i);
|
||||
|
||||
@@ -137,6 +138,7 @@ static int get_index(CA_DB *db, char *id, char type)
|
||||
&& !strcmp(id, pp[DB_srpid]))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -177,16 +179,14 @@ static int update_index(CA_DB *db, BIO *bio, char **row)
|
||||
char **irow;
|
||||
int i;
|
||||
|
||||
if ((irow =
|
||||
(char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
|
||||
irow = (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1));
|
||||
if (irow == NULL) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < DB_NUMBER; i++) {
|
||||
for (i = 0; i < DB_NUMBER; i++)
|
||||
irow[i] = row[i];
|
||||
row[i] = NULL;
|
||||
}
|
||||
irow[DB_NUMBER] = NULL;
|
||||
|
||||
if (!TXT_DB_insert(db->db, irow)) {
|
||||
@@ -207,30 +207,32 @@ static char *srp_verify_user(const char *user, const char *srp_verifier,
|
||||
char *srp_usersalt, const char *g, const char *N,
|
||||
const char *passin, BIO *bio, int verbose)
|
||||
{
|
||||
char password[1024];
|
||||
char password[1025];
|
||||
PW_CB_DATA cb_tmp;
|
||||
char *verifier = NULL;
|
||||
char *gNid = NULL;
|
||||
int len;
|
||||
|
||||
cb_tmp.prompt_info = user;
|
||||
cb_tmp.password = passin;
|
||||
|
||||
if (password_callback(password, 1024, 0, &cb_tmp) > 0) {
|
||||
len = password_callback(password, sizeof(password)-1, 0, &cb_tmp);
|
||||
if (len > 0) {
|
||||
password[len] = 0;
|
||||
VERBOSE BIO_printf(bio,
|
||||
"Validating\n user=\"%s\"\n srp_verifier=\"%s\"\n srp_usersalt=\"%s\"\n g=\"%s\"\n N=\"%s\"\n",
|
||||
user, srp_verifier, srp_usersalt, g, N);
|
||||
BIO_printf(bio, "Pass %s\n", password);
|
||||
VVERBOSE BIO_printf(bio, "Pass %s\n", password);
|
||||
|
||||
if (!
|
||||
(gNid =
|
||||
SRP_create_verifier(user, password, &srp_usersalt, &verifier, N,
|
||||
g))) {
|
||||
if (!(gNid = SRP_create_verifier(user, password, &srp_usersalt,
|
||||
&verifier, N, g))) {
|
||||
BIO_printf(bio, "Internal error validating SRP verifier\n");
|
||||
} else {
|
||||
if (strcmp(verifier, srp_verifier))
|
||||
gNid = NULL;
|
||||
OPENSSL_free(verifier);
|
||||
}
|
||||
OPENSSL_cleanse(password, len);
|
||||
}
|
||||
return gNid;
|
||||
}
|
||||
@@ -239,24 +241,27 @@ static char *srp_create_user(char *user, char **srp_verifier,
|
||||
char **srp_usersalt, char *g, char *N,
|
||||
char *passout, BIO *bio, int verbose)
|
||||
{
|
||||
char password[1024];
|
||||
char password[1025];
|
||||
PW_CB_DATA cb_tmp;
|
||||
char *gNid = NULL;
|
||||
char *salt = NULL;
|
||||
int len;
|
||||
cb_tmp.prompt_info = user;
|
||||
cb_tmp.password = passout;
|
||||
|
||||
if (password_callback(password, 1024, 1, &cb_tmp) > 0) {
|
||||
len = password_callback(password, sizeof(password)-1, 1, &cb_tmp);
|
||||
if (len > 0) {
|
||||
password[len] = 0;
|
||||
VERBOSE BIO_printf(bio,
|
||||
"Creating\n user=\"%s\"\n g=\"%s\"\n N=\"%s\"\n",
|
||||
user, g, N);
|
||||
if (!
|
||||
(gNid =
|
||||
SRP_create_verifier(user, password, &salt, srp_verifier, N,
|
||||
g))) {
|
||||
if (!(gNid = SRP_create_verifier(user, password, &salt,
|
||||
srp_verifier, N, g))) {
|
||||
BIO_printf(bio, "Internal error creating SRP verifier\n");
|
||||
} else
|
||||
} else {
|
||||
*srp_usersalt = salt;
|
||||
}
|
||||
OPENSSL_cleanse(password, len);
|
||||
VVERBOSE BIO_printf(bio, "gNid=%s salt =\"%s\"\n verifier =\"%s\"\n",
|
||||
gNid, salt, *srp_verifier);
|
||||
|
||||
@@ -316,9 +321,9 @@ int MAIN(int argc, char **argv)
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1 && badops == 0) {
|
||||
if (strcmp(*argv, "-verbose") == 0)
|
||||
if (strcmp(*argv, "-verbose") == 0) {
|
||||
verbose++;
|
||||
else if (strcmp(*argv, "-config") == 0) {
|
||||
} else if (strcmp(*argv, "-config") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
configfile = *(++argv);
|
||||
@@ -330,15 +335,15 @@ int MAIN(int argc, char **argv)
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
dbfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-add") == 0)
|
||||
} else if (strcmp(*argv, "-add") == 0) {
|
||||
add_user = 1;
|
||||
else if (strcmp(*argv, "-delete") == 0)
|
||||
} else if (strcmp(*argv, "-delete") == 0) {
|
||||
delete_user = 1;
|
||||
else if (strcmp(*argv, "-modify") == 0)
|
||||
} else if (strcmp(*argv, "-modify") == 0) {
|
||||
modify_user = 1;
|
||||
else if (strcmp(*argv, "-list") == 0)
|
||||
} else if (strcmp(*argv, "-list") == 0) {
|
||||
list_user = 1;
|
||||
else if (strcmp(*argv, "-gn") == 0) {
|
||||
} else if (strcmp(*argv, "-gn") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
gN = *(++argv);
|
||||
@@ -368,8 +373,9 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
} else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
@@ -390,7 +396,7 @@ int MAIN(int argc, char **argv)
|
||||
"Need at least one user for options -add, -delete, -modify. \n");
|
||||
badops = 1;
|
||||
}
|
||||
if ((passin || passout) && argc != 1) {
|
||||
if ((passargin || passargout) && argc != 1) {
|
||||
BIO_printf(bio_err,
|
||||
"-passin, -passout arguments only valid with one user.\n");
|
||||
badops = 1;
|
||||
@@ -708,9 +714,9 @@ int MAIN(int argc, char **argv)
|
||||
doupdatedb = 1;
|
||||
}
|
||||
}
|
||||
if (--argc > 0)
|
||||
if (--argc > 0) {
|
||||
user = *(argv++);
|
||||
else {
|
||||
} else {
|
||||
user = NULL;
|
||||
list_user = 0;
|
||||
}
|
||||
|
||||
@@ -193,4 +193,3 @@ REQUEST: foreach (@ARGV) {
|
||||
STDERR->printflush(", $output written.\n") if $options{v};
|
||||
}
|
||||
$curl->cleanup();
|
||||
WWW::Curl::Easy::global_cleanup();
|
||||
|
||||
@@ -143,7 +143,7 @@ int main (int argc, char *argv[], char *envp[])
|
||||
** Process the terminal input
|
||||
*/
|
||||
LogMessage ("Waiting on terminal I/O ...\n");
|
||||
len = recv (TermSock, TermBuff, sizeof (TermBuff), 0) ;
|
||||
len = recv (TermSock, TermBuff, sizeof(TermBuff), 0) ;
|
||||
TermBuff[len] = '\0';
|
||||
LogMessage ("Received terminal I/O [%s]", TermBuff);
|
||||
|
||||
@@ -209,7 +209,7 @@ int TerminalSocket (int FunctionCode, int *ReturnSocket)
|
||||
TerminalDeviceAst,
|
||||
0,
|
||||
TerminalDeviceBuff,
|
||||
sizeof (TerminalDeviceBuff) - 2,
|
||||
sizeof(TerminalDeviceBuff) - 2,
|
||||
0, 0, 0, 0);
|
||||
if (! (status & 1)) {
|
||||
LogMessage ("TerminalSocket: SYS$QIO () - %08X", status);
|
||||
@@ -317,7 +317,7 @@ static int CreateSocketPair (int SocketFamily,
|
||||
/*
|
||||
** Initialize the socket information
|
||||
*/
|
||||
slen = sizeof (sin);
|
||||
slen = sizeof(sin);
|
||||
memset ((char *) &sin, 0, slen);
|
||||
sin.sin_family = SocketFamily;
|
||||
sin.sin_addr.s_addr = inet_addr (LocalHostAddr);
|
||||
@@ -434,12 +434,12 @@ static int CreateSocketPair (int SocketFamily,
|
||||
/*
|
||||
** Now issue the connect
|
||||
*/
|
||||
memset ((char *) &sin, 0, sizeof (sin)) ;
|
||||
memset ((char *) &sin, 0, sizeof(sin)) ;
|
||||
sin.sin_family = SocketFamily;
|
||||
sin.sin_addr.s_addr = inet_addr (LocalHostAddr) ;
|
||||
sin.sin_port = LocalHostPort ;
|
||||
|
||||
status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof (sin));
|
||||
status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof(sin));
|
||||
if (status < 0 ) {
|
||||
LogMessage ("CreateSocketPair: connect () - %d", errno);
|
||||
sys$cantim (&sptb, 0);
|
||||
@@ -528,7 +528,7 @@ static int TerminalDeviceAst (int astparm)
|
||||
TerminalDeviceAst,
|
||||
0,
|
||||
TerminalDeviceBuff,
|
||||
sizeof (TerminalDeviceBuff) - 1,
|
||||
sizeof(TerminalDeviceBuff) - 1,
|
||||
0, 0, 0, 0);
|
||||
|
||||
/*
|
||||
|
||||
@@ -77,7 +77,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
char buffer[200];
|
||||
|
||||
if (cmdline[0] == '\0')
|
||||
filename = RAND_file_name(buffer, sizeof buffer);
|
||||
filename = RAND_file_name(buffer, sizeof(buffer));
|
||||
else
|
||||
filename = cmdline;
|
||||
|
||||
|
||||
@@ -817,10 +817,10 @@ int MAIN(int argc, char **argv)
|
||||
char *m;
|
||||
int y, z;
|
||||
|
||||
X509_NAME_oneline(X509_get_subject_name(x), buf, sizeof buf);
|
||||
X509_NAME_oneline(X509_get_subject_name(x), buf, sizeof(buf));
|
||||
BIO_printf(STDout, "/* subject:%s */\n", buf);
|
||||
m = X509_NAME_oneline(X509_get_issuer_name(x), buf,
|
||||
sizeof buf);
|
||||
sizeof(buf));
|
||||
BIO_printf(STDout, "/* issuer :%s */\n", buf);
|
||||
|
||||
z = i2d_X509(x, NULL);
|
||||
|
||||
Reference in New Issue
Block a user