BN_ADD_WORD(3ossl)

✨ BN_ADD_WORD ✨

okay bestie, welcome to the BN_ADD_WORD(3ossl) page πŸ’– this is the OpenSSL manual, and today we're doing math with BIGNUMs and regular little unsigned ints. no cap, it's giving "why would I use full bignum arithmetic when I have a whole number" energy. let's go πŸ¦‹


🌸 NAME 🌸

BN_add_word, BN_sub_word, BN_mul_word, BN_div_word, BN_mod_word β€” literally arithmetic functions on BIGNUMs but with integers. iconic behavior honestly πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/bn.h>

int BN_add_word(BIGNUM *a, BN_ULONG w);

int BN_sub_word(BIGNUM *a, BN_ULONG w);

int BN_mul_word(BIGNUM *a, BN_ULONG w);

BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);

BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);

look at that cast, so clean, so demure 🫢


πŸ’… DESCRIPTION πŸ’…

So the whole vibe here: these functions do arithmetic operations on BIGNUMs using unsigned integers. and the tea? they are much more efficient than the normal BIGNUM arithmetic operations. main character speed, fr fr ⭐

  • BN_add_word() β€” adds w to a, aka "a+=w". simple. stunning. slay ✨
  • BN_sub_word() β€” subtracts w from a, aka "a-=w". it's giving subtraction πŸ’œ
  • BN_mul_word() β€” multiplies a and w, aka "a*=w". math but make it fashion 🌈
  • BN_div_word() β€” divides a by w ("a/=w") and returns the remainder. yes babe, you get the leftovers too πŸ“
  • BN_mod_word() β€” returns the remainder of a divided by w, aka "a%w". the classic modulo moment 😭
🚨 okay important bestie: for BN_div_word() and BN_mod_word(), w must not be 0. do not do that. not even as a joke. dividing by zero is NOT the move πŸ’€

πŸ”₯ RETURN VALUES πŸ”₯

  • BN_add_word(), BN_sub_word() and BN_mul_word() return 1 for success, 0 on error. if you got an error, you can pull the error codes with ERR_get_error(3) πŸ‘€
  • BN_mod_word() and BN_div_word() return a%w on success, and (BN_ULONG)-1 if an error occurred. so if you see that, it's not a real remainder, it's a cry for help πŸ™ˆ

🌟 SEE ALSO 🌟

go read those too, they're part of the lore 🧚


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 OpenSSL 3.5.9, dated 2026-09-29, filed under BN_ADD_WORD(3ossl) β€” periodt. go do some efficient math, you've got this πŸŽ€βœ¨

πŸ“¦ where this page comes from