Commit 2aaec9cc authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

Update any code that was using deprecated functions so that everything builds

and links with OPENSSL_NO_DEPRECATED defined.
parent 9d473aa2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@
 Changes between 0.9.7c and 0.9.8  [xx XXX xxxx]

  *) Ensure that deprecated functions do not get compiled when
     OPENSSL_NO_DEPRECATED is defined.
     OPENSSL_NO_DEPRECATED is defined. Some "openssl" subcommands and a few of
     the self-tests were still using deprecated key-generation functions so
     these have been updated also.
     [Geoff Thorpe]

  *) Reorganise PKCS#7 code to separate the digest location functionality
+14 −10
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@
 * -C
 */

static void MS_CALLBACK dh_cb(int p, int n, void *arg);
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);

int MAIN(int, char **);

@@ -294,6 +294,8 @@ bad:

	if(num) {

		BN_GENCB cb;
		BN_GENCB_set(&cb, dh_cb, bio_err);
		if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
			{
			BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
@@ -305,12 +307,13 @@ bad:
#ifndef OPENSSL_NO_DSA
		if (dsaparam)
			{
			DSA *dsa;
			DSA *dsa = DSA_new();
			
			BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
			dsa = DSA_generate_parameters(num, NULL, 0, NULL, NULL, dh_cb, bio_err);
			if (dsa == NULL)
			if(!dsa || !DSA_generate_parameters_ex(dsa, num,
						NULL, 0, NULL, NULL, &cb))
				{
				if(dsa) DSA_free(dsa);
				ERR_print_errors(bio_err);
				goto end;
				}
@@ -326,12 +329,12 @@ bad:
		else
#endif
			{
			dh = DH_new();
			BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
			BIO_printf(bio_err,"This is going to take a long time\n");
			dh=DH_generate_parameters(num,g,dh_cb,bio_err);
			
			if (dh == NULL)
			if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb))
				{
				if(dh) DH_free(dh);
				ERR_print_errors(bio_err);
				goto end;
				}
@@ -534,7 +537,7 @@ end:
	}

/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
static void MS_CALLBACK dh_cb(int p, int n, void *arg)
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
	{
	char c='*';

@@ -542,11 +545,12 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
	if (p == 1) c='+';
	if (p == 2) c='*';
	if (p == 3) c='\n';
	BIO_write((BIO *)arg,&c,1);
	(void)BIO_flush((BIO *)arg);
	BIO_write(cb->arg,&c,1);
	(void)BIO_flush(cb->arg);
#ifdef LINT
	p=n;
#endif
	return 1;
	}

#endif
+10 −7
Original line number Diff line number Diff line
@@ -81,12 +81,13 @@
#undef PROG
#define PROG gendh_main

static void MS_CALLBACK dh_cb(int p, int n, void *arg);
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);

int MAIN(int, char **);

int MAIN(int argc, char **argv)
	{
	BN_GENCB cb;
#ifndef OPENSSL_NO_ENGINE
	ENGINE *e = NULL;
#endif
@@ -102,6 +103,7 @@ int MAIN(int argc, char **argv)

	apps_startup();

	BN_GENCB_set(&cb, dh_cb, bio_err);
	if (bio_err == NULL)
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
@@ -199,9 +201,9 @@ bad:

	BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
	BIO_printf(bio_err,"This is going to take a long time\n");
	dh=DH_generate_parameters(num,g,dh_cb,bio_err);

	if (dh == NULL) goto end;
	if(((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, num, g, &cb))
		goto end;
		
	app_RAND_write_file(NULL, bio_err);

@@ -217,7 +219,7 @@ end:
	OPENSSL_EXIT(ret);
	}

static void MS_CALLBACK dh_cb(int p, int n, void *arg)
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
	{
	char c='*';

@@ -225,10 +227,11 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
	if (p == 1) c='+';
	if (p == 2) c='*';
	if (p == 3) c='\n';
	BIO_write((BIO *)arg,&c,1);
	(void)BIO_flush((BIO *)arg);
	BIO_write(cb->arg,&c,1);
	(void)BIO_flush(cb->arg);
#ifdef LINT
	p=n;
#endif
	return 1;
	}
#endif
+10 −5
Original line number Diff line number Diff line
@@ -81,12 +81,13 @@
#undef PROG
#define PROG genrsa_main

static void MS_CALLBACK genrsa_cb(int p, int n, void *arg);
static int MS_CALLBACK genrsa_cb(int p, int n, BN_GENCB *cb);

int MAIN(int, char **);

int MAIN(int argc, char **argv)
	{
	BN_GENCB cb;
#ifndef OPENSSL_NO_ENGINE
	ENGINE *e = NULL;
#endif
@@ -105,6 +106,7 @@ int MAIN(int argc, char **argv)
	BIO *out=NULL;

	apps_startup();
	BN_GENCB_set(&cb, genrsa_cb, bio_err);

	if (bio_err == NULL)
		if ((bio_err=BIO_new(BIO_s_file())) != NULL)
@@ -239,7 +241,9 @@ bad:

	BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
		num);
	rsa=RSA_generate_key(num,f4,genrsa_cb,bio_err);

	if(((rsa = RSA_new()) == NULL) || !RSA_generate_key_ex(rsa, num, f4, &cb))
		goto err;
		
	app_RAND_write_file(NULL, bio_err);

@@ -277,7 +281,7 @@ err:
	OPENSSL_EXIT(ret);
	}

static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
static int MS_CALLBACK genrsa_cb(int p, int n, BN_GENCB *cb)
	{
	char c='*';

@@ -285,11 +289,12 @@ static void MS_CALLBACK genrsa_cb(int p, int n, void *arg)
	if (p == 1) c='+';
	if (p == 2) c='*';
	if (p == 3) c='\n';
	BIO_write((BIO *)arg,&c,1);
	(void)BIO_flush((BIO *)arg);
	BIO_write(cb->arg,&c,1);
	(void)BIO_flush(cb->arg);
#ifdef LINT
	p=n;
#endif
	return 1;
	}
#else /* !OPENSSL_NO_RSA */

+13 −7
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ static int add_attribute_object(X509_REQ *req, char *text,
static int add_DN_object(X509_NAME *n, char *text, char *def, char *value,
	int nid,int n_min,int n_max, unsigned long chtype, int mval);
#ifndef OPENSSL_NO_RSA
static void MS_CALLBACK req_cb(int p,int n,void *arg);
static int MS_CALLBACK req_cb(int p, int n, BN_GENCB *cb);
#endif
static int req_check_len(int len,int n_min,int n_max);
static int check_end(char *str, char *end);
@@ -712,6 +712,8 @@ bad:

	if (newreq && (pkey == NULL))
		{
		BN_GENCB cb;
		BN_GENCB_set(&cb, req_cb, bio_err);
		char *randfile = NCONF_get_string(req_conf,SECTION,"RANDFILE");
		if (randfile == NULL)
			ERR_clear_error();
@@ -740,11 +742,14 @@ bad:
#ifndef OPENSSL_NO_RSA
		if (pkey_type == TYPE_RSA)
			{
			if (!EVP_PKEY_assign_RSA(pkey,
				RSA_generate_key(newkey,0x10001,
					req_cb,bio_err)))
			RSA *rsa = RSA_new();
			if(!rsa || !RSA_generate_key_ex(rsa, newkey, 0x10001, &cb) ||
					!EVP_PKEY_assign_RSA(pkey, rsa))
				{
				if(rsa) RSA_free(rsa);
				goto end;
				}
			}
		else
#endif
#ifndef OPENSSL_NO_DSA
@@ -1610,7 +1615,7 @@ err:
	}

#ifndef OPENSSL_NO_RSA
static void MS_CALLBACK req_cb(int p, int n, void *arg)
static int MS_CALLBACK req_cb(int p, int n, BN_GENCB *cb)
	{
	char c='*';

@@ -1618,11 +1623,12 @@ static void MS_CALLBACK req_cb(int p, int n, void *arg)
	if (p == 1) c='+';
	if (p == 2) c='*';
	if (p == 3) c='\n';
	BIO_write((BIO *)arg,&c,1);
	(void)BIO_flush((BIO *)arg);
	BIO_write(cb->arg,&c,1);
	(void)BIO_flush(cb->arg);
#ifdef LINT
	p=n;
#endif
	return 1;
	}
#endif

Loading