BN_SET_BIT(3ossl)
π
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 bitninato1(a|=(1<<n)). if the number needs to be expanded to make room, she expands it, no cap. β¨BN_clear_bit()β sets bitninato0(a&=~(1<<n)). ifais shorter thannbits, thatβs an error. π«ΆBN_is_bit_set()β tests whether bitninais set. just a lil vibe check on the bit. πBN_mask_bits()β truncatesato annbit number (a&=~((~0)<<n)). an error occurs ifnis negative. an error is also returned if the internal representation ofais already shorter thannbits. the internal representation depends on the platformβs word size, and this error can be safely ignored. useBN_num_bits(3)to determine the exact number of bits if needed. π§BN_lshift()β shiftsaleft bynbits and places the result inr(r=a*2^n). note thatnmust be nonnegative, bestie. no negative shifts.BN_lshift1()shiftsaleft by one and places the result inr(r=2*a). βBN_rshift()β shiftsaright bynbits and places the result inr(r=a/2^n). note thatnmust be nonnegative.BN_rshift1()shiftsaright by one and places the result inr(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 π
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
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms