Commit af29811e authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Add password command line options to some utils. Fix and update man

pages.
parent 53b1899e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4,6 +4,12 @@

 Changes between 0.9.4 and 0.9.5  [xx XXX 1999]

  *) Add options to some of the utilities to allow the pass phrase
     to be included on either the command line (not recommended on
     OSes like Unix) or read from the environment. Update the
     manpages and fix a few bugs.
     [Steve Henson]

  *) Add a few manpages for some of the openssl commands.
     [Steve Henson]

+1 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ int app_init(long mesgwin)
	}
#endif

int MS_CALLBACK key_callback(char *buf, int len, int verify, void *key)
int MS_CALLBACK key_cb(char *buf, int len, int verify, void *key)
	{
	int i;

+1 −1
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ int args_from_file(char *file, int *argc, char **argv[]);
int str2fmt(char *s);
void program_name(char *in,char *out,int size);
int chopup_args(ARGS *arg,char *buf, int *argc, char **argv[]);
int MS_CALLBACK key_callback(char *buf,int len,int verify,void *u);
int MS_CALLBACK key_cb(char *buf,int len,int verify,void *u);
#define FORMAT_UNDEF    0
#define FORMAT_ASN1     1
#define FORMAT_TEXT     2
+1 −1
Original line number Diff line number Diff line
@@ -534,7 +534,7 @@ bad:
		pkey=PEM_read_bio_PrivateKey(in,NULL,NULL,NULL);
	else
		{
		pkey=PEM_read_bio_PrivateKey(in,NULL,key_callback,key);
		pkey=PEM_read_bio_PrivateKey(in,NULL,key_cb,key);
		memset(key,0,strlen(key));
		}
	if (pkey == NULL)
+60 −13
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ int MAIN(int argc, char **argv)
	int informat,outformat,text=0,noout=0;
	int pubin = 0, pubout = 0;
	char *infile,*outfile,*prog;
	char *passin = NULL, *passout = NULL;
	int modulus=0;

	apps_startup();
@@ -131,6 +132,39 @@ int MAIN(int argc, char **argv)
			if (--argc < 1) goto bad;
			outfile= *(++argv);
			}
		else if (strcmp(*argv,"-passin") == 0)
			{
			if (--argc < 1) goto bad;
			passin= *(++argv);
			}
		else if (strcmp(*argv,"-envpassin") == 0)
			{
			if (--argc < 1) goto bad;
				if(!(passin= getenv(*(++argv))))
				{
				BIO_printf(bio_err,
				 "Can't read environment variable %s\n",
								*argv);
				badops = 1;
				}
			}
		else if (strcmp(*argv,"-envpassout") == 0)
			{
			if (--argc < 1) goto bad;
				if(!(passout= getenv(*(++argv))))
				{
				BIO_printf(bio_err,
				 "Can't read environment variable %s\n",
								*argv);
				badops = 1;
				}
			argv++;
			}
		else if (strcmp(*argv,"-passout") == 0)
			{
			if (--argc < 1) goto bad;
			passout= *(++argv);
			}
		else if (strcmp(*argv,"-noout") == 0)
			noout=1;
		else if (strcmp(*argv,"-text") == 0)
@@ -159,7 +193,11 @@ bad:
		BIO_printf(bio_err," -inform arg     input format - DER or PEM\n");
		BIO_printf(bio_err," -outform arg    output format - DER or PEM\n");
		BIO_printf(bio_err," -in arg         input file\n");
		BIO_printf(bio_err," -passin arg     input file pass phrase\n");
		BIO_printf(bio_err," -envpassin arg  environment variable containing input file pass phrase\n");
		BIO_printf(bio_err," -out arg        output file\n");
		BIO_printf(bio_err," -passout arg    input file pass phrase\n");
		BIO_printf(bio_err," -envpassout arg environment variable containing input file pass phrase\n");
		BIO_printf(bio_err," -des            encrypt PEM output with cbc des\n");
		BIO_printf(bio_err," -des3           encrypt PEM output with ede cbc des using 168 bit key\n");
#ifndef NO_IDEA
@@ -198,7 +236,11 @@ bad:
		else dsa=d2i_DSAPrivateKey_bio(in,NULL);
	} else if (informat == FORMAT_PEM) {
		if(pubin) dsa=PEM_read_bio_DSAPublicKey(in,NULL, NULL, NULL);
		else {
			if(passin) dsa=PEM_read_bio_DSAPrivateKey(in,NULL,
								key_cb,passin);
			else dsa=PEM_read_bio_DSAPrivateKey(in,NULL,NULL,NULL);
		}
	} else
		{
		BIO_printf(bio_err,"bad input format specified for key\n");
@@ -245,7 +287,12 @@ bad:
	} else if (outformat == FORMAT_PEM) {
		if(pubin || pubout)
			i=PEM_write_bio_DSAPublicKey(out,dsa);
		else i=PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL,NULL);
		else {
			if(passout) i=PEM_write_bio_DSAPrivateKey(out,dsa,enc,
							NULL,0,key_cb, passout);
			i=PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,
								     NULL,NULL);
		}
	} else {
		BIO_printf(bio_err,"bad output format specified for outfile\n");
		goto end;
Loading