]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/lib/libcrypto/man/BN_add.3
This commit was generated by cvs2svn to compensate for changes in r102514,
[FreeBSD/FreeBSD.git] / secure / lib / libcrypto / man / BN_add.3
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Tue Jul 30 09:21:16 2002
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
34 .\" Set up some character translations and predefined strings.  \*(-- will
35 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36 .\" double quote, and \*(R" will give a right double quote.  | will give a
37 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used
38 .\" to do unbreakable dashes and therefore won't be available.  \*(C` and
39 .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie n \{\
43 .    ds -- \(*W-
44 .    ds PI pi
45 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
47 .    ds L" ""
48 .    ds R" ""
49 .    ds C` ""
50 .    ds C' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
59 .\" If the F register is turned on, we'll generate index entries on stderr
60 .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61 .\" index entries marked with X<> in POD.  Of course, you'll have to process
62 .\" the output yourself in some meaningful fashion.
63 .if \nF \{\
64 .    de IX
65 .    tm Index:\\$1\t\\n%\t"\\$2"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
71 .\" For nroff, turn off justification.  Always turn off hyphenation; it
72 .\" makes way too many mistakes in technical documents.
73 .hy 0
74 .if n .na
75 .\"
76 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
78 .bd B 3
79 .    \" fudge factors for nroff and troff
80 .if n \{\
81 .    ds #H 0
82 .    ds #V .8m
83 .    ds #F .3m
84 .    ds #[ \f1
85 .    ds #] \fP
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
103 .if t \{\
104 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110 .\}
111 .    \" troff and (daisy-wheel) nroff accents
112 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119 .ds ae a\h'-(\w'a'u*4/10)'e
120 .ds Ae A\h'-(\w'A'u*4/10)'E
121 .    \" corrections for vroff
122 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124 .    \" for low resolution devices (crt and lpr)
125 .if \n(.H>23 .if \n(.V>19 \
126 \{\
127 .    ds : e
128 .    ds 8 ss
129 .    ds o a
130 .    ds d- d\h'-1'\(ga
131 .    ds D- D\h'-1'\(hy
132 .    ds th \o'bp'
133 .    ds Th \o'LP'
134 .    ds ae ae
135 .    ds Ae AE
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "BN_add 3"
141 .TH BN_add 3 "0.9.6e" "2000-04-13" "OpenSSL"
142 .UC
143 .SH "NAME"
144 BN_add, BN_sub, BN_mul, BN_div, BN_sqr, BN_mod, BN_mod_mul, BN_exp,
145 BN_mod_exp, BN_gcd \- arithmetic operations on BIGNUMs
146 .SH "SYNOPSIS"
147 .IX Header "SYNOPSIS"
148 .Vb 1
149 \& #include <openssl/bn.h>
150 .Ve
151 .Vb 1
152 \& int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
153 .Ve
154 .Vb 1
155 \& int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
156 .Ve
157 .Vb 1
158 \& int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
159 .Ve
160 .Vb 2
161 \& int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,
162 \&         BN_CTX *ctx);
163 .Ve
164 .Vb 1
165 \& int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
166 .Ve
167 .Vb 1
168 \& int BN_mod(BIGNUM *rem, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
169 .Ve
170 .Vb 2
171 \& int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
172 \&         BN_CTX *ctx);
173 .Ve
174 .Vb 1
175 \& int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx);
176 .Ve
177 .Vb 2
178 \& int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
179 \&         const BIGNUM *m, BN_CTX *ctx);
180 .Ve
181 .Vb 1
182 \& int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
183 .Ve
184 .SH "DESCRIPTION"
185 .IX Header "DESCRIPTION"
186 \&\fIBN_add()\fR adds \fBa\fR and \fBb\fR and places the result in \fBr\fR (\f(CW\*(C`r=a+b\*(C'\fR).
187 \&\fBr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fBa\fR or \fBb\fR.
188 .PP
189 \&\fIBN_sub()\fR subtracts \fBb\fR from \fBa\fR and places the result in \fBr\fR (\f(CW\*(C`r=a\-b\*(C'\fR).
190 .PP
191 \&\fIBN_mul()\fR multiplies \fBa\fR and \fBb\fR and places the result in \fBr\fR (\f(CW\*(C`r=a*b\*(C'\fR).
192 \&\fBr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fBa\fR or \fBb\fR.
193 For multiplication by powers of 2, use BN_lshift(3).
194 .PP
195 \&\fIBN_div()\fR divides \fBa\fR by \fBd\fR and places the result in \fBdv\fR and the
196 remainder in \fBrem\fR (\f(CW\*(C`dv=a/d, rem=a%d\*(C'\fR). Either of \fBdv\fR and \fBrem\fR may
197 be \s-1NULL\s0, in which case the respective value is not returned.
198 For division by powers of 2, use \fIBN_rshift\fR\|(3).
199 .PP
200 \&\fIBN_sqr()\fR takes the square of \fBa\fR and places the result in \fBr\fR
201 (\f(CW\*(C`r=a^2\*(C'\fR). \fBr\fR and \fBa\fR may be the same \fB\s-1BIGNUM\s0\fR.
202 This function is faster than BN_mul(r,a,a).
203 .PP
204 \&\fIBN_mod()\fR find the remainder of \fBa\fR divided by \fBm\fR and places it in
205 \&\fBrem\fR (\f(CW\*(C`rem=a%m\*(C'\fR).
206 .PP
207 \&\fIBN_mod_mul()\fR multiplies \fBa\fR by \fBb\fR and finds the remainder when
208 divided by \fBm\fR (\f(CW\*(C`r=(a*b)%m\*(C'\fR). \fBr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fBa\fR
209 or \fBb\fR. For a more efficient algorithm, see
210 BN_mod_mul_montgomery(3); for repeated
211 computations using the same modulus, see BN_mod_mul_reciprocal(3).
212 .PP
213 \&\fIBN_exp()\fR raises \fBa\fR to the \fBp\fR\-th power and places the result in \fBr\fR
214 (\f(CW\*(C`r=a^p\*(C'\fR). This function is faster than repeated applications of
215 \&\fIBN_mul()\fR.
216 .PP
217 \&\fIBN_mod_exp()\fR computes \fBa\fR to the \fBp\fR\-th power modulo \fBm\fR (\f(CW\*(C`r=a^p %
218 m\*(C'\fR). This function uses less time and space than \fIBN_exp()\fR.
219 .PP
220 \&\fIBN_gcd()\fR computes the greatest common divisor of \fBa\fR and \fBb\fR and
221 places the result in \fBr\fR. \fBr\fR may be the same \fB\s-1BIGNUM\s0\fR as \fBa\fR or
222 \&\fBb\fR.
223 .PP
224 For all functions, \fBctx\fR is a previously allocated \fB\s-1BN_CTX\s0\fR used for
225 temporary variables; see BN_CTX_new(3).
226 .PP
227 Unless noted otherwise, the result \fB\s-1BIGNUM\s0\fR must be different from
228 the arguments.
229 .SH "RETURN VALUES"
230 .IX Header "RETURN VALUES"
231 For all functions, 1 is returned for success, 0 on error. The return
232 value should always be checked (e.g., \f(CW\*(C`if (!BN_add(r,a,b)) goto err;\*(C'\fR).
233 The error codes can be obtained by ERR_get_error(3).
234 .SH "SEE ALSO"
235 .IX Header "SEE ALSO"
236 bn(3), err(3), BN_CTX_new(3),
237 BN_add_word(3), BN_set_bit(3)
238 .SH "HISTORY"
239 .IX Header "HISTORY"
240 \&\fIBN_add()\fR, \fIBN_sub()\fR, \fIBN_div()\fR, \fIBN_sqr()\fR, \fIBN_mod()\fR, \fIBN_mod_mul()\fR,
241 \&\fIBN_mod_exp()\fR and \fIBN_gcd()\fR are available in all versions of SSLeay and
242 OpenSSL. The \fBctx\fR argument to \fIBN_mul()\fR was added in SSLeay
243 0.9.1b. \fIBN_exp()\fR appeared in SSLeay 0.9.0.