Skip to content

Commit 0c846a7

Browse files
Improve build and fix X509 test failures for Ruby (aws#1887)
1. `bignum_to_string` is called when trying to print out the X509 Extension value. Initially I thought the value wasn't being set correctly, but it turns out that we were printing the value in hex form, rather than decimal (which OpenSSL does and Ruby expects). AWS-LC prints the hex value if the value is more than 32 bits, while OpenSSL has a much more lax restriction at 128 bits. Tweaking this to align with OpenSSL gets past the test for `test_x509crl.rb`. Tweaking the value to align with OpenSSL gets past the test. 2. Great news is I don't think we need to do anything for the test failure in `test_x509req`. This was a testing gap on Ruby's end, documented in this commit: ruby/ruby@6b12013. Only version 1 is available for CSRs and Ruby attempts to set an invalid version in its tests. OpenSSL 3.3 disallows this behavior now and Ruby has removed the test in it's mainline branch. We can brush up the patch to account for this and skip the test with AWS-LC. 3. I also took the chance to add back some of the defines Ruby depends on as no-ops. The X509 defines aren't actually used in neither OpenSSL or AWS-LC as found by this commit: 496838a. ### Call-outs: N/A ### Testing: N/A By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.
1 parent 751fe2a commit 0c846a7

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

crypto/x509/v3_utl.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ static char *bignum_to_string(const BIGNUM *bn) {
172172
// Display large numbers in hex and small numbers in decimal. Converting to
173173
// decimal takes quadratic time and is no more useful than hex for large
174174
// numbers.
175-
if (BN_num_bits(bn) < 32) {
175+
// The threshold for large numbers is set at 128 bits to align with OpenSSL.
176+
if (BN_num_bits(bn) < 128) {
176177
return BN_bn2dec(bn);
177178
}
178179

crypto/x509/x509_test.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -3190,9 +3190,11 @@ TEST(X509Test, PrettyPrintIntegers) {
31903190
"-42",
31913191
"256",
31923192
"-256",
3193+
"4886718345",
3194+
"-4886718345",
31933195
// Large numbers are pretty-printed in hex to avoid taking quadratic time.
3194-
"0x0123456789",
3195-
"-0x0123456789",
3196+
"0x0123456789012345678901234567890123",
3197+
"-0x0123456789012345678901234567890123",
31963198
};
31973199
for (const char *in : kTests) {
31983200
SCOPED_TRACE(in);

include/openssl/ocsp.h

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ extern "C" {
3939
// aACompromise (10) }
4040
//
4141
// Reason Code RFC: https://www.rfc-editor.org/rfc/rfc5280#section-5.3.1
42+
//
43+
// Note: OCSP_REVOKED_STATUS_NOSTATUS is defined by OpenSSL and is not defined
44+
// within the RFC.
45+
#define OCSP_REVOKED_STATUS_NOSTATUS -1
4246
#define OCSP_REVOKED_STATUS_UNSPECIFIED 0
4347
#define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1
4448
#define OCSP_REVOKED_STATUS_CACOMPROMISE 2
@@ -58,6 +62,9 @@ extern "C" {
5862
// Certificates included within |bs| or |req| will be included in the
5963
// search for the signing certificate by default, unless |OCSP_NOINTERN| is set.
6064
#define OCSP_NOINTERN 0x2
65+
// OCSP_NOSIGS does nothing. In OpenSSL, this skips signature verification in
66+
// |OCSP_basic_verify| and |OCSP_request_verify|.
67+
#define OCSP_NOSIGS
6168
// OCSP_NOCHAIN is for |OCSP_basic_verify| and |OCSP_request_verify|.
6269
// For |OCSP_basic_verify|, certificates in both |certs| and in |bs| are
6370
// considered as certificates for the construction of the validation path for

include/openssl/x509.h

+4
Original file line numberDiff line numberDiff line change
@@ -2906,6 +2906,10 @@ OPENSSL_EXPORT int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param,
29062906
// X509_TRUST_OBJECT_SIGN evaluates trust with the |NID_code_sign| OID, for
29072907
// validating code signing certificates.
29082908
#define X509_TRUST_OBJECT_SIGN 5
2909+
// X509_TRUST_OCSP_SIGN does nothing. It's unused in OpenSSL and AWS-LC.
2910+
#define X509_TRUST_OCSP_SIGN 6
2911+
// X509_TRUST_OCSP_REQUEST does nothing. It's unused in OpenSSL and AWS-LC.
2912+
#define X509_TRUST_OCSP_REQUEST 7
29092913
// X509_TRUST_TSA evaluates trust with the |NID_time_stamp| OID, for validating
29102914
// Time Stamping Authority (RFC 3161) certificates.
29112915
#define X509_TRUST_TSA 8

0 commit comments

Comments
 (0)