xref: /openbsd/lib/libcrypto/man/BN_add_word.3 (revision 73471bf0)
1.\"	$OpenBSD: BN_add_word.3,v 1.9 2019/06/10 14:58:48 schwarze Exp $
2.\"	OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2005 The OpenSSL Project.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in
16.\"    the documentation and/or other materials provided with the
17.\"    distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\"    software must display the following acknowledgment:
21.\"    "This product includes software developed by the OpenSSL Project
22.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\"    endorse or promote products derived from this software without
26.\"    prior written permission. For written permission, please contact
27.\"    openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\"    nor may "OpenSSL" appear in their names without prior written
31.\"    permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\"    acknowledgment:
35.\"    "This product includes software developed by the OpenSSL Project
36.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt BN_ADD_WORD 3
53.Os
54.Sh NAME
55.Nm BN_add_word ,
56.Nm BN_sub_word ,
57.Nm BN_mul_word ,
58.Nm BN_div_word ,
59.Nm BN_mod_word
60.Nd arithmetic functions on BIGNUMs with integers
61.Sh SYNOPSIS
62.In openssl/bn.h
63.Ft int
64.Fo BN_add_word
65.Fa "BIGNUM *a"
66.Fa "BN_ULONG w"
67.Fc
68.Ft int
69.Fo BN_sub_word
70.Fa "BIGNUM *a"
71.Fa "BN_ULONG w"
72.Fc
73.Ft int
74.Fo BN_mul_word
75.Fa "BIGNUM *a"
76.Fa "BN_ULONG w"
77.Fc
78.Ft BN_ULONG
79.Fo BN_div_word
80.Fa "BIGNUM *a"
81.Fa "BN_ULONG w"
82.Fc
83.Ft BN_ULONG
84.Fo BN_mod_word
85.Fa "const BIGNUM *a"
86.Fa "BN_ULONG w"
87.Fc
88.Sh DESCRIPTION
89These functions perform arithmetic operations on BIGNUMs with unsigned
90integers.
91They are much more efficient than the normal BIGNUM arithmetic
92operations.
93.Pp
94.Fn BN_add_word
95adds
96.Fa w
97to
98.Fa a
99.Pq Li a+=w .
100.Pp
101.Fn BN_sub_word
102subtracts
103.Fa w
104from
105.Fa a
106.Pq Li a-=w .
107.Pp
108.Fn BN_mul_word
109multiplies
110.Fa a
111and
112.Fa w
113.Pq Li a*=w .
114.Pp
115.Fn BN_div_word
116divides
117.Fa a
118by
119.Fa w
120.Pq Li a/=w
121and returns the remainder.
122.Pp
123.Fn BN_mod_word
124returns the remainder of
125.Fa a
126divided by
127.Fa w
128.Pq Li a%w .
129.Pp
130For
131.Fn BN_div_word
132and
133.Fn BN_mod_word ,
134.Fa w
135must not be 0.
136.Sh RETURN VALUES
137.Fn BN_add_word ,
138.Fn BN_sub_word ,
139and
140.Fn BN_mul_word
141return 1 for success or 0 on error.
142The error codes can be obtained by
143.Xr ERR_get_error 3 .
144.Pp
145.Fn BN_mod_word
146and
147.Fn BN_div_word
148return
149.Fa a Ns % Ns Fa w
150on success and
151.Po Vt BN_ULONG Pc Ns -1
152if an error occurred.
153.Sh SEE ALSO
154.Xr BN_add 3 ,
155.Xr BN_new 3
156.Sh HISTORY
157.Fn BN_add_word ,
158.Fn BN_div_word ,
159and
160.Fn BN_mod_word
161first appeared in SSLeay 0.5.1.
162.Fn BN_sub_word
163and
164.Fn BN_mul_word
165first appeared in SSLeay 0.9.0.
166All these functions have been available since
167.Ox 2.4 .
168.Pp
169Before 0.9.8a, the return value for
170.Fn BN_div_word
171and
172.Fn BN_mod_word
173in case of an error was 0.
174