[openssl/openssl] 8e4c92: design: Fixed size large numbers
'Tomáš Mráz' via openssl-commits <[email protected]>
| Newsgroups | gmane.comp.encryption.openssl.cvs |
|---|---|
| Message-ID | <openssl/openssl/push/refs/heads/feature/ossl_fn/[email protected]> |
Branch: refs/heads/feature/ossl_fn
Home: https://github.com/openssl/openssl
Commit: 8e4c9282802eee13c2be20c6898855f3139398e4
https://github.com/openssl/openssl/commit/8e4c9282802eee13c2be20c6898855f3139398e4
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
A doc/designs/fixed-size-large-numbers.md
Log Message:
-----------
design: Fixed size large numbers
For the longest time, we have mitigated security issues related to large
numbers (BIGNUM) and constant time in a piece-meal fashion, without really
looking at the problem from a zoomed out, holistic perspective.
An interesting aspect in this problem is that large numbers can vary in
size, and that depending on their combined sizes, the time to perform
mathematical calculations with them vary equally much, and may thereby
unintentionally leak information on those numbers.
To mitigate that sort of timing issue, we introduce fixed size numbers,
which are designed to have payload sizes that are pre-determined, usually by
the crypto system that uses them. This means that even a very small number
(let's take 1 as a ridiculous example) would have the same size payload as a
much larger number, and calculations using them would perform across all
payload bits of all input numbers combined.
These fixed size numbers primarly differ from BIGNUMs in that once they have
been allocated to a certain size, that size will not change throughout its
lifetime.
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/28522)
Commit: a5b9c8d60f6b91dbd1688e16d565b43420645b36
https://github.com/openssl/openssl/commit/a5b9c8d60f6b91dbd1688e16d565b43420645b36
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M doc/designs/fixed-size-large-numbers.md
Log Message:
-----------
Fix spelling in doc/designs/fixed-size-large-numbers.md
Found by codespell.
payed → paid
Reviewed-by: Frederik Wedel-Heinen <[email protected]>
Reviewed-by: Shane Lontis <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/28787)
Commit: 584e7138af0ab90be4e97c5bb1959ccafe633b22
https://github.com/openssl/openssl/commit/584e7138af0ab90be4e97c5bb1959ccafe633b22
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/build.info
A crypto/fn/build.info
A crypto/fn/fn_lib.c
A crypto/fn/fn_local.h
A include/crypto/fn.h
M include/crypto/types.h
M include/openssl/bn.h
A include/openssl/bn_limbs.h
M test/build.info
A test/fn_internal_test.c
A test/recipes/03-test_internal_fn.t
Log Message:
-----------
Add the fixed number type (OSSL_FN) and its allocators and deallocator
This includes a small test program that performs introspection of the
OSSL_FN, to check that diverse functions do what's expected of them.
For future compatibility reasons, the limb type OSSL_FN_ULONG is based
on BN_ULONG. This caused a slight rearrangement of public BIGNUM related
headers.
Note: experiments with changing the current BIGNUM's 'dmax' and 'top' to be
"size_t" has shown disastrous effects, due to some lower level functions
assuming that they'll receive the size in "int" form rather than "size_t"
form (on some major platforms, these two types have different sizes).
Therefore, this change deviates slightly from the design for fixed numbers
(doc/designs/fixed-size-large-numbers.md) by making OSSL_FN's 'dsize' an
"int" rather than a "size_t".
Related-to: doc/designs/fixed-size-large-numbers.md
Resolves: https://github.com/openssl/project/issues/1649
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/28784)
Commit: 2a691a034ea742aad155eb752b8d3074af589508
https://github.com/openssl/openssl/commit/2a691a034ea742aad155eb752b8d3074af589508
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_dh.c
M crypto/bn/bn_exp.c
M crypto/bn/bn_intern.c
M crypto/bn/bn_lib.c
M crypto/bn/bn_local.h
M crypto/bn/bn_nist.c
M crypto/bn/bn_prime.c
M crypto/bn/bn_rsa_fips186_5.c
M crypto/bn/bn_srp.c
M crypto/fn/fn_lib.c
M crypto/fn/fn_local.h
M include/crypto/bn.h
M include/crypto/fn.h
Log Message:
-----------
First integration of OSSL_FN into BIGNUM
This integration is made in such a way that OSSL_FN is an optional
'data' field in BIGNUM, i.e. it's allowed to be NULL even though
the BIGNUM's 'd' field is non-NULL.
The public BIGNUM API will do what it can to ensure that the 'data'
field becomes non-NULL, but remains lax on input BIGNUMs, for now.
This allows diverse internal bn constants and hacks to continue to
function with minimal friction. These constants and hacks will
incrementally be modified to use OSSL_FN where they currently use
BN_ULONG.
Related-to: doc/designs/fixed-size-large-numbers.md
Resolves: https://github.com/openssl/openssl/issues/28931
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/28930)
Commit: 2ccd86a0b16952adf006b247d505cc30e8181534
https://github.com/openssl/openssl/commit/2ccd86a0b16952adf006b247d505cc30e8181534
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_add.c
M crypto/bn/bn_blind.c
M crypto/bn/bn_conv.c
M crypto/bn/bn_div.c
M crypto/bn/bn_exp.c
M crypto/bn/bn_gf2m.c
M crypto/bn/bn_intern.c
M crypto/bn/bn_lib.c
M crypto/bn/bn_local.h
M crypto/bn/bn_mod.c
M crypto/bn/bn_mont.c
M crypto/bn/bn_mpi.c
M crypto/bn/bn_mul.c
M crypto/bn/bn_nist.c
M crypto/bn/bn_shift.c
M crypto/bn/bn_sqr.c
Log Message:
-----------
BIGNUM: Adjust the requirements on 'top' and the 'd' array for OSSL_FN compat
BIGNUM is quite sloppy with its contents of the 'd' array above 'top'. This
has been further exasperated by the 'bn_pollute' macro, which makes that slop
quite explicit.
That's fine within a purely BIGNUM context.
Enter OSSL_FN, which requires that the whole 'd' array is numerically
consistent, not just the BN_ULONGs up to 'top'.
This will, of course, cause trouble as soon as an OSSL_FN that's integrated
in a BIGNUM gets passed to OSSL_FN functions.
To ensure consistency, the following updates are made:
- [only for BIGNUMs in which 'data' is non-NULL] when decreasing 'top', all
BN_ULONGs between the preceding 'top' and the new 'top' must be made zero.
- Drop bn_pollute() entirely, as it's now more harmful than useful.
- Modify bn_check_top() to better check the consistency of BIGNUM with
integrated OSSL_FN, by checking that the part of the 'd' array between
'top' and 'dmax' is all zeroes.
- Add the function 'bn_set_top()', which is recommended to use instead of
assigning 'top' directly, as it will zeroise the intermediary limbs in
the 'd' array when 'top' decreases.
On using 'bn_set_top()', it's highly recommended to use it everywhere,
unless you can be absolutely sure that the BIGNUM that's modified will never
be checked with 'bn_check_top()' or passed to any OSSL_FN function.
Related-to: doc/designs/fixed-size-large-numbers.md
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29015)
Commit: 133420b1722c4390c36ed6aa32f87946e1ca4faa
https://github.com/openssl/openssl/commit/133420b1722c4390c36ed6aa32f87946e1ca4faa
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_local.h
Log Message:
-----------
BN_DEBUG: Refactor 'bn_check_top', 'bn_wcheck_size' into static inline functions
All the BN_DEBUG code is also moved below the definition of 'struct bignum_st',
to keep the compilers happy.
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29015)
Commit: 96dc6a9ac8f8bd48f66d0848581f2a1e16007065
https://github.com/openssl/openssl/commit/96dc6a9ac8f8bd48f66d0848581f2a1e16007065
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/err/err_all.c
M crypto/err/openssl.ec
M crypto/err/openssl.txt
M crypto/fn/build.info
A crypto/fn/fn_err.c
A crypto/fn/fn_intern.c
M crypto/fn/fn_local.h
A include/crypto/fn_intern.h
A include/crypto/fnerr.h
M include/openssl/err.h.in
M test/fn_internal_test.c
Log Message:
-----------
OSSL_FN: Add internal construction and introspection functions
These functions will be useful with other test programs without having
to include crypto/fn/fn_local.h, making them closer to real world use.
This also introduces OSSL_FN errors
Related-to: doc/designs/fixed-size-large-numbers.md
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29028)
Commit: 23fdb656c30b7846147883465dd0a0a4f160176f
https://github.com/openssl/openssl/commit/23fdb656c30b7846147883465dd0a0a4f160176f
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/build.info
A crypto/fn/fn_addsub.c
M crypto/fn/fn_local.h
M include/crypto/fn.h
M test/README-dev.md
M test/build.info
A test/fn_api_test.c
A test/recipes/11-test_fn_api.t
Log Message:
-----------
OSSL_FN: Add 'add' and 'sub' functions
This also introduces 'cmp' and 'ucmp' functions, as well as an OSSL_FN
API test program.
OSSL_FNs must not be polluted, so if a BIGNUM has a non-NULL 'data'
field, bn_pollute() will not pollute it. It may be a good idea, though,
to pollute an OSSL_FN before an operation result is written to it, for
testing purposes.
Related-to: doc/designs/fixed-size-large-numbers.md
Resolves: https://github.com/openssl/openssl/issues/28932
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29028)
Commit: 1bde024e9b695eb2349f350559ba711efe4ff6ca
https://github.com/openssl/openssl/commit/1bde024e9b695eb2349f350559ba711efe4ff6ca
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_local.h
Log Message:
-----------
OSSL_FN: Add internal functions to acquire the OSSL_FN from a BIGNUM
bn_acquire_ossl_fn() returns the OSSL_FN of a BIGNUM if there is one,
expanded to a given number of limbs.
bn_release() makes necessary adjustments to the BIGNUM after a run of
OSSL_FN operations on the OSSL instance it's backed by.
These two functions are most useful with BIGNUMs used to store operation
results, and are meant to help refactoring BN operators to be wrappers
around corresponding OSSL_FN operators.
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29028)
Commit: e3ae863a2db66e6bb58b2e91366671ca1946bc92
https://github.com/openssl/openssl/commit/e3ae863a2db66e6bb58b2e91366671ca1946bc92
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_add.c
M crypto/bn/bn_lib.c
M crypto/bn/bn_local.h
Log Message:
-----------
OSSL_FN: Wrap BIGNUM 'add' and 'sub' functions around OSSL_FN functions
This involves the following functions:
- 'BN_add'
- 'BN_sub'
- 'BN_uadd'
- 'BN_usub'
Care is taken to use the previous (now legacy) code if any of the argument
BIGNUMs isn't backed by an OSSL_FN (i.e. if its 'data' field is NULL).
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29028)
Commit: e148c8a233d9967cea7cd9b67c957f15768fe435
https://github.com/openssl/openssl/commit/e148c8a233d9967cea7cd9b67c957f15768fe435
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_mul.c
Log Message:
-----------
BIGNUM: fix setting of 'top' in 'bn_mul_fixed_top'
When 'bn_set_top()' was applied, a couple of spots were missed. This
cause some test failures.
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29028)
Commit: cf738674e17072fff2c890e8123a2d2a9dfdf607
https://github.com/openssl/openssl/commit/cf738674e17072fff2c890e8123a2d2a9dfdf607
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/build.info
A crypto/fn/fn_ctx.c
M crypto/fn/fn_lib.c
M crypto/fn/fn_local.h
M include/crypto/fn.h
M include/crypto/types.h
M test/fn_internal_test.c
Log Message:
-----------
Add the fixed number context (OSSL_FN_CTX) with (de)allocators and tests
OSSL_FN_CTX is a reimplementation of BN_CTX, with the intent to have
good enough API parity.
The distinguishing feature with OSSL_FN_CTX is that it works as an arena
allocator, so it must be allocated with an estimate of how much memory
space will be needed for all OSSL_FN instances that will be retrieved
from that arena, and a bit of overhead.
Related-to: doc/designs/fixed-size-large-numbers.md
Resolves: https://github.com/openssl/openssl/issues/28933
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29161)
Commit: 504fb345aff0c6d2576da847835fe46f11725f44
https://github.com/openssl/openssl/commit/504fb345aff0c6d2576da847835fe46f11725f44
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/asm/x86_64-gcc.c
M crypto/bn/bn_asm.c
M crypto/bn/bn_local.h
M crypto/bn/bn_mul.c
A crypto/bn/bnw_mul.c
A crypto/bn/bnw_sub.c
M crypto/bn/build.info
Log Message:
-----------
BIGNUM: separate out word-only helper functions from bn_mul.c
This separation will allow us to use the word-only helper functions
from OSSL_FN functions without pulling in functions that operate on
BIGNUMs.
This also starts the collection of source files with word-only BN
functions that haven't found their way into bn_asm.c for various
reasons.
To recognise them, they are prefixed 'bnw_' instead of 'bn_'.
While at it, consitification is done where appropriate among words
helpers.
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29203)
Commit: 74ebdc1535846709f41baa320ee9c093f6d229e6
https://github.com/openssl/openssl/commit/74ebdc1535846709f41baa320ee9c093f6d229e6
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_local.h
M crypto/bn/bnw_mul.c
M doc/internal/man3/bn_mul_words.pod
Log Message:
-----------
BIGNUM: add internal function 'bn_mul_truncated'
This is a variant of 'bn_mul_normal' that allows the result array to
have a smaller size than otherwise expected.
'bn_mul_normal' is refactored to be a wrapper around 'bn_mul_truncated',
with an assumed result size (which is the sum of the operands' sizes).
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29203)
Commit: 2532cdf821cb6720fac1ceb0ca581e2d9db54c86
https://github.com/openssl/openssl/commit/2532cdf821cb6720fac1ceb0ca581e2d9db54c86
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_intern.c
M include/crypto/fn_intern.h
Log Message:
-----------
OSSL_FN: constify some of the internal construction and introspection functions
This should have been done when they were added.
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29203)
Commit: 12e7939872e080e34db63bd2577cf8b145e83605
https://github.com/openssl/openssl/commit/12e7939872e080e34db63bd2577cf8b145e83605
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/asn1/x_long.c
M crypto/build.info
A crypto/int.c
M include/crypto/cryptlib.h
Log Message:
-----------
Add ossl_num_bits(), which returns the significant number of bits in a size_t
This existed as an isolated static function in crypto/asn1/x_long.c, but
is really a pretty generic integer function, so it will serve better by
being exactly that.
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29203)
Commit: 5ea9b46e95e95e3e58ba8cd63c89f6b3cd6a31d6
https://github.com/openssl/openssl/commit/5ea9b46e95e95e3e58ba8cd63c89f6b3cd6a31d6
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/build.info
M crypto/fn/fn_lib.c
A crypto/fn/fn_mul.c
M include/crypto/fn.h
M test/fn_api_test.c
Log Message:
-----------
OSSL_FN: Add the 'mul' function
OSSL_FN_mul() multiplies two operands. The result OSSL_FN may be of any
size, and if it's smaller than the result of multiplying the two operands,
the result is truncated to that size.
This also adds the function OSSL_FN_copy(), a counterpart for BN_copy(),
as well as an OSSL_FN API test program.
Finally, test/fn_api_test.c is updated with a 'struct test_case_st', used
to instruct test functions what numbers to operate on, and some conditions,
and the 'add' and 'sub' test functions are upgraded to use that structure
for their input.
Related-to: doc/designs/fixed-size-large-numbers.md
Resolves: https://github.com/openssl/openssl/issues/28934
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29203)
Commit: 8f77f825faf01f6b068b374e86769e201334d6de
https://github.com/openssl/openssl/commit/8f77f825faf01f6b068b374e86769e201334d6de
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_mul.c
Log Message:
-----------
OSSL_FN: Wrap BIGNUM the 'mul' function around the OSSL_FN 'mul' function
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29203)
Commit: ab79f5411473f0f304fd6570106d0470ccb48484
https://github.com/openssl/openssl/commit/ab79f5411473f0f304fd6570106d0470ccb48484
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M .clang-format
M test/fn_api_test.c
Log Message:
-----------
OSSL_FN: Add the OSSL_FN_ typedefs to .clang-format's TypeNames
Furthermore, reformatting left some weird commenting in fn_api_test.c
because of (legitimate) line breaks, so they get adjust for purpose.
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29412)
Commit: ded391d6ce0dc0ad97a990fcbf76ab2524596ff8
https://github.com/openssl/openssl/commit/ded391d6ce0dc0ad97a990fcbf76ab2524596ff8
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_addsub.c
M test/fn_api_test.c
Log Message:
-----------
OSSL_FN: Refactor OSSL_FN_add() and OSSL_FN_sub() for truncation
OSSL_FN_mul() set a path that wasn't considered for OSSL_FN_add() and
OSSL_FN_sub(); a truncated result if the result OSSL_FN isn't large
enough to contain the full result.
This is done to keep the OSSL_FN API consistent, with a (tentative)
bonus, that the function calls become more constant time accross
repeated calls with the same size for operands and result.
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/29309)
Commit: 7e7280f1b2a51f60e6d908a4cc9cea46a8fbb3f2
https://github.com/openssl/openssl/commit/7e7280f1b2a51f60e6d908a4cc9cea46a8fbb3f2
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_local.h
M crypto/fn/fn_mul.c
M test/fn_api_test.c
Log Message:
-----------
Small fixups of things that somehow passed through our tests
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Fri Apr 3 12:32:17 2026
(Merged from https://github.com/openssl/openssl/pull/29819)
Commit: 929db7822d7e6d61a96ba182e7cadeed883965be
https://github.com/openssl/openssl/commit/929db7822d7e6d61a96ba182e7cadeed883965be
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/build.info
M crypto/fn/fn_local.h
A crypto/fn/fn_sqr.c
M include/crypto/fn.h
M test/fn_api_test.c
Log Message:
-----------
OSSL_FN: Add the 'sqr' function
OSSL_FN_sqr() takes the square of on operand. The result OSSL_FN may be of
any size, and if it's smaller than the result of squaring the operand, the
result is truncated to that size.
This also adds OSSL_FN_sqr() testcases in test/fn_api_test.c
Related-to: doc/designs/fixed-size-large-numbers.md
Issue: https://github.com/openssl/project/issues/1654
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Fri Apr 3 12:32:20 2026
(Merged from https://github.com/openssl/openssl/pull/29819)
Commit: f52bf9d167086acf9fbda5efe61ae591e8f825ad
https://github.com/openssl/openssl/commit/f52bf9d167086acf9fbda5efe61ae591e8f825ad
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_sqr.c
Log Message:
-----------
OSSL_FN: Wrap the BIGNUM 'sqr' function around the OSSL_FN 'sqr' function
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Fri Apr 3 12:32:22 2026
(Merged from https://github.com/openssl/openssl/pull/29819)
Commit: 7d5084df86c585c8fee5164b47b3e6d3c51bac2a
https://github.com/openssl/openssl/commit/7d5084df86c585c8fee5164b47b3e6d3c51bac2a
Author: Igor Ustinov <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_lib.c
M crypto/fn/fn_sqr.c
M include/crypto/fn.h
Log Message:
-----------
Added OSSL_FN_truncate() function, which allows to copy a longer number
to a shorter one, truncating the high bytes.
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
MergeDate: Fri Apr 17 14:09:28 2026
(Merged from https://github.com/openssl/openssl/pull/30846)
Commit: 9a86de92b0712a6f25ec0f3bcc16f0eb998b50f8
https://github.com/openssl/openssl/commit/9a86de92b0712a6f25ec0f3bcc16f0eb998b50f8
Author: Igor Ustinov <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bnw_mul.c
M crypto/fn/fn_addsub.c
M crypto/fn/fn_ctx.c
M crypto/fn/fn_lib.c
M include/crypto/fn.h
M test/fn_api_test.c
M test/fn_internal_test.c
Log Message:
-----------
Some bugfixes for OSSL_FN:
- Fixed the stage 2 exit criteria in OSSL_FN_add() and OSSL_FN_sub().
- Fixed the calculation of a-b when a is shorter than b and borrow==1
after stage 1.
- Added sanity check in OSSL_FN_CTX_end().
- Do not set the is_dynamically_allocated flag when getting a
new OSSL_FN from OSSL_FN_CTX.
- Added units of measurement to the error message in the OSSL_FN_copy()
function.
- is_dynamically_allocated and is_securely_allocated shouldn't be
copied in OSSL_BN_copy().
- Fixed the comment in OSSL_FN_add().
- Added a comment to bn_mul_truncated() that it is a duty of the calling
function to zero out the rest of r in case of rn>an+bn.
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
MergeDate: Fri Apr 17 16:02:44 2026
(Merged from https://github.com/openssl/openssl/pull/30833)
Commit: 7e62ed1d3cfe493ca6717ab630b8b02f1a42cf07
https://github.com/openssl/openssl/commit/7e62ed1d3cfe493ca6717ab630b8b02f1a42cf07
Author: Igor Ustinov <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_ctx.c
M crypto/fn/fn_mul.c
M crypto/fn/fn_sqr.c
M include/crypto/fn.h
M test/fn_internal_test.c
Log Message:
-----------
Add an ownership token for OSSL_FN_CTX frames
This prevents ending a frame that wasn't started by the caller.
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Apr 30 09:18:52 2026
(Merged from https://github.com/openssl/openssl/pull/30886)
Commit: 3eb0b45e63c36c7c69fc0e9d65bd3a528ed508c2
https://github.com/openssl/openssl/commit/3eb0b45e63c36c7c69fc0e9d65bd3a528ed508c2
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_add.c
Log Message:
-----------
Use top to size BN add/sub results
Size the acquired result OSSL_FN from the significant operand limbs instead of
the allocated operand width. This keeps BN_uadd() and BN_usub() consistent
with the other wrappers that already use top for result sizing.
This follows a realization that applying OSSL_FN semantics onto BIGNUM too much
is pointless, and as demonstrated with BN_mul(), may be harmful, especially when
the result BIGNUM as the same as one of the operands.
Assisted-by: Pi:openai/gpt-5.5
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
MergeDate: Fri Jun 12 15:16:33 2026
(Merged from https://github.com/openssl/openssl/pull/31448)
Commit: 06bc8339d955a9f8659911aba7a1724c04a7cfef
https://github.com/openssl/openssl/commit/06bc8339d955a9f8659911aba7a1724c04a7cfef
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_mul.c
Log Message:
-----------
Acquire BN_mul result before ctx sizing
Acquire the writable result before reading operand dmax values for the
OSSL_FN_CTX arena size. This avoids stale context sizing when the result
aliases an operand and acquisition expands that BIGNUM.
Assisted-by: Pi:openai/gpt-5.5
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
MergeDate: Fri Jun 12 15:16:34 2026
(Merged from https://github.com/openssl/openssl/pull/31448)
Commit: 1763d6aff3e181fbd7cd3238297e742f0f85d5d7
https://github.com/openssl/openssl/commit/1763d6aff3e181fbd7cd3238297e742f0f85d5d7
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_sqr.c
Log Message:
-----------
Acquire BN_sqr result before ctx sizing
Acquire the writable result before reading the operand dmax value for the
OSSL_FN_CTX arena size. This avoids stale context sizing when the result
aliases the operand and acquisition expands that BIGNUM.
Assisted-by: Pi:openai/gpt-5.5
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
MergeDate: Fri Jun 12 15:16:36 2026
(Merged from https://github.com/openssl/openssl/pull/31448)
Commit: e6f42f6498bbd84061fb334c809654744db87f2c
https://github.com/openssl/openssl/commit/e6f42f6498bbd84061fb334c809654744db87f2c
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_local.h
M test/fn_internal_test.c
Log Message:
-----------
Add OSSL_FN_BITS, use it instead of 'OSSL_FN_BYTES * 8'
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
MergeDate: Sun Jun 14 08:35:04 2026
(Merged from https://github.com/openssl/openssl/pull/31452)
Commit: 0660c6375e33edf5c8e338873837f3deb8520ab6
https://github.com/openssl/openssl/commit/0660c6375e33edf5c8e338873837f3deb8520ab6
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M include/crypto/fn.h
Log Message:
-----------
Document OSSL_FN_copy zero-padding of oversized destination limbs
The OSSL_FN_copy() function already zeroes any high destination limbs
beyond the source size, but this was not stated in the public header.
Add an explicit note so callers know unused high bytes are cleared.
Assisted-by: Pi:moonshotai/kimi-k2.6
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
MergeDate: Sun Jun 14 08:35:06 2026
(Merged from https://github.com/openssl/openssl/pull/31452)
Commit: fb167b50c6c98f682c36981230421d88e6e4c396
https://github.com/openssl/openssl/commit/fb167b50c6c98f682c36981230421d88e6e4c396
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_ctx.c
M include/crypto/fn.h
Log Message:
-----------
Add OSSL_FN_CTX_peak_usage() for arena usage instrumentation
Track the maximum number of frames, numbers and limbs ever consumed
from an OSSL_FN_CTX arena during its lifetime. This allows callers
to empirically size their contexts instead of predicting precise
max_n_frames / max_n_numbers / max_n_limbs ahead of time.
These peak usages are updated whenever a frame is started or an OSSL_FN
is obtained. They never decrease, reflecting the worst-case simultaneous
allocation across all nested frames.
Assisted-by: Pi:moonshotai/kimi-k2.6
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Sun Jun 14 08:40:38 2026
(Merged from https://github.com/openssl/openssl/pull/31431)
Commit: ecdc95dfe38ea5259067a8afaf89191d26384cc1
https://github.com/openssl/openssl/commit/ecdc95dfe38ea5259067a8afaf89191d26384cc1
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M test/fn_internal_test.c
Log Message:
-----------
Add test for OSSL_FN_CTX_peak_usage
Verify that peak_usage starts at zero, rises after frame start and
allocation, and never decreases after a frame is ended.
Also correct misleading comments that claimed OSSL_FN_CTX_new()
takes a size in bytes -- the last parameter is actually max_n_limbs.
Assisted-by: Pi:moonshotai/kimi-k2.6
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Sun Jun 14 08:40:40 2026
(Merged from https://github.com/openssl/openssl/pull/31431)
Commit: 485e79dc6653ffc00db88e14139da40248b58b7b
https://github.com/openssl/openssl/commit/485e79dc6653ffc00db88e14139da40248b58b7b
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/fn/fn_ctx.c
M crypto/fn/fn_local.h
Log Message:
-----------
Expose OSSL_FN_CTX internals via fn_local.h
Move struct ossl_fn_ctx_st and struct ossl_fn_ctx_frame_st from
fn_ctx.c to fn_local.h, making them accessible to internal code in
the bn/ directory and elsewhere. Also expose
ossl_fn_ctx_calculate_arena_size() as an inline helper so callers
can determine the required arena size without duplicating the formula.
This is groundwork for BN_CTX integration.
Assisted-by: Pi:moonshotai/kimi-k2.6
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Sun Jun 14 08:40:42 2026
(Merged from https://github.com/openssl/openssl/pull/31431)
Commit: e3213b0c03cd47b0153b0a3da9f1e5bbf5d118a5
https://github.com/openssl/openssl/commit/e3213b0c03cd47b0153b0a3da9f1e5bbf5d118a5
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_ctx.c
M include/crypto/bn.h
M test/bn_internal_test.c
Log Message:
-----------
Add OSSL_FN_CTX integration with BN_CTX
Add an OSSL_FN_CTX * pointer to struct bignum_ctx, allowing a BN_CTX
to cache an OSSL_FN_CTX for use by BIGNUM wrapper functions. The
pointer is freed automatically when BN_CTX_free() is called.
Also add bn_ctx_acquire_ossl_fn_ctx() and bn_ctx_release_ossl_fn_ctx():
- acquire creates (or reuses if large enough) an OSSL_FN_CTX inside
the BN_CTX, sizing it according to the caller's needs.
- release checks that no frames remain in the cached OSSL_FN_CTX.
The acquire function respects BN_FLG_SECURE: if the BN_CTX was created
with BN_CTX_secure_new(), the OSSL_FN_CTX is also allocated in secure
memory.
Assisted-by: Pi:moonshotai/kimi-k2.6
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Sun Jun 14 08:40:44 2026
(Merged from https://github.com/openssl/openssl/pull/31431)
Commit: a7b662c2827245ababe5d72f638b24471b5aeee0
https://github.com/openssl/openssl/commit/a7b662c2827245ababe5d72f638b24471b5aeee0
Author: Richard Levitte <[email protected]>
Date: 2026-06-19 (Fri, 19 Jun 2026)
Changed paths:
M crypto/bn/bn_mul.c
M crypto/bn/bn_sqr.c
Log Message:
-----------
Use BN_CTX cached OSSL_FN_CTX in BN_mul() and BN_sqr()
The previous commit added bn_ctx_acquire_ossl_fn_ctx() and
bn_ctx_release_ossl_fn_ctx() to cache an OSSL_FN_CTX inside a BN_CTX.
However, BN_mul() and BN_sqr() were still creating and freeing their own
temporary OSSL_FN_CTX on every call, ignoring the passed-in BN_CTX entirely.
Update both functions to acquire the OSSL_FN_CTX from the BN_CTX and release
it afterwards, allowing the cached context to be reused across calls.
Assisted-by: Pi:moonshotai/kimi-k2.6
Signed-off-by: Richard Levitte <[email protected]>
Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Sun Jun 14 08:40:47 2026
(Merged from https://github.com/openssl/openssl/pull/31431)
Commit: dbf9025bc283e297cc9ed7c76960036702b0baaf
https://github.com/openssl/openssl/commit/dbf9025bc283e297cc9ed7c76960036702b0baaf
Author: Tomas Mraz <[email protected]>
Date: 2026-06-25 (Thu, 25 Jun 2026)
Changed paths:
M crypto/bn/bn_add.c
M crypto/bn/bn_mul.c
M crypto/bn/bn_sqr.c
Log Message:
-----------
Check result of acquiring OSSL_FN or OSSL_FN_CTX
These calls might return NULL because they
allocate memory.
Compare: https://github.com/openssl/openssl/compare/e183d91627bf...dbf9025bc283
To unsubscribe from these emails, change your notification settings at https://github.com/openssl/openssl/settings/notifications
--
You received this message because you are subscribed to the Google Groups "openssl-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/a/openssl.org/d/msgid/openssl-commits/openssl/openssl/push/refs/heads/feature/ossl_fn/e183d9-dbf902%40github.com.