<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/lib/libcrypto/bn/bn_rand.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-10T05:54:39+00:00</updated>
<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>Fix signed integer overflow in bnrand()</title>
<updated>2024-03-16T20:42:33+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2024-03-16T20:42:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=7d89192f478748e86555f35904874bd89e4ddbbc'/>
<id>urn:sha1:7d89192f478748e86555f35904874bd89e4ddbbc</id>
<content type='text'>
If more bits than INT_MAX - 7 are requested, the calculation of number
of bytes required to store the bignum triggers undefined behavior due to
signed integer overflow. This will typically result in bytes becoming
negative which will then make malloc() fail. If the ulimit should be
high enough to make malloc() succeed, there is a bad out of bounds write
in case bottom is set (an odd number was requested).

On jsing's request this does not deal with another bug which we could
catch with a similar check due to BN_bn2bin() failing later on as the
number of words in a BIGNUM is some fraction of INT_MAX.

ok jsing
</content>
</entry>
<entry>
<title>Make the bn_rand_interval() API a bit more ergonomic</title>
<updated>2023-08-03T18:53:56+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2023-08-03T18:53:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=44ff07e01874ea8be0c72bf9d20cb7f13b76cca8'/>
<id>urn:sha1:44ff07e01874ea8be0c72bf9d20cb7f13b76cca8</id>
<content type='text'>
Provide bn_rand_in_range() which is a slightly tweaked version of what was
previously called bn_rand_range().

The way bn_rand_range() is called in libcrypto, the lower bound is always
expressible as a word. In fact, most of the time it is 1, the DH code uses
a 2, the MR tests in BPSW use 3 and an exceptinally high number appears in
the Tonelli-Shanks implementation where we use 32. Converting these lower
bounds to BIGNUMs on the call site is annoying so let bn_rand_interval()
do that internally and route that through bn_rand_in_range(). This way we
can avoid using BN_sub_word().

Adjust the bn_isqrt() test to use bn_rand_in_range() since that's the
only caller that uses actual BIGNUMs as lower bounds.

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>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>whitespace</title>
<updated>2021-08-31T11:19:19+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2021-08-31T11:19:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=a5a732ed4c036cb60cfcda0d1737f1d383c2b3d0'/>
<id>urn:sha1:a5a732ed4c036cb60cfcda0d1737f1d383c2b3d0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Unindent a bit of code that performs a few too many checks to</title>
<updated>2020-09-12T17:16:36+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2020-09-12T17:16:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=ad25ca1fcd0c9ca48a2fcd6e68367cd74d82b01f'/>
<id>urn:sha1:ad25ca1fcd0c9ca48a2fcd6e68367cd74d82b01f</id>
<content type='text'>
figure out whether top &gt; 0 or top == 0.
</content>
</entry>
<entry>
<title>Avoid an out-of-bounds access in BN_rand()</title>
<updated>2020-09-12T15:24:39+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2020-09-12T15:24:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=1e0b199599db7da1624618b2509c1d58106f35f7'/>
<id>urn:sha1:1e0b199599db7da1624618b2509c1d58106f35f7</id>
<content type='text'>
If BN_rand() is called with top &gt; 0 and bits == 1, it would allocate
a buf[] of size 1 and set the top bit of buf[1].

Found in OpenSSL commit efee575ad464bfb60bf72dcb73f9b51768f4b1a1 while
looking for something else.

ok beck djm inoguchi
</content>
</entry>
<entry>
<title>Flip reversed test in bn_rand_interval().</title>
<updated>2018-11-06T06:49:45+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2018-11-06T06:49:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=a8249222cfc2738a9d25e498cd781c3b188cb9e0'/>
<id>urn:sha1:a8249222cfc2738a9d25e498cd781c3b188cb9e0</id>
<content type='text'>
ok jsing
</content>
</entry>
</feed>
