OSSL_FN: Wrap the BIGNUM 'sqr' function around the OSSL_FN 'sqr' function
Reviewed-by: Matt Caswell <matt@openssl.foundation> Reviewed-by: Tomas Mraz <tomas@openssl.foundation> MergeDate: Fri Apr 3 12:32:22 2026 (Merged from https://github.com/openssl/openssl/pull/29819)
This commit is contained in:
parent
929db7822d
commit
f52bf9d167
1 changed files with 25 additions and 2 deletions
|
|
@ -16,11 +16,34 @@
|
|||
*/
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
|
||||
{
|
||||
int ret = bn_sqr_fixed_top(r, a, ctx);
|
||||
/* TODO(FIXNUM): TO BE REMOVED */
|
||||
if (r->data == NULL || a->data == NULL) {
|
||||
int ret = bn_sqr_fixed_top(r, a, ctx);
|
||||
|
||||
bn_correct_top(r);
|
||||
bn_correct_top(r);
|
||||
bn_check_top(r);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bn_check_top(a);
|
||||
bn_check_top(r);
|
||||
|
||||
size_t top = a->top * 2;
|
||||
size_t max = a->dmax * 2;
|
||||
|
||||
/*
|
||||
* Unfortunately, OSSL_FN_CTX and BN_CTX are too wildly different to
|
||||
* be interchangeable. We must therefore create an OSSL_FN_CTX here.
|
||||
* (OSSL_FN_CTX is only really useful within OSSL_FN functionality)
|
||||
*/
|
||||
OSSL_FN_CTX *fnctx = OSSL_FN_CTX_new(NULL, 1, 2, max * 4);
|
||||
OSSL_FN *rf = bn_acquire_ossl_fn(r, (int)top);
|
||||
int ret = OSSL_FN_sqr(rf, a->data, fnctx);
|
||||
bn_release(r, (int)top);
|
||||
r->neg = 0;
|
||||
|
||||
OSSL_FN_CTX_free(fnctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue