BN_SWAP(3)
π
BN_SWAP(3) π
okay bestie, welcome to the Library Functions Manual entry for BN_SWAP(3) β yes, we're doing BIGNUM swapping and it's lowkey iconic β¨
πΈ NAME πΈ
BN_swap,BN_consttime_swapβ exchangeBIGNUMs
β¨ SYNOPSIS β¨
#include <openssl/bn.h>
void
BN_swap(BIGNUM *a, BIGNUM *b);
void
BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords);
π DESCRIPTION π
BN_swap() and BN_consttime_swap() exchange the values of a and b. That's the whole vibe: value swap π«Ά
BN_swap() does it by exchanging the pointers to the data buffers of a and b, and it also exchanges the values of the BN_FLG_STATIC_DATA bits. So it's fast, and its execution time does not depend on any properties of the two numbers. But bestie, be real: execution time obviously differs between swapping (by calling this function) and not swapping (by not calling this function) π
BN_consttime_swap() is the careful one: it only performs the exchange if the condition is non-zero; otherwise it has no effect. It implements the exchange by exchanging the contents of the data buffers rather than the pointers to the data buffers. That's slower, but it's implemented in such a way that the execution time is not only independent of the properties of the two numbers, but also independent of the condition argument β i.e. the same for swapping or not swapping. Execution time does however grow in an approximately linear manner with the nwords argument π
β οΈ Important:BN_consttime_swap()callsabort(3)if at least one ofaorbhas fewer thannwordsdata words allocated or more thannwordsdata words are currently in use in at least one of them. Like, do not play with that π
π¦ SEE ALSO π¦
π HISTORY π
BN_swap()first appeared in OpenSSL0.9.7and has been available since OpenBSD3.2.BN_consttime_swap()first appeared in OpenSSL1.0.1gand has been available since OpenBSD5.6.
Bye bestie! This page came from Debian, dated December 19, 2021, and it's BN_SWAP(3) β mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2000 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms