BN_SET_BIT(3ossl)
πΈ 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 bitninato 1 (a|=(1<<n)). the number is expanded if necessary. very main character energy β¨.BN_clear_bit()β sets bitninato 0 (a&=~(1<<n)). ngl, an error occurs ifais shorter thannbits.BN_is_bit_set()β tests if bitninais set. vibe check for one 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. ok that's a whole lot but we keep it π«Ά.BN_lshift()β shiftsaleft bynbits and places the result inr(r=a*2^n). note thatnmust be nonnegative.BN_lshift1()shiftsaleft by one and places the result inr(r=2*a). left shift slay π .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). 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 π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms