[openssl] master update

Richard Levitte levitte at openssl.org
Thu Nov 7 10:40:20 UTC 2019


The branch master has been updated
       via  54a0d4ceb28d53f5b00a27fc5ca8ff8f0ddf9036 (commit)
       via  686923b19824546f5c76a012e41e1fc7141ae712 (commit)
       via  a3844061df7d0e588d018370efd1d309f856e6f3 (commit)
       via  285a0db396ff3a7801c199b6d812eae298178249 (commit)
       via  9fd9951e4b49051c8f69157b478070951c43c5c4 (commit)
       via  00db8c60aaecd2ff9b0a5d9fd10c7771a1e1a73e (commit)
       via  936c2b9e933eacae80d3489e5f7316589f3e9a07 (commit)
       via  a6a4d0acd23b3fc85041d9096b67bcf18ccb635c (commit)
      from  ccd9e70d4efeb2c7a258ba0a567b898174286b13 (commit)


- Log -----------------------------------------------------------------
commit 54a0d4ceb28d53f5b00a27fc5ca8ff8f0ddf9036
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:48:33 2019 +0100

    Update INSTALL to document the changed '--api' and 'no-deprecated'
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

commit 686923b19824546f5c76a012e41e1fc7141ae712
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:38:24 2019 +0100

    include/openssl/asn1.h: Remove version dependent inclusion of <openssl/bn.h>
    
    It's unclear if this dependency was because ASN1 functions that use
    BIGNUM didn't exist before 1.1.0, or if it was a mistaken attempt at
    deprecation.  Since there exist ASN1 functions using BIGNUM now, it
    seems pointless to keep that check, and unnecessarily including
    <openssl/bn.h> should be harmless either way.
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

commit a3844061df7d0e588d018370efd1d309f856e6f3
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:37:17 2019 +0100

    Update the check surround the BN_zero() implementation
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

commit 285a0db396ff3a7801c199b6d812eae298178249
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:36:44 2019 +0100

    Update some inclusions of <openssl/macros.h>
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

commit 9fd9951e4b49051c8f69157b478070951c43c5c4
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:35:12 2019 +0100

    include/openssl/opensslconf.h.in: remove spurious HEADER_FILE_H definition
    
    This macro was never defined in existing releases, there's no reason
    for us to create a macro that we immediately deprecate.
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

commit 00db8c60aaecd2ff9b0a5d9fd10c7771a1e1a73e
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:34:09 2019 +0100

    Update source files for pre-3.0 deprecation
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

commit 936c2b9e933eacae80d3489e5f7316589f3e9a07
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:28:50 2019 +0100

    Update source files for deprecation at 3.0
    
    Previous macros suggested that from 3.0, we're only allowed to
    deprecate things at a major version.  However, there's no policy
    stating this, but there is for removal, saying that to remove
    something, it must have been deprecated for 5 years, and that removal
    can only happen at a major version.
    
    Meanwhile, the semantic versioning rule is that deprecation should
    trigger a MINOR version update, which is reflected in the macro names
    as of this change.
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

commit a6a4d0acd23b3fc85041d9096b67bcf18ccb635c
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Nov 5 17:00:33 2019 +0100

    Change the logic and behaviour surrounding '--api' and 'no-deprecated'
    
    At some point in time, there was a 'no-deprecated' configuration
    option, which had the effect of hiding all declarations of deprecated
    stuff, i.e. make the public API look like they were all removed.
    
    At some point in time, there was a '--api' configuration option, which
    had the effect of having the public API look like it did in the version
    given as value, on a best effort basis.  In practice, this was used to
    get different implementations of BN_zero(), depending on the desired
    API compatibility level.
    
    At some later point in time, '--api' was changed to mean the same as
    'no-deprecated', but only for the deprecations up to and including the
    desired API compatibility level.  BN_zero() has been set to the
    pre-1.0.0 implementation ever since, unless 'no-deprecation' has been
    given.
    
    This change turns these options back to their original meaning, but
    with the slight twist that when combined, i.e. both '--api' and
    'no-deprecated' is given, the declarations that are marked deprecated
    up to an including the desired API compatibility level are hidden,
    simulating that they have been removed.
    
    If no desired API compatibility level has been given, then
    configuration sets the current OpenSSL version by default.
    
    Furthermore, the macro OPENSSL_API_LEVEL is now used exclusively to
    check what API compatibility level is desired.  For checking in code
    if `no-deprecated` has been configured for the desired API
    compatibility level, macros for each supported level is generated,
    such as OPENSSL_NO_DEPRECATED_1_1_1, corresponding to the use of
    DEPRECATEDIN_ macros, such as DEPRECATEDIN_1_1_1().
    
    Just like before, to set an API compatibility level when building an
    application, define OPENSSL_API_COMPAT with an appropriate value.  If
    it's desirable to hide deprecated functions up to and including that
    level, additionally define OPENSSL_NO_DEPRECATED (the value is
    ignored).
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10364)

-----------------------------------------------------------------------

Summary of changes:
 CHANGES                                           |  35 +++-
 Configure                                         |  51 +++---
 INSTALL                                           |  29 +--
 apps/enc.c                                        |   2 +-
 apps/speed.c                                      |   8 +-
 crypto/aes/aes_ige.c                              |   2 +-
 crypto/asn1/asn1_item_list.h                      |   4 +-
 crypto/asn1/asn1_lib.c                            |   2 +-
 crypto/asn1/x_long.c                              |   2 +-
 crypto/bio/b_sock.c                               |   6 +-
 crypto/bn/bn_depr.c                               |   2 +-
 crypto/bn/bn_lib.c                                |   2 +-
 crypto/bn/bn_prime.c                              |   2 +-
 crypto/conf/conf_def.c                            |   6 +-
 crypto/conf/conf_def.h                            |   2 +-
 crypto/conf/conf_sap.c                            |   2 +-
 crypto/conf/keysets.pl                            |   2 +-
 crypto/dh/dh_depr.c                               |   2 +-
 crypto/dsa/dsa_depr.c                             |   2 +-
 crypto/dsa/dsa_sign.c                             |   2 +-
 crypto/ec/ec_lib.c                                |   8 +-
 crypto/ec/ec_oct.c                                |   2 +-
 crypto/ec/ecdh_kdf.c                              |   2 +-
 crypto/engine/eng_all.c                           |   5 +-
 crypto/err/err.c                                  |  14 +-
 crypto/evp/e_old.c                                |   2 +-
 crypto/hmac/hmac.c                                |   2 +-
 crypto/mem_dbg.c                                  |   2 +-
 crypto/pkcs12/p12_sbag.c                          |   2 +-
 crypto/rand/rand_lib.c                            |   2 +-
 crypto/rand/rand_win.c                            |   2 +-
 crypto/rsa/rsa_depr.c                             |   2 +-
 crypto/srp/srp_vfy.c                              |   2 +-
 crypto/x509/x509_d2.c                             |   2 +-
 crypto/x509/x509cset.c                            |   2 +-
 engines/e_afalg_err.h                             |   2 +-
 engines/e_capi_err.h                              |   2 +-
 engines/e_dasync_err.h                            |   2 +-
 engines/e_ossltest_err.h                          |   2 +-
 fuzz/asn1.c                                       |   4 +-
 include/crypto/sm2err.h                           |   2 +-
 include/internal/dsoerr.h                         |   2 +-
 include/internal/propertyerr.h                    |   2 +-
 include/openssl/aes.h                             |   4 +-
 include/openssl/asn1.h                            |   6 +-
 include/openssl/asn1err.h                         |   4 +-
 include/openssl/asn1t.h                           |   4 +-
 include/openssl/async.h                           |   2 +-
 include/openssl/asyncerr.h                        |   4 +-
 include/openssl/bio.h                             |   6 +-
 include/openssl/bioerr.h                          |   4 +-
 include/openssl/blowfish.h                        |   2 +-
 include/openssl/bn.h                              |  14 +-
 include/openssl/bnerr.h                           |   4 +-
 include/openssl/buffer.h                          |   4 +-
 include/openssl/buffererr.h                       |   4 +-
 include/openssl/camellia.h                        |   2 +-
 include/openssl/cast.h                            |   2 +-
 include/openssl/cmac.h                            |   2 +-
 include/openssl/cmperr.h                          |   2 +-
 include/openssl/cms.h                             |   2 +-
 include/openssl/cmserr.h                          |   4 +-
 include/openssl/comp.h                            |   6 +-
 include/openssl/comperr.h                         |   4 +-
 include/openssl/conf.h                            |   8 +-
 include/openssl/conf_api.h                        |   2 +-
 include/openssl/conferr.h                         |   4 +-
 include/openssl/crmferr.h                         |   2 +-
 include/openssl/crypto.h                          |  26 +--
 include/openssl/cryptoerr.h                       |   4 +-
 include/openssl/ct.h                              |   2 +-
 include/openssl/cterr.h                           |   4 +-
 include/openssl/des.h                             |   2 +-
 include/openssl/dh.h                              |   6 +-
 include/openssl/dherr.h                           |   4 +-
 include/openssl/dsa.h                             |  10 +-
 include/openssl/dsaerr.h                          |   4 +-
 include/openssl/dtls1.h                           |   4 +-
 include/openssl/e_os2.h                           |   2 +-
 include/openssl/ebcdic.h                          |   2 +-
 include/openssl/ec.h                              |  34 ++--
 include/openssl/ecerr.h                           |   4 +-
 include/openssl/engine.h                          |   8 +-
 include/openssl/engineerr.h                       |   4 +-
 include/openssl/err.h                             |  24 +--
 include/openssl/esserr.h                          |   2 +-
 include/openssl/evp.h                             |   8 +-
 include/openssl/evperr.h                          |   4 +-
 include/openssl/hmac.h                            |   4 +-
 include/openssl/idea.h                            |   4 +-
 include/openssl/kdf.h                             |   2 +-
 include/openssl/lhash.h                           |   4 +-
 include/openssl/macros.h                          | 205 +++++++++++++++-------
 include/openssl/md2.h                             |   2 +-
 include/openssl/md4.h                             |   2 +-
 include/openssl/md5.h                             |   2 +-
 include/openssl/mdc2.h                            |   2 +-
 include/openssl/modes.h                           |   2 +-
 include/openssl/objects.h                         |   4 +-
 include/openssl/objectserr.h                      |   4 +-
 include/openssl/ocsp.h                            |   2 +-
 include/openssl/ocsperr.h                         |   4 +-
 include/openssl/opensslconf.h.in                  |   3 -
 include/openssl/opensslv.h.in                     |  11 +-
 include/openssl/pem.h                             |   2 +-
 include/openssl/pem2.h                            |   2 +-
 include/openssl/pemerr.h                          |   4 +-
 include/openssl/pkcs12.h                          |   4 +-
 include/openssl/pkcs12err.h                       |   4 +-
 include/openssl/pkcs7.h                           |   2 +-
 include/openssl/pkcs7err.h                        |   4 +-
 include/openssl/rand.h                            |   4 +-
 include/openssl/rand_drbg.h                       |   4 +-
 include/openssl/randerr.h                         |   4 +-
 include/openssl/rc2.h                             |   2 +-
 include/openssl/rc4.h                             |   2 +-
 include/openssl/rc5.h                             |   2 +-
 include/openssl/ripemd.h                          |   2 +-
 include/openssl/rsa.h                             |   8 +-
 include/openssl/rsaerr.h                          |   4 +-
 include/openssl/safestack.h                       |   2 +-
 include/openssl/seed.h                            |   2 +-
 include/openssl/sha.h                             |   2 +-
 include/openssl/srp.h                             |   2 +-
 include/openssl/srtp.h                            |   2 +-
 include/openssl/ssl.h                             |  22 +--
 include/openssl/ssl2.h                            |   2 +-
 include/openssl/ssl3.h                            |   2 +-
 include/openssl/sslerr.h                          |   4 +-
 include/openssl/stack.h                           |   4 +-
 include/openssl/store.h                           |   2 +-
 include/openssl/storeerr.h                        |   4 +-
 include/openssl/symhacks.h                        |   2 +-
 include/openssl/tls1.h                            |   4 +-
 include/openssl/ts.h                              |   4 +-
 include/openssl/tserr.h                           |   4 +-
 include/openssl/txt_db.h                          |   2 +-
 include/openssl/ui.h                              |   6 +-
 include/openssl/uierr.h                           |   4 +-
 include/openssl/whrlpool.h                        |   2 +-
 include/openssl/x509.h                            |   8 +-
 include/openssl/x509_vfy.h                        |  10 +-
 include/openssl/x509err.h                         |   4 +-
 include/openssl/x509v3.h                          |   4 +-
 include/openssl/x509v3err.h                       |   4 +-
 providers/common/include/prov/providercommonerr.h |   2 +-
 ssl/methods.c                                     |   3 +-
 ssl/ssl_lib.c                                     |   4 +-
 test/asn1_decode_test.c                           |   4 +-
 test/asn1_encode_test.c                           |   6 +-
 test/igetest.c                                    |   4 +-
 util/libcrypto.num                                |  56 +++---
 util/libssl.num                                   |   2 +-
 util/mkdef.pl                                     |  14 +-
 util/mkerr.pl                                     |   2 +-
 util/perl/OpenSSL/ParseC.pm                       |  11 +-
 156 files changed, 566 insertions(+), 455 deletions(-)

diff --git a/CHANGES b/CHANGES
index 91c9bc7f06..23a86ddcd1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,32 @@
 
  Changes between 1.1.1 and 3.0.0 [xx XXX xxxx]
 
+  *) Change the interpretation of the '--api' configuration option to
+     mean that this is a desired API compatibility level with no
+     further meaning.  The previous interpretation, that this would
+     also mean to remove all deprecated symbols up to and including
+     the given version, no requires that 'no-deprecated' is also used
+     in the configuration.
+
+     When building applications, the desired API compatibility level
+     can be set with the OPENSSL_API_COMPAT macro like before.  For
+     API compatibility version below 3.0, the old style numerical
+     value is valid as before, such as -DOPENSSL_API_COMPAT=0x10100000L.
+     For version 3.0 and on, the value is expected to be the decimal
+     value calculated from the major and minor version like this:
+
+         MAJOR * 10000 + MINOR * 100
+
+     Examples:
+
+         -DOPENSSL_API_COMPAT=30000             For 3.0
+         -DOPENSSL_API_COMPAT=30200             For 3.2
+
+     To hide declarations that are deprecated up to and including the
+     given API compatibility level, -DOPENSSL_NO_DEPRECATED must be
+     given when building the application as well.
+     [Richard Levitte]
+
   *) Added the X509_LOOKUP_METHOD called X509_LOOKUP_store, to allow
      access to certificate and CRL stores via URIs and OSSL_STORE
      loaders.
@@ -360,15 +386,6 @@
   *) Change the license to the Apache License v2.0.
      [Richard Levitte]
 
-  *) Change the possible version information given with OPENSSL_API_COMPAT.
-     It may be a pre-3.0.0 style numerical version number as it was defined
-     in 1.1.0, and it may also simply take the major version number.
-
-     Because of the version numbering of pre-3.0.0 releases, the values 0,
-     1 and 2 are equivalent to 0x00908000L (0.9.8), 0x10000000L (1.0.0) and
-     0x10100000L (1.1.0), respectively.
-     [Richard Levitte]
-
   *) Switch to a new version scheme using three numbers MAJOR.MINOR.PATCH.
 
      o Major releases (indicated by incrementing the MAJOR release number)
diff --git a/Configure b/Configure
index 19b05b12ad..8087da52e6 100755
--- a/Configure
+++ b/Configure
@@ -45,9 +45,11 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lx
 #
 # --cross-compile-prefix Add specified prefix to binutils components.
 #
-# --api         One of 0.9.8, 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1, or 3.0.0 / 3.
-#               Do not compile support for interfaces deprecated as of the
-#               specified OpenSSL version.
+# --api         One of 0.9.8, 1.0.0, 1.0.1, 1.0.2, 1.1.0, 1.1.1, or 3.0
+#               Define the public APIs as they were for that version
+#               including patch releases.  If 'no-deprecated' is also
+#               given, do not compile support for interfaces deprecated
+#               up to and including the specified OpenSSL version.
 #
 # no-hw-xxx     do not compile support for specific crypto hardware.
 #               Generic OpenSSL-style methods relating to this support
@@ -186,15 +188,24 @@ our $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
 #
 # API compatibility name to version number mapping.
 #
-my $maxapi = "3.0.0";           # API for "no-deprecated" builds
 my $apitable = {
-    "3.0.0" => 3,
-    "1.1.1" => 2,
-    "1.1.0" => 2,
-    "1.0.2" => 1,
-    "1.0.1" => 1,
-    "1.0.0" => 1,
-    "0.9.8" => 0,
+    # This table expresses when API additions or changes can occur.
+    # The numbering used changes from 3.0 and on because we updated
+    # (solidified) our version numbering scheme at that point.
+
+    # From 3.0 and on, we internalise the given version number in dedcimal
+    # as MAJOR * 10000 + MINOR * 100 + 0
+    "3.0.0" => 30000,
+    "3.0"   => 30000,
+
+    # Note that before 3.0, we didn't have the same version number scheme.
+    # Still, the numbering we use here covers what we need.
+    "1.1.1" => 10101,
+    "1.1.0" => 10100,
+    "1.0.2" => 10002,
+    "1.0.1" => 10001,
+    "1.0.0" => 10000,
+    "0.9.8" =>   908,
 };
 
 our %table = ();
@@ -844,7 +855,10 @@ while (@argvcopy)
                         }
                 elsif (/^--api=(.*)$/)
                         {
-                        $config{api}=$1;
+                        my $api = $1;
+                        die "Unknown API compatibility level $api"
+                                unless defined $apitable->{$api};
+                        $config{api}=$apitable->{$api};
                         }
                 elsif (/^--libdir=(.*)$/)
                         {
@@ -961,10 +975,6 @@ while (@argvcopy)
                 }
         }
 
