---
name: "libressl-BN_add_word"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-BN_add_word"
---

# libressl-BN\_add\_word(3)

arithmetic functions on BIGNUMs with integers

## NAME

**BN\_add\_word**, **BN\_sub\_word**, **BN\_mul\_word**, **BN\_div\_word**, **BN\_mod\_word** – arithmetic functions on BIGNUMs with integers

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

## DESCRIPTION

These functions perform arithmetic operations on BIGNUMs with unsigned integers. They are much more efficient than the normal BIGNUM arithmetic operations.

*BN\_ULONG* is a macro that expands to *unsigned* *long* (= *uint64\_t*) on \_LP64 platforms and *unsigned* *int* (= *uint32\_t*) elsewhere.

**BN\_add\_word**() adds *w* to *a* (a+=w).

**BN\_sub\_word**() subtracts *w* from *a* (a-=w).

**BN\_mul\_word**() multiplies *a* and *w* (a\*=w).

**BN\_div\_word**() divides *a* by *w* (a/=w) and returns the remainder.

**BN\_mod\_word**() returns the remainder of *a* divided by *w* (a%w).

For **BN\_div\_word**() and **BN\_mod\_word**(), *w* must not be 0.

## RETURN VALUES

**BN\_add\_word**(), **BN\_sub\_word**(), and **BN\_mul\_word**() return 1 for success or 0 on error. The error codes can be obtained by ERR\_get\_error(3).

**BN\_mod\_word**() and **BN\_div\_word**() return *a*%*w* on success and (*BN\_ULONG*)-1 if an error occurred.

## SEE ALSO

BN\_add(3), BN\_new(3)

## HISTORY

**BN\_add\_word**(), **BN\_div\_word**(), and **BN\_mod\_word**() first appeared in SSLeay 0.5.1. **BN\_sub\_word**() and **BN\_mul\_word**() first appeared in SSLeay 0.9.0. All these functions have been available since OpenBSD 2.4.

Before 0.9.8a, the return value for **BN\_div\_word**() and **BN\_mod\_word**() in case of an error was 0.
