summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/BN_set_bit.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/BN_set_bit.3')
-rw-r--r--src/lib/libcrypto/man/BN_set_bit.3157
1 files changed, 157 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BN_set_bit.3 b/src/lib/libcrypto/man/BN_set_bit.3
new file mode 100644
index 0000000000..4a199cd0d0
--- /dev/null
+++ b/src/lib/libcrypto/man/BN_set_bit.3
@@ -0,0 +1,157 @@
1.Dd $Mdocdate: February 23 2015 $
2.Dt BN_SET_BIT 3
3.Os
4.Sh NAME
5.Nm BN_set_bit ,
6.Nm BN_clear_bit ,
7.Nm BN_is_bit_set ,
8.Nm BN_mask_bits ,
9.Nm BN_lshift ,
10.Nm BN_lshift1 ,
11.Nm BN_rshift ,
12.Nm BN_rshift1
13.Nd bit operations on BIGNUMs
14.Sh SYNOPSIS
15.In openssl/bn.h
16.Ft int
17.Fo BN_set_bit
18.Fa "BIGNUM *a"
19.Fa "int n"
20.Fc
21.Ft int
22.Fo BN_clear_bit
23.Fa "BIGNUM *a"
24.Fa "int n"
25.Fc
26.Ft int
27.Fo BN_is_bit_set
28.Fa "const BIGNUM *a"
29.Fa "int n"
30.Fc
31.Ft int
32.Fo BN_mask_bits
33.Fa "BIGNUM *a"
34.Fa "int n"
35.Fc
36.Ft int
37.Fo BN_lshift
38.Fa "BIGNUM *r"
39.Fa "const BIGNUM *a"
40.Fa "int n"
41.Fc
42.Ft int
43.Fo BN_lshift1
44.Fa "BIGNUM *r"
45.Fa "BIGNUM *a"
46.Fc
47.Ft int
48.Fo BN_rshift
49.Fa "BIGNUM *r"
50.Fa "BIGNUM *a"
51.Fa "int n"
52.Fc
53.Ft int
54.Fo BN_rshift1
55.Fa "BIGNUM *r"
56.Fa "BIGNUM *a"
57.Fc
58.Sh DESCRIPTION
59.Fn BN_set_bit
60sets bit
61.Fa n
62in
63.Fa a
64to 1
65.Pq Li a|=(1<<n) .
66The number is expanded if necessary.
67.Pp
68.Fn BN_clear_bit
69sets bit
70.Fa n
71in
72.Fa a
73to 0
74.Pq Li a&=~(1<<n) .
75An error occurs if
76.Fa a
77is shorter than
78.Fa n
79bits.
80.Pp
81.Fn BN_is_bit_set
82tests if bit
83.Fa n
84in
85.Fa a
86is set.
87.Pp
88.Fn BN_mask_bits
89truncates
90.Fa a
91to an
92.Fa n
93bit number
94.Pq Li a&=~((~0)>>n) .
95An error occurs if
96.Fa a
97already is shorter than
98.Fa n
99bits.
100.Pp
101.Fn BN_lshift
102shifts
103.Fa a
104left by
105.Fa n
106bits and places the result in
107.Fa r
108.Pq Li r=a*2^n .
109.Fn BN_lshift1
110shifts
111.Fa a
112left by one and places the result in
113.Fa r
114.Pq Li r=2*a .
115.Pp
116.Fn BN_rshift
117shifts
118.Fa a
119right by
120.Fa n
121bits and places the result in
122.Fa r
123.Pq Li r=a/2^n .
124.Fn BN_rshift1
125shifts
126.Fa a
127right by one and places the result in
128.Fa r
129.Pq Li r=a/2 .
130.Pp
131For the shift functions,
132.Fa r
133and
134.Fa a
135may be the same variable.
136.Sh RETURN VALUES
137.Fn BN_is_bit_set
138returns 1 if the bit is set, 0 otherwise.
139.Pp
140All other functions return 1 for success, 0 on error.
141The error codes can be obtained by
142.Xr ERR_get_error 3 .
143.Sh SEE ALSO
144.Xr bn 3 ,
145.Xr BN_add 3 ,
146.Xr BN_num_bytes 3
147.Sh HISTORY
148.Fn BN_set_bit ,
149.Fn BN_clear_bit ,
150.Fn BN_is_bit_set ,
151.Fn BN_mask_bits ,
152.Fn BN_lshift ,
153.Fn BN_lshift1 ,
154.Fn BN_rshift ,
155and
156.Fn BN_rshift1
157are available in all versions of SSLeay and OpenSSL.