Commit e1898724 authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

Nils Larsch submitted;

  - a patch to fix a memory leak in rsa_gen.c
  - a note about compiler warnings with unions
  - a note about improving structure element names

This applies his patch and implements a solution to the notes.
parent fdaea9ed
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -281,10 +281,7 @@ bad:
	if (numbits > 0)
		{
		BN_GENCB cb;
		cb.ver = 2;
		cb.cb_2 = dsa_cb;
		cb.arg = bio_err;

		BN_GENCB_set(&cb, dsa_cb, bio_err);
		assert(need_rand);
		dsa = DSA_new();
		if(!dsa)
+13 −1
Original line number Diff line number Diff line
@@ -299,10 +299,22 @@ struct bn_gencb_st
		void (*cb_1)(int, int, void *);
		/* if(ver==2) - new callback style */
		int (*cb_2)(int, int, BN_GENCB *);
		};
		} cb;
	};
/* Wrapper function to make using BN_GENCB easier,  */
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
/* Macro to populate a BN_GENCB structure with an "old"-style callback */
#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
		BN_GENCB *tmp_gencb = (gencb); \
		tmp_gencb->ver = 1; \
		tmp_gencb->arg = (cb_arg); \
		tmp_gencb->cb.cb_1 = (callback); }
/* Macro to populate a BN_GENCB structure with a "new"-style callback */
#define BN_GENCB_set(gencb, callback, cb_arg) { \
		BN_GENCB *tmp_gencb = (gencb); \
		tmp_gencb->ver = 2; \
		tmp_gencb->arg = (cb_arg); \
		tmp_gencb->cb.cb_2 = (callback); }

#define BN_prime_checks 0 /* default: select number of iterations
			     based on the size of the number */
+3 −9
Original line number Diff line number Diff line
@@ -70,9 +70,7 @@ BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
	BIGNUM *rnd=NULL;
	int found = 0;

	cb.ver = 1;
	cb.arg = cb_arg;
	cb.cb_1 = callback;
	BN_GENCB_set_old(&cb, callback, cb_arg);

	if (ret == NULL)
		{
@@ -94,9 +92,7 @@ int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *),
	BN_CTX *ctx_passed, void *cb_arg)
	{
	BN_GENCB cb;
	cb.ver = 1;
	cb.arg = cb_arg;
	cb.cb_1 = callback;
	BN_GENCB_set_old(&cb, callback, cb_arg);
	return BN_is_prime_ex(a, checks, ctx_passed, &cb);
	}

@@ -106,9 +102,7 @@ int BN_is_prime_fasttest(const BIGNUM *a, int checks,
		int do_trial_division)
	{
	BN_GENCB cb;
	cb.ver = 1;
	cb.arg = cb_arg;
	cb.cb_1 = callback;
	BN_GENCB_set_old(&cb, callback, cb_arg);
	return BN_is_prime_fasttest_ex(a, checks, ctx_passed,
				do_trial_division, &cb);
	}
+2 −2
Original line number Diff line number Diff line
@@ -142,11 +142,11 @@ int BN_GENCB_call(BN_GENCB *cb, int a, int b)
		{
	case 1:
		/* Deprecated-style callbacks */
		cb->cb_1(a, b, cb->arg);
		cb->cb.cb_1(a, b, cb->arg);
		return 1;
	case 2:
		/* New-style callbacks */
		return cb->cb_2(a, b, cb);
		return cb->cb.cb_2(a, b, cb);
	default:
		break;
		}
+1 −3
Original line number Diff line number Diff line
@@ -70,9 +70,7 @@ DH *DH_generate_parameters(int prime_len, int generator,
	if((ret=DH_new()) == NULL)
		return NULL;

	cb.ver = 1;
	cb.arg = cb_arg;
	cb.cb_1 = callback;
	BN_GENCB_set_old(&cb, callback, cb_arg);

	if(DH_generate_parameters_ex(ret, prime_len, generator, &cb))
		return ret;
Loading