<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/lib/libcrypto/bn, branch OPENBSD_7_6</title>
<subtitle>A mirror of https://github.com/libressl/openbsd.git
</subtitle>
<id>https://git.lua4.win/openbsd/atom?h=OPENBSD_7_6</id>
<link rel='self' href='https://git.lua4.win/openbsd/atom?h=OPENBSD_7_6'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/'/>
<updated>2024-06-24T06:43:23+00:00</updated>
<entry>
<title>libcrypto: constify most error string tables</title>
<updated>2024-06-24T06:43:23+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2024-06-24T06:43:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=c9802a5afe29675d69b605ce906d34fd89c024ac'/>
<id>urn:sha1:c9802a5afe29675d69b605ce906d34fd89c024ac</id>
<content type='text'>
These constitute the bulk of the remaining global mutable state in
libcrypto. This commit moves most of them into data.rel.ro, leaving
out ERR_str_{functs,libraries,reasons} (which require a slightly
different approach) and SYS_str_reasons which is populated on startup.

The main observation is that if ERR_load_strings() is called with a 0 lib
argument, the ERR_STRING_DATA argument is not actually modified. We could
use this fact to cast away const on the caller side and be done with it.
We can make this cleaner by adding a helper ERR_load_const_strings() which
explicitly avoids the assignment to str-&gt;error overriding the error code
already set in the table.

In order for this to work, we need to sprinkle some const in err/err.c.
CMS called ERR_load_strings() with non-0 lib argument, but this didn't
actually modify the error data since it ored in the value already stored
in the table.

Annoyingly, we need to cast const away once, namely in the call to
lh_insert() in int_err_set_item(). Fixing this would require changing
the public API and is going to be tricky since it requires that the
LHASH_DOALL_FN_* types adjust.

ok jsing
</content>
</entry>
<entry>
<title>Rewrite BN_bn2mpi() using CBB.</title>
<updated>2024-06-22T16:33:00+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-06-22T16:33:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=46f3ac9ae9fffef6fa45edd1e316dc038aac3506'/>
<id>urn:sha1:46f3ac9ae9fffef6fa45edd1e316dc038aac3506</id>
<content type='text'>
The content is effectively a u32 length prefixed field, so use
CBB_add_u32_length_prefixed(). Use BN_bn2binpad() rather than manually
padding if we need to extend and use sensible variable names so that the
code becomes more readable.

Note that since CBB can fail we now need to be able to indicate failure.
This means that BN_bn2mpi() can now return -1 when it would not have
previously (correct callers will check that BN_bn2mpi() returns a positive
length).

ok tb@
</content>
</entry>
<entry>
<title>bn_convert: zap extra blank line</title>
<updated>2024-04-17T21:55:43+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2024-04-17T21:55:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=fb1a8499f5efda58a4a49fccfe94fed7fde87d5d'/>
<id>urn:sha1:fb1a8499f5efda58a4a49fccfe94fed7fde87d5d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rewrite BN_mpi2bn() using CBS and bn_bin2bn_cbs().</title>
<updated>2024-04-17T14:47:17+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-04-17T14:47:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=501a5fea8ddd4572c9635ad63b4e7bc7f4a42b76'/>
<id>urn:sha1:501a5fea8ddd4572c9635ad63b4e7bc7f4a42b76</id>
<content type='text'>
ok tb@
</content>
</entry>
<entry>
<title>Rewrite BN_lebin2bn() using CBS.</title>
<updated>2024-04-17T14:45:46+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-04-17T14:45:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=57550569e5f6adbeb909274b4691bcb6888c78a0'/>
<id>urn:sha1:57550569e5f6adbeb909274b4691bcb6888c78a0</id>
<content type='text'>
We get an implementation of this for free by having bn_bin2bn_cbs() use
CBS_get_u8() instead of CBS_get_last_u8().

ok tb@
</content>
</entry>
<entry>
<title>Invert BN_BITS2 handling in bn_bin2bn_cbs() and bn_hex2bn_cbs().</title>
<updated>2024-04-16T13:14:46+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-04-16T13:14:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=a2d33edef120713fca38edea57eba33f8e3ba217'/>
<id>urn:sha1:a2d33edef120713fca38edea57eba33f8e3ba217</id>
<content type='text'>
This results in simpler code.

Suggested by tb@ during review.
</content>
</entry>
<entry>
<title>Rewrite BN_bin2bn() using CBS.</title>
<updated>2024-04-16T13:11:37+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-04-16T13:11:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=8616d66dbd9b93e2acc6f471938de8f646a5db24'/>
<id>urn:sha1:8616d66dbd9b93e2acc6f471938de8f646a5db24</id>
<content type='text'>
ok tb@
</content>
</entry>
<entry>
<title>Provide bn_expand_bytes().</title>
<updated>2024-04-16T13:07:14+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-04-16T13:07:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=83ae8eaecf53bc2febd138f92b30798eaea265a5'/>
<id>urn:sha1:83ae8eaecf53bc2febd138f92b30798eaea265a5</id>
<content type='text'>
This will be used in an upcoming change.

ok tb@
</content>
</entry>
<entry>
<title>Rename bn_expand() to bn_expand_bits().</title>
<updated>2024-04-16T13:04:05+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-04-16T13:04:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=0cf1dfb91461e728170657af9f15ff5bbb00d2f9'/>
<id>urn:sha1:0cf1dfb91461e728170657af9f15ff5bbb00d2f9</id>
<content type='text'>
Also change the bits type from int to size_t, since that's what the callers
are passing and we can avoid unnecessary input validation.

ok tb@
</content>
</entry>
<entry>
<title>Prevent negative zero from being created via BN bit functions.</title>
<updated>2024-04-15T14:35:25+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2024-04-15T14:35:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=8cf5100e6cbe503f43b30d286c72d8e015986786'/>
<id>urn:sha1:8cf5100e6cbe503f43b30d286c72d8e015986786</id>
<content type='text'>
Both BN_clear_bit() and BN_mask_bits() can create zero values - in both
cases ensure that the negative sign is correctly handled if the value
becomes zero.

Thanks to Guido Vranken for providing a reproducer.

Fixes oss-fuzz #67901

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