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 non-negative. 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 non-negative. 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(3), BN_num_bytes(3), BN_add(3)
55

HISTORY

57       BN_set_bit(), BN_clear_bit(), BN_is_bit_set(), BN_mask_bits(),
58       BN_lshift(), BN_lshift1(), BN_rshift(), and BN_rshift1() are available
59       in all versions of SSLeay and OpenSSL.
60
61
62
631.0.2o                            2020-08-01                     BN_set_bit(3)
Impressum