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>
This commit is contained in:
parent
911cfb7e6e
commit
12f7737d32
@ -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) {
|
||||
|
@ -731,11 +731,7 @@ OPENSSL_EXPORT int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
/* BN_MONT_CTX_new returns a fresh BN_MONT_CTX or NULL on allocation failure. */
|
||||
OPENSSL_EXPORT BN_MONT_CTX *BN_MONT_CTX_new(void);
|
||||
|
||||
/* BN_MONT_CTX_init initialises a stack allocated |BN_MONT_CTX|. */
|
||||
OPENSSL_EXPORT void BN_MONT_CTX_init(BN_MONT_CTX *mont);
|
||||
|
||||
/* BN_MONT_CTX_free frees the contexts of |mont| and, if it was originally
|
||||
* allocated with |BN_MONT_CTX_new|, |mont| itself. */
|
||||
/* BN_MONT_CTX_free frees memory associated with |mont|. */
|
||||
OPENSSL_EXPORT void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||
|
||||
/* BN_MONT_CTX_copy sets |to| equal to |from|. It returns |to| on success or
|
||||
@ -843,7 +839,6 @@ struct bn_mont_ctx_st {
|
||||
* (Ni is only stored for bignum algorithm) */
|
||||
BN_ULONG n0[2]; /* least significant word(s) of Ni;
|
||||
(type changed with 0.9.9, was "BN_ULONG n0;" before) */
|
||||
int flags;
|
||||
int ri; /* number of bits in R */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user