1BN_MOD_EXP_MONT(3ossl)              OpenSSL             BN_MOD_EXP_MONT(3ossl)
2
3
4

NAME

6       BN_mod_exp_mont, BN_mod_exp_mont_consttime,
7       BN_mod_exp_mont_consttime_x2 - Montgomery exponentiation
8

SYNOPSIS

10        #include <openssl/bn.h>
11
12        int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
13                            const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
14
15        int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
16                                      const BIGNUM *m, BN_CTX *ctx,
17                                      BN_MONT_CTX *in_mont);
18
19        int BN_mod_exp_mont_consttime_x2(BIGNUM *rr1, const BIGNUM *a1,
20                                         const BIGNUM *p1, const BIGNUM *m1,
21                                         BN_MONT_CTX *in_mont1, BIGNUM *rr2,
22                                         const BIGNUM *a2, const BIGNUM *p2,
23                                         const BIGNUM *m2, BN_MONT_CTX *in_mont2,
24                                         BN_CTX *ctx);
25

DESCRIPTION

27       BN_mod_exp_mont() computes a to the p-th power modulo m ("rr=a^p % m")
28       using Montgomery multiplication. in_mont is a Montgomery context and
29       can be NULL. In the case in_mont is NULL, it will be initialized within
30       the function, so you can save time on initialization if you provide it
31       in advance.
32
33       BN_mod_exp_mont_consttime() computes a to the p-th power modulo m
34       ("rr=a^p % m") using Montgomery multiplication. It is a variant of
35       BN_mod_exp_mont(3) that uses fixed windows and the special
36       precomputation memory layout to limit data-dependency to a minimum to
37       protect secret exponents.  It is called automatically when
38       BN_mod_exp_mont(3) is called with parameters a, p, m, any of which have
39       BN_FLG_CONSTTIME flag.
40
41       BN_mod_exp_mont_consttime_x2() computes two independent exponentiations
42       a1 to the p1-th power modulo m1 ("rr1=a1^p1 % m1") and a2 to the p2-th
43       power modulo m2 ("rr2=a2^p2 % m2") using Montgomery multiplication. For
44       some fixed and equal modulus sizes m1 and m2 it uses optimizations that
45       allow to speedup two exponentiations. In all other cases the function
46       reduces to two calls of BN_mod_exp_mont_consttime(3).
47

RETURN VALUES

49       For all functions 1 is returned for success, 0 on error.  The error
50       codes can be obtained by ERR_get_error(3).
51

SEE ALSO

53       ERR_get_error(3), BN_mod_exp_mont(3)
54
56       Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
57
58       Licensed under the Apache License 2.0 (the "License").  You may not use
59       this file except in compliance with the License.  You can obtain a copy
60       in the file LICENSE in the source distribution or at
61       <https://www.openssl.org/source/license.html>.
62
63
64
653.0.5                             2022-11-01            BN_MOD_EXP_MONT(3ossl)
Impressum