Skip to content

Commit 89dbb7c

Browse files
committed
libcrypto: update build to apply all patches
Also refresh all the patches from upstream and change the starting number to be in line with other packages
1 parent bdd0933 commit 89dbb7c

14 files changed

+2873
-20
lines changed

packages/libcrypto/0001-Cherry-pick-BORINGSSL_bcm_text_hash-Go-utility-2221.patch renamed to packages/libcrypto/1001-Cherry-pick-BORINGSSL_bcm_text_hash-Go-utility-2221.patch

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,3 @@ index 000000000..cda6a1385
152152
+
153153
+ return hashSymbolSectionData[hashSymbolOffset : hashSymbolOffset+hashSymbol.Size], nil
154154
+}
155-
--
156-
2.48.1
157-

packages/libcrypto/0002-Cherry-pick-Fix-out-of-bound-OOB-input-read-in-AES-X.patch renamed to packages/libcrypto/1002-Cherry-pick-Fix-out-of-bound-OOB-input-read-in-AES-X.patch

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,3 @@ index 039f0c7ac..1aabee193 100644
215215
add rcx,0x100
216216
vpxorq zmm1,zmm1,zmm9
217217
vpxorq zmm2,zmm2,zmm10
218-
--
219-
2.48.1
220-
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From 9083ae0244fbab6064c892e6e7e8e9fc47a7b9f7 Mon Sep 17 00:00:00 2001
2+
From: Sean McGrail <[email protected]>
3+
Date: Thu, 6 Mar 2025 17:31:04 +0000
4+
Subject: [PATCH] Move OCSP ASN1 type functions to public header (#2239)
5+
6+
### Description of changes:
7+
Improve compatibility with OpenSSL APIs for OCSP.
8+
9+
By submitting this pull request, I confirm that my contribution is made
10+
under the terms of the Apache 2.0 license and the ISC license.
11+
12+
(cherry picked from commit b74d80de10cbeccbd357262c0402f90102d21ce8)
13+
---
14+
crypto/ocsp/internal.h | 1 -
15+
include/openssl/ocsp.h | 1 +
16+
2 files changed, 1 insertion(+), 1 deletion(-)
17+
18+
diff --git a/crypto/ocsp/internal.h b/crypto/ocsp/internal.h
19+
index c780fb6bf..04c17d22c 100644
20+
--- a/crypto/ocsp/internal.h
21+
+++ b/crypto/ocsp/internal.h
22+
@@ -233,7 +233,6 @@ struct ocsp_basic_response_st {
23+
STACK_OF(X509) *certs;
24+
};
25+
26+
-DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
27+
DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)
28+
DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)
29+
DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)
30+
diff --git a/include/openssl/ocsp.h b/include/openssl/ocsp.h
31+
index 2f7d249f6..32936ec0e 100644
32+
--- a/include/openssl/ocsp.h
33+
+++ b/include/openssl/ocsp.h
34+
@@ -112,6 +112,7 @@ DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)
35+
DECLARE_ASN1_FUNCTIONS(OCSP_CERTID)
36+
DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)
37+
DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
38+
+DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)
39+
40+
// d2i_OCSP_REQUEST_bio parses a DER-encoded OCSP request from |bp|, converts it
41+
// into an |OCSP_REQUEST|, and writes the result in |preq|.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From 6f95c7dfa9d569b2c78475aee0516e36df5b2c4a Mon Sep 17 00:00:00 2001
2+
From: Sean McGrail <[email protected]>
3+
Date: Mon, 10 Mar 2025 17:54:59 +0000
4+
Subject: [PATCH] Add test around OpenSSL behavior for BIO_get_mem_data macro
5+
6+
(cherry picked from commit 94b8cb68e8f3f93c5bdd78a3c23fc23baf410132)
7+
---
8+
crypto/bio/bio_test.cc | 17 +++++++++++++++++
9+
1 file changed, 17 insertions(+)
10+
11+
diff --git a/crypto/bio/bio_test.cc b/crypto/bio/bio_test.cc
12+
index 822a831ba..8fe742568 100644
13+
--- a/crypto/bio/bio_test.cc
14+
+++ b/crypto/bio/bio_test.cc
15+
@@ -1275,3 +1275,20 @@ TEST(BIOTest, TestCtrlCallback) {
16+
bio_callback_cleanup();
17+
ASSERT_EQ(BIO_free(bio), 1);
18+
}
19+
+
20+
+TEST(BIOTest, GetMemDataBackwardsCompat) {
21+
+ bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
22+
+ ASSERT_TRUE(bio);
23+
+
24+
+ const uint8_t contents[] = {0x72, 0x61, 0x63, 0x63, 0x6f, 0x6f, 0x6e};
25+
+
26+
+ // Write some test data
27+
+ int write_len = BIO_write(bio.get(), contents, sizeof(contents));
28+
+ ASSERT_EQ(sizeof(contents), (size_t)write_len);
29+
+
30+
+ // Yes, this is something gRPC does
31+
+ const uint8_t *ptr = NULL;
32+
+ long data_len = BIO_get_mem_data(bio.get(), &ptr);
33+
+ ASSERT_EQ((size_t)data_len, sizeof(contents));
34+
+ EXPECT_EQ(Bytes(contents, sizeof(contents)), Bytes(ptr, data_len));
35+
+}

packages/libcrypto/0003-Cherry-pick-support-for-CMake-4.0-to-fips-2024-09-27.patch renamed to packages/libcrypto/1005-Cherry-pick-support-for-CMake-4.0-to-fips-2024-09-27.patch

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,3 @@ index 1090cd53e..b4c6302cc 100644
4343

4444
if(POLICY CMP0091)
4545
cmake_policy(SET CMP0091 NEW)
46-
--
47-
2.48.1
48-
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
From 792613641e28dda603369bc34bc32263f24de8ac Mon Sep 17 00:00:00 2001
2+
From: David Benjamin <[email protected]>
3+
Date: Mon, 12 Feb 2024 18:09:37 -0500
4+
Subject: [PATCH] Remove some indirection in SSL_certs_clear
5+
6+
If we move SSL_certs_clear to ssl_cert.cc, ssl_cert_clear_certs does not
7+
need to be in the header. Moreover, its only other caller, ~CERT(), does
8+
not need to call it. Now that everything outside of SSL_X509_METHOD is
9+
managed with scopers, the destructor does it automatically. And
10+
cert_free on SSL_X509_METHOD already automatically calls cert_clear, so
11+
it's a no-op to do it again.
12+
13+
Change-Id: Ief9c704cc45440288783564ac4db4a27fbec1bfc
14+
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66370
15+
Commit-Queue: David Benjamin <[email protected]>
16+
Reviewed-by: Bob Beck <[email protected]>
17+
---
18+
ssl/internal.h | 1 -
19+
ssl/ssl_cert.cc | 45 +++++++++++++++++++++------------------------
20+
ssl/ssl_lib.cc | 7 -------
21+
3 files changed, 21 insertions(+), 32 deletions(-)
22+
23+
diff --git a/ssl/internal.h b/ssl/internal.h
24+
index 80d0675d8..38617640c 100644
25+
--- a/ssl/internal.h
26+
+++ b/ssl/internal.h
27+
@@ -3341,7 +3341,6 @@ struct SSL_CONFIG {
28+
static const size_t kMaxEarlyDataAccepted = 14336;
29+
30+
UniquePtr<CERT> ssl_cert_dup(CERT *cert);
31+
-void ssl_cert_clear_certs(CERT *cert);
32+
bool ssl_set_cert(CERT *cert, UniquePtr<CRYPTO_BUFFER> buffer);
33+
bool ssl_is_key_type_supported(int key_type);
34+
// ssl_compare_public_and_private_key returns true if |pubkey| is the public
35+
diff --git a/ssl/ssl_cert.cc b/ssl/ssl_cert.cc
36+
index 163c3f4cd..6a4b63c54 100644
37+
--- a/ssl/ssl_cert.cc
38+
+++ b/ssl/ssl_cert.cc
39+
@@ -143,10 +143,7 @@ CERT::CERT(const SSL_X509_METHOD *x509_method_arg)
40+
}
41+
}
42+
43+
-CERT::~CERT() {
44+
- ssl_cert_clear_certs(this);
45+
- x509_method->cert_free(this);
46+
-}
47+
+CERT::~CERT() { x509_method->cert_free(this); }
48+
49+
static CRYPTO_BUFFER *buffer_up_ref(const CRYPTO_BUFFER *buffer) {
50+
CRYPTO_BUFFER_up_ref(const_cast<CRYPTO_BUFFER *>(buffer));
51+
@@ -218,26 +215,6 @@ UniquePtr<CERT> ssl_cert_dup(CERT *cert) {
52+
return ret;
53+
}
54+
55+
-// Free up and clear all certificates and chains
56+
-void ssl_cert_clear_certs(CERT *cert) {
57+
- if (cert == nullptr) {
58+
- return;
59+
- }
60+
-
61+
- cert->x509_method->cert_clear(cert);
62+
-
63+
- cert->cert_private_key_idx = -1;
64+
- for (auto &cert_private_key : cert->cert_private_keys) {
65+
- cert_private_key.chain.reset();
66+
- cert_private_key.privatekey.reset();
67+
- }
68+
- cert->key_method = nullptr;
69+
-
70+
- cert->dc.reset();
71+
- cert->dc_privatekey.reset();
72+
- cert->dc_key_method = nullptr;
73+
-}
74+
-
75+
static void ssl_cert_set_cert_cb(CERT *cert, int (*cb)(SSL *ssl, void *arg),
76+
void *arg) {
77+
cert->cert_cb = cb;
78+
@@ -984,6 +961,26 @@ int SSL_CTX_set_chain_and_key(SSL_CTX *ctx, CRYPTO_BUFFER *const *certs,
79+
privkey_method);
80+
}
81+
82+
+void SSL_certs_clear(SSL *ssl) {
83+
+ if (!ssl->config) {
84+
+ return;
85+
+ }
86+
+
87+
+ CERT *cert = ssl->config->cert.get();
88+
+ cert->x509_method->cert_clear(cert);
89+
+
90+
+ cert->cert_private_key_idx = -1;
91+
+ for (auto &cert_private_key : cert->cert_private_keys) {
92+
+ cert_private_key.chain.reset();
93+
+ cert_private_key.privatekey.reset();
94+
+ }
95+
+ cert->key_method = nullptr;
96+
+
97+
+ cert->dc.reset();
98+
+ cert->dc_privatekey.reset();
99+
+ cert->dc_key_method = nullptr;
100+
+}
101+
+
102+
const STACK_OF(CRYPTO_BUFFER) *SSL_CTX_get0_chain(const SSL_CTX *ctx) {
103+
if (!ssl_cert_check_cert_private_keys_usage(ctx->cert.get())) {
104+
return nullptr;
105+
diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc
106+
index c74aa04b1..092dbef31 100644
107+
--- a/ssl/ssl_lib.cc
108+
+++ b/ssl/ssl_lib.cc
109+
@@ -1614,13 +1614,6 @@ const uint8_t *SSL_get0_session_id_context(const SSL *ssl, size_t *out_len) {
110+
return ssl->config->cert->sid_ctx;
111+
}
112+
113+
-void SSL_certs_clear(SSL *ssl) {
114+
- if (!ssl->config) {
115+
- return;
116+
- }
117+
- ssl_cert_clear_certs(ssl->config->cert.get());
118+
-}
119+
-
120+
int SSL_get_fd(const SSL *ssl) { return SSL_get_rfd(ssl); }
121+
122+
int SSL_get_rfd(const SSL *ssl) {

0 commit comments

Comments
 (0)