BN_SET_BIT(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

🌸 NAME 🌸

okay so bestie, this is the BN_SET_BIT(3ossl) page from OpenSSL, and it is literally all about bit operations on BIGNUMs πŸ’…βœ¨. the whole squad is BN_set_bit, BN_clear_bit, BN_is_bit_set, BN_mask_bits, BN_lshift, BN_lshift1, BN_rshift, BN_rshift1 β€” no cap, that's the lineup 🫢.

✨ SYNOPSIS ✨

like, here's the exact include and the function signatures, copy-paste vibes only:

        #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 πŸ’–

  • BN_set_bit() β€” sets bit n in a to 1 (a|=(1<<n)). the number is expanded if necessary. very main character energy ✨.
  • BN_clear_bit() β€” sets bit n in a to 0 (a&=~(1<<n)). ngl, an error occurs if a is shorter than n bits.
  • BN_is_bit_set() β€” tests if bit n in a is set. vibe check for one 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. ok that's a whole lot but we keep it 🫢.
  • BN_lshift() β€” shifts a left by n bits and places the result in r (r=a*2^n). note that n must be nonnegative. BN_lshift1() shifts a left by one and places the result in r (r=2*a). left shift slay πŸ’….
  • 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). right shift era 🌈.

for the shift functions, r and a may be the same variable. periodt. no extra copies required, iykyk.

πŸ’œ RETURN VALUES πŸ’œ

BN_is_bit_set() returns 1 if the bit is set, 0 otherwise. ok cute.

all other functions return 1 for success, 0 on error. the error codes can be obtained by ERR_get_error(3). so if something's cooked, check that πŸ”₯.

πŸ¦‹ 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>.


bye bestie 🫢 this page came from OpenSSL 3.5.6, dated 2026-04-07, and the manual name is BN_SET_BIT(3ossl) β€” periodt πŸ’…βœ¨

πŸ“¦ where this page comes from