BN_COPY(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’– BN_COPY(3ossl) πŸ’–

okay bestie, so this is the OpenSSL page for BN_copy, BN_dup, and BN_with_flags β€” it's giving "copying BIGNUMs" and honestly it's a whole little saga 🌸


✨ SYNOPSIS ✨

like, here's the whole vibe in code:

#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);

πŸ¦‹ DESCRIPTION πŸ¦‹

BN_copy() copies from to to. iconic. very "just take it and go" energy πŸ’…

BN_dup() creates a new BIGNUM containing the value from. fresh allocation, no cap, brand new bignum for you πŸŽ€

BN_with_flags creates a temporary shallow copy of b in dest. and bestie, this one comes with significant restrictions on the copied data. applications that do not adhere to these restrictions may encounter unexpected side effects or crashes 😭 for that reason, use of this function is discouraged β€” I'm gonna say it plainly, this is a "you'd better know what you're doing" function πŸ’€

any flags you put 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. for this reason, the following restrictions apply to the use of dest:

  • dest should be a newly allocated BIGNUM obtained via a call to BN_new(). it should not have been used for other purposes or initialised in any way 🫢
  • dest must only be used in "read-only" operations, i.e. typically those functions where the relevant parameter is declared const ✨
  • dest must be used and freed before any further subsequent use of b ⭐
fr fr, read those three bullets again. the whole function lives or dies by them πŸ™ˆ

🌈 RETURN VALUES 🌈

BN_copy() returns to on success, NULL on error. BN_dup() returns the new BIGNUM, and NULL on error. the error codes can be obtained by ERR_get_error(3) πŸ‘‘


πŸ“ SEE ALSO πŸ“

ERR_get_error(3) β€” literally the only one, go check it out bestie πŸ’œ


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 manual page BN_COPY(3ossl) from OpenSSL 3.5.6, dated 2026-04-07 β€” slay, go copy some bignums responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from