diff options
author | Andy Polyakov <appro@openssl.org> | 2018-07-06 15:13:15 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2018-07-12 14:52:57 +0200 |
commit | 71883868ea5b33416ae8283bcc38dd2d97e5006b (patch) | |
tree | e86cd1d7f051b4381b5a9ef4cb93ecc09dad3b57 /crypto/include | |
parent | bn/bn_lib.c: add BN_FLG_FIXED_TOP flag. (diff) | |
download | openssl-71883868ea5b33416ae8283bcc38dd2d97e5006b.tar.xz openssl-71883868ea5b33416ae8283bcc38dd2d97e5006b.zip |
bn/bn_{mont|exp}.c: switch to zero-padded intermediate vectors.
Note that exported functions maintain original behaviour, so that
external callers won't observe difference. While internally we can
now perform Montogomery multiplication on fixed-length vectors, fixed
at modulus size. The new functions, bn_to_mont_fixed_top and
bn_mul_mont_fixed_top, are declared in bn_int.h, because one can use
them even outside bn, e.g. in RSA, DSA, ECDSA...
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: David Benjamin <davidben@google.com>
(Merged from https://github.com/openssl/openssl/pull/6662)
Diffstat (limited to 'crypto/include')
-rw-r--r-- | crypto/include/internal/bn_int.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crypto/include/internal/bn_int.h b/crypto/include/internal/bn_int.h index 9379951dea..e7fd8992f4 100644 --- a/crypto/include/internal/bn_int.h +++ b/crypto/include/internal/bn_int.h @@ -60,4 +60,16 @@ void bn_set_static_words(BIGNUM *a, BN_ULONG *words, int size); */ int bn_set_words(BIGNUM *a, BN_ULONG *words, int num_words); +/* + * Some BIGNUM functions assume most significant limb to be non-zero, which + * is customarily arranged by bn_correct_top. Output from below functions + * is not processed with bn_correct_top, and for this reason it may not be + * returned out of public API. It may only be passed internally into other + * functions known to support non-minimal or zero-padded BIGNUMs. + */ +int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); + #endif |