<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/lib/libcrypto/bn/bn_internal.h, branch OPENBSD_7_9_BASE</title>
<subtitle>A mirror of https://github.com/libressl/openbsd.git
</subtitle>
<id>https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9_BASE</id>
<link rel='self' href='https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9_BASE'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/'/>
<updated>2025-12-05T14:12:32+00:00</updated>
<entry>
<title>libcrypto: make most of the BN_* macro pollution internal</title>
<updated>2025-12-05T14:12:32+00:00</updated>
<author>
<name>tb</name>
<email></email>
</author>
<published>2025-12-05T14:12:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=f3f05f0cf8c30a990193e332e26fdd8e54b3f59b'/>
<id>urn:sha1:f3f05f0cf8c30a990193e332e26fdd8e54b3f59b</id>
<content type='text'>
This is a first sweep of reducing the number of terribly named macros
in bn.h More can go away. Those we need internally go to bn_local.h.
Annoyingly bn_internal.h uses some of them, so it includes bn_local.h
now. This can be cleaned up later.

ok jsing kenjiro
</content>
</entry>
<entry>
<title>Provide bn_mod_sqr_words() and call it from ec_field_element_sqr().</title>
<updated>2025-08-02T16:20:00+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2025-08-02T16:20:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=39d33c1bb185014e05def87e04f21103d92dc455'/>
<id>urn:sha1:39d33c1bb185014e05def87e04f21103d92dc455</id>
<content type='text'>
For now this still calls bn_montgomery_multiply_words(), however it can
be optimised further in the future.
</content>
</entry>
<entry>
<title>Implement EC field element operations.</title>
<updated>2025-05-25T05:12:05+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2025-05-25T05:12:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=2f7bf75477a5741ad76c3c793c7ed887b41fcceb'/>
<id>urn:sha1:2f7bf75477a5741ad76c3c793c7ed887b41fcceb</id>
<content type='text'>
Provide EC_FIELD_ELEMENT and EC_FIELD_MODULUS, which allow for operations
on fixed width fields in constant time. These can in turn be used to
implement Elliptic Curve cryptography for prime fields, without needing
to use BN. This will improve the code, reduces timing leaks and enable
further optimisation.

ok beck@ tb@
</content>
</entry>
<entry>
<title>Provide bn_mod_{add,sub,mul}_words().</title>
<updated>2025-05-25T04:58:32+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2025-05-25T04:58:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=48472c192c88669e44bdba626a93217f709ca4d4'/>
<id>urn:sha1:48472c192c88669e44bdba626a93217f709ca4d4</id>
<content type='text'>
These implement constant time modular addition, subtraction and
multiplication in the Montegomery domain.

ok tb@
</content>
</entry>
<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>Provide additional variants of bn_add_words()/bn_sub_words().</title>
<updated>2025-05-25T04:30:55+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2025-05-25T04:30:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=cbdbb6515eba8411eeb6f22618e029f1a461aa60'/>
<id>urn:sha1:cbdbb6515eba8411eeb6f22618e029f1a461aa60</id>
<content type='text'>
Move bn_add_words() and bn_sub_words() from bn_add.c to bn_add_sub.c.
These have effectively been replaced in the previous rewrites. Remove
the asserts - if bad lengths are passed the results will be incorrect
and things will fail (these should use size_t instead of int, but that
is a problem for another day).

Provide bn_sub_words_borrow(), which computes a subtraction but only
returns the resulting borrow. Provide bn_add_words_masked() and
bn_sub_words_masked(), which perform an masked addition or subtraction.
These can also be used to implement constant time addition and subtraction,
especially for reduction.

ok beck@ tb@
</content>
</entry>
<entry>
<title>Provide additional BN primitives for BN_ULLONG architectures.</title>
<updated>2023-06-25T11:42:26+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-06-25T11:42:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=8b6c9ea88db3e77ebd54669fbcaad15b57395510'/>
<id>urn:sha1:8b6c9ea88db3e77ebd54669fbcaad15b57395510</id>
<content type='text'>
On BN_ULLONG architectures, the C compiler can usually do a decent job
of optimising primitives, however it struggles to see through primitive
calls due to type narrowing. As such, providing explicit versions of
compound primitives can result in the production of more optimal code.
For example, on arm the bn_mulw_addw_addw() primitive can be replaced
with a single umaal instruction, which provides significant performance
gains.

Rather than intermingling #ifdef/#else throughout the header, the
BN_ULLONG defines are pulled up above the normal functions. This also
allows complex compound primitives to be reused. The conditionals have also
been changed from BN_LLONG to BN_ULLONG, since that is what really matters.

ok tb@
</content>
</entry>
<entry>
<title>Provide and use bn_clzw() in place of bn_word_clz().</title>
<updated>2023-06-21T07:48:41+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-06-21T07:48:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=b0edbf3f98eba4b1effd31584dae0af06eb2deff'/>
<id>urn:sha1:b0edbf3f98eba4b1effd31584dae0af06eb2deff</id>
<content type='text'>
On some architectures, we can provide an optimised (often single
instruction) count-leading-zero implementation. In order to do this
effectively, provide bn_clzw() as a static inline that can be replaced
by an architecture specific version. The default implementation defers
to the bn_word_clz() function (which may also be architecture specific).

ok tb@
</content>
</entry>
<entry>
<title>Make BN_num_bits() independent of bn-&gt;top.</title>
<updated>2023-06-21T07:41:55+00:00</updated>
<author>
<name>jsing</name>
<email></email>
</author>
<published>2023-06-21T07:41:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=88e97173c6cf4f4ec8c6138cff25d7b1c51a54e9'/>
<id>urn:sha1:88e97173c6cf4f4ec8c6138cff25d7b1c51a54e9</id>
<content type='text'>
Provide bn_bitsize(), which performs a constant time scan of a BN in order
to determine the bit size of the BN value. Use this for BN_num_bits() such
that it is no longer dependent on the bn-&gt;top value.

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>
</feed>