-if (defined($config{api}) && !exists $apitable->{$config{api}}) {
-        die "***** Unsupported api compatibility level: $config{api}\n",
-}
-
 if (keys %deprecated_options)
         {
         warn "***** Deprecated options: ",
@@ -1365,11 +1375,6 @@ unless($disabled{threads}) {
     push @{$config{openssl_feature_defines}}, "OPENSSL_THREADS";
 }
 
-# With "deprecated" disable all deprecated features.
-if (defined($disabled{"deprecated"})) {
-        $config{api} = $maxapi;
-}
-
 my $no_shared_warn=0;
 if ($target{shared_target} eq "")
         {
@@ -1503,6 +1508,8 @@ foreach (sort split(/\s+/,$target{bn_ops})) {
 die "Exactly one of SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT can be set in bn_ops\n"
     if $count > 1;
 
+$config{api} = $config{major} * 10000 + $config{minor} * 100
+    unless $config{api};
 
 # Hack cflags for better warnings (dev option) #######################
 
@@ -1514,7 +1521,7 @@ $config{cxxflags} = [ map { (my $x = $_) =~ s/([\\\"])/\\$1/g; $x }
                           @{$config{cxxflags}} ] if $config{CXX};
 
 $config{openssl_api_defines} = [
-    "OPENSSL_MIN_API=".($apitable->{$config{api} // ""} // -1)
+    "OPENSSL_CONFIGURED_API=".$config{api}
 ];
 
 my @strict_warnings_collection=();
diff --git a/INSTALL b/INSTALL
index c818ed72b1..0bddf761a1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -141,14 +141,20 @@
  --openssldir depend in what configuration is used and what Windows
  implementation OpenSSL is built on.  More notes on this in NOTES.WIN):
 
-  --api=x.y.z
-                   Don't build with support for deprecated APIs below the
-                   specified version number. For example "--api=1.1.0" will
-                   remove support for all APIS that were deprecated in OpenSSL
-                   version 1.1.0 or below. This is a rather specialized option
-                   for developers. If you just intend to remove all deprecated
-                   APIs entirely (up to the current version), it is easier
-                   to add the 'no-deprecated' option instead (see below).
+  --api=x.y[.z]
+                   Build the OpenSSL libraries to support the API for
+                   the specified version.  If "no-deprecated" is also
+                   given, don't build with support for deprecated APIs
+                   in or below the specified version number. For example
+                   "--api=1.1.0" with "no-deprecated" will remove
+                   support for all APIS that were deprecated in
+                   OpenSSL version 1.1.0 or below.
+                   This is a rather specialized option for developers.
+                   If you just intend to remove all deprecated APIs
+                   entirely (up to the current version), only specify
+                   "-no-deprecated" (see below).
+                   If "--api" isn't given, it defaults to the current
+                   OpenSSL minor version.
 
   --cross-compile-prefix=PREFIX
                    The PREFIX to include in front of commands for your
@@ -356,9 +362,10 @@
                    Don't build support for Certificate Transparency.
 
   no-deprecated
-                   Don't build with support for any deprecated APIs. This is the
-                   same as using "--api" and supplying the latest version
-                   number.
+                   Don't build with support for deprecated APIs up
+                   until and including the version given with
+                   "--api" (or the current version of "--api" wasn't
+                   given).
 
   no-dgram
                    Don't build support for datagram based BIOs. Selecting this
diff --git a/apps/enc.c b/apps/enc.c
index 611d0536bc..243cc1280c 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -51,7 +51,7 @@ typedef enum OPTION_choice {
 const OPTIONS enc_options[] = {
     {"help", OPT_HELP, '-', "Display this summary"},
     {"list", OPT_LIST, '-', "List ciphers"},
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     {"ciphers", OPT_LIST, '-', "Alias for -list"},
 #endif
     {"in", OPT_IN, '<', "Input file"},
diff --git a/apps/speed.c b/apps/speed.c
index 7117c6f068..75d3149ae0 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -169,7 +169,7 @@ static int DES_ede3_cbc_encrypt_loop(void *args);
 static int AES_cbc_128_encrypt_loop(void *args);
 static int AES_cbc_192_encrypt_loop(void *args);
 static int AES_cbc_256_encrypt_loop(void *args);
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 static int AES_ige_128_encrypt_loop(void *args);
 static int AES_ige_192_encrypt_loop(void *args);
 static int AES_ige_256_encrypt_loop(void *args);
@@ -436,7 +436,7 @@ static const OPT_PAIR doit_choices[] = {
     {"aes-128-cbc", D_CBC_128_AES},
     {"aes-192-cbc", D_CBC_192_AES},
     {"aes-256-cbc", D_CBC_256_AES},
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     {"aes-128-ige", D_IGE_128_AES},
     {"aes-192-ige", D_IGE_192_AES},
     {"aes-256-ige", D_IGE_256_AES},
@@ -896,7 +896,7 @@ static int AES_cbc_256_encrypt_loop(void *args)
     return count;
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 static int AES_ige_128_encrypt_loop(void *args)
 {
     loopargs_t *tempargs = *(loopargs_t **) args;
@@ -2565,7 +2565,7 @@ int speed_main(int argc, char **argv)
         }
     }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     if (doit[D_IGE_128_AES]) {
         for (testnum = 0; testnum < size_num; testnum++) {
             print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][testnum],
diff --git a/crypto/aes/aes_ige.c b/crypto/aes/aes_ige.c
index b95d3d4ba6..3300e518d2 100644
--- a/crypto/aes/aes_ige.c
+++ b/crypto/aes/aes_ige.c
@@ -9,7 +9,7 @@
 
 #include "internal/cryptlib.h"
 
-#if OPENSSL_API_3
+#ifdef OPENSSL_NO_DEPRECATED_3_0
 NON_EMPTY_TRANSLATION_UNIT
 #else
 
diff --git a/crypto/asn1/asn1_item_list.h b/crypto/asn1/asn1_item_list.h
index b0b607a0db..c8727e5790 100644
--- a/crypto/asn1/asn1_item_list.h
+++ b/crypto/asn1/asn1_item_list.h
@@ -78,7 +78,7 @@ static ASN1_ITEM_EXP *asn1_item_list[] = {
     ASN1_ITEM_ref(IPAddressRange),
 #endif
     ASN1_ITEM_ref(ISSUING_DIST_POINT),
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     ASN1_ITEM_ref(LONG),
 #endif
     ASN1_ITEM_ref(NAME_CONSTRAINTS),
@@ -164,7 +164,7 @@ static ASN1_ITEM_EXP *asn1_item_list[] = {
     ASN1_ITEM_ref(X509_SIG),
     ASN1_ITEM_ref(X509_VAL),
     ASN1_ITEM_ref(X509),
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     ASN1_ITEM_ref(ZLONG),
 #endif
     ASN1_ITEM_ref(INT32),
diff --git a/crypto/asn1/asn1_lib.c b/crypto/asn1/asn1_lib.c
index 6399de7c2a..52eb16ba9c 100644
--- a/crypto/asn1/asn1_lib.c
+++ b/crypto/asn1/asn1_lib.c
@@ -383,7 +383,7 @@ const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
     return x->data;
 }
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 unsigned char *ASN1_STRING_data(ASN1_STRING *x)
 {
     return x->data;
diff --git a/crypto/asn1/x_long.c b/crypto/asn1/x_long.c
index 89d5e838a3..76d6674b50 100644
--- a/crypto/asn1/x_long.c
+++ b/crypto/asn1/x_long.c
@@ -11,7 +11,7 @@
 #include "internal/cryptlib.h"
 #include <openssl/asn1t.h>
 
-#if OPENSSL_API_3
+#ifdef OPENSSL_NO_DEPRECATED_3_0
 NON_EMPTY_TRANSLATION_UNIT
 #else
 
diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c
index 8e40d8644c..78bcffdb13 100644
--- a/crypto/bio/b_sock.c
+++ b/crypto/bio/b_sock.c
@@ -24,7 +24,7 @@
 static int wsa_init_done = 0;
 # endif
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 int BIO_get_host_ip(const char *str, unsigned char *ip)
 {
     BIO_ADDRINFO *res = NULL;
@@ -103,7 +103,7 @@ int BIO_sock_error(int sock)
         return j;
 }
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 struct hostent *BIO_gethostbyname(const char *name)
 {
     /*
@@ -195,7 +195,7 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
     return i;
 }
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 int BIO_get_accept_socket(char *host, int bind_mode)
 {
     int s = INVALID_SOCKET;
diff --git a/crypto/bn/bn_depr.c b/crypto/bn/bn_depr.c
index 4dbbdc3814..9c1c3d57c8 100644
--- a/crypto/bn/bn_depr.c
+++ b/crypto/bn/bn_depr.c
@@ -13,7 +13,7 @@
  */
 
 #include <openssl/opensslconf.h>
-#if OPENSSL_API_0_9_8
+#ifdef OPENSSL_NO_DEPRECATED_0_9_8
 NON_EMPTY_TRANSLATION_UNIT
 #else
 
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index bdd4caa21d..1e62b96874 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -15,7 +15,7 @@
 #include "internal/constant_time.h"
 
 /* This stuff appears to be completely unused, so is deprecated */
-#if !OPENSSL_API_0_9_8
+#ifndef OPENSSL_NO_DEPRECATED_0_9_8
 /*-
  * For a 32 bit machine
  * 2 -   4 ==  128
diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c
index fd1c3c3088..ce5789ea3e 100644
--- a/crypto/bn/bn_prime.c
+++ b/crypto/bn/bn_prime.c
@@ -224,7 +224,7 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
 }
 #endif
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
                    BN_GENCB *cb)
 {
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index a43225ecf7..a8581d7320 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -54,7 +54,7 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx);
 
 static CONF *def_create(CONF_METHOD *meth);
 static int def_init_default(CONF *conf);
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 static int def_init_WIN32(CONF *conf);
 #endif
 static int def_destroy(CONF *conf);
@@ -83,7 +83,7 @@ CONF_METHOD *NCONF_default(void)
     return &default_method;
 }
 
-#if ! OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 static CONF_METHOD WIN32_method = {
     "WIN32",
     def_create,
@@ -128,7 +128,7 @@ static int def_init_default(CONF *conf)
     return 1;
 }
 
-#if ! OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 static int def_init_WIN32(CONF *conf)
 {
     if (conf == NULL)
diff --git a/crypto/conf/conf_def.h b/crypto/conf/conf_def.h
index 725c430c63..160611788f 100644
--- a/crypto/conf/conf_def.h
+++ b/crypto/conf/conf_def.h
@@ -56,7 +56,7 @@ static const unsigned short CONF_type_default[128] = {
     0x0004, 0x0004, 0x0004, 0x0000, 0x0200, 0x0000, 0x0200, 0x0000,
 };
 
-#if ! OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 static const unsigned short CONF_type_win32[128] = {
     0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
     0x0000, 0x0010, 0x0010, 0x0000, 0x0000, 0x0010, 0x0000, 0x0000,
diff --git a/crypto/conf/conf_sap.c b/crypto/conf/conf_sap.c
index 921ff77085..2c5ee2a131 100644
--- a/crypto/conf/conf_sap.c
+++ b/crypto/conf/conf_sap.c
@@ -27,7 +27,7 @@
 
 static int openssl_configured = 0;
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 void OPENSSL_config(const char *appname)
 {
     OPENSSL_INIT_SETTINGS settings;
diff --git a/crypto/conf/keysets.pl b/crypto/conf/keysets.pl
index 05b086f7fa..3c6eecd9ca 100644
--- a/crypto/conf/keysets.pl
+++ b/crypto/conf/keysets.pl
@@ -108,7 +108,7 @@ for ($i = 0; $i < 128; $i++) {
 }
 print "\n};\n\n";
 
-print "#if ! OPENSSL_API_3\n";
+print "#ifndef OPENSSL_NO_DEPRECATED_3_0\n";
 print "static const unsigned short CONF_type_win32[128] = {";
 for ($i = 0; $i < 128; $i++) {
     print "\n   " if ($i % 8) == 0;
diff --git a/crypto/dh/dh_depr.c b/crypto/dh/dh_depr.c
index f0903ca20a..09403f6ad5 100644
--- a/crypto/dh/dh_depr.c
+++ b/crypto/dh/dh_depr.c
@@ -10,7 +10,7 @@
 /* This file contains deprecated functions as wrappers to the new ones */
 
 #include <openssl/opensslconf.h>
-#if OPENSSL_API_0_9_8
+#ifdef OPENSSL_NO_DEPRECATED_0_9_8
 NON_EMPTY_TRANSLATION_UNIT
 #else
 
diff --git a/crypto/dsa/dsa_depr.c b/crypto/dsa/dsa_depr.c
index e97eaf124c..2b363e2642 100644
--- a/crypto/dsa/dsa_depr.c
+++ b/crypto/dsa/dsa_depr.c
@@ -20,7 +20,7 @@
 #define xxxHASH    EVP_sha1()
 
 #include <openssl/opensslconf.h>
-#if OPENSSL_API_0_9_8
+#ifdef OPENSSL_NO_DEPRECATED_0_9_8
 NON_EMPTY_TRANSLATION_UNIT
 #else
 
diff --git a/crypto/dsa/dsa_sign.c b/crypto/dsa/dsa_sign.c
index 68501efab5..99ef0043eb 100644
--- a/crypto/dsa/dsa_sign.c
+++ b/crypto/dsa/dsa_sign.c
@@ -16,7 +16,7 @@ DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
     return dsa->meth->dsa_do_sign(dgst, dlen, dsa);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
 {
     return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp);
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index 08d018c4e6..168cf72973 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -116,7 +116,7 @@ void EC_GROUP_free(EC_GROUP *group)
     OPENSSL_free(group);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 void EC_GROUP_clear_free(EC_GROUP *group)
 {
     if (!group)
@@ -540,7 +540,7 @@ int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
     return group->meth->group_get_curve(group, p, a, b, ctx);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,
                            const BIGNUM *b, BN_CTX *ctx)
 {
@@ -849,7 +849,7 @@ int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
     return 1;
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
                                         EC_POINT *point, const BIGNUM *x,
                                         const BIGNUM *y, BN_CTX *ctx)
@@ -887,7 +887,7 @@ int EC_POINT_get_affine_coordinates(const EC_GROUP *group,
     return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
                                         const EC_POINT *point, BIGNUM *x,
                                         BIGNUM *y, BN_CTX *ctx)
diff --git a/crypto/ec/ec_oct.c b/crypto/ec/ec_oct.c
index e9b1b87a5f..041c442b62 100644
--- a/crypto/ec/ec_oct.c
+++ b/crypto/ec/ec_oct.c
@@ -49,7 +49,7 @@ int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
                                                          y_bit, ctx);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
                                             EC_POINT *point, const BIGNUM *x,
                                             int y_bit, BN_CTX *ctx)
diff --git a/crypto/ec/ecdh_kdf.c b/crypto/ec/ecdh_kdf.c
index 8c4d530b11..000b12a515 100644
--- a/crypto/ec/ecdh_kdf.c
+++ b/crypto/ec/ecdh_kdf.c
@@ -48,7 +48,7 @@ int ecdh_KDF_X9_63(unsigned char *out, size_t outlen,
  * The old name for ecdh_KDF_X9_63
  * Retained for ABI compatibility
  */
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
                    const unsigned char *Z, size_t Zlen,
                    const unsigned char *sinfo, size_t sinfolen,
diff --git a/crypto/engine/eng_all.c b/crypto/engine/eng_all.c
index 0c5e4bdfd5..2f83b2ec18 100644
--- a/crypto/engine/eng_all.c
+++ b/crypto/engine/eng_all.c
@@ -15,9 +15,10 @@ void ENGINE_load_builtin_engines(void)
     OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL);
 }
 
-#if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)) \
-    && !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
+# if (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__))
 void ENGINE_setup_bsd_cryptodev(void)
 {
 }
+# endif
 #endif
diff --git a/crypto/err/err.c b/crypto/err/err.c
index b636473ba6..28a5db8ad4 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -407,7 +407,7 @@ unsigned long ERR_get_error_all(const char **file, int *line,
     return get_error_values(EV_POP, file, line, func, data, flags);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 unsigned long ERR_get_error_line_data(const char **file, int *line,
                                       const char **data, int *flags)
 {
@@ -442,7 +442,7 @@ unsigned long ERR_peek_error_all(const char **file, int *line,
     return get_error_values(EV_PEEK, file, line, func, data, flags);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 unsigned long ERR_peek_error_line_data(const char **file, int *line,
                                        const char **data, int *flags)
 {
@@ -477,7 +477,7 @@ unsigned long ERR_peek_last_error_all(const char **file, int *line,
     return get_error_values(EV_PEEK_LAST, file, line, func, data, flags);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 unsigned long ERR_peek_last_error_line_data(const char **file, int *line,
                                             const char **data, int *flags)
 {
@@ -621,7 +621,7 @@ const char *ERR_lib_error_string(unsigned long e)
     return ((p == NULL) ? NULL : p->string);
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 const char *ERR_func_error_string(unsigned long e)
 {
     return NULL;
@@ -659,13 +659,13 @@ static void err_delete_thread_state(void *arg)
     ERR_STATE_free(state);
 }
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 void ERR_remove_thread_state(void *dummy)
 {
 }
 #endif
 
-#if !OPENSSL_API_1_0_0
+#ifndef OPENSSL_NO_DEPRECATED_1_0_0
 void ERR_remove_state(unsigned long pid)
 {
 }
@@ -716,7 +716,7 @@ ERR_STATE *err_get_state_int(void)
     return state;
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 ERR_STATE *ERR_get_state(void)
 {
     return err_get_state_int();
diff --git a/crypto/evp/e_old.c b/crypto/evp/e_old.c
index 02b16d0f97..82e0c1282c 100644
--- a/crypto/evp/e_old.c
+++ b/crypto/evp/e_old.c
@@ -8,7 +8,7 @@
  */
 
 #include <openssl/opensslconf.h>
-#if OPENSSL_API_0_9_8
+#ifdef OPENSSL_NO_DEPRECATED_0_9_8
 NON_EMPTY_TRANSLATION_UNIT
 #else
 
diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c
index 17cc58717b..6d4d24d77b 100644
--- a/crypto/hmac/hmac.c
+++ b/crypto/hmac/hmac.c
@@ -86,7 +86,7 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
     return rv;
 }
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md)
 {
     if (key && md)
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 1a08b2bb9e..779ad3cec9 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -209,7 +209,7 @@ static unsigned long mem_hash(const MEM *a)
     return ret;
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int CRYPTO_mem_debug_push(const char *info, const char *file, int line)
 {
     return 0;
diff --git a/crypto/pkcs12/p12_sbag.c b/crypto/pkcs12/p12_sbag.c
index 2b4ca65399..ccb9acb17e 100644
--- a/crypto/pkcs12/p12_sbag.c
+++ b/crypto/pkcs12/p12_sbag.c
@@ -12,7 +12,7 @@
 #include <openssl/pkcs12.h>
 #include "p12_local.h"
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid)
 {
     return PKCS12_get_attr_gen(bag->attrib, attr_nid);
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index 3508cfb25c..c6b4ad3ae4 100644
--- a/crypto/rand/rand_lib.c
+++ b/crypto/rand/rand_lib.c
@@ -896,7 +896,7 @@ int RAND_bytes(unsigned char *buf, int num)
     return rand_bytes_ex(NULL, buf, num);
 }
 
-#if !OPENSSL_API_1_1_0 && !defined(FIPS_MODE)
+#if !defined(OPENSSL_NO_DEPRECATED_1_1_0) && !defined(FIPS_MODE)
 int RAND_pseudo_bytes(unsigned char *buf, int num)
 {
     const RAND_METHOD *meth = RAND_get_rand_method();
diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c
index 5f67c87c3c..40b0de9209 100644
--- a/crypto/rand/rand_win.c
+++ b/crypto/rand/rand_win.c
@@ -163,7 +163,7 @@ int rand_pool_add_additional_data(RAND_POOL *pool)
     return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
 }
 
-# if !OPENSSL_API_1_1_0 && !defined(FIPS_MODE)
+# if !defined(OPENSSL_NO_DEPRECATED_1_1_0) && !defined(FIPS_MODE)
 int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam)
 {
     RAND_poll();
diff --git a/crypto/rsa/rsa_depr.c b/crypto/rsa/rsa_depr.c
index c34c605859..ed63262645 100644
--- a/crypto/rsa/rsa_depr.c
+++ b/crypto/rsa/rsa_depr.c
@@ -13,7 +13,7 @@
  */
 
 #include <openssl/opensslconf.h>
-#if OPENSSL_API_0_9_8
+#ifdef OPENSSL_NO_DEPRECATED_0_9_8
 NON_EMPTY_TRANSLATION_UNIT
 
 #else
diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c
index c4dd5153f2..9505d4265e 100644
--- a/crypto/srp/srp_vfy.c
+++ b/crypto/srp/srp_vfy.c
@@ -525,7 +525,7 @@ int SRP_VBASE_add0_user(SRP_VBASE *vb, SRP_user_pwd *user_pwd)
     return 1;
 }
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /*
  * DEPRECATED: use SRP_VBASE_get1_by_user instead.
  * This method ignores the configured seed and fails for an unknown user.
diff --git a/crypto/x509/x509_d2.c b/crypto/x509/x509_d2.c
index 5beb7034a7..cb0f84a7e8 100644
--- a/crypto/x509/x509_d2.c
+++ b/crypto/x509/x509_d2.c
@@ -74,7 +74,7 @@ int X509_STORE_load_store(X509_STORE *ctx, const char *uri)
 }
 
 /* Deprecated */
-#if OPENSSL_API_LEVEL < 3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
                               const char *path)
 {
diff --git a/crypto/x509/x509cset.c b/crypto/x509/x509cset.c
index f1992ddcf0..2350995239 100644
--- a/crypto/x509/x509cset.c
+++ b/crypto/x509/x509cset.c
@@ -91,7 +91,7 @@ const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl)
     return crl->crl.nextUpdate;
 }
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl)
 {
     return crl->crl.lastUpdate;
diff --git a/engines/e_afalg_err.h b/engines/e_afalg_err.h
index 371723535b..557df5d401 100644
--- a/engines/e_afalg_err.h
+++ b/engines/e_afalg_err.h
@@ -21,7 +21,7 @@
 /*
  * AFALG function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define AFALG_F_AFALG_CHK_PLATFORM                       0
 #  define AFALG_F_AFALG_CREATE_SK                          0
 #  define AFALG_F_AFALG_INIT_AIO                           0
diff --git a/engines/e_capi_err.h b/engines/e_capi_err.h
index 048b6d171a..c8bd24869a 100644
--- a/engines/e_capi_err.h
+++ b/engines/e_capi_err.h
@@ -21,7 +21,7 @@
 /*
  * CAPI function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define CAPI_F_CAPI_CERT_GET_FNAME                       0
 #  define CAPI_F_CAPI_CTRL                                 0
 #  define CAPI_F_CAPI_CTX_NEW                              0
diff --git a/engines/e_dasync_err.h b/engines/e_dasync_err.h
index a9db187f1d..7d2ea7936f 100644
--- a/engines/e_dasync_err.h
+++ b/engines/e_dasync_err.h
@@ -21,7 +21,7 @@
 /*
  * DASYNC function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define DASYNC_F_BIND_DASYNC                             0
 #  define DASYNC_F_CIPHER_AES_128_CBC_CODE                 0
 #  define DASYNC_F_DASYNC_AES128_CBC_HMAC_SHA1_INIT_KEY    0
diff --git a/engines/e_ossltest_err.h b/engines/e_ossltest_err.h
index 70a0bc667f..0c23b0c453 100644
--- a/engines/e_ossltest_err.h
+++ b/engines/e_ossltest_err.h
@@ -21,7 +21,7 @@
 /*
  * OSSLTEST function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define OSSLTEST_F_BIND_OSSLTEST                         0
 #  define OSSLTEST_F_OSSLTEST_AES128_INIT_KEY              0
 # endif
diff --git a/fuzz/asn1.c b/fuzz/asn1.c
index 4a5458af3e..17eaf6ca35 100644
--- a/fuzz/asn1.c
+++ b/fuzz/asn1.c
@@ -108,7 +108,7 @@ static ASN1_ITEM_EXP *item_type[] = {
     ASN1_ITEM_ref(IPAddressRange),
 #endif
     ASN1_ITEM_ref(ISSUING_DIST_POINT),
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     ASN1_ITEM_ref(LONG),
 #endif
     ASN1_ITEM_ref(NAME_CONSTRAINTS),
@@ -189,7 +189,7 @@ static ASN1_ITEM_EXP *item_type[] = {
     ASN1_ITEM_ref(X509_REVOKED),
     ASN1_ITEM_ref(X509_SIG),
     ASN1_ITEM_ref(X509_VAL),
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     ASN1_ITEM_ref(ZLONG),
 #endif
     ASN1_ITEM_ref(INT32),
diff --git a/include/crypto/sm2err.h b/include/crypto/sm2err.h
index 3b86c38c3c..d0b04baf71 100644
--- a/include/crypto/sm2err.h
+++ b/include/crypto/sm2err.h
@@ -27,7 +27,7 @@ int ERR_load_SM2_strings(void);
 /*
  * SM2 function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define SM2_F_PKEY_SM2_COPY                              0
 #   define SM2_F_PKEY_SM2_CTRL                              0
 #   define SM2_F_PKEY_SM2_CTRL_STR                          0
diff --git a/include/internal/dsoerr.h b/include/internal/dsoerr.h
index 9ddb9cff4d..ce9c8f0cf3 100644
--- a/include/internal/dsoerr.h
+++ b/include/internal/dsoerr.h
@@ -23,7 +23,7 @@ int ERR_load_DSO_strings(void);
 /*
  * DSO function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define DSO_F_DLFCN_BIND_FUNC                            0
 #  define DSO_F_DLFCN_LOAD                                 0
 #  define DSO_F_DLFCN_MERGER                               0
diff --git a/include/internal/propertyerr.h b/include/internal/propertyerr.h
index ebbd8619b2..b3d63ab4a0 100644
--- a/include/internal/propertyerr.h
+++ b/include/internal/propertyerr.h
@@ -23,7 +23,7 @@ int ERR_load_PROP_strings(void);
 /*
  * PROP function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define PROP_F_OSSL_PARSE_PROPERTY                       0
 #  define PROP_F_OSSL_PARSE_QUERY                          0
 #  define PROP_F_PARSE_HEX                                 0
diff --git a/include/openssl/aes.h b/include/openssl/aes.h
index 4e93d3dc93..a21e72d473 100644
--- a/include/openssl/aes.h
+++ b/include/openssl/aes.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_AES_H
 # endif
 
@@ -73,7 +73,7 @@ void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
 void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
                         size_t length, const AES_KEY *key,
                         unsigned char *ivec, int *num);
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 /* NB: the IV is _two_ blocks long */
 void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
                      size_t length, const AES_KEY *key,
diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h
index 32d39c14a6..1aa4b8300c 100644
--- a/include/openssl/asn1.h
+++ b/include/openssl/asn1.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ASN1_H
 # endif
 
@@ -25,9 +25,7 @@
 # include <openssl/symhacks.h>
 
 # include <openssl/types.h>
-# if !OPENSSL_API_1_1_0
-#  include <openssl/bn.h>
-# endif
+# include <openssl/bn.h>
 
 # ifdef OPENSSL_BUILD_SHLIBCRYPTO
 #  undef OPENSSL_EXTERN
diff --git a/include/openssl/asn1err.h b/include/openssl/asn1err.h
index 9166f17142..15f993915a 100644
--- a/include/openssl/asn1err.h
+++ b/include/openssl/asn1err.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ASN1ERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_ASN1_strings(void);
 /*
  * ASN1 function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define ASN1_F_A2D_ASN1_OBJECT                           0
 #  define ASN1_F_A2I_ASN1_INTEGER                          0
 #  define ASN1_F_A2I_ASN1_STRING                           0
diff --git a/include/openssl/asn1t.h b/include/openssl/asn1t.h
index 00ccdf5156..754cab5f3d 100644
--- a/include/openssl/asn1t.h
+++ b/include/openssl/asn1t.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ASN1T_H
 # endif
 
@@ -870,7 +870,7 @@ DECLARE_ASN1_ITEM(ZINT64)
 DECLARE_ASN1_ITEM(UINT64)
 DECLARE_ASN1_ITEM(ZUINT64)
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 /*
  * LONG and ZLONG are strongly discouraged for use as stored data, as the
  * underlying C type (long) differs in size depending on the architecture.
diff --git a/include/openssl/async.h b/include/openssl/async.h
index e372e43c47..bc27d5db06 100644
--- a/include/openssl/async.h
+++ b/include/openssl/async.h
@@ -14,7 +14,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ASYNC_H
 # endif
 
diff --git a/include/openssl/asyncerr.h b/include/openssl/asyncerr.h
index 8e8c66fc52..17defd0494 100644
--- a/include/openssl/asyncerr.h
+++ b/include/openssl/asyncerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ASYNCERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_ASYNC_strings(void);
 /*
  * ASYNC function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define ASYNC_F_ASYNC_CTX_NEW                            0
 #  define ASYNC_F_ASYNC_INIT_THREAD                        0
 #  define ASYNC_F_ASYNC_JOB_NEW                            0
diff --git a/include/openssl/bio.h b/include/openssl/bio.h
index bb289e6fa2..ed9ecc6cca 100644
--- a/include/openssl/bio.h
+++ b/include/openssl/bio.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_BIO_H
 # endif
 
@@ -181,7 +181,7 @@ extern "C" {
 # define BIO_FLAGS_IO_SPECIAL    0x04
 # define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)
 # define BIO_FLAGS_SHOULD_RETRY  0x08
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 /* This #define was replaced by an internal constant and should not be used. */
 #  define BIO_FLAGS_UPLINK       0
 # endif
@@ -704,7 +704,7 @@ int BIO_sock_error(int sock);
 int BIO_socket_ioctl(int fd, long type, void *arg);
 int BIO_socket_nbio(int fd, int mode);
 int BIO_sock_init(void);
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define BIO_sock_cleanup() while(0) continue
 # endif
 int BIO_set_tcp_ndelay(int sock, int turn_on);
diff --git a/include/openssl/bioerr.h b/include/openssl/bioerr.h
index 2f4dd3394b..46e1840700 100644
--- a/include/openssl/bioerr.h
+++ b/include/openssl/bioerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_BIOERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_BIO_strings(void);
 /*
  * BIO function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define BIO_F_ACPT_STATE                                 0
 #  define BIO_F_ADDRINFO_WRAP                              0
 #  define BIO_F_ADDR_STRINGS                               0
diff --git a/include/openssl/blowfish.h b/include/openssl/blowfish.h
index 6532915200..986367e51a 100644
--- a/include/openssl/blowfish.h
+++ b/include/openssl/blowfish.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_BLOWFISH_H
 # endif
 
diff --git a/include/openssl/bn.h b/include/openssl/bn.h
index 2eabadab27..8512ddf284 100644
--- a/include/openssl/bn.h
+++ b/include/openssl/bn.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_BN_H
 # endif
 
@@ -67,7 +67,7 @@ extern "C" {
 # define BN_FLG_CONSTTIME        0x04
 # define BN_FLG_SECURE           0x08
 
-# if !OPENSSL_API_0_9_8
+# ifndef OPENSSL_NO_DEPRECATED_0_9_8
 /* deprecated name for the flag */
 #  define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME
 #  define BN_FLG_FREE            0x8000 /* used for debugging */
@@ -109,7 +109,7 @@ void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),
 
 void *BN_GENCB_get_arg(BN_GENCB *cb);
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define BN_prime_checks 0      /* default: select number of iterations based
                                   * on the size of the number */
 
@@ -198,7 +198,7 @@ int BN_is_odd(const BIGNUM *a);
 
 void BN_zero_ex(BIGNUM *a);
 
-# if OPENSSL_API_0_9_8
+# if OPENSSL_API_LEVEL > 908
 #  define BN_zero(a)      BN_zero_ex(a)
 # else
 #  define BN_zero(a)      (BN_set_word((a),0))
@@ -355,8 +355,8 @@ DEPRECATEDIN_0_9_8(int
                                         BN_CTX *ctx, void *cb_arg,
                                         int do_trial_division))
 
-DEPRECATEDIN_3(int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb))
-DEPRECATEDIN_3(int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,
+DEPRECATEDIN_3_0(int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb))
+DEPRECATEDIN_3_0(int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,
                             int do_trial_division, BN_GENCB *cb))
 /* Newer versions */
 int BN_generate_prime_ex2(BIGNUM *ret, int bits, int safe,
@@ -539,7 +539,7 @@ BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn);
 BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn);
 BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define get_rfc2409_prime_768 BN_get_rfc2409_prime_768
 #  define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024
 #  define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536
diff --git a/include/openssl/bnerr.h b/include/openssl/bnerr.h
index a4b666f9cc..cce4cbbf97 100644
--- a/include/openssl/bnerr.h
+++ b/include/openssl/bnerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_BNERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_BN_strings(void);
 /*
  * BN function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define BN_F_BNRAND                                      0
 #  define BN_F_BNRAND_RANGE                                0
 #  define BN_F_BN_BLINDING_CONVERT_EX                      0
diff --git a/include/openssl/buffer.h b/include/openssl/buffer.h
index 49581b826a..5773b986bd 100644
--- a/include/openssl/buffer.h
+++ b/include/openssl/buffer.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_BUFFER_H
 # endif
 
@@ -30,7 +30,7 @@ extern "C" {
 # include <stddef.h>
 # include <sys/types.h>
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define BUF_strdup(s) OPENSSL_strdup(s)
 #  define BUF_strndup(s, size) OPENSSL_strndup(s, size)
 #  define BUF_memdup(data, size) OPENSSL_memdup(data, size)
diff --git a/include/openssl/buffererr.h b/include/openssl/buffererr.h
index fbe0d99843..1a5de3a65d 100644
--- a/include/openssl/buffererr.h
+++ b/include/openssl/buffererr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_BUFERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_BUF_strings(void);
 /*
  * BUF function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define BUF_F_BUF_MEM_GROW                               0
 #  define BUF_F_BUF_MEM_GROW_CLEAN                         0
 #  define BUF_F_BUF_MEM_NEW                                0
diff --git a/include/openssl/camellia.h b/include/openssl/camellia.h
index 23605cf393..cac999ecee 100644
--- a/include/openssl/camellia.h
+++ b/include/openssl/camellia.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CAMELLIA_H
 # endif
 
diff --git a/include/openssl/cast.h b/include/openssl/cast.h
index a1aad6bda3..5f81217d14 100644
--- a/include/openssl/cast.h
+++ b/include/openssl/cast.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CAST_H
 # endif
 
diff --git a/include/openssl/cmac.h b/include/openssl/cmac.h
index 426536fa35..e2b49a0574 100644
--- a/include/openssl/cmac.h
+++ b/include/openssl/cmac.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CMAC_H
 # endif
 
diff --git a/include/openssl/cmperr.h b/include/openssl/cmperr.h
index 02d0a36f94..7da9a17829 100644
--- a/include/openssl/cmperr.h
+++ b/include/openssl/cmperr.h
@@ -27,7 +27,7 @@ int ERR_load_CMP_strings(void);
 /*
  * CMP function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 # endif
 
 /*
diff --git a/include/openssl/cms.h b/include/openssl/cms.h
index cf4ad37f3a..3c2bad271c 100644
--- a/include/openssl/cms.h
+++ b/include/openssl/cms.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CMS_H
 # endif
 
diff --git a/include/openssl/cmserr.h b/include/openssl/cmserr.h
index 407bdfd5fd..10e0fd6ae8 100644
--- a/include/openssl/cmserr.h
+++ b/include/openssl/cmserr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CMSERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_CMS_strings(void);
 /*
  * CMS function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define CMS_F_CHECK_CONTENT                              0
 #   define CMS_F_CMS_ADD0_CERT                              0
 #   define CMS_F_CMS_ADD0_RECIPIENT_KEY                     0
diff --git a/include/openssl/comp.h b/include/openssl/comp.h
index 47f782b57a..06ff58100f 100644
--- a/include/openssl/comp.h
+++ b/include/openssl/comp.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_COMP_H
 # endif
 
@@ -41,8 +41,8 @@ int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
 
 COMP_METHOD *COMP_zlib(void);
 
-#if !OPENSSL_API_1_1_0
-#define COMP_zlib_cleanup() while(0) continue
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
+# define COMP_zlib_cleanup() while(0) continue
 #endif
 
 # ifdef OPENSSL_BIO_H
diff --git a/include/openssl/comperr.h b/include/openssl/comperr.h
index 89faccb115..47945628ee 100644
--- a/include/openssl/comperr.h
+++ b/include/openssl/comperr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_COMPERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_COMP_strings(void);
 /*
  * COMP function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define COMP_F_BIO_ZLIB_FLUSH                            0
 #   define COMP_F_BIO_ZLIB_NEW                              0
 #   define COMP_F_BIO_ZLIB_READ                             0
diff --git a/include/openssl/conf.h b/include/openssl/conf.h
index c2bd31176f..39bfe570c8 100644
--- a/include/openssl/conf.h
+++ b/include/openssl/conf.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CONF_H
 # endif
 
@@ -96,7 +96,7 @@ int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);
 
 DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 # define OPENSSL_no_config() \
     OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL)
 #endif
@@ -114,7 +114,7 @@ struct conf_st {
 
 CONF *NCONF_new(CONF_METHOD *meth);
 CONF_METHOD *NCONF_default(void);
-DEPRECATEDIN_3(CONF_METHOD *NCONF_WIN32(void))
+DEPRECATEDIN_3_0(CONF_METHOD *NCONF_WIN32(void))
 void NCONF_free(CONF *conf);
 void NCONF_free_data(CONF *conf);
 
@@ -143,7 +143,7 @@ int CONF_modules_load_file(const char *filename, const char *appname,
                            unsigned long flags);
 void CONF_modules_unload(int all);
 void CONF_modules_finish(void);
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 # define CONF_modules_free() while(0) continue
 #endif
 int CONF_module_add(const char *name, conf_init_func *ifunc,
diff --git a/include/openssl/conf_api.h b/include/openssl/conf_api.h
index 43076932e1..ed67d5778f 100644
--- a/include/openssl/conf_api.h
+++ b/include/openssl/conf_api.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CONF_API_H
 # endif
 
diff --git a/include/openssl/conferr.h b/include/openssl/conferr.h
index 4bf5b9e28f..eb41737fd7 100644
--- a/include/openssl/conferr.h
+++ b/include/openssl/conferr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CONFERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_CONF_strings(void);
 /*
  * CONF function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define CONF_F_CONF_DUMP_FP                              0
 #  define CONF_F_CONF_LOAD                                 0
 #  define CONF_F_CONF_LOAD_FP                              0
diff --git a/include/openssl/crmferr.h b/include/openssl/crmferr.h
index 715b78c2e6..97f5159b51 100644
--- a/include/openssl/crmferr.h
+++ b/include/openssl/crmferr.h
@@ -27,7 +27,7 @@ int ERR_load_CRMF_strings(void);
 /*
  * CRMF function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define CRMF_F_CRMF_POPOSIGNINGKEY_INIT                  0
 #   define CRMF_F_OSSL_CRMF_CERTID_GEN                      0
 #   define CRMF_F_OSSL_CRMF_CERTTEMPLATE_FILL               0
diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h
index 28c8939e96..a6020fdd4c 100644
--- a/include/openssl/crypto.h
+++ b/include/openssl/crypto.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CRYPTO_H
 # endif
 
@@ -42,7 +42,7 @@
  */
 # include <openssl/symhacks.h>
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/opensslv.h>
 # endif
 
@@ -50,7 +50,7 @@
 extern "C" {
 #endif
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define SSLeay                  OpenSSL_version_num
 #  define SSLeay_version          OpenSSL_version
 #  define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER
@@ -68,7 +68,7 @@ typedef struct {
     int dummy;
 } CRYPTO_dynlock;
 
-# endif /* OPENSSL_API_1_1_0 */
+# endif /* OPENSSL_NO_DEPRECATED_1_1_0 */
 
 typedef void CRYPTO_RWLOCK;
 
@@ -238,7 +238,7 @@ int CRYPTO_alloc_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad,
 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
 void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /*
  * This function cleans up all "ex_data" state. It mustn't be called under
  * potential race-conditions.
@@ -285,11 +285,11 @@ typedef struct crypto_threadid_st {
 #  define CRYPTO_THREADID_cpy(dest, src)
 #  define CRYPTO_THREADID_hash(id)                      (0UL)
 
-#  if !OPENSSL_API_1_0_0
+#  ifndef OPENSSL_NO_DEPRECATED_1_0_0
 #   define CRYPTO_set_id_callback(func)
 #   define CRYPTO_get_id_callback()                     (NULL)
 #   define CRYPTO_thread_id()                           (0UL)
-#  endif /* OPENSSL_API_1_0_0 */
+#  endif /* OPENSSL_NO_DEPRECATED_1_0_0 */
 
 #  define CRYPTO_set_dynlock_create_callback(dyn_create_function)
 #  define CRYPTO_set_dynlock_lock_callback(dyn_lock_function)
@@ -297,7 +297,7 @@ typedef struct crypto_threadid_st {
 #  define CRYPTO_get_dynlock_create_callback()          (NULL)
 #  define CRYPTO_get_dynlock_lock_callback()            (NULL)
 #  define CRYPTO_get_dynlock_destroy_callback()         (NULL)
-# endif /* OPENSSL_API_1_1_0 */
+# endif /* OPENSSL_NO_DEPRECATED_1_1_0 */
 
 int CRYPTO_set_mem_functions(
         void *(*m) (size_t, const char *, int),
@@ -335,15 +335,15 @@ size_t CRYPTO_secure_used(void);
 void OPENSSL_cleanse(void *ptr, size_t len);
 
 # ifndef OPENSSL_NO_CRYPTO_MDEBUG
-#  if !OPENSSL_API_3
+#  ifndef OPENSSL_NO_DEPRECATED_3_0
 #    define OPENSSL_mem_debug_push(info) \
          CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE)
 #    define OPENSSL_mem_debug_pop() \
          CRYPTO_mem_debug_pop()
 #  endif
-DEPRECATEDIN_3(int CRYPTO_mem_debug_push(const char *info,
-                                         const char *file, int line))
-DEPRECATEDIN_3(int CRYPTO_mem_debug_pop(void))
+DEPRECATEDIN_3_0(int CRYPTO_mem_debug_push(const char *info,
+                                           const char *file, int line))
+DEPRECATEDIN_3_0(int CRYPTO_mem_debug_pop(void))
 
 void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount);
 
@@ -370,7 +370,7 @@ int CRYPTO_mem_leaks(BIO *bio);
 
 /* die if we have to */
 ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line);
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l))
 # endif
 # define OPENSSL_assert(e) \
diff --git a/include/openssl/cryptoerr.h b/include/openssl/cryptoerr.h
index 99872af161..43b7aa5a22 100644
--- a/include/openssl/cryptoerr.h
+++ b/include/openssl/cryptoerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CRYPTOERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_CRYPTO_strings(void);
 /*
  * CRYPTO function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define CRYPTO_F_CMAC_CTX_NEW                            0
 #  define CRYPTO_F_CRYPTO_DUP_EX_DATA                      0
 #  define CRYPTO_F_CRYPTO_FREE_EX_DATA                     0
diff --git a/include/openssl/ct.h b/include/openssl/ct.h
index 17271d6777..b7c211d920 100644
--- a/include/openssl/ct.h
+++ b/include/openssl/ct.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CT_H
 # endif
 
diff --git a/include/openssl/cterr.h b/include/openssl/cterr.h
index c5c646cc9b..b0d904eb1f 100644
--- a/include/openssl/cterr.h
+++ b/include/openssl/cterr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_CTERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_CT_strings(void);
 /*
  * CT function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define CT_F_CTLOG_NEW                                   0
 #   define CT_F_CTLOG_NEW_FROM_BASE64                       0
 #   define CT_F_CTLOG_NEW_FROM_CONF                         0
diff --git a/include/openssl/des.h b/include/openssl/des.h
index 0a874f4bcc..6bbf5828d0 100644
--- a/include/openssl/des.h
+++ b/include/openssl/des.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_DES_H
 # endif
 
diff --git a/include/openssl/dh.h b/include/openssl/dh.h
index 84f4f07d2c..1e39e86a33 100644
--- a/include/openssl/dh.h
+++ b/include/openssl/dh.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_DH_H
 # endif
 
@@ -23,7 +23,7 @@
 # include <openssl/bio.h>
 # include <openssl/asn1.h>
 # include <openssl/types.h>
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/bn.h>
 # endif
 # include <openssl/dherr.h>
@@ -40,7 +40,7 @@ extern "C" {
 
 # define DH_FLAG_CACHE_MONT_P     0x01
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /*
  * Does nothing. Previously this switched off constant time behaviour.
  */
diff --git a/include/openssl/dherr.h b/include/openssl/dherr.h
index a926dab999..463019d0e1 100644
--- a/include/openssl/dherr.h
+++ b/include/openssl/dherr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_DHERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_DH_strings(void);
 /*
  * DH function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define DH_F_COMPUTE_KEY                                 0
 #   define DH_F_DHPARAMS_PRINT_FP                           0
 #   define DH_F_DH_BUF2KEY                                  0
diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h
index 858c316b66..9697a9cafd 100644
--- a/include/openssl/dsa.h
+++ b/include/openssl/dsa.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_DSA_H
 # endif
 
@@ -28,7 +28,7 @@ extern "C" {
 # include <openssl/crypto.h>
 # include <openssl/types.h>
 # include <openssl/bn.h>
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/dh.h>
 # endif
 # include <openssl/dsaerr.h>
@@ -40,7 +40,7 @@ extern "C" {
 # define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024
 
 # define DSA_FLAG_CACHE_MONT_P   0x01
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /*
  * Does nothing. Previously this switched off constant time behaviour.
  */
@@ -105,7 +105,7 @@ int DSA_size(const DSA *);
 int DSA_bits(const DSA *d);
 int DSA_security_bits(const DSA *d);
         /* next 4 return -1 on error */
-DEPRECATEDIN_3(int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp))
+DEPRECATEDIN_3_0(int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp))
 int DSA_sign(int type, const unsigned char *dgst, int dlen,
              unsigned char *sig, unsigned int *siglen, DSA *dsa);
 int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
@@ -144,7 +144,7 @@ int DSAparams_print_fp(FILE *fp, const DSA *x);
 int DSA_print_fp(FILE *bp, const DSA *x, int off);
 # endif
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define DSS_prime_checks 64
 /*
  * Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only
diff --git a/include/openssl/dsaerr.h b/include/openssl/dsaerr.h
index 9e0d5cfe2a..48dd7d03b7 100644
--- a/include/openssl/dsaerr.h
+++ b/include/openssl/dsaerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_DSAERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_DSA_strings(void);
 /*
  * DSA function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define DSA_F_DSAPARAMS_PRINT                            0
 #   define DSA_F_DSAPARAMS_PRINT_FP                         0
 #   define DSA_F_DSA_BUILTIN_PARAMGEN                       0
diff --git a/include/openssl/dtls1.h b/include/openssl/dtls1.h
index d535c05c49..bfc2d6e38f 100644
--- a/include/openssl/dtls1.h
+++ b/include/openssl/dtls1.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_DTLS1_H
 # endif
 
@@ -24,7 +24,7 @@ extern "C" {
 
 # define DTLS1_VERSION                   0xFEFF
 # define DTLS1_2_VERSION                 0xFEFD
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define DTLS_MIN_VERSION                DTLS1_VERSION
 #  define DTLS_MAX_VERSION                DTLS1_2_VERSION
 # endif
diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h
index 69a50911dd..982dd2b8a7 100644
--- a/include/openssl/e_os2.h
+++ b/include/openssl/e_os2.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_E_OS2_H
 # endif
 
diff --git a/include/openssl/ebcdic.h b/include/openssl/ebcdic.h
index a75a71d4d9..e0ae1aa84e 100644
--- a/include/openssl/ebcdic.h
+++ b/include/openssl/ebcdic.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_EBCDIC_H
 # endif
 
diff --git a/include/openssl/ec.h b/include/openssl/ec.h
index b4c50ecfc7..1ffdb56c6f 100644
--- a/include/openssl/ec.h
+++ b/include/openssl/ec.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_EC_H
 # endif
 
@@ -22,7 +22,7 @@
 # ifndef OPENSSL_NO_EC
 # include <openssl/asn1.h>
 # include <openssl/symhacks.h>
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/bn.h>
 # endif
 # include <openssl/ecerr.h>
@@ -131,7 +131,7 @@ void EC_GROUP_free(EC_GROUP *group);
 /** Clears and frees a EC_GROUP object
  *  \param  group  EC_GROUP object to be cleared and freed.
  */
-DEPRECATEDIN_3(void EC_GROUP_clear_free(EC_GROUP *group))
+DEPRECATEDIN_3_0(void EC_GROUP_clear_free(EC_GROUP *group))
 
 /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.
  *  \param  dst  destination EC_GROUP object
@@ -281,7 +281,7 @@ int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
+DEPRECATEDIN_3_0(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
                                           const BIGNUM *a, const BIGNUM *b,
                                           BN_CTX *ctx))
 
@@ -294,7 +294,7 @@ DEPRECATEDIN_3(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
+DEPRECATEDIN_3_0(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
                                           BIGNUM *a, BIGNUM *b,
                                           BN_CTX *ctx))
 
@@ -308,7 +308,7 @@ DEPRECATEDIN_3(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p,
+DEPRECATEDIN_3_0(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p,
                                            const BIGNUM *a, const BIGNUM *b,
                                            BN_CTX *ctx))
 
@@ -321,7 +321,7 @@ DEPRECATEDIN_3(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p,
+DEPRECATEDIN_3_0(int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p,
                                            BIGNUM *a, BIGNUM *b,
                                            BN_CTX *ctx))
 # endif
@@ -562,7 +562,7 @@ int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
+DEPRECATEDIN_3_0(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
                                                        EC_POINT *p,
                                                        const BIGNUM *x,
                                                        const BIGNUM *y,
@@ -577,7 +577,7 @@ DEPRECATEDIN_3(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
+DEPRECATEDIN_3_0(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
                                                        const EC_POINT *p,
                                                        BIGNUM *x,
                                                        BIGNUM *y,
@@ -604,7 +604,7 @@ int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
+DEPRECATEDIN_3_0(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,
                                                            EC_POINT *p,
                                                            const BIGNUM *x,
                                                            int y_bit,
@@ -619,7 +619,7 @@ DEPRECATEDIN_3(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
+DEPRECATEDIN_3_0(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
                                                         EC_POINT *p,
                                                         const BIGNUM *x,
                                                         const BIGNUM *y,
@@ -634,7 +634,7 @@ DEPRECATEDIN_3(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
+DEPRECATEDIN_3_0(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
                                                         const EC_POINT *p,
                                                         BIGNUM *x,
                                                         BIGNUM *y,
@@ -649,7 +649,7 @@ DEPRECATEDIN_3(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
  *  \param  ctx    BN_CTX object (optional)
  *  \return 1 on success and 0 if an error occurred
  */
-DEPRECATEDIN_3(int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
+DEPRECATEDIN_3_0(int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,
                                                             EC_POINT *p,
                                                             const BIGNUM *x,
                                                             int y_bit,
@@ -1172,10 +1172,10 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine);
  *  it is actually specified in ANSI X9.63.
  *  This identifier is retained for backwards compatibility
  */
-DEPRECATEDIN_3(int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
-                                  const unsigned char *Z, size_t Zlen,
-                                  const unsigned char *sinfo, size_t sinfolen,
-                                  const EVP_MD *md))
+DEPRECATEDIN_3_0(int ECDH_KDF_X9_62(unsigned char *out, size_t outlen,
+                                    const unsigned char *Z, size_t Zlen,
+                                    const unsigned char *sinfo, size_t sinfolen,
+                                    const EVP_MD *md))
 
 int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
                      const EC_KEY *ecdh,
diff --git a/include/openssl/ecerr.h b/include/openssl/ecerr.h
index 07ef524f7a..88399db50d 100644
--- a/include/openssl/ecerr.h
+++ b/include/openssl/ecerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ECERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_EC_strings(void);
 /*
  * EC function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define EC_F_BN_TO_FELEM                                 0
 #   define EC_F_D2I_ECPARAMETERS                            0
 #   define EC_F_D2I_ECPKPARAMETERS                          0
diff --git a/include/openssl/engine.h b/include/openssl/engine.h
index 816eb4e2e6..3c9648dc02 100644
--- a/include/openssl/engine.h
+++ b/include/openssl/engine.h
@@ -13,14 +13,14 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ENGINE_H
 # endif
 
 # include <openssl/opensslconf.h>
 
 # ifndef OPENSSL_NO_ENGINE
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/bn.h>
 #  include <openssl/rsa.h>
 #  include <openssl/dsa.h>
@@ -326,7 +326,7 @@ int ENGINE_remove(ENGINE *e);
 /* Retrieve an engine from the list by its unique "id" value. */
 ENGINE *ENGINE_by_id(const char *id);
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 # define ENGINE_load_openssl() \
     OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL)
 # define ENGINE_load_dynamic() \
@@ -500,7 +500,7 @@ int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);
 int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);
 void *ENGINE_get_ex_data(const ENGINE *e, int idx);
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /*
  * This function previously cleaned up anything that needs it. Auto-deinit will
  * now take care of it so it is no longer required to call this function.
diff --git a/include/openssl/engineerr.h b/include/openssl/engineerr.h
index 27b2df6d76..006d73a431 100644
--- a/include/openssl/engineerr.h
+++ b/include/openssl/engineerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ENGINEERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_ENGINE_strings(void);
 /*
  * ENGINE function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define ENGINE_F_DIGEST_UPDATE                           0
 #   define ENGINE_F_DYNAMIC_CTRL                            0
 #   define ENGINE_F_DYNAMIC_GET_DATA_CTX                    0
diff --git a/include/openssl/err.h b/include/openssl/err.h
index fc7ead8b68..e5766ee241 100644
--- a/include/openssl/err.h
+++ b/include/openssl/err.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ERR_H
 # endif
 
@@ -31,7 +31,7 @@
 extern "C" {
 #endif
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  ifndef OPENSSL_NO_FILENAMES
 #   define ERR_PUT_error(l,f,r,fn,ln)      ERR_put_error(l,f,r,fn,ln)
 #  else
@@ -44,7 +44,7 @@ extern "C" {
 # define ERR_TXT_MALLOCED        0x01
 # define ERR_TXT_STRING          0x02
 
-# if !OPENSSL_API_3 || defined(OSSL_FORCE_ERR_STATE)
+# if !defined(OPENSSL_NO_DEPRECATED_3_0) || defined(OSSL_FORCE_ERR_STATE)
 #  define ERR_FLAG_MARK           0x01
 #  define ERR_FLAG_CLEAR          0x02
 
@@ -114,7 +114,7 @@ struct err_state_st {
 
 # define ERR_LIB_USER            128
 
-# if 1 || !OPENSSL_API_3
+# if 1 || !defined(OPENSSL_NO_DEPRECATED_3_0)
 #  define ASN1err(f, r) ERR_raise_data(ERR_LIB_ASN1, (r), NULL)
 #  define ASYNCerr(f, r) ERR_raise_data(ERR_LIB_ASYNC, (r), NULL)
 #  define BIOerr(f, r) ERR_raise_data(ERR_LIB_BIO, (r), NULL)
@@ -167,7 +167,7 @@ struct err_state_st {
 # define ERR_GET_REASON(l)       (int)( (l)         & 0xFFFL)
 # define ERR_FATAL_ERROR(l)      (int)( (l)         & ERR_R_FATAL)
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define SYS_F_FOPEN             0
 #  define SYS_F_CONNECT           0
 #  define SYS_F_GETSERVBYNAME     0
@@ -258,7 +258,7 @@ void ERR_vset_error(int lib, int reason, const char *fmt, va_list args);
      ERR_set_debug(OPENSSL_FILE,OPENSSL_LINE,OPENSSL_FUNC),     \
      ERR_set_error)
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 /* Backward compatibility */
 #  define ERR_put_error(lib, func, reason, file, line)          \
     (ERR_new(),                                                 \
@@ -282,7 +282,7 @@ unsigned long ERR_get_error_data(const char **data, int *flags);
 unsigned long ERR_get_error_all(const char **file, int *line,
                                 const char **func,
                                 const char **data, int *flags);
-DEPRECATEDIN_3(unsigned long ERR_get_error_line_data(const char **file,
+DEPRECATEDIN_3_0(unsigned long ERR_get_error_line_data(const char **file,
                                                      int *line,
                                                      const char **data,
                                                      int *flags))
@@ -293,7 +293,7 @@ unsigned long ERR_peek_error_data(const char **data, int *flags);
 unsigned long ERR_peek_error_all(const char **file, int *line,
                                  const char **func,
                                  const char **data, int *flags);
-DEPRECATEDIN_3(unsigned long ERR_peek_error_line_data(const char **file,
+DEPRECATEDIN_3_0(unsigned long ERR_peek_error_line_data(const char **file,
                                                       int *line,
                                                       const char **data,
                                                       int *flags))
@@ -304,7 +304,7 @@ unsigned long ERR_peek_last_error_data(const char **data, int *flags);
 unsigned long ERR_peek_last_error_all(const char **file, int *line,
                                       const char **func,
                                       const char **data, int *flags);
-DEPRECATEDIN_3(unsigned long ERR_peek_last_error_line_data(const char **file,
+DEPRECATEDIN_3_0(unsigned long ERR_peek_last_error_line_data(const char **file,
                                                            int *line,
                                                            const char **data,
                                                            int *flags))
@@ -314,7 +314,7 @@ void ERR_clear_error(void);
 char *ERR_error_string(unsigned long e, char *buf);
 void ERR_error_string_n(unsigned long e, char *buf, size_t len);
 const char *ERR_lib_error_string(unsigned long e);
-DEPRECATEDIN_3(const char *ERR_func_error_string(unsigned long e))
+DEPRECATEDIN_3_0(const char *ERR_func_error_string(unsigned long e))
 const char *ERR_reason_error_string(unsigned long e);
 
 void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
@@ -332,7 +332,7 @@ int ERR_load_strings_const(const ERR_STRING_DATA *str);
 int ERR_unload_strings(int lib, ERR_STRING_DATA *str);
 int ERR_load_ERR_strings(void);
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 # define ERR_load_crypto_strings() \
     OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
 # define ERR_free_strings() while(0) continue
@@ -340,7 +340,7 @@ int ERR_load_ERR_strings(void);
 
 DEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *))
 DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid))
-DEPRECATEDIN_3(ERR_STATE *ERR_get_state(void))
+DEPRECATEDIN_3_0(ERR_STATE *ERR_get_state(void))
 
 int ERR_get_next_error_library(void);
 
diff --git a/include/openssl/esserr.h b/include/openssl/esserr.h
index ee3041aa0b..8befce5c48 100644
--- a/include/openssl/esserr.h
+++ b/include/openssl/esserr.h
@@ -23,7 +23,7 @@ int ERR_load_ESS_strings(void);
 /*
  * ESS function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define ESS_F_ESS_CERT_ID_NEW_INIT                       0
 #  define ESS_F_ESS_CERT_ID_V2_NEW_INIT                    0
 #  define ESS_F_ESS_SIGNING_CERT_ADD                       0
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index c1c253c1e3..06f8b1f1db 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_ENVELOPE_H
 # endif
 
@@ -526,7 +526,7 @@ void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);
 void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);
 # define EVP_CIPHER_CTX_name(c)         EVP_CIPHER_name(EVP_CIPHER_CTX_cipher(c))
 # define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define EVP_CIPHER_CTX_flags(c)       EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c))
 # endif
 # define EVP_CIPHER_CTX_mode(c)         EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c))
@@ -726,7 +726,7 @@ int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
                     char *out, int *outl);
 int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define EVP_CIPHER_CTX_init(c)      EVP_CIPHER_CTX_reset(c)
 #  define EVP_CIPHER_CTX_cleanup(c)   EVP_CIPHER_CTX_reset(c)
 # endif
@@ -1005,7 +1005,7 @@ const EVP_CIPHER *EVP_sm4_ofb(void);
 const EVP_CIPHER *EVP_sm4_ctr(void);
 # endif
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define OPENSSL_add_all_algorithms_conf() \
     OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
                         | OPENSSL_INIT_ADD_ALL_DIGESTS \
diff --git a/include/openssl/evperr.h b/include/openssl/evperr.h
index 7da9083ae1..7744465906 100644
--- a/include/openssl/evperr.h
+++ b/include/openssl/evperr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_EVPERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_EVP_strings(void);
 /*
  * EVP function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define EVP_F_AESNI_INIT_KEY                             0
 #  define EVP_F_AESNI_XTS_INIT_KEY                         0
 #  define EVP_F_AES_GCM_CTRL                               0
diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h
index 8214853e07..2f80038f78 100644
--- a/include/openssl/hmac.h
+++ b/include/openssl/hmac.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_HMAC_H
 # endif
 
@@ -20,7 +20,7 @@
 
 # include <openssl/evp.h>
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HMAC_MAX_MD_CBLOCK      128    /* Deprecated */
 # endif
 
diff --git a/include/openssl/idea.h b/include/openssl/idea.h
index 667865281d..3e46f2822d 100644
--- a/include/openssl/idea.h
+++ b/include/openssl/idea.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_IDEA_H
 # endif
 
@@ -51,7 +51,7 @@ void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out,
                         int *num);
 void IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define idea_options          IDEA_options
 #  define idea_ecb_encrypt      IDEA_ecb_encrypt
 #  define idea_set_encrypt_key  IDEA_set_encrypt_key
diff --git a/include/openssl/kdf.h b/include/openssl/kdf.h
index b80f6b3e0f..d8f81c9c4d 100644
--- a/include/openssl/kdf.h
+++ b/include/openssl/kdf.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_KDF_H
 # endif
 
diff --git a/include/openssl/lhash.h b/include/openssl/lhash.h
index 7cf2800dcd..b1b5aa550a 100644
--- a/include/openssl/lhash.h
+++ b/include/openssl/lhash.h
@@ -16,7 +16,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_LHASH_H
 # endif
 
@@ -98,7 +98,7 @@ void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
 void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
 void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define _LHASH OPENSSL_LHASH
 #  define LHASH_NODE OPENSSL_LH_NODE
 #  define lh_error OPENSSL_LH_error
diff --git a/include/openssl/macros.h b/include/openssl/macros.h
index 78fbd38698..0c45580405 100644
--- a/include/openssl/macros.h
+++ b/include/openssl/macros.h
@@ -8,6 +8,7 @@
  */
 
 #include <openssl/opensslconf.h>
+#include <openssl/opensslv.h>
 
 #ifndef OPENSSL_MACROS_H
 # define OPENSSL_MACROS_H
@@ -19,14 +20,7 @@
 # define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;
 
 /*
- * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
- * declarations of functions deprecated in or before <version>.  If this is
- * undefined, the value of the macro OPENSSL_API_MIN above is the default.
- *
- * For any version number up until version 1.1.x, <version> is expected to be
- * the calculated version number 0xMNNFFPPSL.  For version numbers 3.0.0 and
- * on, <version> is expected to be only the major version number (i.e. 3 for
- * version 3.0.0).
+ * Generic deprecation macro
  */
 # ifndef DECLARE_DEPRECATED
 #  define DECLARE_DEPRECATED(f)   f;
@@ -44,82 +38,169 @@
 # endif
 
 /*
- * We convert the OPENSSL_API_COMPAT value to an API level.  The API level
- * is the major version number for 3.0.0 and on.  For earlier versions, it
- * uses this scheme, which is close enough for our purposes:
+ * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
+ * declarations of functions deprecated in or before <version>.  If this is
+ * undefined, the value of the macro OPENSSL_CONFIGURED_API (defined in
+ * <openssl/opensslconf.h>) is the default.
+ *
+ * For any version number up until version 1.1.x, <version> is expected to be
+ * the calculated version number 0xMNNFFPPSL.
+ * For version numbers 3.0 and on, <version> is expected to be a computation
+ * of the major and minor numbers in decimal using this formula:
+ *
+ *     MAJOR * 10000 + MINOR * 100
  *
- *      0.x.y   0       (0.9.8 was the last release in this series)
- *      1.0.x   1       (1.0.2 was the last release in this series)
- *      1.1.x   2       (1.1.1 was the last release in this series)
+ * So version 3.0 becomes 30000, version 3.2 becomes 30200, etc.
  */
 
-/* In case someone defined both */
-# if defined(OPENSSL_API_COMPAT) && defined(OPENSSL_API_LEVEL)
-#  error "Disallowed to define both OPENSSL_API_COMPAT and OPENSSL_API_LEVEL"
+/*
+ * We use the OPENSSL_API_COMPAT value to define API level macros.  These
+ * macros are used to enable or disable features at that API version boundary.
+ */
+
+# ifdef OPENSSL_API_LEVEL
+#  error "OPENSSL_API_LEVEL must not be defined by application"
 # endif
 
-# ifndef OPENSSL_API_COMPAT
-#  define OPENSSL_API_LEVEL OPENSSL_MIN_API
-# else
-#  if (OPENSSL_API_COMPAT < 0x1000L) /* Major version numbers up to 16777215 */
-#   define OPENSSL_API_LEVEL OPENSSL_API_COMPAT
-#  elif (OPENSSL_API_COMPAT & 0xF0000000L) == 0x00000000L
-#   define OPENSSL_API_LEVEL 0
-#  elif (OPENSSL_API_COMPAT & 0xFFF00000L) == 0x10000000L
-#   define OPENSSL_API_LEVEL 1
-#  elif (OPENSSL_API_COMPAT & 0xFFF00000L) == 0x10100000L
-#   define OPENSSL_API_LEVEL 2
+/*
+ * We figure out what API level was intended by simple numeric comparison.
+ * The lowest old style number we recognise is 0x00908000L, so we take some
+ * safety margin and assume that anything below 0x00900000L is a new style
+ * number.  This allows new versions up to and including v943.71.83.
+ */
+# ifdef OPENSSL_API_COMPAT
+#  if OPENSSL_API_COMPAT < 0x900000L
+#   define OPENSSL_API_LEVEL (OPENSSL_API_COMPAT)
 #  else
-    /* Major number 3 to 15 */
-#   define OPENSSL_API_LEVEL ((OPENSSL_API_COMPAT >> 28) & 0xF)
+#   define OPENSSL_API_LEVEL                            \
+           (((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000  \
+            + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
+            + ((OPENSSL_API_COMPAT >> 12) & 0xFF))
 #  endif
 # endif
 
 /*
- * Define API level check macros up to what makes sense.  Since we
- * do future deprecations, we define one API level beyond the current
- * major version number.
+ * If OPENSSL_API_COMPAT wasn't given, we use default numbers to set
+ * the API compatibility level.
  */
+# ifndef OPENSSL_API_LEVEL
+#  if OPENSSL_CONFIGURED_API > 0
+#   define OPENSSL_API_LEVEL (OPENSSL_CONFIGURED_API)
+#  else
+#   define OPENSSL_API_LEVEL \
+           (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100)
+#  endif
+# endif
 
-# if OPENSSL_API_LEVEL < 4
-#  define DEPRECATEDIN_4(f)       DECLARE_DEPRECATED(f)
-#  define OPENSSL_API_4 0
-# else
-#  define DEPRECATEDIN_4(f)
-#  define OPENSSL_API_4 1
+# if OPENSSL_API_LEVEL > OPENSSL_CONFIGURED_API
+#  error "The requested API level higher than the configured API compatibility level"
 # endif
 
-# if OPENSSL_API_LEVEL < 3
-#  define DEPRECATEDIN_3(f)       DECLARE_DEPRECATED(f)
-#  define OPENSSL_API_3 0
-# else
-#  define DEPRECATEDIN_3(f)
-#  define OPENSSL_API_3 1
+/*
+ * Check of sane values.
+ */
+/* Can't go higher than the current version. */
+# if OPENSSL_API_LEVEL > (OPENSSL_VERSION_MAJOR * 10000 + OPENSSL_VERSION_MINOR * 100)
+#  error "OPENSSL_API_COMPAT expresses an impossible API compatibility level"
+# endif
+/* OpenSSL will have no version 2.y.z */
+# if OPENSSL_API_LEVEL < 30000 && OPENSSL_API_LEVEL >= 20000
+#  error "OPENSSL_API_COMPAT expresses an impossible API compatibility level"
+# endif
+/* Below 0.9.8 is unacceptably low */
+# if OPENSSL_API_LEVEL < 908
+#  error "OPENSSL_API_COMPAT expresses an impossible API compatibility level"
 # endif
 
-# if OPENSSL_API_LEVEL < 2
-#  define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)
-#  define OPENSSL_API_1_1_0 0
+/*
+ * Define macros for deprecation purposes.  We always define the macros
+ * DEPERECATEDIN_{major}_{minor}() for all OpenSSL versions we care for,
+ * and OPENSSL_NO_DEPRECATED_{major}_{minor} to be used to check if
+ * removal of deprecated functions applies on that particular version.
+ */
+
+# undef OPENSSL_NO_DEPRECATED_3_0
+# undef OPENSSL_NO_DEPRECATED_1_1_1
+# undef OPENSSL_NO_DEPRECATED_1_1_0
+# undef OPENSSL_NO_DEPRECATED_1_0_2
+# undef OPENSSL_NO_DEPRECATED_1_0_1
+# undef OPENSSL_NO_DEPRECATED_1_0_0
+# undef OPENSSL_NO_DEPRECATED_0_9_8
+
+# if OPENSSL_API_LEVEL >= 30000
+#  ifndef OPENSSL_NO_DEPRECATED
+#   define DEPRECATEDIN_3_0(f)       DECLARE_DEPRECATED(f)
+#  else
+#   define DEPRECATEDIN_3_0(f)
+#   define OPENSSL_NO_DEPRECATED_3_0
+#  endif
 # else
-#  define DEPRECATEDIN_1_1_0(f)
-#  define OPENSSL_API_1_1_0 1
+#  define DEPRECATEDIN_3_0(f)        f;
 # endif
-
-# if OPENSSL_API_LEVEL < 1
-#  define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)
-#  define OPENSSL_API_1_0_0 0
+# if OPENSSL_API_LEVEL >= 10101
+#  ifndef OPENSSL_NO_DEPRECATED
+#   define DEPRECATEDIN_1_1_1(f)     DECLARE_DEPRECATED(f)
+#  else
+#   define DEPRECATEDIN_1_1_1(f)
+#   define OPENSSL_NO_DEPRECATED_1_1_1
+#  endif
 # else
-#  define DEPRECATEDIN_1_0_0(f)
-#  define OPENSSL_API_1_0_0 1
+#  define DEPRECATEDIN_1_1_1(f)      f;
 # endif
-
-# if OPENSSL_API_LEVEL < 0
-#  define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)
-#  define OPENSSL_API_0_9_8 0
+# if OPENSSL_API_LEVEL >= 10100
+#  ifndef OPENSSL_NO_DEPRECATED
+#   define DEPRECATEDIN_1_1_0(f)     DECLARE_DEPRECATED(f)
+#  else
+#   define DEPRECATEDIN_1_1_0(f)
+#   define OPENSSL_NO_DEPRECATED_1_1_0
+#  endif
 # else
-#  define DEPRECATEDIN_0_9_8(f)
-#  define OPENSSL_API_0_9_8 1
+#  define DEPRECATEDIN_1_1_0(f)      f;
 # endif
+# if OPENSSL_API_LEVEL >= 10002
+#  ifndef OPENSSL_NO_DEPRECATED
+#   define DEPRECATEDIN_1_0_2(f)     DECLARE_DEPRECATED(f)
+#  else
+#   define DEPRECATEDIN_1_0_2(f)
+#   define OPENSSL_NO_DEPRECATED_1_0_2
+#  endif
+# else
+#  define DEPRECATEDIN_1_0_2(f)      f;
+# endif
+# if OPENSSL_API_LEVEL >= 10001
+#  ifndef OPENSSL_NO_DEPRECATED
+#   define DEPRECATEDIN_1_0_1(f)     DECLARE_DEPRECATED(f)
+#  else
+#   define DEPRECATEDIN_1_0_1(f)
+#   define OPENSSL_NO_DEPRECATED_1_0_1
+#  endif
+# else
+#  define DEPRECATEDIN_1_0_1(f)      f;
+# endif
+# if OPENSSL_API_LEVEL >= 10000
+#  ifndef OPENSSL_NO_DEPRECATED
+#   define DEPRECATEDIN_1_0_0(f)     DECLARE_DEPRECATED(f)
+#  else
+#   define DEPRECATEDIN_1_0_0(f)
+#   define OPENSSL_NO_DEPRECATED_1_0_0
+#  endif
+# else
+#  define DEPRECATEDIN_1_0_0(f)      f;
+# endif
+# if OPENSSL_API_LEVEL >= 908
+#  ifndef OPENSSL_NO_DEPRECATED
+#   define DEPRECATEDIN_0_9_8(f)     DECLARE_DEPRECATED(f)
+#  else
+#   define DEPRECATEDIN_0_9_8(f)
+#   define OPENSSL_NO_DEPRECATED_0_9_8
+#  endif
+# else
+#  define DEPRECATEDIN_0_9_8(f)      f;
+# endif
+
+/*
+ * Make our own variants of __FILE__ and __LINE__, depending on configuration
+ */
 
 # ifndef OPENSSL_FILE
 #  ifdef OPENSSL_NO_FILENAMES
diff --git a/include/openssl/md2.h b/include/openssl/md2.h
index 005a7bd4fc..f4a14caa72 100644
--- a/include/openssl/md2.h
+++ b/include/openssl/md2.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_MD2_H
 # endif
 
diff --git a/include/openssl/md4.h b/include/openssl/md4.h
index a66db24263..6ba2d5d9ac 100644
--- a/include/openssl/md4.h
+++ b/include/openssl/md4.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_MD4_H
 # endif
 
diff --git a/include/openssl/md5.h b/include/openssl/md5.h
index 78133a3474..0a75b084a2 100644
--- a/include/openssl/md5.h
+++ b/include/openssl/md5.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_MD5_H
 # endif
 
diff --git a/include/openssl/mdc2.h b/include/openssl/mdc2.h
index c1dc1cf62d..a74e529bc7 100644
--- a/include/openssl/mdc2.h
+++ b/include/openssl/mdc2.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_MDC2_H
 # endif
 
diff --git a/include/openssl/modes.h b/include/openssl/modes.h
index 78cc98cd7e..1c672d2a46 100644
--- a/include/openssl/modes.h
+++ b/include/openssl/modes.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_MODES_H
 # endif
 
diff --git a/include/openssl/objects.h b/include/openssl/objects.h
index 45fa7e683b..9ea91c27c8 100644
--- a/include/openssl/objects.h
+++ b/include/openssl/objects.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_OBJECTS_H
 # endif
 
@@ -163,7 +163,7 @@ const void *OBJ_bsearch_ex_(const void *key, const void *base, int num,
 int OBJ_new_nid(int num);
 int OBJ_add_object(const ASN1_OBJECT *obj);
 int OBJ_create(const char *oid, const char *sn, const char *ln);
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 # define OBJ_cleanup() while(0) continue
 #endif
 int OBJ_create_objects(BIO *in);
diff --git a/include/openssl/objectserr.h b/include/openssl/objectserr.h
index 9aa4acbbc0..84c75012d2 100644
--- a/include/openssl/objectserr.h
+++ b/include/openssl/objectserr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_OBJERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_OBJ_strings(void);
 /*
  * OBJ function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define OBJ_F_OBJ_ADD_OBJECT                             0
 #  define OBJ_F_OBJ_ADD_SIGID                              0
 #  define OBJ_F_OBJ_CREATE                                 0
diff --git a/include/openssl/ocsp.h b/include/openssl/ocsp.h
index 1cc2cc6bcd..b9dc9887de 100644
--- a/include/openssl/ocsp.h
+++ b/include/openssl/ocsp.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_OCSP_H
 # endif
 
diff --git a/include/openssl/ocsperr.h b/include/openssl/ocsperr.h
index fa68f6ef00..57f0a90c12 100644
--- a/include/openssl/ocsperr.h
+++ b/include/openssl/ocsperr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_OCSPERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_OCSP_strings(void);
 /*
  * OCSP function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define OCSP_F_D2I_OCSP_NONCE                            0
 #   define OCSP_F_OCSP_BASIC_ADD1_STATUS                    0
 #   define OCSP_F_OCSP_BASIC_SIGN                           0
diff --git a/include/openssl/opensslconf.h.in b/include/openssl/opensslconf.h.in
index c3448338a2..c0ef3ddcff 100644
--- a/include/openssl/opensslconf.h.in
+++ b/include/openssl/opensslconf.h.in
@@ -66,8 +66,5 @@ extern "C" {
 # endif
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
-#  define HEADER_FILE_H /* deprecated in version 3.0 */
-# endif
 
 #endif                          /* OPENSSL_OPENSSLCONF_H */
diff --git a/include/openssl/opensslv.h.in b/include/openssl/opensslv.h.in
index 69ba8c657a..9380504721 100644
--- a/include/openssl/opensslv.h.in
+++ b/include/openssl/opensslv.h.in
@@ -13,11 +13,6 @@
 # define OPENSSL_OPENSSLV_H
 # pragma once
 
-# include <openssl/macros.h>
-# if !OPENSSL_API_3
-#  define HEADER_OPENSSLV_H
-# endif
-
 # ifdef  __cplusplus
 extern "C" {
 # endif
@@ -138,4 +133,10 @@ _____
 # ifdef  __cplusplus
 }
 # endif
+
+# include <openssl/macros.h>
+# ifndef OPENSSL_NO_DEPRECATED_3_0
+#  define HEADER_OPENSSLV_H
+# endif
+
 #endif                          /* OPENSSL_OPENSSLV_H */
diff --git a/include/openssl/pem.h b/include/openssl/pem.h
index 915b5df4ab..3f56a9fb02 100644
--- a/include/openssl/pem.h
+++ b/include/openssl/pem.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_PEM_H
 # endif
 
diff --git a/include/openssl/pem2.h b/include/openssl/pem2.h
index baaff3204d..a8a5325bd4 100644
--- a/include/openssl/pem2.h
+++ b/include/openssl/pem2.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_PEM2_H
 # endif
 # include <openssl/pemerr.h>
diff --git a/include/openssl/pemerr.h b/include/openssl/pemerr.h
index ca1b5d4ae3..c37a3acb9e 100644
--- a/include/openssl/pemerr.h
+++ b/include/openssl/pemerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_PEMERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_PEM_strings(void);
 /*
  * PEM function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define PEM_F_B2I_DSS                                    0
 #  define PEM_F_B2I_PVK_BIO                                0
 #  define PEM_F_B2I_RSA                                    0
diff --git a/include/openssl/pkcs12.h b/include/openssl/pkcs12.h
index 7fd5827d8a..51d6e8a485 100644
--- a/include/openssl/pkcs12.h
+++ b/include/openssl/pkcs12.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_PKCS12_H
 # endif
 
@@ -61,7 +61,7 @@ typedef struct pkcs12_bag_st PKCS12_BAGS;
 
 /* Compatibility macros */
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 
 # define M_PKCS12_bag_type PKCS12_bag_type
 # define M_PKCS12_cert_bag_type PKCS12_cert_bag_type
diff --git a/include/openssl/pkcs12err.h b/include/openssl/pkcs12err.h
index b994240438..12eac4a75c 100644
--- a/include/openssl/pkcs12err.h
+++ b/include/openssl/pkcs12err.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_PKCS12ERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_PKCS12_strings(void);
 /*
  * PKCS12 function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define PKCS12_F_OPENSSL_ASC2UNI                         0
 #  define PKCS12_F_OPENSSL_UNI2ASC                         0
 #  define PKCS12_F_OPENSSL_UNI2UTF8                        0
diff --git a/include/openssl/pkcs7.h b/include/openssl/pkcs7.h
index 8b208f3700..7c079a2ec5 100644
--- a/include/openssl/pkcs7.h
+++ b/include/openssl/pkcs7.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_PKCS7_H
 # endif
 
diff --git a/include/openssl/pkcs7err.h b/include/openssl/pkcs7err.h
index e82f6ef83f..41735bdfc8 100644
--- a/include/openssl/pkcs7err.h
+++ b/include/openssl/pkcs7err.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_PKCS7ERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_PKCS7_strings(void);
 /*
  * PKCS7 function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   0
 #  define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           0
 #  define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                0
diff --git a/include/openssl/rand.h b/include/openssl/rand.h
index 974476765d..1cffab7c54 100644
--- a/include/openssl/rand.h
+++ b/include/openssl/rand.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RAND_H
 # endif
 
@@ -42,7 +42,7 @@ int RAND_set_rand_engine(ENGINE *engine);
 
 RAND_METHOD *RAND_OpenSSL(void);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #   define RAND_cleanup() while(0) continue
 # endif
 int RAND_bytes(unsigned char *buf, int num);
diff --git a/include/openssl/rand_drbg.h b/include/openssl/rand_drbg.h
index f52e5ee041..e9857ec431 100644
--- a/include/openssl/rand_drbg.h
+++ b/include/openssl/rand_drbg.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_DRBG_RAND_H
 # endif
 
@@ -42,7 +42,7 @@
 /* Used by RAND_DRBG_set_defaults() to set the private DRBG type and flags. */
 # define RAND_DRBG_FLAG_PRIVATE              0x10
 
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 /* This #define was replaced by an internal constant and should not be used. */
 #  define RAND_DRBG_USED_FLAGS  (RAND_DRBG_FLAG_CTR_NO_DF)
 # endif
diff --git a/include/openssl/randerr.h b/include/openssl/randerr.h
index eb952b4ad4..e633260712 100644
--- a/include/openssl/randerr.h
+++ b/include/openssl/randerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RANDERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_RAND_strings(void);
 /*
  * RAND function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define RAND_F_DRBG_BYTES                                0
 #  define RAND_F_DRBG_CTR_INIT                             0
 #  define RAND_F_DRBG_GET_ENTROPY                          0
diff --git a/include/openssl/rc2.h b/include/openssl/rc2.h
index d7be6b49ea..250168abf9 100644
--- a/include/openssl/rc2.h
+++ b/include/openssl/rc2.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RC2_H
 # endif
 
diff --git a/include/openssl/rc4.h b/include/openssl/rc4.h
index fed6fcae65..6a3a191abf 100644
--- a/include/openssl/rc4.h
+++ b/include/openssl/rc4.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RC4_H
 # endif
 
diff --git a/include/openssl/rc5.h b/include/openssl/rc5.h
index d4d97ed226..53e23ff915 100644
--- a/include/openssl/rc5.h
+++ b/include/openssl/rc5.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RC5_H
 # endif
 
diff --git a/include/openssl/ripemd.h b/include/openssl/ripemd.h
index 7f1dbd2a68..3db616d186 100644
--- a/include/openssl/ripemd.h
+++ b/include/openssl/ripemd.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RIPEMD_H
 # endif
 
diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h
index 9214efd499..eba0604455 100644
--- a/include/openssl/rsa.h
+++ b/include/openssl/rsa.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RSA_H
 # endif
 
@@ -23,7 +23,7 @@
 # include <openssl/bio.h>
 # include <openssl/crypto.h>
 # include <openssl/types.h>
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/bn.h>
 # endif
 # include <openssl/rsaerr.h>
@@ -81,13 +81,13 @@ extern "C" {
  * but other engines might not need it
  */
 # define RSA_FLAG_NO_BLINDING            0x0080
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /*
  * Does nothing. Previously this switched off constant time behaviour.
  */
 #  define RSA_FLAG_NO_CONSTTIME           0x0000
 # endif
-# if !OPENSSL_API_0_9_8
+# ifndef OPENSSL_NO_DEPRECATED_0_9_8
 /* deprecated name for the flag*/
 /*
  * new with 0.9.7h; the built-in RSA
diff --git a/include/openssl/rsaerr.h b/include/openssl/rsaerr.h
index 1f685ec8ea..91fcc1cf8e 100644
--- a/include/openssl/rsaerr.h
+++ b/include/openssl/rsaerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_RSAERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_RSA_strings(void);
 /*
  * RSA function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define RSA_F_CHECK_PADDING_MD                           0
 #  define RSA_F_ENCODE_PKCS1                               0
 #  define RSA_F_INT_RSA_VERIFY                             0
diff --git a/include/openssl/safestack.h b/include/openssl/safestack.h
index 1b7b73d4b5..b8de23cf3a 100644
--- a/include/openssl/safestack.h
+++ b/include/openssl/safestack.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SAFESTACK_H
 # endif
 
diff --git a/include/openssl/seed.h b/include/openssl/seed.h
index 9ae2bce1ca..81533f203b 100644
--- a/include/openssl/seed.h
+++ b/include/openssl/seed.h
@@ -37,7 +37,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SEED_H
 # endif
 
diff --git a/include/openssl/sha.h b/include/openssl/sha.h
index 5d21bdf0d8..e262ea3700 100644
--- a/include/openssl/sha.h
+++ b/include/openssl/sha.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SHA_H
 # endif
 
diff --git a/include/openssl/srp.h b/include/openssl/srp.h
index 82b4d5b3dd..9f6f1b8644 100644
--- a/include/openssl/srp.h
+++ b/include/openssl/srp.h
@@ -16,7 +16,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SRP_H
 # endif
 
diff --git a/include/openssl/srtp.h b/include/openssl/srtp.h
index 32056cb280..d64606e5d9 100644
--- a/include/openssl/srtp.h
+++ b/include/openssl/srtp.h
@@ -18,7 +18,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_D1_SRTP_H
 # endif
 
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index dbf1b48f14..972e2ef827 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -14,7 +14,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SSL_H
 # endif
 
@@ -22,7 +22,7 @@
 # include <openssl/opensslconf.h>
 # include <openssl/comp.h>
 # include <openssl/bio.h>
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/x509.h>
 #  include <openssl/crypto.h>
 #  include <openssl/buffer.h>
@@ -178,7 +178,7 @@ extern "C" {
  * DEPRECATED IN 3.0.0, in favor of OSSL_default_cipher_list()
  * Update both macro and function simultaneously
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL"
 /*
  * This is the default set of TLSv1.3 ciphersuites
@@ -1125,7 +1125,7 @@ size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);
 # define SSL_VERIFY_CLIENT_ONCE          0x04
 # define SSL_VERIFY_POST_HANDSHAKE       0x08
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define OpenSSL_add_ssl_algorithms()   SSL_library_init()
 #  define SSLeay_add_ssl_algorithms()    SSL_library_init()
 # endif
@@ -1345,7 +1345,7 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
         SSL_ctrl(s,SSL_CTRL_SET_DH_AUTO,onoff,NULL)
 # define SSL_set_tmp_dh(ssl,dh) \
         SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)(dh))
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \
         SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh))
 #  define SSL_set_tmp_ecdh(ssl,ecdh) \
@@ -1500,7 +1500,7 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
 # define SSL_get_shared_curve          SSL_get_shared_group
 
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /* Provide some compatibility macros for removed functionality. */
 #  define SSL_CTX_need_tmp_RSA(ctx)                0
 #  define SSL_CTX_set_tmp_rsa(ctx,rsa)             1
@@ -1630,7 +1630,7 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
 int SSL_add_store_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
                                        const char *uri);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define SSL_load_error_strings() \
     OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \
                      | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
@@ -1987,7 +1987,7 @@ void SSL_set_accept_state(SSL *s);
 
 __owur long SSL_get_default_timeout(const SSL *s);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define SSL_library_init() OPENSSL_init_ssl(0, NULL)
 # endif
 
@@ -2020,7 +2020,7 @@ __owur int SSL_CTX_set_default_verify_store(SSL_CTX *ctx);
 __owur int SSL_CTX_load_verify_file(SSL_CTX *ctx, const char *CAfile);
 __owur int SSL_CTX_load_verify_dir(SSL_CTX *ctx, const char *CApath);
 __owur int SSL_CTX_load_verify_store(SSL_CTX *ctx, const char *CAstore);
-DEPRECATEDIN_3(__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx,
+DEPRECATEDIN_3_0(__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx,
                                                         const char *CAfile,
                                                         const char *CApath))
 # define SSL_get0_session SSL_get_session/* just peek at pointer */
@@ -2121,7 +2121,7 @@ __owur int SSL_COMP_get_id(const SSL_COMP *comp);
 STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);
 __owur STACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP)
                                                              *meths);
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define SSL_COMP_free_compression_methods() while(0) continue
 # endif
 __owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);
@@ -2173,7 +2173,7 @@ size_t SSL_get_num_tickets(const SSL *s);
 int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets);
 size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define SSL_cache_hit(s) SSL_session_reused(s)
 # endif
 
diff --git a/include/openssl/ssl2.h b/include/openssl/ssl2.h
index e9b9ba8802..428ead0540 100644
--- a/include/openssl/ssl2.h
+++ b/include/openssl/ssl2.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SSL2_H
 # endif
 
diff --git a/include/openssl/ssl3.h b/include/openssl/ssl3.h
index 63ab2a58e4..efef3ccfeb 100644
--- a/include/openssl/ssl3.h
+++ b/include/openssl/ssl3.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SSL3_H
 # endif
 
diff --git a/include/openssl/sslerr.h b/include/openssl/sslerr.h
index 87c6465edc..3f1c851349 100644
--- a/include/openssl/sslerr.h
+++ b/include/openssl/sslerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SSLERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_SSL_strings(void);
 /*
  * SSL function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define SSL_F_ADD_CLIENT_KEY_SHARE_EXT                   0
 #  define SSL_F_ADD_KEY_SHARE                              0
 #  define SSL_F_BYTES_TO_CIPHER_LIST                       0
diff --git a/include/openssl/stack.h b/include/openssl/stack.h
index 018e0d0a8b..031b672ed1 100644
--- a/include/openssl/stack.h
+++ b/include/openssl/stack.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_STACK_H
 # endif
 
@@ -56,7 +56,7 @@ OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st);
 void OPENSSL_sk_sort(OPENSSL_STACK *st);
 int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define _STACK OPENSSL_STACK
 #  define sk_num OPENSSL_sk_num
 #  define sk_value OPENSSL_sk_value
diff --git a/include/openssl/store.h b/include/openssl/store.h
index 8cceff7dbb..7b2561c2d5 100644
--- a/include/openssl/store.h
+++ b/include/openssl/store.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_OSSL_STORE_H
 # endif
 
diff --git a/include/openssl/storeerr.h b/include/openssl/storeerr.h
index 29e365bcc9..cb7304d9e5 100644
--- a/include/openssl/storeerr.h
+++ b/include/openssl/storeerr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_OSSL_STOREERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_OSSL_STORE_strings(void);
 /*
  * OSSL_STORE function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define OSSL_STORE_F_FILE_CTRL                           0
 #  define OSSL_STORE_F_FILE_FIND                           0
 #  define OSSL_STORE_F_FILE_GET_PASS                       0
diff --git a/include/openssl/symhacks.h b/include/openssl/symhacks.h
index abc5df3874..d3eacc293f 100644
--- a/include/openssl/symhacks.h
+++ b/include/openssl/symhacks.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_SYMHACKS_H
 # endif
 
diff --git a/include/openssl/tls1.h b/include/openssl/tls1.h
index 62a1763623..9a1683e0fd 100644
--- a/include/openssl/tls1.h
+++ b/include/openssl/tls1.h
@@ -14,7 +14,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_TLS1_H
 # endif
 
@@ -34,7 +34,7 @@ extern "C" {
 # define TLS1_1_VERSION                  0x0302
 # define TLS1_2_VERSION                  0x0303
 # define TLS1_3_VERSION                  0x0304
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define TLS_MAX_VERSION                TLS1_3_VERSION
 # endif
 
diff --git a/include/openssl/ts.h b/include/openssl/ts.h
index 6bd1f89152..1229838da6 100644
--- a/include/openssl/ts.h
+++ b/include/openssl/ts.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_TS_H
 # endif
 
@@ -421,7 +421,7 @@ BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b);
 unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx,
                                          unsigned char *hexstr, long len);
 X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s);
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define TS_VERIFY_CTS_set_certs(ctx, cert) TS_VERIFY_CTX_set_certs(ctx,cert)
 # endif
 STACK_OF(X509) *TS_VERIFY_CTX_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs);
diff --git a/include/openssl/tserr.h b/include/openssl/tserr.h
index 6da6946ffc..4684dc2652 100644
--- a/include/openssl/tserr.h
+++ b/include/openssl/tserr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_TSERR_H
 # endif
 
@@ -33,7 +33,7 @@ int ERR_load_TS_strings(void);
 /*
  * TS function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #   define TS_F_DEF_SERIAL_CB                               0
 #   define TS_F_DEF_TIME_CB                                 0
 #   define TS_F_INT_TS_RESP_VERIFY_TOKEN                    0
diff --git a/include/openssl/txt_db.h b/include/openssl/txt_db.h
index cb646450ca..af169a309e 100644
--- a/include/openssl/txt_db.h
+++ b/include/openssl/txt_db.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_TXT_DB_H
 # endif
 
diff --git a/include/openssl/ui.h b/include/openssl/ui.h
index a084402c68..56fb6f580f 100644
--- a/include/openssl/ui.h
+++ b/include/openssl/ui.h
@@ -12,13 +12,13 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_UI_H
 # endif
 
 # include <openssl/opensslconf.h>
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/crypto.h>
 # endif
 # include <openssl/safestack.h>
@@ -27,7 +27,7 @@
 # include <openssl/uierr.h>
 
 /* For compatibility reasons, the macro OPENSSL_NO_UI is currently retained */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  ifdef OPENSSL_NO_UI_CONSOLE
 #   define OPENSSL_NO_UI
 #  endif
diff --git a/include/openssl/uierr.h b/include/openssl/uierr.h
index 36567dce45..dbc6432476 100644
--- a/include/openssl/uierr.h
+++ b/include/openssl/uierr.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_UIERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_UI_strings(void);
 /*
  * UI function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define UI_F_CLOSE_CONSOLE                               0
 #  define UI_F_ECHO_CONSOLE                                0
 #  define UI_F_GENERAL_ALLOCATE_BOOLEAN                    0
diff --git a/include/openssl/whrlpool.h b/include/openssl/whrlpool.h
index f375607a36..83f34288e4 100644
--- a/include/openssl/whrlpool.h
+++ b/include/openssl/whrlpool.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_WHRLPOOL_H
 # endif
 
diff --git a/include/openssl/x509.h b/include/openssl/x509.h
index 3b9c7ad506..116b30205c 100644
--- a/include/openssl/x509.h
+++ b/include/openssl/x509.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_X509_H
 # endif
 
@@ -27,7 +27,7 @@
 # include <openssl/safestack.h>
 # include <openssl/ec.h>
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  include <openssl/rsa.h>
 #  include <openssl/dsa.h>
 #  include <openssl/dh.h>
@@ -658,7 +658,7 @@ int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
 int X509_up_ref(X509 *x);
 int X509_get_signature_type(const X509 *x);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define X509_get_notBefore X509_getm_notBefore
 #  define X509_get_notAfter X509_getm_notAfter
 #  define X509_set_notBefore X509_set1_notBefore
@@ -724,7 +724,7 @@ int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
 int X509_CRL_sort(X509_CRL *crl);
 int X509_CRL_up_ref(X509_CRL *crl);
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate
 #  define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate
 #endif
diff --git a/include/openssl/x509_vfy.h b/include/openssl/x509_vfy.h
index 8b5f3f6dd6..651ffbcbe6 100644
--- a/include/openssl/x509_vfy.h
+++ b/include/openssl/x509_vfy.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_X509_VFY_H
 # endif
 
@@ -55,7 +55,7 @@ typedef enum {
     X509_LU_X509, X509_LU_CRL
 } X509_LOOKUP_TYPE;
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #define X509_LU_RETRY   -1
 #define X509_LU_FAIL    0
 #endif
@@ -205,7 +205,7 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);
 
 /* Certificate verify flags */
 
-# if !OPENSSL_API_1_1_0
+# ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define X509_V_FLAG_CB_ISSUER_CHECK             0x0   /* Deprecated */
 # endif
 /* Use check time instead of current time */
@@ -375,7 +375,7 @@ X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(X509_STORE_CTX *c
 X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(X509_STORE_CTX *ctx);
 X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(X509_STORE_CTX *ctx);
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 # define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain
 # define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted
 # define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack
@@ -500,7 +500,7 @@ int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
 int X509_STORE_load_file(X509_STORE *ctx, const char *file);
 int X509_STORE_load_path(X509_STORE *ctx, const char *path);
 int X509_STORE_load_store(X509_STORE *ctx, const char *store);
-DEPRECATEDIN_3(int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
+DEPRECATEDIN_3_0(int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
                                              const char *dir))
 int X509_STORE_set_default_paths(X509_STORE *ctx);
 
diff --git a/include/openssl/x509err.h b/include/openssl/x509err.h
index 19eb3ddcf1..5b0a6b5eaa 100644
--- a/include/openssl/x509err.h
+++ b/include/openssl/x509err.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_X509ERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_X509_strings(void);
 /*
  * X509 function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define X509_F_ADD_CERT_DIR                              0
 #  define X509_F_BUILD_CHAIN                               0
 #  define X509_F_BY_FILE_CTRL                              0
diff --git a/include/openssl/x509v3.h b/include/openssl/x509v3.h
index 419dc795dd..a4004867fc 100644
--- a/include/openssl/x509v3.h
+++ b/include/openssl/x509v3.h
@@ -12,7 +12,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_X509V3_H
 # endif
 
@@ -635,7 +635,7 @@ X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);
 int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,
                     int crit, unsigned long flags);
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 /* The new declarations are in crypto.h, but the old ones were here. */
 # define hex_to_string OPENSSL_buf2hexstr
 # define string_to_hex OPENSSL_hexstr2buf
diff --git a/include/openssl/x509v3err.h b/include/openssl/x509v3err.h
index f5f7e0bf2c..0dab8a2a36 100644
--- a/include/openssl/x509v3err.h
+++ b/include/openssl/x509v3err.h
@@ -13,7 +13,7 @@
 # pragma once
 
 # include <openssl/macros.h>
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define HEADER_X509V3ERR_H
 # endif
 
@@ -29,7 +29,7 @@ int ERR_load_X509V3_strings(void);
 /*
  * X509V3 function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define X509V3_F_A2I_GENERAL_NAME                        0
 #  define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL             0
 #  define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE             0
diff --git a/providers/common/include/prov/providercommonerr.h b/providers/common/include/prov/providercommonerr.h
index c726a1ec29..48daf69861 100644
--- a/providers/common/include/prov/providercommonerr.h
+++ b/providers/common/include/prov/providercommonerr.h
@@ -23,7 +23,7 @@ int ERR_load_PROV_strings(void);
 /*
  * PROV function codes.
  */
-# if !OPENSSL_API_3
+# ifndef OPENSSL_NO_DEPRECATED_3_0
 #  define PROV_F_AESNI_INIT_KEY                            0
 #  define PROV_F_AES_BLOCK_FINAL                           0
 #  define PROV_F_AES_BLOCK_UPDATE                          0
diff --git a/ssl/methods.c b/ssl/methods.c
index 0b03f80160..525f59e912 100644
--- a/ssl/methods.c
+++ b/ssl/methods.c
@@ -8,6 +8,7 @@
  */
 
 #include <stdio.h>
+#include <openssl/macros.h>
 #include <openssl/objects.h>
 #include "ssl_local.h"
 
@@ -172,7 +173,7 @@ IMPLEMENT_dtls1_meth_func(DTLS_ANY_VERSION, 0, 0,
                           DTLS_client_method,
                           ssl_undefined_function,
                           ossl_statem_connect, DTLSv1_2_enc_data)
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 # ifndef OPENSSL_NO_TLS1_2_METHOD
 const SSL_METHOD *TLSv1_2_method(void)
 {
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 2c901ff176..74161b0cb7 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -4243,7 +4243,7 @@ int SSL_CTX_load_verify_store(SSL_CTX *ctx, const char *CAstore)
     return X509_STORE_load_store(ctx->cert_store, CAstore);
 }
 
-#if OPENSSL_API_LEVEL < 3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
                                   const char *CApath)
 {
@@ -4668,7 +4668,7 @@ int SSL_is_server(const SSL *s)
     return s->server;
 }
 
-#if !OPENSSL_API_1_1_0
+#ifndef OPENSSL_NO_DEPRECATED_1_1_0
 void SSL_set_debug(SSL *s, int debug)
 {
     /* Old function was do-nothing anyway... */
diff --git a/test/asn1_decode_test.c b/test/asn1_decode_test.c
index 81c0f93558..b0c031a5a2 100644
--- a/test/asn1_decode_test.c
+++ b/test/asn1_decode_test.c
@@ -28,7 +28,7 @@ static unsigned char t_invalid_zero[] = {
     0x02, 0x00                   /* INTEGER tag + length */
 };
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 /* LONG case ************************************************************* */
 
 typedef struct {
@@ -162,7 +162,7 @@ static int test_uint64(void)
 
 int setup_tests(void)
 {
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     ADD_TEST(test_long);
 #endif
     ADD_TEST(test_int32);
diff --git a/test/asn1_encode_test.c b/test/asn1_encode_test.c
index 64f8f1754c..4ff8a20ff4 100644
--- a/test/asn1_encode_test.c
+++ b/test/asn1_encode_test.c
@@ -179,7 +179,7 @@ typedef struct {
     ENCDEC_DATA(-1, -1),                        \
     ENCDEC_DATA(0, ASN1_LONG_UNDEF)
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 /***** LONG ******************************************************************/
 
 typedef struct {
@@ -824,7 +824,7 @@ static int test_intern(const TEST_PACKAGE *package)
     return fail == 0;
 }
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 static int test_long_32bit(void)
 {
     return test_intern(&long_test_package_32bit);
@@ -858,7 +858,7 @@ static int test_uint64(void)
 
 int setup_tests(void)
 {
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     ADD_TEST(test_long_32bit);
     ADD_TEST(test_long_64bit);
 #endif
diff --git a/test/igetest.c b/test/igetest.c
index a4b8cfab4a..5a9ebb5b56 100644
--- a/test/igetest.c
+++ b/test/igetest.c
@@ -15,7 +15,7 @@
 #include "internal/nelem.h"
 #include "testutil.h"
 
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
 
 # define TEST_SIZE       128
 # define BIG_TEST_SIZE 10240
@@ -438,7 +438,7 @@ static int test_bi_ige_garble3(void)
 
 int setup_tests(void)
 {
-#if !OPENSSL_API_3
+#ifndef OPENSSL_NO_DEPRECATED_3_0
     RAND_bytes(rkey, sizeof(rkey));
     RAND_bytes(rkey2, sizeof(rkey2));
     RAND_bytes(plaintext, sizeof(plaintext));
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 625e10996b..ac28f86b25 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -149,7 +149,7 @@ ASN1_get_object                         151	3_0_0	EXIST::FUNCTION:
 i2d_IPAddressFamily                     152	3_0_0	EXIST::FUNCTION:RFC3779
 ENGINE_get_ctrl_function                153	3_0_0	EXIST::FUNCTION:ENGINE
 X509_REVOKED_get_ext_count              154	3_0_0	EXIST::FUNCTION:
-BN_is_prime_fasttest_ex                 155	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+BN_is_prime_fasttest_ex                 155	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 ERR_load_PKCS12_strings                 156	3_0_0	EXIST::FUNCTION:
 EVP_sha384                              157	3_0_0	EXIST::FUNCTION:
 i2d_DHparams                            158	3_0_0	EXIST::FUNCTION:DH
@@ -257,7 +257,7 @@ ASN1_NULL_free                          262	3_0_0	EXIST::FUNCTION:
 EC_KEY_copy                             263	3_0_0	EXIST::FUNCTION:EC
 EVP_des_ede3                            264	3_0_0	EXIST::FUNCTION:DES
 PKCS7_add1_attrib_digest                265	3_0_0	EXIST::FUNCTION:
-EC_POINT_get_affine_coordinates_GFp     266	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC
+EC_POINT_get_affine_coordinates_GFp     266	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
 EVP_seed_ecb                            267	3_0_0	EXIST::FUNCTION:SEED
 BIO_dgram_sctp_wait_for_dry             268	3_0_0	EXIST::FUNCTION:DGRAM,SCTP
 ASN1_OCTET_STRING_NDEF_it               269	3_0_0	EXIST::FUNCTION:
@@ -280,7 +280,7 @@ X509V3_EXT_get_nid                      285	3_0_0	EXIST::FUNCTION:
 BIO_s_log                               286	3_0_0	EXIST::FUNCTION:
 EC_POINT_set_to_infinity                287	3_0_0	EXIST::FUNCTION:EC
 EVP_des_ede_ofb                         288	3_0_0	EXIST::FUNCTION:DES
-ECDH_KDF_X9_62                          289	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC
+ECDH_KDF_X9_62                          289	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
 ASN1_UNIVERSALSTRING_to_string          290	3_0_0	EXIST::FUNCTION:
 CRYPTO_gcm128_setiv                     291	3_0_0	EXIST::FUNCTION:
 ASN1_PCTX_set_oid_flags                 292	3_0_0	EXIST::FUNCTION:
@@ -515,7 +515,7 @@ DH_generate_parameters                  526	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_0
 BN_set_negative                         527	3_0_0	EXIST::FUNCTION:
 i2d_TS_RESP_bio                         528	3_0_0	EXIST::FUNCTION:TS
 ASYNC_WAIT_CTX_set_wait_fd              529	3_0_0	EXIST::FUNCTION:
-ERR_func_error_string                   530	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+ERR_func_error_string                   530	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 ASN1_STRING_data                        531	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_1_1_0
 X509_CRL_add1_ext_i2d                   532	3_0_0	EXIST::FUNCTION:
 i2d_TS_TST_INFO                         533	3_0_0	EXIST::FUNCTION:TS
@@ -532,7 +532,7 @@ PEM_write_bio_RSAPrivateKey             543	3_0_0	EXIST::FUNCTION:RSA
 CONF_get_number                         544	3_0_0	EXIST::FUNCTION:
 X509_EXTENSION_get_object               545	3_0_0	EXIST::FUNCTION:
 X509_EXTENSIONS_it                      546	3_0_0	EXIST::FUNCTION:
-EC_POINT_set_compressed_coordinates_GF2m 547	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC,EC2M
+EC_POINT_set_compressed_coordinates_GF2m 547	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC,EC2M
 RSA_sign_ASN1_OCTET_STRING              548	3_0_0	EXIST::FUNCTION:RSA
 d2i_X509_CRL_fp                         549	3_0_0	EXIST::FUNCTION:STDIO
 i2d_RSA_PUBKEY                          550	3_0_0	EXIST::FUNCTION:RSA
@@ -622,7 +622,7 @@ BN_get_rfc3526_prime_8192               637	3_0_0	EXIST::FUNCTION:
 X509_REVOKED_it                         638	3_0_0	EXIST::FUNCTION:
 CRYPTO_THREAD_write_lock                639	3_0_0	EXIST::FUNCTION:
 X509V3_NAME_from_section                640	3_0_0	EXIST::FUNCTION:
-EC_POINT_set_compressed_coordinates_GFp 641	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC
+EC_POINT_set_compressed_coordinates_GFp 641	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
 OCSP_SINGLERESP_get0_id                 642	3_0_0	EXIST::FUNCTION:OCSP
 UI_add_info_string                      643	3_0_0	EXIST::FUNCTION:
 OBJ_NAME_remove                         644	3_0_0	EXIST::FUNCTION:
@@ -666,7 +666,7 @@ DSO_global_lookup                       682	3_0_0	EXIST::FUNCTION:
 PKCS7_SIGNER_INFO_it                    683	3_0_0	EXIST::FUNCTION:
 CRYPTO_ocb128_copy_ctx                  684	3_0_0	EXIST::FUNCTION:OCB
 TS_REQ_get_ext_d2i                      685	3_0_0	EXIST::FUNCTION:TS
-AES_ige_encrypt                         686	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+AES_ige_encrypt                         686	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 d2i_SXNET                               687	3_0_0	EXIST::FUNCTION:
 CTLOG_get0_log_id                       688	3_0_0	EXIST::FUNCTION:CT
 CMS_RecipientInfo_ktri_get0_signer_id   689	3_0_0	EXIST::FUNCTION:CMS
@@ -708,7 +708,7 @@ BIO_snprintf                            726	3_0_0	EXIST::FUNCTION:
 EC_POINT_hex2point                      727	3_0_0	EXIST::FUNCTION:EC
 X509v3_get_ext_by_critical              728	3_0_0	EXIST::FUNCTION:
 ENGINE_get_default_RSA                  729	3_0_0	EXIST::FUNCTION:ENGINE
-DSA_sign_setup                          730	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,DSA
+DSA_sign_setup                          730	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,DSA
 OPENSSL_sk_new_null                     731	3_0_0	EXIST::FUNCTION:
 PEM_read_PKCS8                          732	3_0_0	EXIST::FUNCTION:STDIO
 BN_mod_sqr                              733	3_0_0	EXIST::FUNCTION:
@@ -757,7 +757,7 @@ EVP_rc5_32_12_16_cfb64                  775	3_0_0	EXIST::FUNCTION:RC5
 PKCS7_dataVerify                        776	3_0_0	EXIST::FUNCTION:
 PKCS7_SIGNER_INFO_free                  777	3_0_0	EXIST::FUNCTION:
 PKCS7_add_attrib_smimecap               778	3_0_0	EXIST::FUNCTION:
-ERR_peek_last_error_line_data           779	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+ERR_peek_last_error_line_data           779	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 EVP_PKEY_meth_set_sign                  780	3_0_0	EXIST::FUNCTION:
 ASN1_i2d_bio                            781	3_0_0	EXIST::FUNCTION:
 DSA_verify                              782	3_0_0	EXIST::FUNCTION:DSA
@@ -969,7 +969,7 @@ DH_get_default_method                   993	3_0_0	EXIST::FUNCTION:DH
 PEM_proc_type                           994	3_0_0	EXIST::FUNCTION:
 BIO_printf                              995	3_0_0	EXIST::FUNCTION:
 a2i_IPADDRESS                           996	3_0_0	EXIST::FUNCTION:
-ERR_peek_error_line_data                997	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+ERR_peek_error_line_data                997	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 ERR_unload_strings                      998	3_0_0	EXIST::FUNCTION:
 SEED_cfb128_encrypt                     999	3_0_0	EXIST::FUNCTION:SEED
 ASN1_BIT_STRING_it                      1000	3_0_0	EXIST::FUNCTION:
@@ -1157,7 +1157,7 @@ EVP_PKEY_CTX_set0_keygen_info           1183	3_0_0	EXIST::FUNCTION:
 ENGINE_unregister_digests               1184	3_0_0	EXIST::FUNCTION:ENGINE
 IPAddressOrRange_new                    1185	3_0_0	EXIST::FUNCTION:RFC3779
 EVP_aes_256_ofb                         1186	3_0_0	EXIST::FUNCTION:
-CRYPTO_mem_debug_push                   1187	3_0_0	EXIST::FUNCTION:CRYPTO_MDEBUG,DEPRECATEDIN_3
+CRYPTO_mem_debug_push                   1187	3_0_0	EXIST::FUNCTION:CRYPTO_MDEBUG,DEPRECATEDIN_3_0
 X509_PKEY_new                           1188	3_0_0	EXIST::FUNCTION:
 X509_get_key_usage                      1189	3_0_0	EXIST::FUNCTION:
 X509_ATTRIBUTE_create_by_txt            1190	3_0_0	EXIST::FUNCTION:
@@ -1410,7 +1410,7 @@ EVP_PKEY_get0_DH                        1442	3_0_0	EXIST::FUNCTION:DH
 d2i_OCSP_CRLID                          1443	3_0_0	EXIST::FUNCTION:OCSP
 EVP_CIPHER_CTX_set_padding              1444	3_0_0	EXIST::FUNCTION:
 CTLOG_new_from_base64                   1445	3_0_0	EXIST::FUNCTION:CT
-AES_bi_ige_encrypt                      1446	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+AES_bi_ige_encrypt                      1446	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 ERR_pop_to_mark                         1447	3_0_0	EXIST::FUNCTION:
 CRL_DIST_POINTS_new                     1449	3_0_0	EXIST::FUNCTION:
 EVP_PKEY_get0_asn1                      1450	3_0_0	EXIST::FUNCTION:
@@ -1554,7 +1554,7 @@ SRP_VBASE_free                          1588	3_0_0	EXIST::FUNCTION:SRP
 PKCS7_add0_attrib_signing_time          1589	3_0_0	EXIST::FUNCTION:
 X509_STORE_set_flags                    1590	3_0_0	EXIST::FUNCTION:
 UI_get0_output_string                   1591	3_0_0	EXIST::FUNCTION:
-ERR_get_error_line_data                 1592	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+ERR_get_error_line_data                 1592	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 CTLOG_get0_name                         1593	3_0_0	EXIST::FUNCTION:CT
 ASN1_TBOOLEAN_it                        1594	3_0_0	EXIST::FUNCTION:
 RC2_set_key                             1595	3_0_0	EXIST::FUNCTION:RC2
@@ -1663,7 +1663,7 @@ X509_PURPOSE_cleanup                    1700	3_0_0	EXIST::FUNCTION:
 ESS_SIGNING_CERT_dup                    1701	3_0_0	EXIST::FUNCTION:
 ENGINE_set_default_DSA                  1702	3_0_0	EXIST::FUNCTION:ENGINE
 X509_REVOKED_new                        1703	3_0_0	EXIST::FUNCTION:
-NCONF_WIN32                             1704	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+NCONF_WIN32                             1704	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 RSA_padding_check_PKCS1_OAEP_mgf1       1705	3_0_0	EXIST::FUNCTION:RSA
 X509_policy_tree_get0_level             1706	3_0_0	EXIST::FUNCTION:
 ASN1_parse_dump                         1708	3_0_0	EXIST::FUNCTION:
@@ -1717,7 +1717,7 @@ ASYNC_init_thread                       1755	3_0_0	EXIST::FUNCTION:
 OCSP_BASICRESP_get_ext_by_OBJ           1756	3_0_0	EXIST::FUNCTION:OCSP
 X509_reject_clear                       1757	3_0_0	EXIST::FUNCTION:
 DH_security_bits                        1758	3_0_0	EXIST::FUNCTION:DH
-LONG_it                                 1759	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+LONG_it                                 1759	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 ASN1_dup                                1760	3_0_0	EXIST::FUNCTION:
 TS_RESP_new                             1761	3_0_0	EXIST::FUNCTION:TS
 i2d_PKCS8PrivateKeyInfo_fp              1762	3_0_0	EXIST::FUNCTION:STDIO
@@ -1780,7 +1780,7 @@ X509V3_EXT_add_list                     1821	3_0_0	EXIST::FUNCTION:
 CMS_compress                            1822	3_0_0	EXIST::FUNCTION:CMS
 X509_get_ext_by_critical                1823	3_0_0	EXIST::FUNCTION:
 ASYNC_WAIT_CTX_clear_fd                 1824	3_0_0	EXIST::FUNCTION:
-ZLONG_it                                1825	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+ZLONG_it                                1825	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 OPENSSL_sk_find_ex                      1826	3_0_0	EXIST::FUNCTION:
 ASN1_ENUMERATED_to_BN                   1827	3_0_0	EXIST::FUNCTION:
 X509_CRL_get_ext_d2i                    1828	3_0_0	EXIST::FUNCTION:
@@ -1815,7 +1815,7 @@ i2b_PrivateKey_bio                      1858	3_0_0	EXIST::FUNCTION:DSA
 ASN1_STRING_length_set                  1859	3_0_0	EXIST::FUNCTION:
 PEM_write_PKCS8                         1860	3_0_0	EXIST::FUNCTION:STDIO
 PKCS7_digest_from_attributes            1861	3_0_0	EXIST::FUNCTION:
-EC_GROUP_set_curve_GFp                  1862	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC
+EC_GROUP_set_curve_GFp                  1862	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
 X509_PURPOSE_get0                       1863	3_0_0	EXIST::FUNCTION:
 EVP_PKEY_set1_DSA                       1864	3_0_0	EXIST::FUNCTION:DSA
 X509_NAME_it                            1865	3_0_0	EXIST::FUNCTION:
@@ -1847,7 +1847,7 @@ IDEA_cbc_encrypt                        1890	3_0_0	EXIST::FUNCTION:IDEA
 BN_CTX_secure_new                       1891	3_0_0	EXIST::FUNCTION:
 OCSP_ONEREQ_add_ext                     1892	3_0_0	EXIST::FUNCTION:OCSP
 CMS_uncompress                          1893	3_0_0	EXIST::FUNCTION:CMS
-CRYPTO_mem_debug_pop                    1895	3_0_0	EXIST::FUNCTION:CRYPTO_MDEBUG,DEPRECATEDIN_3
+CRYPTO_mem_debug_pop                    1895	3_0_0	EXIST::FUNCTION:CRYPTO_MDEBUG,DEPRECATEDIN_3_0
 EVP_aes_192_cfb128                      1896	3_0_0	EXIST::FUNCTION:
 OCSP_REQ_CTX_nbio                       1897	3_0_0	EXIST::FUNCTION:OCSP
 EVP_CIPHER_CTX_copy                     1898	3_0_0	EXIST::FUNCTION:
@@ -1920,7 +1920,7 @@ X509_CRL_it                             1966	3_0_0	EXIST::FUNCTION:
 d2i_X509_ALGOR                          1967	3_0_0	EXIST::FUNCTION:
 PKCS12_PBE_keyivgen                     1968	3_0_0	EXIST::FUNCTION:
 BIO_test_flags                          1969	3_0_0	EXIST::FUNCTION:
-EC_POINT_get_affine_coordinates_GF2m    1970	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC,EC2M
+EC_POINT_get_affine_coordinates_GF2m    1970	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC,EC2M
 EVP_ENCODE_CTX_num                      1971	3_0_0	EXIST::FUNCTION:
 Camellia_cfb1_encrypt                   1972	3_0_0	EXIST::FUNCTION:CAMELLIA
 NCONF_load_fp                           1973	3_0_0	EXIST::FUNCTION:STDIO
@@ -2110,7 +2110,7 @@ i2d_ASN1_T61STRING                      2156	3_0_0	EXIST::FUNCTION:
 X509_add1_trust_object                  2157	3_0_0	EXIST::FUNCTION:
 PEM_write_X509                          2158	3_0_0	EXIST::FUNCTION:STDIO
 BN_CTX_free                             2159	3_0_0	EXIST::FUNCTION:
-EC_GROUP_get_curve_GF2m                 2160	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC,EC2M
+EC_GROUP_get_curve_GF2m                 2160	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC,EC2M
 EVP_MD_flags                            2161	3_0_0	EXIST::FUNCTION:
 OPENSSL_sk_set                          2162	3_0_0	EXIST::FUNCTION:
 OCSP_request_sign                       2163	3_0_0	EXIST::FUNCTION:OCSP
@@ -2122,7 +2122,7 @@ X509_EXTENSION_create_by_NID            2168	3_0_0	EXIST::FUNCTION:
 i2d_RSAPrivateKey                       2169	3_0_0	EXIST::FUNCTION:RSA
 d2i_CERTIFICATEPOLICIES                 2170	3_0_0	EXIST::FUNCTION:
 CMAC_CTX_get0_cipher_ctx                2171	3_0_0	EXIST::FUNCTION:CMAC
-X509_STORE_load_locations               2172	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+X509_STORE_load_locations               2172	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 OBJ_find_sigid_algs                     2173	3_0_0	EXIST::FUNCTION:
 TS_RESP_CTX_set_accuracy                2174	3_0_0	EXIST::FUNCTION:TS
 NETSCAPE_SPKI_get_pubkey                2175	3_0_0	EXIST::FUNCTION:
@@ -2187,7 +2187,7 @@ ENGINE_set_name                         2235	3_0_0	EXIST::FUNCTION:ENGINE
 TS_TST_INFO_get_policy_id               2236	3_0_0	EXIST::FUNCTION:TS
 PKCS7_SIGNER_INFO_set                   2237	3_0_0	EXIST::FUNCTION:
 PEM_write_bio_PKCS8_PRIV_KEY_INFO       2238	3_0_0	EXIST::FUNCTION:
-EC_GROUP_set_curve_GF2m                 2239	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC,EC2M
+EC_GROUP_set_curve_GF2m                 2239	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC,EC2M
 ENGINE_load_builtin_engines             2240	3_0_0	EXIST::FUNCTION:ENGINE
 SRP_VBASE_init                          2241	3_0_0	EXIST::FUNCTION:SRP
 SHA224_Final                            2242	3_0_0	EXIST::FUNCTION:
@@ -2213,7 +2213,7 @@ EVP_PKEY_missing_parameters             2261	3_0_0	EXIST::FUNCTION:
 X509_REQ_INFO_new                       2262	3_0_0	EXIST::FUNCTION:
 EVP_rc2_cfb64                           2263	3_0_0	EXIST::FUNCTION:RC2
 PKCS7_get_smimecap                      2264	3_0_0	EXIST::FUNCTION:
-ERR_get_state                           2265	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+ERR_get_state                           2265	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 d2i_DSAPrivateKey_bio                   2266	3_0_0	EXIST::FUNCTION:DSA
 X509_PURPOSE_get_trust                  2267	3_0_0	EXIST::FUNCTION:
 EC_GROUP_get_point_conversion_form      2268	3_0_0	EXIST::FUNCTION:EC
@@ -2577,7 +2577,7 @@ PKCS7_ENVELOPE_it                       2632	3_0_0	EXIST::FUNCTION:
 ASIdentifierChoice_it                   2633	3_0_0	EXIST::FUNCTION:RFC3779
 CMS_RecipientEncryptedKey_cert_cmp      2634	3_0_0	EXIST::FUNCTION:CMS
 EVP_PKEY_CTX_get_app_data               2635	3_0_0	EXIST::FUNCTION:
-EC_GROUP_clear_free                     2636	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC
+EC_GROUP_clear_free                     2636	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
 BN_get_rfc2409_prime_1024               2637	3_0_0	EXIST::FUNCTION:
 CRYPTO_set_mem_functions                2638	3_0_0	EXIST::FUNCTION:
 i2d_ASN1_VISIBLESTRING                  2639	3_0_0	EXIST::FUNCTION:
@@ -2874,7 +2874,7 @@ EVP_aes_192_cbc                         2936	3_0_0	EXIST::FUNCTION:
 PKCS8_pkey_set0                         2937	3_0_0	EXIST::FUNCTION:
 X509_get1_email                         2938	3_0_0	EXIST::FUNCTION:
 EC_POINT_point2oct                      2939	3_0_0	EXIST::FUNCTION:EC
-EC_GROUP_get_curve_GFp                  2940	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC
+EC_GROUP_get_curve_GFp                  2940	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
 ASYNC_block_pause                       2941	3_0_0	EXIST::FUNCTION:
 OCSP_SINGLERESP_get_ext                 2942	3_0_0	EXIST::FUNCTION:OCSP
 CRYPTO_strdup                           2943	3_0_0	EXIST::FUNCTION:
@@ -3120,7 +3120,7 @@ X509_NAME_oneline                       3186	3_0_0	EXIST::FUNCTION:
 X509V3_set_nconf                        3187	3_0_0	EXIST::FUNCTION:
 RSAPrivateKey_dup                       3188	3_0_0	EXIST::FUNCTION:RSA
 BN_mod_add                              3189	3_0_0	EXIST::FUNCTION:
-EC_POINT_set_affine_coordinates_GFp     3190	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC
+EC_POINT_set_affine_coordinates_GFp     3190	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC
 X509_get_default_cert_file              3191	3_0_0	EXIST::FUNCTION:
 UI_method_set_flusher                   3192	3_0_0	EXIST::FUNCTION:
 RSA_new_method                          3193	3_0_0	EXIST::FUNCTION:RSA
@@ -3452,7 +3452,7 @@ PROXY_CERT_INFO_EXTENSION_new           3523	3_0_0	EXIST::FUNCTION:
 EVP_bf_cbc                              3524	3_0_0	EXIST::FUNCTION:BF
 DSA_do_verify                           3525	3_0_0	EXIST::FUNCTION:DSA
 EC_GROUP_get_seed_len                   3526	3_0_0	EXIST::FUNCTION:EC
-EC_POINT_set_affine_coordinates_GF2m    3527	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3,EC,EC2M
+EC_POINT_set_affine_coordinates_GF2m    3527	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0,EC,EC2M
 TS_REQ_set_policy_id                    3528	3_0_0	EXIST::FUNCTION:TS
 BIO_callback_ctrl                       3529	3_0_0	EXIST::FUNCTION:
 v2i_GENERAL_NAME                        3530	3_0_0	EXIST::FUNCTION:
@@ -3531,7 +3531,7 @@ CMS_add1_recipient_cert                 3608	3_0_0	EXIST::FUNCTION:CMS
 CMS_RecipientInfo_kekri_get0_id         3609	3_0_0	EXIST::FUNCTION:CMS
 BN_mod_word                             3610	3_0_0	EXIST::FUNCTION:
 ASN1_PCTX_new                           3611	3_0_0	EXIST::FUNCTION:
-BN_is_prime_ex                          3612	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+BN_is_prime_ex                          3612	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 PKCS5_v2_PBE_keyivgen                   3613	3_0_0	EXIST::FUNCTION:
 CRYPTO_ctr128_encrypt                   3614	3_0_0	EXIST::FUNCTION:
 CMS_unsigned_add1_attr_by_OBJ           3615	3_0_0	EXIST::FUNCTION:CMS
diff --git a/util/libssl.num b/util/libssl.num
index 4b5965285a..f24cdd7834 100644
--- a/util/libssl.num
+++ b/util/libssl.num
@@ -354,7 +354,7 @@ SSL_set_session_id_context              354	3_0_0	EXIST::FUNCTION:
 SSL_new                                 355	3_0_0	EXIST::FUNCTION:
 TLSv1_1_method                          356	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_1_1_0,TLS1_1_METHOD
 SSL_CTX_get_cert_store                  357	3_0_0	EXIST::FUNCTION:
-SSL_CTX_load_verify_locations           358	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3
+SSL_CTX_load_verify_locations           358	3_0_0	EXIST::FUNCTION:DEPRECATEDIN_3_0
 SSL_SESSION_print_fp                    359	3_0_0	EXIST::FUNCTION:STDIO
 SSL_get0_dane_tlsa                      360	3_0_0	EXIST::FUNCTION:
 SSL_CTX_set_generate_session_id         361	3_0_0	EXIST::FUNCTION:
diff --git a/util/mkdef.pl b/util/mkdef.pl
index 11471499df..b923cb62c3 100755
--- a/util/mkdef.pl
+++ b/util/mkdef.pl
@@ -100,10 +100,6 @@ die "Please supply arguments\n"
 #
 (my $SO_VARIANT = uc($target{"shlib_variant"} // '')) =~ s/\W/_/g;
 
-my $apiv = undef;
-$apiv = sprintf "%x%02x%02x", split(/\./, $config{api})
-    if $config{api};
-
 my $libname = platform->sharedname($name);
 
 my %OS_data = (
@@ -191,11 +187,13 @@ sub feature_filter {
 
     my $verdict = ! grep { $disabled_uc{$_} } @features;
 
-    if ($apiv) {
+    if ($disabled{deprecated}) {
         foreach (@features) {
-            next unless /^DEPRECATEDIN_(\d+)(?:_(\d+)_(\d+))?$/;
-            my $symdep = sprintf "%x%02x%02x", $1, ($2 // 0), ($3 // 0);
-            $verdict = 0 if $apiv ge $symdep;
+            next unless /^DEPRECATEDIN_(\d+)_(\d+)(?:_(\d+))?$/;
+            my $symdep = $1 * 10000 + $2 * 100 + ($3 // 0);
+            $verdict = 0 if $config{api} >= $symdep;
+            print STDERR "DEBUG: \$symdep = $symdep, \$verdict = $verdict\n"
+                if $1 == 0;
         }
     }
 
diff --git a/util/mkerr.pl b/util/mkerr.pl
index c8ec94d288..1d8cdfdfb4 100755
--- a/util/mkerr.pl
+++ b/util/mkerr.pl
@@ -496,7 +496,7 @@ EOF
     }
 
     print OUT "\n/*\n * $lib function codes.\n */\n";
-    print OUT "# if !OPENSSL_API_3\n";
+    print OUT "# ifndef OPENSSL_NO_DEPRECATED_3_0\n";
     foreach my $i ( @function ) {
         my $z = 48 - length($i);
         $z = 0 if $z < 0;
diff --git a/util/perl/OpenSSL/ParseC.pm b/util/perl/OpenSSL/ParseC.pm
index 286fa7e0ef..2db43e2a61 100644
--- a/util/perl/OpenSSL/ParseC.pm
+++ b/util/perl/OpenSSL/ParseC.pm
@@ -65,11 +65,14 @@ my @opensslcpphandlers = (
     # These are used to convert certain pre-precessor expressions into
     # others that @cpphandlers have a better chance to understand.
 
-    { regexp   => qr/#if (!?)OPENSSL_API_([0-9_]+)$/,
+    # This changes any OPENSSL_NO_DEPRECATED_x_y[_z] check to a check of
+    # OPENSSL_NO_DEPRECATEDIN_x_y[_z].  That's due to <openssl/macros.h>
+    # creating OPENSSL_NO_DEPRECATED_x_y[_z], but the ordinals files using
+    # DEPRECATEDIN_x_y[_z].
+    { regexp   => qr/#if(def|ndef) OPENSSL_NO_DEPRECATED_(\d+_\d+(?:_\d+)?)$/,
       massager => sub {
-          my $cnd = $1 eq '!' ? 'ndef' : 'def';
           return (<<"EOF");
-#if$cnd DEPRECATEDIN_$2
+#if$1 OPENSSL_NO_DEPRECATEDIN_$2
 EOF
       }
    }
@@ -261,7 +264,7 @@ my @opensslchandlers = (
     # We trick the parser by pretending that the declaration is wrapped in a
     # check if the DEPRECATEDIN macro is defined or not.  Callers of parse()
     # will have to decide what to do with it.
-    { regexp   => qr/(DEPRECATEDIN_\d+(?:_\d+_\d+)?)<<<\((.*)\)>>>/,
+    { regexp   => qr/(DEPRECATEDIN_\d+_\d+(?:_\d+)?)<<<\((.*)\)>>>/,
       massager => sub { return (<<"EOF");
 #ifndef $1
 $2;


More information about the openssl-commits mailing list