<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/lib/libcrypto/bn/bn_add.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-05-25T04:53:05+00:00</updated>
<entry>
<title>Fix previous.</title>
<updated>2025-05-25T04:53:05+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2025-05-25T04:53:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=86cba432b5dc2b5ae7e5ff806bb23d4507eab4e7'/>
<id>urn:sha1:86cba432b5dc2b5ae7e5ff806bb23d4507eab4e7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix handling of different length inputs in bn_sub().</title>
<updated>2025-05-25T04:16:36+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2025-05-25T04:16:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=007dbe05ae354e7202733f4217948276624e0e9f'/>
<id>urn:sha1:007dbe05ae354e7202733f4217948276624e0e9f</id>
<content type='text'>
In the diff_len &lt; 0 case, it incorrectly uses 0 - b[0], which mishandles
the borrow - fix this by using bn_subw_subw(). Do the same in the
diff_len &gt; 0 case for consistency. Note that this is never currently
reached since BN_usub() requires a &gt;= b.

ok beck@ tb@
</content>
</entry>
<entry>
<title>Use err_local.h rather than err.h in most places</title>
<updated>2025-05-10T05:54:39+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2025-05-10T05:54:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=41e8f99dd1625a9f0c80ce9d4383e95b18e85709'/>
<id>urn:sha1:41e8f99dd1625a9f0c80ce9d4383e95b18e85709</id>
<content type='text'>
ok jsing
</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>Provide and use various quad word primitives.</title>
<updated>2023-06-12T16:17:24+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-06-12T16:17:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=e65682b76bcfaec43a218a52db723a341bec5b90'/>
<id>urn:sha1:e65682b76bcfaec43a218a52db723a341bec5b90</id>
<content type='text'>
This includes bn_qwaddqw(), bn_qwsubqw(), bn_qwmulw_addw() and
bn_qwmulw_addqw_addw(). These can typically be optimised on architectures
that have a reasonable number of general purpose registers.

ok tb@
</content>
</entry>
<entry>
<title>Rework bn_add()/bn_sub() to operate on word arrays.</title>
<updated>2023-02-22T05:46:37+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-02-22T05:46:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=b78cccc526d31cefe3af77cef6ddab0981e8a45b'/>
<id>urn:sha1:b78cccc526d31cefe3af77cef6ddab0981e8a45b</id>
<content type='text'>
Rather than working on BIGNUMs, change bn_add()/bn_sub() to operate on word
arrays that potentially differ in length. This matches the behaviour of
s2n-bignum's bignum_add() and bignum_sub().

ok tb@
</content>
</entry>
<entry>
<title>Reimplement bn_add_words() and bn_sub_words() using bignum primitives.</title>
<updated>2023-02-16T04:42:20+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-02-16T04:42:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=3170d87c6599656e7568dca509714cf70723f0d2'/>
<id>urn:sha1:3170d87c6599656e7568dca509714cf70723f0d2</id>
<content type='text'>
This removes the effectively duplicate BN_LLONG version of bn_add_words()
and simplifies the code considerably.

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>Refactor BN_uadd() and BN_usub().</title>
<updated>2023-02-02T18:39:26+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-02-02T18:39:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=6dde0660e73e2597e14e06a5b2d1c9b84bf66d89'/>
<id>urn:sha1:6dde0660e73e2597e14e06a5b2d1c9b84bf66d89</id>
<content type='text'>
Unlike bn_add_words()/bn_sub_words(), the s2n-bignum bignum_add() and
bignum_sub() functions correctly handle inputs with differing word
lengths. This means that they can be called directly, without needing to
fix up any remaining words manually.

Split BN_uadd() in two - the default bn_add() implementation calls
bn_add_words(), before handling the carry for any remaining words.
Likewise split BN_usub() in two - the default bn_sub() implementation
calls bn_sub_words(), before handling the borrow for any remaining words.

On amd64, provide an implementation of bn_add() that calls s2n-bignum's
bignum_add() directly, similarly with an implementation of bn_sub() that
calls s2n-bignum's bignum_sub() directly.

ok tb@
</content>
</entry>
<entry>
<title>Correctly detect b &lt; a in BN_usub().</title>
<updated>2023-01-31T05:16:52+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-01-31T05:16:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=1577bb088bd6ac8a2578ab2e8af7f0ed8cbb1584'/>
<id>urn:sha1:1577bb088bd6ac8a2578ab2e8af7f0ed8cbb1584</id>
<content type='text'>
BN_usub() requires that a &gt;= b and should return an error in the case that
b &lt; a. This is currently only detected by checking the number of words in
a versus b - if they have the same number of words, the top word is not
checked and b &lt; a, which then succeeds and produces an incorrect result.

Fix this by checking for the case where a and b have an equal number of
words, yet there is a borrow returned from bn_sub_words().

ok miod@ tb@
</content>
</entry>
</feed>
