summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn')
-rw-r--r--src/lib/libcrypto/bn/bn_blind.c4
-rw-r--r--src/lib/libcrypto/bn/bn_ctx.c14
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c4
-rw-r--r--src/lib/libcrypto/bn/bn_gf2m.c20
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c16
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c4
-rw-r--r--src/lib/libcrypto/bn/bn_print.c14
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c4
-rw-r--r--src/lib/libcrypto/bn/bn_recp.c4
9 files changed, 42 insertions, 42 deletions
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c
index 9ed8bc2b40..264531013e 100644
--- a/src/lib/libcrypto/bn/bn_blind.c
+++ b/src/lib/libcrypto/bn/bn_blind.c
@@ -140,7 +140,7 @@ BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
140 140
141 bn_check_top(mod); 141 bn_check_top(mod);
142 142
143 if ((ret=(BN_BLINDING *)OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL) 143 if ((ret=(BN_BLINDING *)malloc(sizeof(BN_BLINDING))) == NULL)
144 { 144 {
145 BNerr(BN_F_BN_BLINDING_NEW,ERR_R_MALLOC_FAILURE); 145 BNerr(BN_F_BN_BLINDING_NEW,ERR_R_MALLOC_FAILURE);
146 return(NULL); 146 return(NULL);
@@ -180,7 +180,7 @@ void BN_BLINDING_free(BN_BLINDING *r)
180 if (r->Ai != NULL) BN_free(r->Ai); 180 if (r->Ai != NULL) BN_free(r->Ai);
181 if (r->e != NULL) BN_free(r->e ); 181 if (r->e != NULL) BN_free(r->e );
182 if (r->mod != NULL) BN_free(r->mod); 182 if (r->mod != NULL) BN_free(r->mod);
183 OPENSSL_free(r); 183 free(r);
184 } 184 }
185 185
186int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx) 186int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)
diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c
index 3f2256f675..ef67f4781c 100644
--- a/src/lib/libcrypto/bn/bn_ctx.c
+++ b/src/lib/libcrypto/bn/bn_ctx.c
@@ -213,7 +213,7 @@ void BN_CTX_init(BN_CTX *ctx)
213 213
214BN_CTX *BN_CTX_new(void) 214BN_CTX *BN_CTX_new(void)
215 { 215 {
216 BN_CTX *ret = OPENSSL_malloc(sizeof(BN_CTX)); 216 BN_CTX *ret = malloc(sizeof(BN_CTX));
217 if(!ret) 217 if(!ret)
218 { 218 {
219 BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE); 219 BNerr(BN_F_BN_CTX_NEW,ERR_R_MALLOC_FAILURE);
@@ -249,7 +249,7 @@ void BN_CTX_free(BN_CTX *ctx)
249#endif 249#endif
250 BN_STACK_finish(&ctx->stack); 250 BN_STACK_finish(&ctx->stack);
251 BN_POOL_finish(&ctx->pool); 251 BN_POOL_finish(&ctx->pool);
252 OPENSSL_free(ctx); 252 free(ctx);
253 } 253 }
254 254
255void BN_CTX_start(BN_CTX *ctx) 255void BN_CTX_start(BN_CTX *ctx)
@@ -317,7 +317,7 @@ static void BN_STACK_init(BN_STACK *st)
317 317
318static void BN_STACK_finish(BN_STACK *st) 318static void BN_STACK_finish(BN_STACK *st)
319 { 319 {
320 if(st->size) OPENSSL_free(st->indexes); 320 if(st->size) free(st->indexes);
321 } 321 }
322 322
323#ifndef OPENSSL_NO_DEPRECATED 323#ifndef OPENSSL_NO_DEPRECATED
@@ -334,13 +334,13 @@ static int BN_STACK_push(BN_STACK *st, unsigned int idx)
334 { 334 {
335 unsigned int newsize = (st->size ? 335 unsigned int newsize = (st->size ?
336 (st->size * 3 / 2) : BN_CTX_START_FRAMES); 336 (st->size * 3 / 2) : BN_CTX_START_FRAMES);
337 unsigned int *newitems = OPENSSL_malloc(newsize * 337 unsigned int *newitems = malloc(newsize *
338 sizeof(unsigned int)); 338 sizeof(unsigned int));
339 if(!newitems) return 0; 339 if(!newitems) return 0;
340 if(st->depth) 340 if(st->depth)
341 memcpy(newitems, st->indexes, st->depth * 341 memcpy(newitems, st->indexes, st->depth *
342 sizeof(unsigned int)); 342 sizeof(unsigned int));
343 if(st->size) OPENSSL_free(st->indexes); 343 if(st->size) free(st->indexes);
344 st->indexes = newitems; 344 st->indexes = newitems;
345 st->size = newsize; 345 st->size = newsize;
346 } 346 }
@@ -375,7 +375,7 @@ static void BN_POOL_finish(BN_POOL *p)
375 bn++; 375 bn++;
376 } 376 }
377 p->current = p->head->next; 377 p->current = p->head->next;
378 OPENSSL_free(p->head); 378 free(p->head);
379 p->head = p->current; 379 p->head = p->current;
380 } 380 }
381 } 381 }
@@ -406,7 +406,7 @@ static BIGNUM *BN_POOL_get(BN_POOL *p)
406 { 406 {
407 BIGNUM *bn; 407 BIGNUM *bn;
408 unsigned int loop = 0; 408 unsigned int loop = 0;
409 BN_POOL_ITEM *item = OPENSSL_malloc(sizeof(BN_POOL_ITEM)); 409 BN_POOL_ITEM *item = malloc(sizeof(BN_POOL_ITEM));
410 if(!item) return NULL; 410 if(!item) return NULL;
411 /* Initialise the structure */ 411 /* Initialise the structure */
412 bn = item->vals; 412 bn = item->vals;
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index 2abf6fd678..2047e1cc3f 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -636,7 +636,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
636 powerbufFree = alloca(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH); 636 powerbufFree = alloca(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH);
637 else 637 else
638#endif 638#endif
639 if ((powerbufFree=(unsigned char*)OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL) 639 if ((powerbufFree=(unsigned char*)malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL)
640 goto err; 640 goto err;
641 641
642 powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree); 642 powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree);
@@ -823,7 +823,7 @@ err:
823 if (powerbuf!=NULL) 823 if (powerbuf!=NULL)
824 { 824 {
825 OPENSSL_cleanse(powerbuf,powerbufLen); 825 OPENSSL_cleanse(powerbuf,powerbufLen);
826 if (powerbufFree) OPENSSL_free(powerbufFree); 826 if (powerbufFree) free(powerbufFree);
827 } 827 }
828 BN_CTX_end(ctx); 828 BN_CTX_end(ctx);
829 return(ret); 829 return(ret);
diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c
index 8a4dc20ad9..68a5faa52d 100644
--- a/src/lib/libcrypto/bn/bn_gf2m.c
+++ b/src/lib/libcrypto/bn/bn_gf2m.c
@@ -444,7 +444,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p
444 bn_check_top(a); 444 bn_check_top(a);
445 bn_check_top(b); 445 bn_check_top(b);
446 bn_check_top(p); 446 bn_check_top(p);
447 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; 447 if ((arr = (int *)malloc(sizeof(int) * max)) == NULL) goto err;
448 ret = BN_GF2m_poly2arr(p, arr, max); 448 ret = BN_GF2m_poly2arr(p, arr, max);
449 if (!ret || ret > max) 449 if (!ret || ret > max)
450 { 450 {
@@ -454,7 +454,7 @@ int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p
454 ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx); 454 ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
455 bn_check_top(r); 455 bn_check_top(r);
456err: 456err:
457 if (arr) OPENSSL_free(arr); 457 if (arr) free(arr);
458 return ret; 458 return ret;
459 } 459 }
460 460
@@ -500,7 +500,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
500 500
501 bn_check_top(a); 501 bn_check_top(a);
502 bn_check_top(p); 502 bn_check_top(p);
503 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; 503 if ((arr = (int *)malloc(sizeof(int) * max)) == NULL) goto err;
504 ret = BN_GF2m_poly2arr(p, arr, max); 504 ret = BN_GF2m_poly2arr(p, arr, max);
505 if (!ret || ret > max) 505 if (!ret || ret > max)
506 { 506 {
@@ -510,7 +510,7 @@ int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
510 ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx); 510 ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);
511 bn_check_top(r); 511 bn_check_top(r);
512err: 512err:
513 if (arr) OPENSSL_free(arr); 513 if (arr) free(arr);
514 return ret; 514 return ret;
515 } 515 }
516 516
@@ -861,7 +861,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p
861 bn_check_top(a); 861 bn_check_top(a);
862 bn_check_top(b); 862 bn_check_top(b);
863 bn_check_top(p); 863 bn_check_top(p);
864 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; 864 if ((arr = (int *)malloc(sizeof(int) * max)) == NULL) goto err;
865 ret = BN_GF2m_poly2arr(p, arr, max); 865 ret = BN_GF2m_poly2arr(p, arr, max);
866 if (!ret || ret > max) 866 if (!ret || ret > max)
867 { 867 {
@@ -871,7 +871,7 @@ int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p
871 ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx); 871 ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx);
872 bn_check_top(r); 872 bn_check_top(r);
873err: 873err:
874 if (arr) OPENSSL_free(arr); 874 if (arr) free(arr);
875 return ret; 875 return ret;
876 } 876 }
877 877
@@ -919,7 +919,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
919 int *arr=NULL; 919 int *arr=NULL;
920 bn_check_top(a); 920 bn_check_top(a);
921 bn_check_top(p); 921 bn_check_top(p);
922 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err; 922 if ((arr = (int *)malloc(sizeof(int) * max)) == NULL) goto err;
923 ret = BN_GF2m_poly2arr(p, arr, max); 923 ret = BN_GF2m_poly2arr(p, arr, max);
924 if (!ret || ret > max) 924 if (!ret || ret > max)
925 { 925 {
@@ -929,7 +929,7 @@ int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
929 ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx); 929 ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx);
930 bn_check_top(r); 930 bn_check_top(r);
931err: 931err:
932 if (arr) OPENSSL_free(arr); 932 if (arr) free(arr);
933 return ret; 933 return ret;
934 } 934 }
935 935
@@ -1037,7 +1037,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *
1037 int *arr=NULL; 1037 int *arr=NULL;
1038 bn_check_top(a); 1038 bn_check_top(a);
1039 bn_check_top(p); 1039 bn_check_top(p);
1040 if ((arr = (int *)OPENSSL_malloc(sizeof(int) * 1040 if ((arr = (int *)malloc(sizeof(int) *
1041 max)) == NULL) goto err; 1041 max)) == NULL) goto err;
1042 ret = BN_GF2m_poly2arr(p, arr, max); 1042 ret = BN_GF2m_poly2arr(p, arr, max);
1043 if (!ret || ret > max) 1043 if (!ret || ret > max)
@@ -1048,7 +1048,7 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *
1048 ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx); 1048 ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx);
1049 bn_check_top(r); 1049 bn_check_top(r);
1050err: 1050err:
1051 if (arr) OPENSSL_free(arr); 1051 if (arr) free(arr);
1052 return ret; 1052 return ret;
1053 } 1053 }
1054 1054
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index 5461e6ee7d..b491c785d4 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -245,12 +245,12 @@ void BN_clear_free(BIGNUM *a)
245 { 245 {
246 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0])); 246 OPENSSL_cleanse(a->d,a->dmax*sizeof(a->d[0]));
247 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA))) 247 if (!(BN_get_flags(a,BN_FLG_STATIC_DATA)))
248 OPENSSL_free(a->d); 248 free(a->d);
249 } 249 }
250 i=BN_get_flags(a,BN_FLG_MALLOCED); 250 i=BN_get_flags(a,BN_FLG_MALLOCED);
251 OPENSSL_cleanse(a,sizeof(BIGNUM)); 251 OPENSSL_cleanse(a,sizeof(BIGNUM));
252 if (i) 252 if (i)
253 OPENSSL_free(a); 253 free(a);
254 } 254 }
255 255
256void BN_free(BIGNUM *a) 256void BN_free(BIGNUM *a)
@@ -258,9 +258,9 @@ void BN_free(BIGNUM *a)
258 if (a == NULL) return; 258 if (a == NULL) return;
259 bn_check_top(a); 259 bn_check_top(a);
260 if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA))) 260 if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA)))
261 OPENSSL_free(a->d); 261 free(a->d);
262 if (a->flags & BN_FLG_MALLOCED) 262 if (a->flags & BN_FLG_MALLOCED)
263 OPENSSL_free(a); 263 free(a);
264 else 264 else
265 { 265 {
266#ifndef OPENSSL_NO_DEPRECATED 266#ifndef OPENSSL_NO_DEPRECATED
@@ -280,7 +280,7 @@ BIGNUM *BN_new(void)
280 { 280 {
281 BIGNUM *ret; 281 BIGNUM *ret;
282 282
283 if ((ret=(BIGNUM *)OPENSSL_malloc(sizeof(BIGNUM))) == NULL) 283 if ((ret=(BIGNUM *)malloc(sizeof(BIGNUM))) == NULL)
284 { 284 {
285 BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE); 285 BNerr(BN_F_BN_NEW,ERR_R_MALLOC_FAILURE);
286 return(NULL); 286 return(NULL);
@@ -314,7 +314,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
314 BNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); 314 BNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
315 return(NULL); 315 return(NULL);
316 } 316 }
317 a=A=(BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG)*words); 317 a=A=(BN_ULONG *)malloc(sizeof(BN_ULONG)*words);
318 if (A == NULL) 318 if (A == NULL)
319 { 319 {
320 BNerr(BN_F_BN_EXPAND_INTERNAL,ERR_R_MALLOC_FAILURE); 320 BNerr(BN_F_BN_EXPAND_INTERNAL,ERR_R_MALLOC_FAILURE);
@@ -401,7 +401,7 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
401 else 401 else
402 { 402 {
403 /* r == NULL, BN_new failure */ 403 /* r == NULL, BN_new failure */
404 OPENSSL_free(a); 404 free(a);
405 } 405 }
406 } 406 }
407 /* If a == NULL, there was an error in allocation in 407 /* If a == NULL, there was an error in allocation in
@@ -431,7 +431,7 @@ BIGNUM *bn_expand2(BIGNUM *b, int words)
431 { 431 {
432 BN_ULONG *a = bn_expand_internal(b, words); 432 BN_ULONG *a = bn_expand_internal(b, words);
433 if(!a) return NULL; 433 if(!a) return NULL;
434 if(b->d) OPENSSL_free(b->d); 434 if(b->d) free(b->d);
435 b->d=a; 435 b->d=a;
436 b->dmax=words; 436 b->dmax=words;
437 } 437 }
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index a6713ae5b1..133c597c33 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -322,7 +322,7 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
322 { 322 {
323 BN_MONT_CTX *ret; 323 BN_MONT_CTX *ret;
324 324
325 if ((ret=(BN_MONT_CTX *)OPENSSL_malloc(sizeof(BN_MONT_CTX))) == NULL) 325 if ((ret=(BN_MONT_CTX *)malloc(sizeof(BN_MONT_CTX))) == NULL)
326 return(NULL); 326 return(NULL);
327 327
328 BN_MONT_CTX_init(ret); 328 BN_MONT_CTX_init(ret);
@@ -349,7 +349,7 @@ void BN_MONT_CTX_free(BN_MONT_CTX *mont)
349 BN_free(&(mont->N)); 349 BN_free(&(mont->N));
350 BN_free(&(mont->Ni)); 350 BN_free(&(mont->Ni));
351 if (mont->flags & BN_FLG_MALLOCED) 351 if (mont->flags & BN_FLG_MALLOCED)
352 OPENSSL_free(mont); 352 free(mont);
353 } 353 }
354 354
355int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) 355int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index c7c407e494..e2cab2497f 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -64,14 +64,14 @@
64 64
65static const char Hex[]="0123456789ABCDEF"; 65static const char Hex[]="0123456789ABCDEF";
66 66
67/* Must 'OPENSSL_free' the returned data */ 67/* Must 'free' the returned data */
68char *BN_bn2hex(const BIGNUM *a) 68char *BN_bn2hex(const BIGNUM *a)
69 { 69 {
70 int i,j,v,z=0; 70 int i,j,v,z=0;
71 char *buf; 71 char *buf;
72 char *p; 72 char *p;
73 73
74 buf=(char *)OPENSSL_malloc(a->top*BN_BYTES*2+2); 74 buf=(char *)malloc(a->top*BN_BYTES*2+2);
75 if (buf == NULL) 75 if (buf == NULL)
76 { 76 {
77 BNerr(BN_F_BN_BN2HEX,ERR_R_MALLOC_FAILURE); 77 BNerr(BN_F_BN_BN2HEX,ERR_R_MALLOC_FAILURE);
@@ -99,7 +99,7 @@ err:
99 return(buf); 99 return(buf);
100 } 100 }
101 101
102/* Must 'OPENSSL_free' the returned data */ 102/* Must 'free' the returned data */
103char *BN_bn2dec(const BIGNUM *a) 103char *BN_bn2dec(const BIGNUM *a)
104 { 104 {
105 int i=0,num, ok = 0; 105 int i=0,num, ok = 0;
@@ -115,8 +115,8 @@ char *BN_bn2dec(const BIGNUM *a)
115 */ 115 */
116 i=BN_num_bits(a)*3; 116 i=BN_num_bits(a)*3;
117 num=(i/10+i/1000+1)+1; 117 num=(i/10+i/1000+1)+1;
118 bn_data=(BN_ULONG *)OPENSSL_malloc((num/BN_DEC_NUM+1)*sizeof(BN_ULONG)); 118 bn_data=(BN_ULONG *)malloc((num/BN_DEC_NUM+1)*sizeof(BN_ULONG));
119 buf=(char *)OPENSSL_malloc(num+3); 119 buf=(char *)malloc(num+3);
120 if ((buf == NULL) || (bn_data == NULL)) 120 if ((buf == NULL) || (bn_data == NULL))
121 { 121 {
122 BNerr(BN_F_BN_BN2DEC,ERR_R_MALLOC_FAILURE); 122 BNerr(BN_F_BN_BN2DEC,ERR_R_MALLOC_FAILURE);
@@ -158,11 +158,11 @@ char *BN_bn2dec(const BIGNUM *a)
158 } 158 }
159 ok = 1; 159 ok = 1;
160err: 160err:
161 if (bn_data != NULL) OPENSSL_free(bn_data); 161 if (bn_data != NULL) free(bn_data);
162 if (t != NULL) BN_free(t); 162 if (t != NULL) BN_free(t);
163 if (!ok && buf) 163 if (!ok && buf)
164 { 164 {
165 OPENSSL_free(buf); 165 free(buf);
166 buf = NULL; 166 buf = NULL;
167 } 167 }
168 168
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c
index 5cbb1f33c1..baa62d584c 100644
--- a/src/lib/libcrypto/bn/bn_rand.c
+++ b/src/lib/libcrypto/bn/bn_rand.c
@@ -130,7 +130,7 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
130 bit=(bits-1)%8; 130 bit=(bits-1)%8;
131 mask=0xff<<(bit+1); 131 mask=0xff<<(bit+1);
132 132
133 buf=(unsigned char *)OPENSSL_malloc(bytes); 133 buf=(unsigned char *)malloc(bytes);
134 if (buf == NULL) 134 if (buf == NULL)
135 { 135 {
136 BNerr(BN_F_BNRAND,ERR_R_MALLOC_FAILURE); 136 BNerr(BN_F_BNRAND,ERR_R_MALLOC_FAILURE);
@@ -199,7 +199,7 @@ err:
199 if (buf != NULL) 199 if (buf != NULL)
200 { 200 {
201 OPENSSL_cleanse(buf,bytes); 201 OPENSSL_cleanse(buf,bytes);
202 OPENSSL_free(buf); 202 free(buf);
203 } 203 }
204 bn_check_top(rnd); 204 bn_check_top(rnd);
205 return(ret); 205 return(ret);
diff --git a/src/lib/libcrypto/bn/bn_recp.c b/src/lib/libcrypto/bn/bn_recp.c
index 2e8efb8dae..0f808fca64 100644
--- a/src/lib/libcrypto/bn/bn_recp.c
+++ b/src/lib/libcrypto/bn/bn_recp.c
@@ -72,7 +72,7 @@ BN_RECP_CTX *BN_RECP_CTX_new(void)
72 { 72 {
73 BN_RECP_CTX *ret; 73 BN_RECP_CTX *ret;
74 74
75 if ((ret=(BN_RECP_CTX *)OPENSSL_malloc(sizeof(BN_RECP_CTX))) == NULL) 75 if ((ret=(BN_RECP_CTX *)malloc(sizeof(BN_RECP_CTX))) == NULL)
76 return(NULL); 76 return(NULL);
77 77
78 BN_RECP_CTX_init(ret); 78 BN_RECP_CTX_init(ret);
@@ -88,7 +88,7 @@ void BN_RECP_CTX_free(BN_RECP_CTX *recp)
88 BN_free(&(recp->N)); 88 BN_free(&(recp->N));
89 BN_free(&(recp->Nr)); 89 BN_free(&(recp->Nr));
90 if (recp->flags & BN_FLG_MALLOCED) 90 if (recp->flags & BN_FLG_MALLOCED)
91 OPENSSL_free(recp); 91 free(recp);
92 } 92 }
93 93
94int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) 94int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)