BN_SET_BIT(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… bit ops on BIGNUMs: BN_SET_BIT(3ossl) πŸ’…

okay bestie, welcome to the OpenSSL manual β€” this is the BN_SET_BIT(3ossl) page, and we are talking bit operations on BIGNUMs. no cap, it’s a whole vibe. πŸ¦‹

✨ NAME ✨

BN_set_bit, BN_clear_bit, BN_is_bit_set, BN_mask_bits, BN_lshift, BN_lshift1, BN_rshift, BN_rshift1 β€” bit operations on BIGNUMs. that’s the whole cast, periodt. πŸ‘‘

πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/bn.h>

int BN_set_bit(BIGNUM *a, int n);
int BN_clear_bit(BIGNUM *a, int n);

int BN_is_bit_set(const BIGNUM *a, int n);

int BN_mask_bits(BIGNUM *a, int n);

int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
int BN_lshift1(BIGNUM *r, BIGNUM *a);

int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
int BN_rshift1(BIGNUM *r, BIGNUM *a);

🌸 DESCRIPTION 🌸

okay so here’s the tea, one function at a time:

  • BN_set_bit() β€” sets bit n in a to 1 (a|=(1<<n)). if the number needs to be expanded to make room, she expands it, no cap. ✨
  • BN_clear_bit() β€” sets bit n in a to 0 (a&=~(1<<n)). if a is shorter than n bits, that’s an error. 🫢
  • BN_is_bit_set() β€” tests whether bit n in a is set. just a lil vibe check on the bit. πŸ’…
  • BN_mask_bits() β€” truncates a to an n bit number (a&=~((~0)<<n)). an error occurs if n is negative. an error is also returned if the internal representation of a is already shorter than n bits. the internal representation depends on the platform’s word size, and this error can be safely ignored. use BN_num_bits(3) to determine the exact number of bits if needed. 🧚
  • BN_lshift() β€” shifts a left by n bits and places the result in r (r=a*2^n). note that n must be nonnegative, bestie. no negative shifts. BN_lshift1() shifts a left by one and places the result in r (r=2*a). ⭐
  • BN_rshift() β€” shifts a right by n bits and places the result in r (r=a/2^n). note that n must be nonnegative. BN_rshift1() shifts a right by one and places the result in r (r=a/2). πŸ’–

for the shift functions, r and a may be the same variable β€” the shift girlies are cool with that. 🌈

πŸ‘‘ RETURN VALUES πŸ‘‘

BN_is_bit_set() returns 1 if the bit is set, and 0 otherwise. that’s it, that’s the whole answer. πŸ’…

all the other functions return 1 for success and 0 on error. if you need the error codes, grab them with ERR_get_error(3). no guessing, bestie. πŸ”₯

πŸ¦‹ SEE ALSO πŸ¦‹

Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License").  You may not use
this file except in compliance with the License.  You can obtain a copy
in the file LICENSE in the source distribution or at
<https://www.openssl.org/source/license.html>.

xoxo, your OpenSSL bestie πŸ’– β€” this page is from OpenSSL 3.5.0, dated 2026-09-25, and it’s the BN_SET_BIT(3ossl) manual page. periodt 🫢

πŸ“¦ where this page comes from