From 0a1fd4b91548f5fdc7fc95ac3ea3264f44ea495f Mon Sep 17 00:00:00 2001 From: tb Date: Sun, 16 Apr 2023 08:55:44 +0000 Subject: [PATCH] Mark public bn_nist and ec_nist API for removal The faster nist code is rife with problematic C. While this is generally considered to be a pleonasm nowadays, here it specifically refers to aliasing issues and other flavors of undefined behavior. With compilers and standardization committees becoming seemingly more determined about making C even more unusable than it already is, this code has resulted in miscompilations and generally is a target rich environment for fuzzers to feast on. We're better off without it. Go look while it's still there. It's some of the very worst we have to offer. ok jsing --- lib/libcrypto/bn/bn.h | 4 +++- lib/libcrypto/ec/ec.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h index ba6c25ba0a0..d6f77288c11 100644 --- a/lib/libcrypto/bn/bn.h +++ b/lib/libcrypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.57 2022/12/17 15:56:25 jsing Exp $ */ +/* $OpenBSD: bn.h,v 1.58 2023/04/16 08:55:44 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -612,6 +612,7 @@ int BN_GF2m_arr2poly(const int p[], BIGNUM *a); #endif +#if !defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_INTERNAL) /* faster mod functions for the 'NIST primes' * 0 <= a < p^2 */ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); @@ -625,6 +626,7 @@ const BIGNUM *BN_get0_nist_prime_224(void); const BIGNUM *BN_get0_nist_prime_256(void); const BIGNUM *BN_get0_nist_prime_384(void); const BIGNUM *BN_get0_nist_prime_521(void); +#endif /* Primes from RFC 2409 */ BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); diff --git a/lib/libcrypto/ec/ec.h b/lib/libcrypto/ec/ec.h index 2e674c424f4..f0f2d8cf0ce 100644 --- a/lib/libcrypto/ec/ec.h +++ b/lib/libcrypto/ec/ec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec.h,v 1.32 2023/04/16 08:36:13 tb Exp $ */ +/* $OpenBSD: ec.h,v 1.33 2023/04/16 08:55:44 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -145,10 +145,12 @@ const EC_METHOD *EC_GFp_simple_method(void); */ const EC_METHOD *EC_GFp_mont_method(void); +#if !defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_INTERNAL) /** Returns GFp methods using optimized methods for NIST recommended curves * \return EC_METHOD object */ const EC_METHOD *EC_GFp_nist_method(void); +#endif #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 /** Returns 64-bit optimized methods for nistp224 -- 2.20.1