[openssl/openssl] 1d95a4: OSSL_FN: unwrap the BIGNUM 'add' and 'sub' functions

"'Richard Levitte' via openssl-commits" <[email protected]> Thu, 09 Jul 2026 08:36:37 -0700
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: 1d95a4d2bb7b5de491a14b86e47dd4a79c5791ef
      https://github.com/openssl/openssl/commit/1d95a4d2bb7b5de491a14b86e47dd4a79c5791ef
  Author: Richard Levitte <[email protected]>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    M crypto/bn/bn_add.c

  Log Message:
  -----------
  OSSL_FN: unwrap the BIGNUM 'add' and 'sub' functions

Restore the top-aware BN_add/BN_sub/BN_uadd/BN_usub implementations to
their pre-wrap form, removing the OSSL_FN call-site wrapping introduced in:

  e3ae863a2d ("OSSL_FN: Wrap BIGNUM 'add' and 'sub' functions around OSSL_FN functions")

This also reverts the in-body tuning that landed on top of that wrapping:

  3eb0b45e63 ("Use top to size BN add/sub results")
  cbc3f0b448 ("Check result of acquiring OSSL_FN or OSSL_FN_CTX")

(only the BN_add/BN_sub portions of cbc3f0b448 are affected).

The conversion helpers bn_acquire_ossl_fn()/bn_release() and the
foundational BN_MAX_WORDS hardening in bn_lib.c/bn_local.h are left in
place; BN->OSSL_FN conversion moves to top-level crypto call sites
instead.

Issue: https://github.com/openssl/project/issues/2020
Assisted-by: Pi:z-ai/glm-5.2
Signed-off-by: Richard Levitte <[email protected]>

Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jul  9 15:34:20 2026
(Merged from https://github.com/openssl/openssl/pull/31884)


  Commit: 354683faba085825034e5de05b8c16bf757f599b
      https://github.com/openssl/openssl/commit/354683faba085825034e5de05b8c16bf757f599b
  Author: Richard Levitte <[email protected]>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    M crypto/bn/bn_mul.c

  Log Message:
  -----------
  OSSL_FN: unwrap the BIGNUM 'mul' function

Restore the top-aware BN_mul implementation to its pre-wrap form, removing
the OSSL_FN call-site wrapping introduced in:

  8f77f825fa ("OSSL_FN: Wrap BIGNUM the 'mul' function around the OSSL_FN 'mul' function")

This also reverts the in-body tuning that landed on top of that wrapping:

  06bc8339d9 ("Acquire BN_mul result before ctx sizing")
  a7b662c282 ("Use BN_CTX cached OSSL_FN_CTX in BN_mul() and BN_sqr()")
  cbc3f0b448 ("Check result of acquiring OSSL_FN or OSSL_FN_CTX")

(only the BN_mul portions of a7b662c282 and cbc3f0b448 are affected).

The conversion helpers bn_acquire_ossl_fn()/bn_release() and the
foundational BN_MAX_WORDS hardening in bn_lib.c/bn_local.h are left in
place; BN->OSSL_FN conversion moves to top-level crypto call sites
instead.

Issue: https://github.com/openssl/project/issues/2020
Assisted-by: Pi:z-ai/glm-5.2
Signed-off-by: Richard Levitte <[email protected]>

Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jul  9 15:34:22 2026
(Merged from https://github.com/openssl/openssl/pull/31884)


  Commit: 7832575f9c45d3376e822c4b372a34f4c75b961a
      https://github.com/openssl/openssl/commit/7832575f9c45d3376e822c4b372a34f4c75b961a
  Author: Richard Levitte <[email protected]>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    M crypto/bn/bn_sqr.c

  Log Message:
  -----------
  OSSL_FN: unwrap the BIGNUM 'sqr' function

Restore the top-aware BN_sqr implementation to its pre-wrap form, removing
the OSSL_FN call-site wrapping introduced in:

  f52bf9d167 ("OSSL_FN: Wrap the BIGNUM 'sqr' function around the OSSL_FN 'sqr' function")

This also reverts the in-body tuning that landed on top of that wrapping:

  1763d6aff3 ("Acquire BN_sqr result before ctx sizing")
  a7b662c282 ("Use BN_CTX cached OSSL_FN_CTX in BN_mul() and BN_sqr()")
  cbc3f0b448 ("Check result of acquiring OSSL_FN or OSSL_FN_CTX")

(only the BN_sqr portions of a7b662c282 and cbc3f0b448 are affected).

The conversion helpers bn_acquire_ossl_fn()/bn_release() and the
foundational BN_MAX_WORDS hardening in bn_lib.c/bn_local.h are left in
place; BN->OSSL_FN conversion moves to top-level crypto call sites
instead.

Issue: https://github.com/openssl/project/issues/2020
Assisted-by: Pi:z-ai/glm-5.2
Signed-off-by: Richard Levitte <[email protected]>

Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jul  9 15:34:24 2026
(Merged from https://github.com/openssl/openssl/pull/31884)


  Commit: d45453c42805f78fa4690522a6657d46f17abd4b
      https://github.com/openssl/openssl/commit/d45453c42805f78fa4690522a6657d46f17abd4b
  Author: Richard Levitte <[email protected]>
  Date:   2026-07-09 (Thu, 09 Jul 2026)

  Changed paths:
    M crypto/bn/bn_lib.c
    M crypto/bn/bn_shift.c

  Log Message:
  -----------
  OSSL_FN: unwrap the BIGNUM shift and compare functions

Restore the top-aware implementations of BN_num_bits, BN_ucmp, BN_cmp,
BN_lshift1, and BN_lshift to their pre-wrap form, removing the OSSL_FN
call-site wrapping (the dual-path `if (a->data == NULL) { legacy } else
{ OSSL_FN_* }` branches, each marked TODO(FIXNUM): TO BE REMOVED)
introduced in:

  5072424737 ("OSSL_FN: Wrap BN shift and compare functions around OSSL_FN functions")

This also reverts the in-body tuning that landed on top of that wrapping:

  1a87fdb411 ("Check result of acquiring OSSL_FN")

The foundational BN_MAX_WORDS bound in bn_expand_internal (bn_lib.c) and
the bn_check_top dmax assert (bn_local.h), both from e3ae863a2d, are
preserved -- restoring bn_lib.c to 5072424737^ keeps them, since they
predate the shift/compare wrapper and were never modified by it.

The conversion helpers bn_acquire_ossl_fn()/bn_release() are left in
place; BN->OSSL_FN conversion moves to top-level crypto call sites
instead.

Issue: https://github.com/openssl/project/issues/2020
Assisted-by: Pi:z-ai/glm-5.2
Signed-off-by: Richard Levitte <[email protected]>

Reviewed-by: Igor Ustinov <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Thu Jul  9 15:34:26 2026
(Merged from https://github.com/openssl/openssl/pull/31884)


Compare: https://github.com/openssl/openssl/compare/24820bec814f...d45453c42805

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/24820b-d45453%40github.com.