Commit c62b26fd authored by Bodo Möller's avatar Bodo Möller
Browse files

Hide BN_CTX structure details.

Incease the number of BIGNUMs in a BN_CTX.
parent e0a9ba9c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@

 Changes between 0.9.6 and 0.9.7  [xx XXX 2000]

  *) Hide BN_CTX structure details in bn_lcl.h instead of publishing them
     in <openssl/bn.h>.  Also further increase BN_CTX_NUM to 24.
     [Bodo Moeller]

  *) Modify EVP_Digest*() routines so they now return values. Although the
     internal software routines can never fail additional hardware versions
     might.
+2 −12
Original line number Diff line number Diff line
@@ -238,18 +238,8 @@ typedef struct bignum_st
	int flags;
	} BIGNUM;

/* Used for temp variables */
#define BN_CTX_NUM	20
#define BN_CTX_NUM_POS	12
typedef struct bignum_ctx
	{
	int tos;
	BIGNUM bn[BN_CTX_NUM];
	int flags;
	int depth;
	int pos[BN_CTX_NUM_POS];
	int too_many;
	} BN_CTX;
/* Used for temp variables (declaration hidden in bn_lcl.h) */
typedef struct bignum_ctx BN_CTX;

typedef struct bn_blinding_st
	{
+6 −1
Original line number Diff line number Diff line
@@ -61,8 +61,9 @@

#include <stdio.h>
#include <assert.h>

#include "cryptlib.h"
#include <openssl/bn.h>
#include "bn_lcl.h"


BN_CTX *BN_CTX_new(void)
@@ -83,6 +84,7 @@ BN_CTX *BN_CTX_new(void)

void BN_CTX_init(BN_CTX *ctx)
	{
#if 0 /* explicit version */
	int i;
	ctx->tos = 0;
	ctx->flags = 0;
@@ -90,6 +92,9 @@ void BN_CTX_init(BN_CTX *ctx)
	ctx->too_many = 0;
	for (i = 0; i < BN_CTX_NUM; i++)
		BN_init(&(ctx->bn[i]));
#else
	memset(ctx, 0, sizeof *ctx);
#endif
	}

void BN_CTX_free(BN_CTX *ctx)
+14 −0
Original line number Diff line number Diff line
@@ -119,6 +119,20 @@ extern "C" {
#endif


/* Used for temp variables */
#define BN_CTX_NUM	24
#define BN_CTX_NUM_POS	12
struct bignum_ctx
	{
	int tos;
	BIGNUM bn[BN_CTX_NUM];
	int flags;
	int depth;
	int pos[BN_CTX_NUM_POS];
	int too_many;
	} /* BN_CTX */;


/*
 * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
 *
+7 −5
Original line number Diff line number Diff line
@@ -485,9 +485,11 @@ int test_mul(BIO *bp)
	{
	BIGNUM a,b,c,d,e;
	int i;
	BN_CTX ctx;
	BN_CTX *ctx;

	ctx = BN_CTX_new();
	if (ctx == NULL) exit(1);
	
	BN_CTX_init(&ctx);
	BN_init(&a);
	BN_init(&b);
	BN_init(&c);
@@ -505,7 +507,7 @@ int test_mul(BIO *bp)
			BN_bntest_rand(&b,i-num1,0,0);
		a.neg=rand_neg();
		b.neg=rand_neg();
		BN_mul(&c,&a,&b,&ctx);
		BN_mul(&c,&a,&b,ctx);
		if (bp != NULL)
			{
			if (!results)
@@ -518,7 +520,7 @@ int test_mul(BIO *bp)
			BN_print(bp,&c);
			BIO_puts(bp,"\n");
			}
		BN_div(&d,&e,&c,&a,&ctx);
		BN_div(&d,&e,&c,&a,ctx);
		BN_sub(&d,&d,&b);
		if(!BN_is_zero(&d) || !BN_is_zero(&e))
		    {
@@ -531,7 +533,7 @@ int test_mul(BIO *bp)
	BN_free(&c);
	BN_free(&d);
	BN_free(&e);
	BN_CTX_free(&ctx);
	BN_CTX_free(ctx);
	return(1);
	}

Loading