Subject: | RSA_get_key_parameters() with LibreSSL |
To enable RSA_get_key_parameters() with LibreSSL you need another
#ifdef as the LibreSSL versioning scheme differs from OpenSSL.
I have tested this diff with LibreSSL and commited it to the OpenBSD
ports system. Please make sure that it also works for OpenSSL on
other platforms.
--- SSLeay.xs.orig Wed Jan 4 22:39:08 2017
+++ SSLeay.xs Thu Jan 5 22:01:15 2017
@@ -4989,7 +4989,7 @@ RSA_generate_key(bits,e,perl_cb=&PL_sv_undef,perl_data
#endif
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
void
RSA_get_key_parameters(rsa)
--- t/local/33_x509_create_cert.t.orig Tue Nov 1 22:46:12 2016
+++ t/local/33_x509_create_cert.t Wed Jan 4 17:39:35 2017
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 122;
+use Test::More tests => 123;
use Net::SSLeay qw/MBSTRING_ASC MBSTRING_UTF8 EVP_PK_RSA EVP_PKT_SIGN EVP_PKT_ENC/;
use File::Spec;
use utf8;
@@ -32,9 +32,12 @@ is(Net::SSLeay::X509_NAME_cmp($ca_issuer, $ca_subject)
ok(my $rsa = Net::SSLeay::RSA_generate_key(2048, &Net::SSLeay::RSA_F4), "RSA_generate_key");
ok(Net::SSLeay::EVP_PKEY_assign_RSA($pk,$rsa), "EVP_PKEY_assign_RSA");
-# ONly in pre 1.1:
-# my @params = Net::SSLeay::RSA_get_key_parameters($rsa);
-# ok(@params == 8, "RSA_get_key_parameters");
+ SKIP: {
+ skip 'openssl<1.1.0 required', 1 unless Net::SSLeay::SSLeay < 0x10100000
+ or Net::SSLeay::constant("LIBRESSL_VERSION_NUMBER");
+ my @params = Net::SSLeay::RSA_get_key_parameters($rsa);
+ ok(@params == 8, "RSA_get_key_parameters");
+ }
ok(my $x509 = Net::SSLeay::X509_new(), "X509_new");
ok(Net::SSLeay::X509_set_pubkey($x509,$pk), "X509_set_pubkey");