OpenSSL generate_key(): Use EVP_RSA_gen() when using OpenSSL 3.0 or later
authorFabian Keil <fk@fabiankeil.de>
Wed, 10 Jul 2024 17:39:03 +0000 (19:39 +0200)
committerFabian Keil <fk@fabiankeil.de>
Thu, 11 Jul 2024 08:07:08 +0000 (10:07 +0200)
commitec4392e4bb11651c2f8154c526cceddd0dae6646
treede26984dc9879601ac3647ac3d9a20a9de685bef
parentb6d807f76153fa487059c65cd15727704eadba8f
OpenSSL generate_key(): Use EVP_RSA_gen() when using OpenSSL 3.0 or later

Silences a bunch of deprecation warnings:

    openssl.c:1523:10: warning: 'RSA_new' is deprecated [-Wdeprecated-declarations]
     1523 |    rsa = RSA_new();
          |          ^
    /usr/local/include/openssl/rsa.h:201:1: note: 'RSA_new' has been explicitly marked deprecated here
      201 | OSSL_DEPRECATEDIN_3_0 RSA *RSA_new(void);
          | ^
    /usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
      182 | #   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
          |                                                 ^
    /usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
       62 | #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
          |                                                    ^
    openssl.c:1540:10: warning: 'RSA_generate_key_ex' is deprecated [-Wdeprecated-declarations]
     1540 |    ret = RSA_generate_key_ex(rsa, RSA_KEYSIZE, exp, NULL);
          |          ^
    /usr/local/include/openssl/rsa.h:260:1: note: 'RSA_generate_key_ex' has been explicitly marked deprecated here
      260 | OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e,
          | ^
    /usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
      182 | #   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
          |                                                 ^
    /usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
       62 | #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
          |                                                    ^
    openssl.c:1549:9: warning: 'EVP_PKEY_set1_RSA' is deprecated [-Wdeprecated-declarations]
     1549 |    if (!EVP_PKEY_set1_RSA(key, rsa))
          |         ^
    /usr/local/include/openssl/evp.h:1345:1: note: 'EVP_PKEY_set1_RSA' has been explicitly marked deprecated here
     1345 | OSSL_DEPRECATEDIN_3_0
          | ^
    /usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
      182 | #   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
          |                                                 ^
    /usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
       62 | #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
          |                                                    ^
    openssl.c:1592:7: warning: 'RSA_free' is deprecated [-Wdeprecated-declarations]
     1592 |       RSA_free(rsa);
          |       ^
    /usr/local/include/openssl/rsa.h:293:1: note: 'RSA_free' has been explicitly marked deprecated here
      293 | OSSL_DEPRECATEDIN_3_0 void RSA_free(RSA *r);
          | ^
    /usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
      182 | #   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
          |                                                 ^
    /usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
       62 | #     define OSSL_DEPRECATED(since) __attribute__((deprecated))
          |                                                    ^
openssl.c