Remove BN_init
authorRich Salz <rsalz@akamai.com>
Sat, 21 Nov 2015 13:27:46 +0000 (08:27 -0500)
committerRich Salz <rsalz@openssl.org>
Mon, 30 Nov 2015 21:10:12 +0000 (16:10 -0500)
Rename it to be an internal function bn_init.

Reviewed-by: Tim Hudson <tjh@openssl.org>
crypto/bn/bn_ctx.c
crypto/bn/bn_gcd.c
crypto/bn/bn_lcl.h
crypto/bn/bn_lib.c
crypto/bn/bn_mont.c
crypto/bn/bn_recp.c
doc/crypto/BN_new.pod

index 19ff68e1eb7a9a3fe877f403eba692e569f3d4a6..be7a20d63425471d81ef4324d3ed4dc8d6215258 100644 (file)
@@ -365,7 +365,7 @@ static BIGNUM *BN_POOL_get(BN_POOL *p, int flag)
         if (item == NULL)
             return NULL;
         for (loop = 0, bn = item->vals; loop++ < BN_CTX_POOL_SIZE; bn++) {
-            BN_init(bn);
+            bn_init(bn);
             if ((flag & BN_FLG_SECURE) != 0)
                 BN_set_flags(bn, BN_FLG_SECURE);
         }
index d24360615f90b7d031840870da7f5d5ce75212fa..84d1df574390ebc1f96d62e47146509c7c5e2884 100644 (file)
@@ -598,7 +598,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in,
          */
          {
             BIGNUM local_B;
-            BN_init(&local_B);
+            bn_init(&local_B);
             BN_with_flags(&local_B, B, BN_FLG_CONSTTIME);
             if (!BN_nnmod(B, &local_B, A, ctx))
                 goto err;
@@ -629,7 +629,7 @@ static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in,
          */
         {
             BIGNUM local_A;
-            BN_init(&local_A);
+            bn_init(&local_A);
             BN_with_flags(&local_A, A, BN_FLG_CONSTTIME);
 
             /* (D, M) := (A/B, A%B) ... */
index 1a75c10c8d8d50177943d3bd8943277ff002e87b..e4281a34b44fa7324b6098879b0c1ca0502c1627 100644 (file)
@@ -638,10 +638,10 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
         }
 # endif                         /* !BN_LLONG */
 
-void BN_init(BIGNUM *a);
 void BN_RECP_CTX_init(BN_RECP_CTX *recp);
 void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
 
+void bn_init(BIGNUM *a);
 void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
 void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
 void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
index 4a6480ba97c0f578a95f4955279f9240d5418b0e..b9e96b553ee6e1932b1322f63c0bd3c690940df7 100644 (file)
@@ -265,9 +265,11 @@ void BN_free(BIGNUM *a)
     }
 }
 
-void BN_init(BIGNUM *a)
+void bn_init(BIGNUM *a)
 {
-    memset(a, 0, sizeof(*a));
+    static BIGNUM nilbn;
+
+    *a = nilbn;
     bn_check_top(a);
 }
 
index bda2157aa5dd9f8b3aee9f468447bcf4b1f74192..90c718ba59137762904f04f2308a1fdf7a9c2a2c 100644 (file)
@@ -327,9 +327,9 @@ BN_MONT_CTX *BN_MONT_CTX_new(void)
 void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
 {
     ctx->ri = 0;
-    BN_init(&(ctx->RR));
-    BN_init(&(ctx->N));
-    BN_init(&(ctx->Ni));
+    bn_init(&(ctx->RR));
+    bn_init(&(ctx->N));
+    bn_init(&(ctx->Ni));
     ctx->n0[0] = ctx->n0[1] = 0;
     ctx->flags = 0;
 }
@@ -367,7 +367,7 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
         BIGNUM tmod;
         BN_ULONG buf[2];
 
-        BN_init(&tmod);
+        bn_init(&tmod);
         tmod.d = buf;
         tmod.dmax = 2;
         tmod.neg = 0;
index 39eed8b29750d5d06d7772870d1d5fbde98d32a4..ef23a8c7517e289c74a89f6ecf7d41efbd812b25 100644 (file)
@@ -61,8 +61,8 @@
 
 void BN_RECP_CTX_init(BN_RECP_CTX *recp)
 {
-    BN_init(&(recp->N));
-    BN_init(&(recp->Nr));
+    bn_init(&(recp->N));
+    bn_init(&(recp->Nr));
     recp->num_bits = 0;
     recp->flags = 0;
 }
index 0629b19d5e5cb1ee9263f2917c0a90281b36bc57..22596dcbb367f8e6a42fc1159c2475590d35d9e7 100644 (file)
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-BN_new, BN_init, BN_clear, BN_free, BN_clear_free - allocate and free BIGNUMs
+BN_new, BN_clear, BN_free, BN_clear_free - allocate and free BIGNUMs
 
 =head1 SYNOPSIS
 
@@ -37,30 +37,12 @@ by L<ERR_get_error(3)>.
 
 BN_clear(), BN_free() and BN_clear_free() have no return values.
 
-=head1 REMOVED FUNCTIONALITY
-
- void BN_init(BIGNUM *);
-
-BN_init() is no longer available as of OpenSSL 1.1.0. It was used to initialize
-an existing uninitialized B<BIGNUM>. Typically this would be done as follows:
-
- BIGNUM a;
- BN_init(&a);
-
-Applications should replace use of BN_init with BN_new instead:
-
- BIGNUM *a;
- a = BN_new();
- if(!a) /* Handle error */
- ...
- BN_free(a);
-
 =head1 SEE ALSO
 
 L<bn(3)>, L<ERR_get_error(3)>
 
 =head1 HISTORY
 
-BN_init() was removed in OpenSSL 1.1.0.
+BN_init() was removed in OpenSSL 1.1.0; use BN_new() instead.
 
 =cut