diff options
author | David Benjamin <davidben@chromium.org> | 2015-10-26 18:31:51 +0300 |
---|---|---|
committer | Adam Langley <alangley@gmail.com> | 2015-10-26 22:47:26 +0300 |
commit | 12f7737d32caa387f86a6dbed5e393aa01035272 (patch) | |
tree | 0d5485b20829e55afecd3ba83633dd31e428e8f8 /crypto/bn | |
parent | 911cfb7e6ed4355cbf7099e5c743bdcc57e2b69c (diff) |
Remove BN_MONT_CTX_init.
One less exported function. Nothing ever stack-allocates them, within BoringSSL
or in consumers. This avoids the slightly odd mechanism where BN_MONT_CTX_free
might or might not free the BN_MONT_CTX itself based on a flag.
(This is also consistent with OpenSSL 1.1.x which does away with the _init
variants of both this and BIGNUM so it shouldn't be a compatibility concern
long-term either.)
Change-Id: Id885ae35a26f75686cc68a8aa971e2ea6767ba88
Reviewed-on: https://boringssl-review.googlesource.com/6350
Reviewed-by: Adam Langley <alangley@gmail.com>
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/montgomery.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/crypto/bn/montgomery.c b/crypto/bn/montgomery.c index c6c9c886..3fec7e36 100644 --- a/crypto/bn/montgomery.c +++ b/crypto/bn/montgomery.c @@ -130,16 +130,12 @@ BN_MONT_CTX *BN_MONT_CTX_new(void) { return NULL; } - BN_MONT_CTX_init(ret); - ret->flags = BN_FLG_MALLOCED; - return ret; -} + memset(ret, 0, sizeof(BN_MONT_CTX)); + BN_init(&ret->RR); + BN_init(&ret->N); + BN_init(&ret->Ni); -void BN_MONT_CTX_init(BN_MONT_CTX *mont) { - memset(mont, 0, sizeof(BN_MONT_CTX)); - BN_init(&mont->RR); - BN_init(&mont->N); - BN_init(&mont->Ni); + return ret; } void BN_MONT_CTX_free(BN_MONT_CTX *mont) { @@ -150,9 +146,7 @@ void BN_MONT_CTX_free(BN_MONT_CTX *mont) { BN_free(&mont->RR); BN_free(&mont->N); BN_free(&mont->Ni); - if (mont->flags & BN_FLG_MALLOCED) { - OPENSSL_free(mont); - } + OPENSSL_free(mont); } BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from) { |