Skip to content

Suppress OpenSSL-3 warnings #576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
if with_config("debug") or enable_config("debug")
$defs.push("-DOSSL_DEBUG")
end
$defs.push("-D""OPENSSL_SUPPRESS_DEPRECATED")

have_func("rb_io_maybe_wait") # Ruby 3.1

Expand Down
6 changes: 6 additions & 0 deletions ext/openssl/ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
(LIBRESSL_VERSION_NUMBER >= ((maj << 28) | (min << 20) | (pat << 12)))
#endif

#if OSSL_OPENSSL_PREREQ(3, 0, 0)
# define OSSL_3_const const
#else
# define OSSL_3_const /* const */
#endif

#if !defined(OPENSSL_NO_ENGINE) && !OSSL_OPENSSL_PREREQ(3, 0, 0)
# define OSSL_USE_ENGINE
#endif
Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/ossl_pkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void Init_ossl_ec(void);
*/ \
static VALUE ossl_##_keytype##_get_##_name(VALUE self) \
{ \
_type *obj; \
const _type *obj; \
const BIGNUM *bn; \
\
Get##_type(self, obj); \
Expand Down
12 changes: 6 additions & 6 deletions ext/openssl/ossl_pkey_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ ossl_dh_initialize_copy(VALUE self, VALUE other)
static VALUE
ossl_dh_is_public(VALUE self)
{
DH *dh;
OSSL_3_const DH *dh;
const BIGNUM *bn;

GetDH(self, dh);
Expand All @@ -197,14 +197,14 @@ ossl_dh_is_public(VALUE self)
static VALUE
ossl_dh_is_private(VALUE self)
{
DH *dh;
OSSL_3_const DH *dh;
const BIGNUM *bn;

GetDH(self, dh);
DH_get0_key(dh, NULL, &bn);

#if !defined(OPENSSL_NO_ENGINE)
return (bn || DH_get0_engine(dh)) ? Qtrue : Qfalse;
return (bn || DH_get0_engine((DH *)dh)) ? Qtrue : Qfalse;
#else
return bn ? Qtrue : Qfalse;
#endif
Expand All @@ -223,7 +223,7 @@ ossl_dh_is_private(VALUE self)
static VALUE
ossl_dh_export(VALUE self)
{
DH *dh;
OSSL_3_const DH *dh;
BIO *out;
VALUE str;

Expand Down Expand Up @@ -252,7 +252,7 @@ ossl_dh_export(VALUE self)
static VALUE
ossl_dh_to_der(VALUE self)
{
DH *dh;
OSSL_3_const DH *dh;
unsigned char *p;
long len;
VALUE str;
Expand Down Expand Up @@ -280,7 +280,7 @@ ossl_dh_to_der(VALUE self)
static VALUE
ossl_dh_get_params(VALUE self)
{
DH *dh;
OSSL_3_const DH *dh;
VALUE hash;
const BIGNUM *p, *q, *g, *pub_key, *priv_key;

Expand Down
14 changes: 7 additions & 7 deletions ext/openssl/ossl_pkey_dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
} while (0)

static inline int
DSA_HAS_PRIVATE(DSA *dsa)
DSA_HAS_PRIVATE(OSSL_3_const DSA *dsa)
{
const BIGNUM *bn;
DSA_get0_key(dsa, NULL, &bn);
return !!bn;
}

static inline int
DSA_PRIVATE(VALUE obj, DSA *dsa)
DSA_PRIVATE(VALUE obj, OSSL_3_const DSA *dsa)
{
return DSA_HAS_PRIVATE(dsa) || OSSL_PKEY_IS_PRIVATE(obj);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ ossl_dsa_initialize_copy(VALUE self, VALUE other)
static VALUE
ossl_dsa_is_public(VALUE self)
{
DSA *dsa;
const DSA *dsa;
const BIGNUM *bn;

GetDSA(self, dsa);
Expand All @@ -198,7 +198,7 @@ ossl_dsa_is_public(VALUE self)
static VALUE
ossl_dsa_is_private(VALUE self)
{
DSA *dsa;
OSSL_3_const DSA *dsa;

GetDSA(self, dsa);

Expand All @@ -225,7 +225,7 @@ ossl_dsa_is_private(VALUE self)
static VALUE
ossl_dsa_export(int argc, VALUE *argv, VALUE self)
{
DSA *dsa;
OSSL_3_const DSA *dsa;

GetDSA(self, dsa);
if (DSA_HAS_PRIVATE(dsa))
Expand All @@ -244,7 +244,7 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self)
static VALUE
ossl_dsa_to_der(VALUE self)
{
DSA *dsa;
OSSL_3_const DSA *dsa;

GetDSA(self, dsa);
if (DSA_HAS_PRIVATE(dsa))
Expand All @@ -265,7 +265,7 @@ ossl_dsa_to_der(VALUE self)
static VALUE
ossl_dsa_get_params(VALUE self)
{
DSA *dsa;
OSSL_3_const DSA *dsa;
VALUE hash;
const BIGNUM *p, *q, *g, *pub_key, *priv_key;

Expand Down
14 changes: 7 additions & 7 deletions ext/openssl/ossl_pkey_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ ossl_ec_key_initialize_copy(VALUE self, VALUE other)
static VALUE
ossl_ec_key_get_group(VALUE self)
{
EC_KEY *ec;
OSSL_3_const EC_KEY *ec;
const EC_GROUP *group;

GetEC(self, ec);
Expand Down Expand Up @@ -272,7 +272,7 @@ ossl_ec_key_set_group(VALUE self, VALUE group_v)
*/
static VALUE ossl_ec_key_get_private_key(VALUE self)
{
EC_KEY *ec;
OSSL_3_const EC_KEY *ec;
const BIGNUM *bn;

GetEC(self, ec);
Expand Down Expand Up @@ -323,7 +323,7 @@ static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
*/
static VALUE ossl_ec_key_get_public_key(VALUE self)
{
EC_KEY *ec;
OSSL_3_const EC_KEY *ec;
const EC_POINT *point;

GetEC(self, ec);
Expand Down Expand Up @@ -375,7 +375,7 @@ static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
*/
static VALUE ossl_ec_key_is_public(VALUE self)
{
EC_KEY *ec;
OSSL_3_const EC_KEY *ec;

GetEC(self, ec);

Expand All @@ -391,7 +391,7 @@ static VALUE ossl_ec_key_is_public(VALUE self)
*/
static VALUE ossl_ec_key_is_private(VALUE self)
{
EC_KEY *ec;
OSSL_3_const EC_KEY *ec;

GetEC(self, ec);

Expand All @@ -411,7 +411,7 @@ static VALUE ossl_ec_key_is_private(VALUE self)
static VALUE
ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
{
EC_KEY *ec;
OSSL_3_const EC_KEY *ec;

GetEC(self, ec);
if (EC_KEY_get0_public_key(ec) == NULL)
Expand All @@ -431,7 +431,7 @@ ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
static VALUE
ossl_ec_key_to_der(VALUE self)
{
EC_KEY *ec;
OSSL_3_const EC_KEY *ec;

GetEC(self, ec);
if (EC_KEY_get0_public_key(ec) == NULL)
Expand Down
12 changes: 6 additions & 6 deletions ext/openssl/ossl_pkey_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
} while (0)

static inline int
RSA_HAS_PRIVATE(RSA *rsa)
RSA_HAS_PRIVATE(OSSL_3_const RSA *rsa)
{
const BIGNUM *e, *d;

Expand All @@ -33,7 +33,7 @@ RSA_HAS_PRIVATE(RSA *rsa)
}

static inline int
RSA_PRIVATE(VALUE obj, RSA *rsa)
RSA_PRIVATE(VALUE obj, OSSL_3_const RSA *rsa)
{
return RSA_HAS_PRIVATE(rsa) || OSSL_PKEY_IS_PRIVATE(obj);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ ossl_rsa_initialize_copy(VALUE self, VALUE other)
static VALUE
ossl_rsa_is_public(VALUE self)
{
RSA *rsa;
OSSL_3_const RSA *rsa;

GetRSA(self, rsa);
/*
Expand All @@ -193,7 +193,7 @@ ossl_rsa_is_public(VALUE self)
static VALUE
ossl_rsa_is_private(VALUE self)
{
RSA *rsa;
OSSL_3_const RSA *rsa;

GetRSA(self, rsa);

Expand All @@ -203,7 +203,7 @@ ossl_rsa_is_private(VALUE self)
static int
can_export_rsaprivatekey(VALUE self)
{
RSA *rsa;
OSSL_3_const RSA *rsa;
const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;

GetRSA(self, rsa);
Expand Down Expand Up @@ -453,7 +453,7 @@ ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
static VALUE
ossl_rsa_get_params(VALUE self)
{
RSA *rsa;
OSSL_3_const RSA *rsa;
VALUE hash;
const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;

Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/ossl_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
if (!pkey)
return NULL;

return EVP_PKEY_get0_DH(pkey);
return (DH *)EVP_PKEY_get0_DH(pkey);
}
#endif /* OPENSSL_NO_DH */

Expand Down