Macro to support 3.0 and 1.0

Richard Levitte levitte at openssl.org
Thu May 6 11:30:13 UTC 2021


Before using OPENSSL_VERSION_NUMBER, you should have this line:

    #include <openssl/opensslv.h>

So something like this should make it possible:

    #include <openssl/opensslv.h>

    #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
    
      /******higher version code************/
    
     #include <openssl/evp.h>
    
    #else
    
      /*******lower version code *********/
    
     #include <openssl/aes.h>
    
    #endif

If that's not the case, you may have found a bug.  A short example
program that demonstrates this flaw would be nice in that case.

Cheers,
Richard

On Thu, 06 May 2021 12:38:30 +0200,
Shivakumar Poojari wrote:
> 
> 
> Hi All,
> 
>          We are upgrading our code to openssl 3.0. But we need to keep the older
>          version of code also which is 1.0. So, we tried by keeping the newer version 
>          of the code as below but when we compiled the code for 3.0, evp.h is not
>          getting included. Please suggest f our approach is correct
> 
> #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
> 
>   /******higher version code************/
> 
>  #include <openssl/evp.h>
> 
> #else
> 
>   /*******lower version code *********/
> 
>  #include <openssl/aes.h>
> 
> #endif
> 
>        Also, we found that OPENSSL_VERSION_NUMBER is deprecated, so thought of using
>        the below macros but we think since this macro is defined in newer version this might
>        not work when we compile it for older versions. Please suggest how to handle this.
> 
> if (OPENSSL_VERSION_MAJOR >= 3)
>   #include <openssl/evp.h>
> else if (OPENSSL_VERSION_MAJOR < 3)
>   #include <openssl/aes.h>
> 
> thanks, 
> shiva kumar 
> 
> Notice: This e-mail together with any attachments may contain information of Ribbon Communications
> Inc. and its Affiliates that is confidential and/or proprietary for the sole use of the intended
> recipient. Any review, disclosure, reliance or distribution by others or forwarding without
> express permission is strictly prohibited. If you are not the intended recipient, please notify
> the sender immediately and then delete all copies, including any attachments.
> 
> 
-- 
Richard Levitte         levitte at openssl.org
OpenSSL Project         http://www.openssl.org/~levitte/


More information about the openssl-users mailing list