<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/lib/libcrypto/bn/bn_word.c, branch OPENBSD_7_9</title>
<subtitle>A mirror of https://github.com/libressl/openbsd.git
</subtitle>
<id>https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9</id>
<link rel='self' href='https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/'/>
<updated>2025-08-30T07:54:27+00:00</updated>
<entry>
<title>Rename bn_mul_words()/bn_mul_add_words().</title>
<updated>2025-08-30T07:54:27+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2025-08-30T07:54:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=694b88dc8ad458db9997e90128806a423fec09db'/>
<id>urn:sha1:694b88dc8ad458db9997e90128806a423fec09db</id>
<content type='text'>
Most bn_.*_words() functions operate on two word arrays, however
bn_mul_words() and bn_mul_add_words() operate on one word array and
multiply by a single word. Rename these to bn_mulw_words() and
bn_mulw_add_words() to reflect this, following naming scheme that we use
for primitives.

This frees up bn_mul_words() to actually be used for multiplying two word
arrays. Rename bn_mul_normal() to bn_mul_words(), which will then become
one of the possible assembly integration points.

ok tb@
</content>
</entry>
<entry>
<title>Hide symbols in bn</title>
<updated>2023-07-08T12:21:58+00:00</updated>
<author>
<name>beck</name>
<email></email>
</author>
<published>2023-07-08T12:21:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=1dad5f352903aa46e83f0b1265298f7e1d4a9633'/>
<id>urn:sha1:1dad5f352903aa46e83f0b1265298f7e1d4a9633</id>
<content type='text'>
ok tb@
</content>
</entry>
<entry>
<title>Avoid -0 in BN_div_word().</title>
<updated>2023-03-11T14:14:54+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-03-11T14:14:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=52fd1244f8c53de73ef10d4f9511eee80489d31a'/>
<id>urn:sha1:52fd1244f8c53de73ef10d4f9511eee80489d31a</id>
<content type='text'>
Currently, the use of BN_div_word() can result in -0 - avoid this by
setting negative again, at the end of the computation.

Should fix oss-fuzz 56667.

ok tb@
</content>
</entry>
<entry>
<title>Correct sign handling in BN_add_word().</title>
<updated>2023-03-11T14:13:11+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-03-11T14:13:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=0011bd4b5ca21dd631b72942920a62fa4a90fa88'/>
<id>urn:sha1:0011bd4b5ca21dd631b72942920a62fa4a90fa88</id>
<content type='text'>
A sign handling bug was introduced to BN_add_word() in bn_word.c r1.18.
When handling addition to a negative bignum, the BN_sub_word() call can
result in the sign being flipped, which we need to account for. Use the
same code in BN_sub_word() - while not technically needed here it keeps
the code consistent.

Issue discovered by tb@

ok tb@
</content>
</entry>
<entry>
<title>Avoid negative zero.</title>
<updated>2023-02-13T04:25:37+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-02-13T04:25:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=53aa84bf6a4cfaffa003a28a5651a7f30bd74400'/>
<id>urn:sha1:53aa84bf6a4cfaffa003a28a5651a7f30bd74400</id>
<content type='text'>
Whenever setting negative to one (or when it could potentially be one),
always use BN_set_negative() since it checks for a zero valued bignum and
will not permit negative to be set in this case. Since BN_is_zero()
currently relies on top == 0, call BN_set_negative() after top has been
set (or bn_correct_top() has been called).

This fixes a long standing issue where -0 and +0 have been permitted,
however multiple code paths (such as BN_cmp()) fail to treat these as
equivalent.

Prompted by Guido Vranken who is adding negative zero fuzzing to oss-fuzz.

