[ruby/openssl] Add build support for AWS-LC
CI Changes 1. I've split the original patch up to make it easier to digest, but that forces my hand to turn off testing in the AWS-LC CI for the time being. However, do let me know if you would prefer to review the test adjustments in the same PR and I can remove the temporary CI workaround. 2. AWS-LC has a few no-op functions and we use -Wdeprecated-declarations to alert the consuming application of these. I've leveraged the skip-warnings CI option so that the build doesn't fail. Build Adjustments 1. AWS-LC FIPS mode is decided at compile time. This is different from OpenSSL's togglable FIPS switch, so I've adjusted the build to account for this. 2. AWS-LC does not support for the two KEY_SIG or KEY_EX flags that were only ever supported by old MSIE. 3. AWS-LC has no current support for post handshake authentication in TLS 1.3. 4. EC_GROUP structures for named curves in AWS-LC are constant, static, and immutable by default. This means that the EC_GROUP_set_* functions are essentially no-ops due to the immutability of the structure. We've introduced a new API for consumers that depend on the OpenSSL's default mutability of the EC_GROUP structure called EC_GROUP_new_by_curve_name_mutable. Since Ruby has a bit of functionality that's dependent on the mutability of these structures, I've made the corresponding adjustments to allow things to work as expected. https://github.com/ruby/openssl/commit/e53ec5a101
This commit is contained in:
parent
e603a420e9
commit
06faf28558
@ -404,7 +404,7 @@ ossl_fips_mode_get(VALUE self)
|
|||||||
VALUE enabled;
|
VALUE enabled;
|
||||||
enabled = EVP_default_properties_is_fips_enabled(NULL) ? Qtrue : Qfalse;
|
enabled = EVP_default_properties_is_fips_enabled(NULL) ? Qtrue : Qfalse;
|
||||||
return enabled;
|
return enabled;
|
||||||
#elif defined(OPENSSL_FIPS)
|
#elif defined(OPENSSL_FIPS) || defined(OPENSSL_IS_AWSLC)
|
||||||
VALUE enabled;
|
VALUE enabled;
|
||||||
enabled = FIPS_mode() ? Qtrue : Qfalse;
|
enabled = FIPS_mode() ? Qtrue : Qfalse;
|
||||||
return enabled;
|
return enabled;
|
||||||
@ -439,7 +439,7 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return enabled;
|
return enabled;
|
||||||
#elif defined(OPENSSL_FIPS)
|
#elif defined(OPENSSL_FIPS) || defined(OPENSSL_IS_AWSLC)
|
||||||
if (RTEST(enabled)) {
|
if (RTEST(enabled)) {
|
||||||
int mode = FIPS_mode();
|
int mode = FIPS_mode();
|
||||||
if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */
|
if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */
|
||||||
@ -1004,6 +1004,8 @@ Init_openssl(void)
|
|||||||
Qtrue
|
Qtrue
|
||||||
#elif defined(OPENSSL_FIPS)
|
#elif defined(OPENSSL_FIPS)
|
||||||
Qtrue
|
Qtrue
|
||||||
|
#elif defined(OPENSSL_IS_AWSLC) // AWS-LC FIPS can only be enabled during compile time.
|
||||||
|
FIPS_mode() ? Qtrue : Qfalse
|
||||||
#else
|
#else
|
||||||
Qfalse
|
Qfalse
|
||||||
#endif
|
#endif
|
||||||
|
@ -134,9 +134,15 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
|
|||||||
if (!NIL_P(keytype))
|
if (!NIL_P(keytype))
|
||||||
ktype = NUM2INT(keytype);
|
ktype = NUM2INT(keytype);
|
||||||
|
|
||||||
|
#if defined(OPENSSL_IS_AWSLC)
|
||||||
|
if (ktype != 0) {
|
||||||
|
ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (ktype != 0 && ktype != KEY_SIG && ktype != KEY_EX) {
|
if (ktype != 0 && ktype != KEY_SIG && ktype != KEY_EX) {
|
||||||
ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
|
ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
obj = NewPKCS12(cPKCS12);
|
obj = NewPKCS12(cPKCS12);
|
||||||
x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
|
x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
|
||||||
@ -316,7 +322,9 @@ Init_ossl_pkcs12(void)
|
|||||||
rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
|
rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
|
||||||
rb_define_method(cPKCS12, "set_mac", pkcs12_set_mac, -1);
|
rb_define_method(cPKCS12, "set_mac", pkcs12_set_mac, -1);
|
||||||
|
|
||||||
|
#if !defined(OPENSSL_IS_AWSLC)
|
||||||
/* MSIE specific PKCS12 key usage extensions */
|
/* MSIE specific PKCS12 key usage extensions */
|
||||||
rb_define_const(cPKCS12, "KEY_EX", INT2NUM(KEY_EX));
|
rb_define_const(cPKCS12, "KEY_EX", INT2NUM(KEY_EX));
|
||||||
rb_define_const(cPKCS12, "KEY_SIG", INT2NUM(KEY_SIG));
|
rb_define_const(cPKCS12, "KEY_SIG", INT2NUM(KEY_SIG));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -657,8 +657,11 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
ossl_clear_error(); /* ignore errors in d2i_ECPKParameters_bio() */
|
ossl_clear_error(); /* ignore errors in d2i_ECPKParameters_bio() */
|
||||||
if (nid == NID_undef)
|
if (nid == NID_undef)
|
||||||
ossl_raise(eEC_GROUP, "unknown curve name (%"PRIsVALUE")", arg1);
|
ossl_raise(eEC_GROUP, "unknown curve name (%"PRIsVALUE")", arg1);
|
||||||
|
#if !defined(OPENSSL_IS_AWSLC)
|
||||||
group = EC_GROUP_new_by_curve_name(nid);
|
group = EC_GROUP_new_by_curve_name(nid);
|
||||||
|
#else /* EC_GROUPs are static and immutable by default in AWS-LC. */
|
||||||
|
group = EC_GROUP_new_by_curve_name_mutable(nid);
|
||||||
|
#endif
|
||||||
if (group == NULL)
|
if (group == NULL)
|
||||||
ossl_raise(eEC_GROUP, "unable to create curve (%"PRIsVALUE")", arg1);
|
ossl_raise(eEC_GROUP, "unable to create curve (%"PRIsVALUE")", arg1);
|
||||||
|
|
||||||
@ -1367,7 +1370,7 @@ static VALUE ossl_ec_point_make_affine(VALUE self)
|
|||||||
GetECPointGroup(self, group);
|
GetECPointGroup(self, group);
|
||||||
|
|
||||||
rb_warn("OpenSSL::PKey::EC::Point#make_affine! is deprecated");
|
rb_warn("OpenSSL::PKey::EC::Point#make_affine! is deprecated");
|
||||||
#if !OSSL_OPENSSL_PREREQ(3, 0, 0)
|
#if !OSSL_OPENSSL_PREREQ(3, 0, 0) && !defined(OPENSSL_IS_AWSLC)
|
||||||
if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
|
if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
|
||||||
ossl_raise(eEC_POINT, "EC_POINT_make_affine");
|
ossl_raise(eEC_POINT, "EC_POINT_make_affine");
|
||||||
#endif
|
#endif
|
||||||
|
@ -705,7 +705,9 @@ ossl_sslctx_setup(VALUE self)
|
|||||||
SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback);
|
SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(OPENSSL_IS_AWSLC) /* AWS-LC has no support for TLS 1.3 PHA. */
|
||||||
SSL_CTX_set_post_handshake_auth(ctx, 1);
|
SSL_CTX_set_post_handshake_auth(ctx, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
val = rb_attr_get(self, id_i_cert_store);
|
val = rb_attr_get(self, id_i_cert_store);
|
||||||
if (!NIL_P(val)) {
|
if (!NIL_P(val)) {
|
||||||
|
@ -103,7 +103,7 @@ module OpenSSL::TestUtils
|
|||||||
end
|
end
|
||||||
|
|
||||||
def openssl?(major = nil, minor = nil, fix = nil, patch = 0, status = 0)
|
def openssl?(major = nil, minor = nil, fix = nil, patch = 0, status = 0)
|
||||||
return false if OpenSSL::OPENSSL_VERSION.include?("LibreSSL")
|
return false if OpenSSL::OPENSSL_VERSION.include?("LibreSSL") || OpenSSL::OPENSSL_VERSION.include?("AWS-LC")
|
||||||
return true unless major
|
return true unless major
|
||||||
OpenSSL::OPENSSL_VERSION_NUMBER >=
|
OpenSSL::OPENSSL_VERSION_NUMBER >=
|
||||||
major * 0x10000000 + minor * 0x100000 + fix * 0x1000 + patch * 0x10 +
|
major * 0x10000000 + minor * 0x100000 + fix * 0x1000 + patch * 0x10 +
|
||||||
@ -115,6 +115,10 @@ module OpenSSL::TestUtils
|
|||||||
return false unless version
|
return false unless version
|
||||||
!major || (version.map(&:to_i) <=> [major, minor, fix]) >= 0
|
!major || (version.map(&:to_i) <=> [major, minor, fix]) >= 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def aws_lc?
|
||||||
|
OpenSSL::OPENSSL_VERSION.include?("AWS-LC")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class OpenSSL::TestCase < Test::Unit::TestCase
|
class OpenSSL::TestCase < Test::Unit::TestCase
|
||||||
|
Loading…
x
Reference in New Issue
Block a user