1BN_SET_BIT(3)                       OpenSSL                      BN_SET_BIT(3)
2
3
4

NAME

6       BN_set_bit, BN_clear_bit, BN_is_bit_set, BN_mask_bits, BN_lshift,
7       BN_lshift1, BN_rshift, BN_rshift1 - bit operations on BIGNUMs
8

SYNOPSIS

10        #include <openssl/bn.h>
11
12        int BN_set_bit(BIGNUM *a, int n);
13        int BN_clear_bit(BIGNUM *a, int n);
14
15        int BN_is_bit_set(const BIGNUM *a, int n);
16
17        int BN_mask_bits(BIGNUM *a, int n);
18
19        int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
20        int BN_lshift1(BIGNUM *r, BIGNUM *a);
21
22        int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
23        int BN_rshift1(BIGNUM *r, BIGNUM *a);
24

DESCRIPTION

26       BN_set_bit() sets bit n in a to 1 ("a|=(1<<n)"). The number is expanded
27       if necessary.
28
29       BN_clear_bit() sets bit n in a to 0 ("a&=~(1<<n)"). An error occurs if
30       a is shorter than n bits.
31
32       BN_is_bit_set() tests if bit n in a is set.
33
34       BN_mask_bits() truncates a to an n bit number ("a&=~((~0)<<n)").  An
35       error occurs if a already is shorter than n bits.
36
37       BN_lshift() shifts a left by n bits and places the result in r
38       ("r=a*2^n"). Note that n must be nonnegative. BN_lshift1() shifts a
39       left by one and places the result in r ("r=2*a").
40
41       BN_rshift() shifts a right by n bits and places the result in r
42       ("r=a/2^n"). Note that n must be nonnegative. BN_rshift1() shifts a
43       right by one and places the result in r ("r=a/2").
44
45       For the shift functions, r and a may be the same variable.
46

RETURN VALUES

48       BN_is_bit_set() returns 1 if the bit is set, 0 otherwise.
49
50       All other functions return 1 for success, 0 on error. The error codes
51       can be obtained by ERR_get_error(3).
52

SEE ALSO

54       BN_num_bytes(3), BN_add(3)
55
57       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
58
59       Licensed under the OpenSSL license (the "License").  You may not use
60       this file except in compliance with the License.  You can obtain a copy
61       in the file LICENSE in the source distribution or at
62       <https://www.openssl.org/source/license.html>.
63
64
65
661.1.1i                            2021-07-22                     BN_SET_BIT(3)
Impressum