BN_SET_FLAGS(3)
okay so bestie, this is BN_SET_FLAGS(3) from the Library Functions Manual, and weβre talking about flags on BIGNUM objects β lowkey important, highkey iconic β¨π
π NAME π
BN_set_flags, BN_get_flags β enable and inspect flags on BIGNUM objects π«Ά
β¨ SYNOPSIS β¨
#include <openssl/bn.h>
void
BN_set_flags(BIGNUM *b, int flags);
int
BN_get_flags(const BIGNUM *b, int flags);
π¦ DESCRIPTION π¦
BN_set_flags() enables the given flags on b. The flags argument can contain zero or more of the following constants ORβed together, no cap:
BN_FLG_CONSTTIMEβ if this flag is set on the dividentaor the divisordinBN_div(3), on the exponentpinBN_mod_exp(3), or on the divisoraor the modulusninBN_mod_inverse(3), these functions select algorithms with an execution time independent of the respective numbers, to avoid exposing sensitive information to timing side-channel attacks. This flag is off by default forBIGNUMobjects created withBN_new(3)β±οΈπ‘οΈBN_FLG_MALLOCEDβ if this flag is set,BN_free(3)andBN_clear_free(3)will not only clear and free the components ofb, but alsobitself. This flag is set internally byBN_new(3). Setting it manually on an existingBIGNUMobject is usually a bad idea and can cause calls tofree(3)with bogus arguments ππBN_FLG_STATIC_DATAβ if this flag is set,BN_clear_free(3)will neither clear nor free the memory used for storing the number. Consequently, setting it manually on an existingBIGNUMobject is usually a terrible idea that can cause both disclosure of secret data and memory leaks. This flag is automatically set on the constantBIGNUMobject returned byBN_value_one(3)π¨π§¨
BN_get_flags() interprets flags as a bitmask and returns those of the given flags that are set in b, ORβed together, or 0 if none of the given flags is set. The flags argument has the same syntax as for BN_set_flags() πβ¨
π RETURN VALUES π
BN_get_flags() returns zero or more of the above constants, ORβed together. Thatβs the whole vibe check π
π SEE ALSO π
β HISTORY β
BN_set_flags() and BN_get_flags() first appeared in SSLeay 0.9.1 and have been available since OpenBSD 2.6. vintage but still serving ππ
π CAVEATS π
No public interface exists to clear a flag once it is set. So think twice before using BN_set_flags(), bestie β fr fr π«Άβ οΈ
π BUGS π
- Even if the
BN_FLG_CONSTTIMEflag is set onaorb,BN_gcd()neither fails nor operates in constant time, potentially allowing timing side-channel attacks πβ±οΈ - Even if the
BN_FLG_CONSTTIMEflag is set onp, if the modulusmis even,BN_mod_exp(3)does not operate in constant time, potentially allowing timing side-channel attacks π¬π³οΈ - If
BN_FLG_CONSTTIMEis set onp,BN_exp()fails instead of operating in constant time π₯π«
okay bye bestie β this oneβs from the Debian edition, dated April 27, 2023 πππ«Ά
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms