Skip to content

Commit

Permalink
2024 March Chromium update [skip ci] (#268)
Browse files Browse the repository at this point in the history
* 2024 March Chromium update

Update Chromium patch and build instructions:

liboqs: 890a6aa448598a019e72b5431d8ba8e0a5dbcc85
boringssl: c0a0bb4d1243952819b983129c546f9ae1c03008
Chromium: 124.0.6339.0

Co-authored-by: pi-314159 <[email protected]>
Signed-off-by: Raytonne <[email protected]>
  • Loading branch information
Raytonne and pi-314159 authored Mar 21, 2024
1 parent a3881e6 commit 374f268
Show file tree
Hide file tree
Showing 6 changed files with 432 additions and 526 deletions.
15 changes: 7 additions & 8 deletions chromium/README-Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The rest of the instructions will use **$CHROMIUM_ROOT** to refer to the root di

```shellscript
cd $CHROMIUM_ROOT
git checkout tags/117.0.5863.0
git checkout tags/124.0.6339.0
gclient sync
```

Expand All @@ -20,26 +20,26 @@ gclient sync
cd $CHROMIUM_ROOT/third_party/boringssl/src
git remote add oqs-bssl https://github.com/open-quantum-safe/boringssl
git fetch oqs-bssl
git checkout -b oqs-bssl-master 1ca41b49e9198f510991fb4f350b4a5fd4c1d5ff
git checkout -b oqs-bssl-master c0a0bb4d1243952819b983129c546f9ae1c03008
```

### 4. Clone and Build liboqs

Choose a directory to store the liboqs source code and use the `cd` command to move to that directory. We will use ninja to build liboqs.

```shellscript
git clone https://github.com/open-quantum-safe/liboqs.git --branch 0.8.0 --single-branch
git clone https://github.com/open-quantum-safe/liboqs.git && git checkout 890a6aa448598a019e72b5431d8ba8e0a5dbcc85
cd liboqs && mkdir build && cd build
cmake .. -G"Ninja" -DCMAKE_INSTALL_PREFIX=$CHROMIUM_ROOT/third_party/boringssl/src/oqs -DOQS_USE_OPENSSL=OFF
cmake .. -G"Ninja" -DCMAKE_INSTALL_PREFIX=$CHROMIUM_ROOT/third_party/boringssl/src/oqs -DOQS_USE_OPENSSL=OFF -DCMAKE_BUILD_TYPE=Release
ninja && ninja install
```

### 5. Enable Quantum-Safe Crypto

```shellscript
cd $CHROMIUM_ROOT
wget https://raw.githubusercontent.com/open-quantum-safe/oqs-demos/main/chromium/oqs-changes.patch
git apply oqs-changes.patch
wget https://raw.githubusercontent.com/open-quantum-safe/oqs-demos/main/chromium/oqs-Linux.patch
git apply oqs-Linux.patch
```

### 6. Generate BoringSSL Build Files for Chromium
Expand Down Expand Up @@ -70,5 +70,4 @@ If the build completes successfully, it will create _chrome_ in _$CHROMIUM_ROOT/

### 8. Miscellaneous

- This guide is published on July 1, 2023, and may be outdated.
- A certificate chain that includes quantum-safe signatures can only be validated if it terminates with a root certificate that is in the [Chrome Root Store](https://chromium.googlesource.com/chromium/src/+/main/net/data/ssl/chrome_root_store/faq.md).
- This guide is published on March 8, 2024, and may be outdated.
27 changes: 8 additions & 19 deletions chromium/README-Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In Command Prompt, run following commands:

```bat
cd %CHROMIUM_ROOT%
git checkout tags/117.0.5863.0
git checkout tags/124.0.6339.0
gclient sync
```

Expand All @@ -25,7 +25,7 @@ In Command Prompt, run following commands:
cd %CHROMIUM_ROOT%/third_party/boringssl/src
git remote add oqs-bssl https://github.com/open-quantum-safe/boringssl
git fetch oqs-bssl
git checkout -b oqs-bssl-master 1ca41b49e9198f510991fb4f350b4a5fd4c1d5ff
git checkout -b oqs-bssl-master c0a0bb4d1243952819b983129c546f9ae1c03008
```

### 4. Clone and Build liboqs
Expand All @@ -34,29 +34,19 @@ Choose a directory to store the liboqs source code and use the `cd` command to m
Start _x64 Native Tools Command Prompt for VS 2022_ (usually it's in _C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\VC_) and run following commands:

```bat
git clone https://github.com/open-quantum-safe/liboqs.git --branch 0.8.0 --single-branch
git clone https://github.com/open-quantum-safe/liboqs.git && git checkout 890a6aa448598a019e72b5431d8ba8e0a5dbcc85
cd liboqs && mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=%CHROMIUM_ROOT%/third_party/boringssl/src/oqs -DOQS_USE_OPENSSL=OFF
cmake .. -DCMAKE_INSTALL_PREFIX=%CHROMIUM_ROOT%/third_party/boringssl/src/oqs -DOQS_USE_OPENSSL=OFF -DCMAKE_BUILD_TYPE=Release
msbuild ALL_BUILD.vcxproj
msbuild INSTALL.vcxproj
```

### 5. Enable Quantum-Safe Crypto

Download the [oqs-changes.patch](https://raw.githubusercontent.com/open-quantum-safe/oqs-demos/main/chromium/oqs-changes.patch) and save it at _%CHROMIUM_ROOT%_, then apply the patch by running
Download the [oqs-changes.patch](https://raw.githubusercontent.com/open-quantum-safe/oqs-demos/main/chromium/oqs-Windows.patch) and save it at _%CHROMIUM_ROOT%_, then apply the patch by running

```bat
git apply oqs-changes.patch
```

Open _%CHROMIUM_ROOT%/third_party/boringssl/BUILD.gn_ and find `libs = [ "//third_party/boringssl/src/oqs/lib/liboqs.a" ]`, then replace it with

```diff
public = all_headers
friend = [ ":*" ]
-libs = [ "//third_party/boringssl/src/oqs/lib/liboqs.a" ]
+libs = [ "//third_party/boringssl/src/oqs/lib/oqs.lib" ]
deps = [ "//third_party/boringssl/src/third_party/fiat:fiat_license" ]
git apply oqs-Windows.patch
```

### 6. Generate BoringSSL Build Files for Chromium
Expand Down Expand Up @@ -93,7 +83,6 @@ If the build completes successfully, it will create _chrome.exe_ in _%CHROMIUM_R

### 8. Miscellaneous

- BIKE key exchange will crash Chromium.
- This guide was initially published on July 1, 2023, and may be outdated.
- A certificate chain that includes quantum-safe signatures can only be validated if it terminates with a root certificate that is in the [Chrome Root Store](https://chromium.googlesource.com/chromium/src/+/main/net/data/ssl/chrome_root_store/faq.md).
- BIKE key exchange is not supported.
- This guide was initially published on March 8, 2024, and may be outdated.
- These instructions have been tested on 64-bit Windows 10 Enterprise with Visual Studio 2022 Community, [Go 1.20.5](https://go.dev/dl/), and [ActiveState Perl 5.36](https://www.activestate.com/products/perl/).
2 changes: 1 addition & 1 deletion chromium/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This directory contains no longer fully maintained instructions and corresponding patches to build the Chromium web browser using the [OQS-BoringSSL fork](https://github.com/open-quantum-safe/boringssl), thereby enabling Chromium to use quantum-safe key exchange algorithms.

These instructions are specifically tailored for liboqs version `0.8.0` and Chromium version `117.0.5863.0`. It is important to note that using any other versions of liboqs or Chromium may result in failure. The instructions have been tested on Windows 10 and Ubuntu 22 LTS(x64) installations only. Additionally, they currently apply to a limited subset of quantum-safe key-exchanges, as detailed in the documentation [provided here](https://github.com/open-quantum-safe/boringssl#key-exchange).
These instructions are specifically tailored for liboqs commit `890a6aa448598a019e72b5431d8ba8e0a5dbcc85` and Chromium version `124.0.6339.0`. It is important to note that using any other versions of liboqs or Chromium may result in failure. The instructions have been tested on Windows 10 and Ubuntu 22 LTS(x64) installations only. Additionally, they currently apply to a limited subset of quantum-safe key-exchanges, as detailed in the documentation [provided here](https://github.com/open-quantum-safe/boringssl#key-exchange).

Please be aware that this information is intended for individuals who acknowledge and accept these limitations. While we prioritize support for open source software, we are unable to dedicate the same level of support to the Chromium and BoringSSL PQ software stack as we have in the past. We encourage contributors to update the instructions and patch files for more recent versions of liboqs and Chromium.

Expand Down
208 changes: 208 additions & 0 deletions chromium/oqs-Linux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
diff --git a/net/base/features.cc b/net/base/features.cc
index 1ca71165d2..525cd9e9d5 100644
--- a/net/base/features.cc
+++ b/net/base/features.cc
@@ -157,7 +157,7 @@ BASE_FEATURE(kPermuteTLSExtensions,

BASE_FEATURE(kPostQuantumKyber,
"PostQuantumKyber",
- base::FEATURE_DISABLED_BY_DEFAULT);
+ base::FEATURE_ENABLED_BY_DEFAULT);

BASE_FEATURE(kNetUnusedIdleSocketTimeout,
"NetUnusedIdleSocketTimeout",
diff --git a/net/cert/cert_verify_proc.cc b/net/cert/cert_verify_proc.cc
index 90383f320e..ce2e8cf245 100644
--- a/net/cert/cert_verify_proc.cc
+++ b/net/cert/cert_verify_proc.cc
@@ -97,6 +97,16 @@ const char* CertTypeToString(X509Certificate::PublicKeyType cert_type) {
return "DH";
case X509Certificate::kPublicKeyTypeECDH:
return "ECDH";
+ case X509Certificate::kPublicKeyTypeDilithium:
+ return "Dilithium";
+ case X509Certificate::kPublicKeyTypeFalcon:
+ return "Falcon";
+ case X509Certificate::kPublicKeyTypeMLDSA:
+ return "ML-DSA";
+ case X509Certificate::kPublicKeyTypeSPHINCSSHA2:
+ return "SPHINCSSHA2";
+ case X509Certificate::kPublicKeyTypeSPHINCSSHAKE:
+ return "SPHINCSSHAKE";
}
NOTREACHED();
return "Unsupported";
@@ -309,6 +319,26 @@ void RecordTrustAnchorHistogram(const HashValueVector& spki_hashes,
case bssl::SignatureAlgorithm::kRsaPssSha256:
case bssl::SignatureAlgorithm::kRsaPssSha384:
case bssl::SignatureAlgorithm::kRsaPssSha512:
+ case bssl::SignatureAlgorithm::kDilithium2:
+ case bssl::SignatureAlgorithm::kMldsa44:
+ case bssl::SignatureAlgorithm::kFalcon512:
+ case bssl::SignatureAlgorithm::kSphincssha2128fsimple:
+ case bssl::SignatureAlgorithm::kSphincssha2128ssimple:
+ case bssl::SignatureAlgorithm::kSphincsshake128fsimple:
+ case bssl::SignatureAlgorithm::kSphincsshake128ssimple:
+ case bssl::SignatureAlgorithm::kDilithium3:
+ case bssl::SignatureAlgorithm::kMldsa65:
+ case bssl::SignatureAlgorithm::kSphincssha2192fsimple:
+ case bssl::SignatureAlgorithm::kSphincssha2192ssimple:
+ case bssl::SignatureAlgorithm::kSphincsshake192fsimple:
+ case bssl::SignatureAlgorithm::kSphincsshake192ssimple:
+ case bssl::SignatureAlgorithm::kDilithium5:
+ case bssl::SignatureAlgorithm::kMldsa87:
+ case bssl::SignatureAlgorithm::kFalcon1024:
+ case bssl::SignatureAlgorithm::kSphincssha2256fsimple:
+ case bssl::SignatureAlgorithm::kSphincssha2256ssimple:
+ case bssl::SignatureAlgorithm::kSphincsshake256fsimple:
+ case bssl::SignatureAlgorithm::kSphincsshake256ssimple:
return true;
}

diff --git a/net/cert/x509_certificate.cc b/net/cert/x509_certificate.cc
index f23121ac4a..9b213e3dcc 100644
--- a/net/cert/x509_certificate.cc
+++ b/net/cert/x509_certificate.cc
@@ -644,6 +644,36 @@ void X509Certificate::GetPublicKeyInfo(const CRYPTO_BUFFER* cert_buffer,
case EVP_PKEY_DH:
*type = kPublicKeyTypeDH;
break;
+ case EVP_PKEY_DILITHIUM2:
+ case EVP_PKEY_DILITHIUM3:
+ case EVP_PKEY_DILITHIUM5:
+ *type = kPublicKeyTypeDilithium;
+ break;
+ case EVP_PKEY_FALCON512:
+ case EVP_PKEY_FALCON1024:
+ *type = kPublicKeyTypeFalcon;
+ break;
+ case EVP_PKEY_MLDSA44:
+ case EVP_PKEY_MLDSA65:
+ case EVP_PKEY_MLDSA87:
+ *type = kPublicKeyTypeMLDSA;
+ break;
+ case EVP_PKEY_SPHINCSSHA2128FSIMPLE:
+ case EVP_PKEY_SPHINCSSHA2128SSIMPLE:
+ case EVP_PKEY_SPHINCSSHA2192FSIMPLE:
+ case EVP_PKEY_SPHINCSSHA2192SSIMPLE:
+ case EVP_PKEY_SPHINCSSHA2256FSIMPLE:
+ case EVP_PKEY_SPHINCSSHA2256SSIMPLE:
+ *type = kPublicKeyTypeSPHINCSSHA2;
+ break;
+ case EVP_PKEY_SPHINCSSHAKE128FSIMPLE:
+ case EVP_PKEY_SPHINCSSHAKE128SSIMPLE:
+ case EVP_PKEY_SPHINCSSHAKE192FSIMPLE:
+ case EVP_PKEY_SPHINCSSHAKE192SSIMPLE:
+ case EVP_PKEY_SPHINCSSHAKE256FSIMPLE:
+ case EVP_PKEY_SPHINCSSHAKE256SSIMPLE:
+ *type = kPublicKeyTypeSPHINCSSHAKE;
+ break;
}
*size_bits = base::saturated_cast<size_t>(EVP_PKEY_bits(pkey.get()));
}
diff --git a/net/cert/x509_certificate.h b/net/cert/x509_certificate.h
index ad138a534e..2749f29efe 100644
--- a/net/cert/x509_certificate.h
+++ b/net/cert/x509_certificate.h
@@ -47,7 +47,12 @@ class NET_EXPORT X509Certificate
kPublicKeyTypeDSA,
kPublicKeyTypeECDSA,
kPublicKeyTypeDH,
- kPublicKeyTypeECDH
+ kPublicKeyTypeECDH,
+ kPublicKeyTypeDilithium,
+ kPublicKeyTypeFalcon,
+ kPublicKeyTypeMLDSA,
+ kPublicKeyTypeSPHINCSSHA2,
+ kPublicKeyTypeSPHINCSSHAKE
};

enum Format {
diff --git a/net/quic/quic_session_pool.cc b/net/quic/quic_session_pool.cc
index a7e1ecbe60..3ab2c9cff7 100644
--- a/net/quic/quic_session_pool.cc
+++ b/net/quic/quic_session_pool.cc
@@ -347,7 +347,16 @@ QuicSessionPool::QuicCryptoClientConfigOwner::QuicCryptoClientConfigOwner(
base::Unretained(this)));
if (quic_session_pool_->ssl_config_service_->GetSSLContextConfig()
.PostQuantumKeyAgreementEnabled()) {
- config_.set_preferred_groups({SSL_GROUP_X25519_KYBER768_DRAFT00,
+ config_.set_preferred_groups({SSL_GROUP_KYBER512, SSL_GROUP_KYBER768, SSL_GROUP_KYBER1024,
+ SSL_GROUP_HQC128, SSL_GROUP_HQC192, SSL_GROUP_HQC256,
+ SSL_GROUP_MLKEM512, SSL_GROUP_MLKEM768, SSL_GROUP_MLKEM1024,
+ SSL_GROUP_FRODO640AES, SSL_GROUP_FRODO640SHAKE, SSL_GROUP_FRODO976AES, SSL_GROUP_FRODO976SHAKE, SSL_GROUP_FRODO1344AES, SSL_GROUP_FRODO1344SHAKE,
+ SSL_GROUP_X25519_KYBER512, SSL_GROUP_X25519_KYBER768_DRAFT00, SSL_GROUP_P256_KYBER512, SSL_GROUP_P384_KYBER768, SSL_GROUP_P521_KYBER1024,
+ SSL_GROUP_X25519_HQC128, SSL_GROUP_P256_HQC128, SSL_GROUP_P384_HQC192, SSL_GROUP_P521_HQC256,
+ SSL_GROUP_X25519_MLKEM512, SSL_GROUP_P256_MLKEM512, SSL_GROUP_P384_MLKEM768, SSL_GROUP_P521_MLKEM1024,
+ SSL_GROUP_X25519_FRODO640AES, SSL_GROUP_X25519_FRODO640SHAKE, SSL_GROUP_P256_FRODO640AES, SSL_GROUP_P256_FRODO640SHAKE, SSL_GROUP_P384_FRODO976AES, SSL_GROUP_P384_FRODO976SHAKE, SSL_GROUP_P521_FRODO1344AES, SSL_GROUP_P521_FRODO1344SHAKE,
+ SSL_GROUP_BIKEL1, SSL_GROUP_BIKEL3,
+ SSL_GROUP_X25519_BIKEL1, SSL_GROUP_P256_BIKEL1, SSL_GROUP_P384_BIKEL3,
SSL_GROUP_X25519, SSL_GROUP_SECP256R1,
SSL_GROUP_SECP384R1});
}
diff --git a/net/socket/ssl_client_socket_impl.cc b/net/socket/ssl_client_socket_impl.cc
index 236de0c0bb..4595cccd30 100644
--- a/net/socket/ssl_client_socket_impl.cc
+++ b/net/socket/ssl_client_socket_impl.cc
@@ -741,8 +741,17 @@ int SSLClientSocketImpl::Init() {
}

if (context_->config().PostQuantumKeyAgreementEnabled()) {
- static const int kCurves[] = {NID_X25519Kyber768Draft00, NID_X25519,
- NID_X9_62_prime256v1, NID_secp384r1};
+ static const int kCurves[] = {NID_kyber512, NID_kyber768, NID_kyber1024,
+ NID_hqc128, NID_hqc192, NID_hqc256,
+ NID_mlkem512, NID_mlkem768, NID_mlkem1024,
+ NID_x25519_kyber512, NID_X25519Kyber768Draft00, NID_p256_kyber512, NID_p384_kyber768, NID_p521_kyber1024,
+ NID_x25519_hqc128, NID_p256_hqc128, NID_p384_hqc192, NID_p521_hqc256,
+ NID_x25519_mlkem512, NID_p256_mlkem512, NID_p384_mlkem768, NID_p521_mlkem1024,
+ NID_frodo640aes, NID_frodo640shake, NID_frodo976aes, NID_frodo976shake, NID_frodo1344aes, NID_frodo1344shake,
+ NID_x25519_frodo640aes, NID_x25519_frodo640shake, NID_p256_frodo640aes, NID_p256_frodo640shake, NID_p384_frodo976aes, NID_p384_frodo976shake, NID_p521_frodo1344aes, NID_p521_frodo1344shake,
+ NID_bikel1, NID_bikel3,
+ NID_x25519_bikel1, NID_p256_bikel1, NID_p384_bikel3,
+ NID_X25519, NID_X9_62_prime256v1, NID_secp384r1};
if (!SSL_set1_curves(ssl_.get(), kCurves, std::size(kCurves))) {
return ERR_UNEXPECTED;
}
@@ -842,6 +851,11 @@ int SSLClientSocketImpl::Init() {
SSL_SIGN_RSA_PKCS1_SHA256, SSL_SIGN_ECDSA_SECP384R1_SHA384,
SSL_SIGN_RSA_PSS_RSAE_SHA384, SSL_SIGN_RSA_PKCS1_SHA384,
SSL_SIGN_RSA_PSS_RSAE_SHA512, SSL_SIGN_RSA_PKCS1_SHA512,
+ SSL_SIGN_DILITHIUM2, SSL_SIGN_DILITHIUM3, SSL_SIGN_DILITHIUM5,
+ SSL_SIGN_FALCON512, SSL_SIGN_FALCON1024,
+ SSL_SIGN_MLDSA44, SSL_SIGN_MLDSA65, SSL_SIGN_MLDSA87,
+ SSL_SIGN_SPHINCSSHA2128FSIMPLE, SSL_SIGN_SPHINCSSHA2128SSIMPLE, SSL_SIGN_SPHINCSSHA2192FSIMPLE, SSL_SIGN_SPHINCSSHA2192SSIMPLE, SSL_SIGN_SPHINCSSHA2256FSIMPLE, SSL_SIGN_SPHINCSSHA2256SSIMPLE,
+ SSL_SIGN_SPHINCSSHAKE128FSIMPLE, SSL_SIGN_SPHINCSSHAKE128SSIMPLE, SSL_SIGN_SPHINCSSHAKE192FSIMPLE, SSL_SIGN_SPHINCSSHAKE192SSIMPLE, SSL_SIGN_SPHINCSSHAKE256FSIMPLE, SSL_SIGN_SPHINCSSHAKE256SSIMPLE,
};
if (!SSL_set_verify_algorithm_prefs(ssl_.get(), kVerifyPrefs,
std::size(kVerifyPrefs))) {
diff --git a/third_party/boringssl/BUILD.gn b/third_party/boringssl/BUILD.gn
index 6a0e44685b..13e61a12ef 100644
--- a/third_party/boringssl/BUILD.gn
+++ b/third_party/boringssl/BUILD.gn
@@ -18,7 +18,7 @@ if (enable_rust) {

# Config for us and everybody else depending on BoringSSL.
config("external_config") {
- include_dirs = [ "src/include" ]
+ include_dirs = [ "src/include", "src/oqs/include" ]
if (is_component_build) {
defines = [ "BORINGSSL_SHARED_LIBRARY" ]
}
@@ -54,7 +54,7 @@ config("no_asm_config") {
# TODO(crbug.com/1496373): having the headers in all_sources is hacky and should
# be fixed. It is caused by issues with the fuzzer target.
all_sources = crypto_sources + ssl_sources + pki_sources + pki_internal_headers
-all_headers = crypto_headers + ssl_headers + pki_headers + pki_internal_headers
+all_headers = crypto_headers + ssl_headers + pki_headers + pki_internal_headers + oqs_headers

if (enable_rust_boringssl) {
rust_bindgen("raw_bssl_sys_bindings") {
@@ -142,6 +142,7 @@ component("boringssl") {
sources = all_sources
public = all_headers
friend = [ ":*" ]
+ libs = [ "//third_party/boringssl/src/oqs/lib/liboqs.a" ]
deps = [ "//third_party/boringssl/src/third_party/fiat:fiat_license" ]

# Mark boringssl_asm as a public dependency so the OPENSSL_NO_ASM
Loading

0 comments on commit 374f268

Please sign in to comment.