"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "apps/dsa.c" between
openssl-1.1.1f.tar.gz and openssl-1.1.1g.tar.gz

About: OpenSSL is a toolkit implementing the Transport Layer Security (TLS) protocols (including SSLv3) as well as a full-strength general purpose cryptographic library. Long Term Support (LTS) version (includes support for TLSv1.3).

dsa.c  (openssl-1.1.1f):dsa.c  (openssl-1.1.1g)
/* /*
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
* *
* Licensed under the OpenSSL license (the "License"). You may not use * Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy * this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at * in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#include <openssl/opensslconf.h> #include <openssl/opensslconf.h>
#ifdef OPENSSL_NO_DSA #include <stdio.h>
NON_EMPTY_TRANSLATION_UNIT #include <stdlib.h>
#else #include <string.h>
#include <time.h>
# include <stdio.h> #include "apps.h"
# include <stdlib.h> #include "progs.h"
# include <string.h> #include <openssl/bio.h>
# include <time.h> #include <openssl/err.h>
# include "apps.h" #include <openssl/dsa.h>
# include "progs.h" #include <openssl/evp.h>
# include <openssl/bio.h> #include <openssl/x509.h>
# include <openssl/err.h> #include <openssl/pem.h>
# include <openssl/dsa.h> #include <openssl/bn.h>
# include <openssl/evp.h>
# include <openssl/x509.h>
# include <openssl/pem.h>
# include <openssl/bn.h>
typedef enum OPTION_choice { typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_ENGINE, OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_ENGINE,
/* Do not change the order here; see case statements below */ /* Do not change the order here; see case statements below */
OPT_PVK_NONE, OPT_PVK_WEAK, OPT_PVK_STRONG, OPT_PVK_NONE, OPT_PVK_WEAK, OPT_PVK_STRONG,
OPT_NOOUT, OPT_TEXT, OPT_MODULUS, OPT_PUBIN, OPT_NOOUT, OPT_TEXT, OPT_MODULUS, OPT_PUBIN,
OPT_PUBOUT, OPT_CIPHER, OPT_PASSIN, OPT_PASSOUT OPT_PUBOUT, OPT_CIPHER, OPT_PASSIN, OPT_PASSOUT
} OPTION_CHOICE; } OPTION_CHOICE;
skipping to change at line 52 skipping to change at line 48
{"in", OPT_IN, 's', "Input key"}, {"in", OPT_IN, 's', "Input key"},
{"out", OPT_OUT, '>', "Output file"}, {"out", OPT_OUT, '>', "Output file"},
{"noout", OPT_NOOUT, '-', "Don't print key out"}, {"noout", OPT_NOOUT, '-', "Don't print key out"},
{"text", OPT_TEXT, '-', "Print the key in text"}, {"text", OPT_TEXT, '-', "Print the key in text"},
{"modulus", OPT_MODULUS, '-', "Print the DSA public value"}, {"modulus", OPT_MODULUS, '-', "Print the DSA public value"},
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"}, {"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"}, {"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
{"", OPT_CIPHER, '-', "Any supported cipher"}, {"", OPT_CIPHER, '-', "Any supported cipher"},
# ifndef OPENSSL_NO_RC4 #ifndef OPENSSL_NO_RC4
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (def ault)"}, {"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (def ault)"},
{"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"}, {"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"},
{"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"}, {"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"},
# endif #endif
# ifndef OPENSSL_NO_ENGINE #ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
# endif #endif
{NULL} {NULL}
}; };
int dsa_main(int argc, char **argv) int dsa_main(int argc, char **argv)
{ {
BIO *out = NULL; BIO *out = NULL;
DSA *dsa = NULL; DSA *dsa = NULL;
ENGINE *e = NULL; ENGINE *e = NULL;
const EVP_CIPHER *enc = NULL; const EVP_CIPHER *enc = NULL;
char *infile = NULL, *outfile = NULL, *prog; char *infile = NULL, *outfile = NULL, *prog;
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL; char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
OPTION_CHOICE o; OPTION_CHOICE o;
int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
int i, modulus = 0, pubin = 0, pubout = 0, ret = 1; int i, modulus = 0, pubin = 0, pubout = 0, ret = 1;
# ifndef OPENSSL_NO_RC4 #ifndef OPENSSL_NO_RC4
int pvk_encr = 2; int pvk_encr = 2;
# endif #endif
int private = 0; int private = 0;
prog = opt_init(argc, argv, dsa_options); prog = opt_init(argc, argv, dsa_options);
while ((o = opt_next()) != OPT_EOF) { while ((o = opt_next()) != OPT_EOF) {
switch (o) { switch (o) {
case OPT_EOF: case OPT_EOF:
case OPT_ERR: case OPT_ERR:
opthelp: opthelp:
ret = 0; ret = 0;
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
skipping to change at line 217 skipping to change at line 213
i = i2d_DSAPrivateKey_bio(out, dsa); i = i2d_DSAPrivateKey_bio(out, dsa);
} }
} else if (outformat == FORMAT_PEM) { } else if (outformat == FORMAT_PEM) {
if (pubin || pubout) { if (pubin || pubout) {
i = PEM_write_bio_DSA_PUBKEY(out, dsa); i = PEM_write_bio_DSA_PUBKEY(out, dsa);
} else { } else {
assert(private); assert(private);
i = PEM_write_bio_DSAPrivateKey(out, dsa, enc, i = PEM_write_bio_DSAPrivateKey(out, dsa, enc,
NULL, 0, NULL, passout); NULL, 0, NULL, passout);
} }
# ifndef OPENSSL_NO_RSA #ifndef OPENSSL_NO_RSA
} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) { } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
EVP_PKEY *pk; EVP_PKEY *pk;
pk = EVP_PKEY_new(); pk = EVP_PKEY_new();
if (pk == NULL) if (pk == NULL)
goto end; goto end;
EVP_PKEY_set1_DSA(pk, dsa); EVP_PKEY_set1_DSA(pk, dsa);
if (outformat == FORMAT_PVK) { if (outformat == FORMAT_PVK) {
if (pubin) { if (pubin) {
BIO_printf(bio_err, "PVK form impossible with public key input\n "); BIO_printf(bio_err, "PVK form impossible with public key input\n ");
EVP_PKEY_free(pk); EVP_PKEY_free(pk);
goto end; goto end;
} }
assert(private); assert(private);
# ifdef OPENSSL_NO_RC4 # ifdef OPENSSL_NO_RC4
BIO_printf(bio_err, "PVK format not supported\n"); BIO_printf(bio_err, "PVK format not supported\n");
EVP_PKEY_free(pk); EVP_PKEY_free(pk);
goto end; goto end;
# else # else
i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout); i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout);
# endif # endif
} else if (pubin || pubout) { } else if (pubin || pubout) {
i = i2b_PublicKey_bio(out, pk); i = i2b_PublicKey_bio(out, pk);
} else { } else {
assert(private); assert(private);
i = i2b_PrivateKey_bio(out, pk); i = i2b_PrivateKey_bio(out, pk);
} }
EVP_PKEY_free(pk); EVP_PKEY_free(pk);
# endif #endif
} else { } else {
BIO_printf(bio_err, "bad output format specified for outfile\n"); BIO_printf(bio_err, "bad output format specified for outfile\n");
goto end; goto end;
} }
if (i <= 0) { if (i <= 0) {
BIO_printf(bio_err, "unable to write private key\n"); BIO_printf(bio_err, "unable to write private key\n");
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
goto end; goto end;
} }
ret = 0; ret = 0;
end: end:
BIO_free_all(out); BIO_free_all(out);
DSA_free(dsa); DSA_free(dsa);
release_engine(e); release_engine(e);
OPENSSL_free(passin); OPENSSL_free(passin);
OPENSSL_free(passout); OPENSSL_free(passout);
return ret; return ret;
} }
#endif
 End of changes. 13 change blocks. 
29 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)