BN_ADD_WORD(3ossl)
π BN_ADD_WORD(3ossl) β the OpenSSL manual page, bestie edition β¨
okay so this is a page straight out of the OpenSSL manual, and it's about the lil' shortcuts for doing math on big numbers with plain unsigned integers. group-chat recap below, no cap π«Ά
β¨ NAME β¨
BN_add_word, BN_sub_word, BN_mul_word, BN_div_word, BN_mod_word β these are the arithmetic functions on BIGNUMs with integers. yeah. that's the whole vibe. big-number math but the other operand is just a regular little integer π
π¦ 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);
like, look at them. five little functions. all iconic. all doing one (1) job π
π DESCRIPTION π
So here's the tea: these functions perform arithmetic operations on BIGNUMs with unsigned integers. and the way that they're much more efficient than the normal BIGNUM arithmetic operations?? we love a fast path. literally obsessed. π₯
BN_add_word()β addswtoa("a+=w"). that's it. that's the function. slay. πBN_sub_word()β subtractswfroma("a-=w"). bye byew, you will not be missed π¦BN_mul_word()β multipliesaandw("a*=w"). growth era β¨BN_div_word()β dividesabyw("a/=w") and returns the remainder. not me giving you two things at once, main character energy fr πBN_mod_word()β returns the remainder ofadivided byw("a%w"). stays in its lane, gives you the leftovers π
β οΈ okay important bestie: forBN_div_word()andBN_mod_word(),wmust not be0. like. do not. that's a no from me π dividing by zero is not the vibe and it is not covered by these functions.
πΈ RETURN VALUES πΈ
BN_add_word(),BN_sub_word()andBN_mul_word()return1for success,0on error. and if you're sitting there like "hmm what went wrong tho", the error codes can be obtained byERR_get_error(3)π§BN_mod_word()andBN_div_word()returna%won success and(BN_ULONG)-1if an error occurred. yes, that's the cast, keep it exactly like that, don't get cute with it π
π₯ SEE ALSO π₯
iykyk. go read those next, bestie πβ¨
π 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!! π this version of the docs is from 3.5.0, dated 2026-09-25, and it says BN_ADD_WORD(3ossl) at the bottom too β so if you ever forget where you are, that's your girl. mwah ππ«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms