BN_COPY(3ossl)
π BN_COPY π
okay bestie, gather round, because today we're talking about the BN_COPY(3ossl) page from OpenSSL β yes that OpenSSL, the one your whole internet depends on π«Ά β and it's literally all about copying BIGNUMs. iconic behavior tbh.
β¨ NAME β¨
BN_copy, BN_dup, BN_with_flags β the three besties that copy BIGNUMs around π
πΈ SYNOPSIS πΈ
#include <openssl/bn.h>
BIGNUM *BN_copy(BIGNUM *to, const BIGNUM *from);
BIGNUM *BN_dup(const BIGNUM *from);
void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags);
no cap, that's the whole vibe right there β¨
π¦ DESCRIPTION π¦
BN_copy() copies from into to. simple as that, she just moves the value over π
BN_dup() is the glow-up version β she makes a brand new BIGNUM containing the value from from. fresh allocation, fresh energy, main character moment π
BN_with_flags() β okay so this one, listen. she creates a temporary shallow copy of b in dest. and likeβ¦ it places significant restrictions on the copied data. applications that don't adhere to these restrictions may encounter unexpected side effects or crashes. so for that reason, use of this function is discouraged. not me warning you fr fr π
any flags you pass in flags will be set in dest in addition to any flags already set in b. for example, this might commonly be used to create a temporary copy of a BIGNUM with the BN_FLG_CONSTTIME flag set for constant time operations πβ¨
the temporary copy in dest will share some internal state with b. and for this reason, the following restrictions apply to the use of dest:
destshould be a newly allocatedBIGNUMobtained via a call toBN_new(). it should not have been used for other purposes or initialised in any way πdestmust only be used in "read-only" operations, i.e. typically those functions where the relevant parameter is declared "const" π§destmust be used and freed before any further subsequent use ofbπ
bestie please actually read those three bullets. this is the part where the manpage is being dead serious. shallow copy = shared state = chaos if you ignore the rules π
β RETURN VALUES β
BN_copy()returnstoon success,NULLon error πBN_dup()returns the newBIGNUM, andNULLon error β¨
the error codes can be obtained by ERR_get_error(3) π
π SEE ALSO π
ERR_get_error(3)β go read it, she's got the deets on those error codes π«Ά
π COPYRIGHT π
Copyright 2000-2017 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>.
and that's the whole page, bestie π this was BN_COPY(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β go forth and copy your BIGNUMs responsibly, and remember: read the restrictions before you BN_with_flags anything, iykyk π
β¨π¦
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms