Debian Codegraph @

upstream/debian-unstable/man3/BN_mod_exp_mont.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "BN_MOD_EXP_MONT 3SSL"
58 .TH BN_MOD_EXP_MONT 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 BN_mod_exp_mont, BN_mod_exp_mont_consttime, BN_mod_exp_mont_consttime_x2 \-
65 Montgomery exponentiation
66 .SH SYNOPSIS
67 .IX Header "SYNOPSIS"
68 .Vb 1
69 \& #include <openssl/bn.h>
70 \&
71 \& int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
72 \& const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
73 \&
74 \& int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
75 \& const BIGNUM *m, BN_CTX *ctx,
76 \& BN_MONT_CTX *in_mont);
77 \&
78 \& int BN_mod_exp_mont_consttime_x2(BIGNUM *rr1, const BIGNUM *a1,
79 \& const BIGNUM *p1, const BIGNUM *m1,
80 \& BN_MONT_CTX *in_mont1, BIGNUM *rr2,
81 \& const BIGNUM *a2, const BIGNUM *p2,
82 \& const BIGNUM *m2, BN_MONT_CTX *in_mont2,
83 \& BN_CTX *ctx);
84 .Ve
85 .SH DESCRIPTION
86 .IX Header "DESCRIPTION"
87 \&\fBBN_mod_exp_mont()\fR computes \fIa\fR to the \fIp\fR\-th power modulo \fIm\fR (\f(CW\*(C`rr=a^p % m\*(C'\fR)
88 using Montgomery multiplication. \fIin_mont\fR is a Montgomery context and can be
89 NULL. In the case \fIin_mont\fR is NULL, it will be initialized within the
90 function, so you can save time on initialization if you provide it in advance.
91 .PP
92 \&\fBBN_mod_exp_mont_consttime()\fR computes \fIa\fR to the \fIp\fR\-th power modulo \fIm\fR
93 (\f(CW\*(C`rr=a^p % m\*(C'\fR) using Montgomery multiplication. It is a variant of
94 \&\fBBN_mod_exp_mont\fR\|(3) that uses fixed windows and the special precomputation
95 memory layout to limit data-dependency to a minimum to protect secret exponents.
96 It is called automatically when \fBBN_mod_exp_mont\fR\|(3) is called with parameters
97 \&\fIa\fR, \fIp\fR, \fIm\fR, any of which have \fBBN_FLG_CONSTTIME\fR flag.
98 .PP
99 \&\fBBN_mod_exp_mont_consttime_x2()\fR computes two independent exponentiations \fIa1\fR to
100 the \fIp1\fR\-th power modulo \fIm1\fR (\f(CW\*(C`rr1=a1^p1 % m1\*(C'\fR) and \fIa2\fR to the \fIp2\fR\-th
101 power modulo \fIm2\fR (\f(CW\*(C`rr2=a2^p2 % m2\*(C'\fR) using Montgomery multiplication. For some
102 fixed and equal modulus sizes \fIm1\fR and \fIm2\fR it uses optimizations that allow
103 to speedup two exponentiations. In all other cases the function reduces to two
104 calls of \fBBN_mod_exp_mont_consttime\fR\|(3).
105 .SH "RETURN VALUES"
106 .IX Header "RETURN VALUES"
107 For all functions 1 is returned for success, 0 on error.
108 The error codes can be obtained by \fBERR_get_error\fR\|(3).
109 .SH "SEE ALSO"
110 .IX Header "SEE ALSO"
111 \&\fBERR_get_error\fR\|(3), \fBBN_mod_exp_mont\fR\|(3)
112 .SH COPYRIGHT
113 .IX Header "COPYRIGHT"
114 Copyright 2000\-2021 The OpenSSL Project Authors. All Rights Reserved.
115 .PP
116 Licensed under the Apache License 2.0 (the "License"). You may not use
117 this file except in compliance with the License. You can obtain a copy
118 in the file LICENSE in the source distribution or at
119 <https://www.openssl.org/source/license.html>.