ok tb@
</content>
</entry>
<entry>
<title>Provide bn_div_rem_words() and make use of it.</title>
<updated>2023-01-28T16:33:34+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-01-28T16:33:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=636918f6cfde69d37b71f6ff3da1a6eb6cf4ad65'/>
<id>urn:sha1:636918f6cfde69d37b71f6ff3da1a6eb6cf4ad65</id>
<content type='text'>
Provide a function that divides a double word (h:l) by d, returning the
quotient q and the remainder r, such that q * d + r is equal to the
numerator. Call this from the three places that currently implement this
themselves.

This is implemented with some slight indirection, which allows for per
architecture implementations, replacing the define/macro tangle, which
messes with variables that are not passed to it.

Also remove a duplicate of bn_div_words() for the BN_ULLONG &amp;&amp; BN_DIV2W
case - this is already handled.

ok tb@
</content>
</entry>
<entry>
<title>Make internal header file names consistent</title>
<updated>2022-11-26T16:08:57+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2022-11-26T16:08:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=81d98bf600a381a625eb11b39a725b08c0ba547f'/>
<id>urn:sha1:81d98bf600a381a625eb11b39a725b08c0ba547f</id>
<content type='text'>
Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names
used for internal headers. Move all these headers we inherited from
OpenSSL to *_local.h, reserving the name *_internal.h for our own code.
Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h.
constant_time_locl.h is moved to constant_time.h since it's special.

Adjust all .c files in libcrypto, libssl and regress.

The diff is mechanical with the exception of tls13_quic.c, where
#include &lt;ssl_locl.h&gt; was fixed manually.

discussed with jsing,
no objection bcook
</content>
</entry>
<entry>
<title>Remove BIGNUM consistency macros.</title>
<updated>2022-11-26T13:56:33+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2022-11-26T13:56:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=9171ca1447e11e58ff2d00ba6d28293a138ae41a'/>
<id>urn:sha1:9171ca1447e11e58ff2d00ba6d28293a138ae41a</id>
<content type='text'>
Compiling with BN_DEBUG (and if you want to take it further, BN_DEBUG_RAND)
supposedly adds consistency checks to the BN code. These are rarely if ever
used and introduce a bunch of clutter in the code. Furthermore, there are
hacks in place to undo things that the debugging code does.

Remove all of this mess and instead rely on always enabled checks, more
readable code and proper regress coverage to ensure correct behaviour.

"Good riddance." tb@
</content>
</entry>
<entry>
<title>Change bn_expand()/bn_wexpand() to indicate failure/success via 0/1.</title>
<updated>2022-11-24T01:30:01+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2022-11-24T01:30:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=fb8d4760ac6775963983a2690ca829edbf8324c4'/>
<id>urn:sha1:fb8d4760ac6775963983a2690ca829edbf8324c4</id>
<content type='text'>
Currently bn_expand()/bn_wexpand() return a BIGNUM *, however none of the
callers use this (and many already treat it as a true/false value).
Change these functions to return 0 on failure and 1 on success, revising
callers that test against NULL in the process.

ok tb@
</content>
</entry>
<entry>
<title>On systems where we do not have BN_ULLONG defined (most 64-bit systems),</title>
<updated>2016-07-05T02:54:35+00:00</updated>
<author>
<name>bcook</name>
<email></email>
</author>
<published>2016-07-05T02:54:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=29ecf1f5b4cb5a580dcac440216b7127a56e3f84'/>
<id>urn:sha1:29ecf1f5b4cb5a580dcac440216b7127a56e3f84</id>
<content type='text'>
BN_mod_word() can return incorrect results if the supplied modulus is
too big, so we need to fall back to BN_div_word.

Now that BN_mod_word may fail, handle errors properly update the man page.

Thanks to Brian Smith for pointing out these fixes from BoringSSL:

https://boringssl.googlesource.com/boringssl/+/67cb49d045f04973ddba0f92fe8a8ad483c7da89
https://boringssl.googlesource.com/boringssl/+/44bedc348d9491e63c7ed1438db100a4b8a830be

ok beck@
</content>
</entry>
</feed>
