-
Notifications
You must be signed in to change notification settings - Fork 10
Enable ML-KEM key change in TLS handshake between gRPC server/clients #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/bin/bash | ||
| # Copyright lowRISC contributors (OpenTitan project). | ||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| set -e | ||
|
|
||
| # Explicitly enable job control so that we can run the SPM server | ||
| # in the background and still be able to run other commands in parallel. | ||
| set -m | ||
|
|
||
| # Ensure we are running from the repository root | ||
| cd "$(dirname "$0")/.." | ||
|
|
||
| # Build and deploy the provisioning infrastructure. | ||
| source util/integration_test_setup.sh | ||
|
|
||
| SKU_NAMES="sival,cr01,pi01,ti01" | ||
|
|
||
| # Run the PA loadtest. | ||
| echo "Running PA loadtest ..." | ||
| bazelisk run //src/pa:loadtest -- \ | ||
| --ca_root_certs=${DEPLOYMENT_DIR}/certs/out/ca-cert.pem \ | ||
| --client_cert="${DEPLOYMENT_DIR}/certs/out/ate-client-cert.pem" \ | ||
| --client_key="${DEPLOYMENT_DIR}/certs/out/ate-client-key.pem" \ | ||
| --enable_tls=true \ | ||
| --hsm_so="${HSMTOOL_MODULE}" \ | ||
| --pa_address="${OTPROV_DNS_PA}:${OTPROV_PORT_PA}" \ | ||
| --parallel_clients=5 \ | ||
| --sku_auth="test_password" \ | ||
| --sku_names="${SKU_NAMES}" \ | ||
| --spm_config_dir="${DEPLOYMENT_DIR}/spm" \ | ||
| --total_duts=10 | ||
| echo "Done." | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/bin/bash | ||
| # Copyright lowRISC contributors (OpenTitan project). | ||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| set -e | ||
|
|
||
| # Explicitly enable job control so that we can run the SPM server | ||
| # in the background and still be able to run other commands in parallel. | ||
| set -m | ||
|
|
||
| export ENABLE_MLKEM="true" | ||
|
|
||
| # Ensure we are running from the repository root | ||
| cd "$(dirname "$0")/.." | ||
|
|
||
| # Build and deploy the provisioning infrastructure. | ||
| source util/integration_test_setup.sh | ||
|
|
||
| # Dump PA logs on failure | ||
| dump_pa_logs() { | ||
| echo "----------------------------------------------------------------" | ||
| echo "Dumping PA logs (provapp-paserver-1)..." | ||
| podman logs provapp-paserver-1 | ||
| echo "----------------------------------------------------------------" | ||
| } | ||
| trap dump_pa_logs ERR | ||
|
|
||
| # Run the TLS connection test. | ||
| echo "Running TLS connection test ..." | ||
| bazelisk run //src/ate/test_programs:tls_test -- \ | ||
| --enable_mtls=true \ | ||
| --client_cert="${DEPLOYMENT_DIR}/certs/out/ate-client-cert.pem" \ | ||
| --client_key="${DEPLOYMENT_DIR}/certs/out/ate-client-key.pem" \ | ||
| --ca_root_certs=${DEPLOYMENT_DIR}/certs/out/ca-cert.pem \ | ||
| --pa_target="ipv4:${OTPROV_IP_PA}:${OTPROV_PORT_PA}" \ | ||
| --sku="sival" \ | ||
| --sku_auth_pw="test_password" | ||
|
|
||
| echo "Done." | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // Copyright lowRISC contributors (OpenTitan project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <grpcpp/grpcpp.h> | ||
|
|
||
| #include <fstream> | ||
| #include <iomanip> | ||
| #include <iostream> | ||
| #include <memory> | ||
| #include <sstream> | ||
| #include <string> | ||
|
|
||
| #include "absl/flags/flag.h" | ||
| #include "absl/flags/parse.h" | ||
| #include "absl/flags/usage_config.h" | ||
| #include "absl/log/log.h" | ||
| #include "absl/status/status.h" | ||
| #include "absl/status/statusor.h" | ||
| #include "src/ate/ate_api.h" | ||
| #include "src/version/version.h" | ||
|
|
||
| /** | ||
| * PA configuration flags. | ||
| */ | ||
| ABSL_FLAG(std::string, pa_target, "", | ||
| "Endpoint address in gRPC name-syntax format, including port " | ||
| "number. For example: \"localhost:5000\", " | ||
| "\"ipv4:127.0.0.1:5000,127.0.0.2:5000\", or " | ||
| "\"ipv6:[::1]:5000,[::1]:5001\"."); | ||
| ABSL_FLAG(std::string, load_balancing_policy, "", | ||
| "gRPC load balancing policy. If not set, it will be selected by " | ||
| "the gRPC library. For example: \"round_robin\" or " | ||
| "\"pick_first\"."); | ||
| ABSL_FLAG(std::string, sku, "", "SKU string to initialize the PA session."); | ||
| ABSL_FLAG(std::string, sku_auth_pw, "", | ||
| "SKU authorization password string to initialize the PA session."); | ||
|
|
||
| /** | ||
| * mTLS configuration flags. | ||
| */ | ||
| ABSL_FLAG(bool, enable_mtls, false, "Enable mTLS secure channel."); | ||
| ABSL_FLAG(std::string, client_key, "", | ||
| "File path to the PEM encoding of the client's private key."); | ||
| ABSL_FLAG(std::string, client_cert, "", | ||
| "File path to the PEM encoding of the client's certificate chain."); | ||
| ABSL_FLAG(std::string, ca_root_certs, "", | ||
| "File path to the PEM encoding of the server root certificates."); | ||
|
|
||
| namespace { | ||
| using provisioning::VersionFormatted; | ||
|
|
||
| absl::StatusOr<ate_client_ptr> AteClientNew(void) { | ||
| client_options_t options; | ||
|
|
||
| std::string pa_target = absl::GetFlag(FLAGS_pa_target); | ||
| if (pa_target.empty()) { | ||
| return absl::InvalidArgumentError( | ||
| "--pa_target not set. This is a required argument."); | ||
| } | ||
| options.pa_target = pa_target.c_str(); | ||
| options.enable_mtls = absl::GetFlag(FLAGS_enable_mtls); | ||
|
|
||
| std::string lb_policy = absl::GetFlag(FLAGS_load_balancing_policy); | ||
| options.load_balancing_policy = lb_policy.c_str(); | ||
|
|
||
| std::string pem_private_key = absl::GetFlag(FLAGS_client_key); | ||
| std::string pem_cert_chain = absl::GetFlag(FLAGS_client_cert); | ||
| std::string pem_root_certs = absl::GetFlag(FLAGS_ca_root_certs); | ||
|
|
||
| if (options.enable_mtls) { | ||
| if (pem_private_key.empty() || pem_cert_chain.empty() || | ||
| pem_root_certs.empty()) { | ||
| return absl::InvalidArgumentError( | ||
| "--client_key, --client_cert, and --ca_root_certs are required " | ||
| "arguments when --enable_mtls is set."); | ||
| } | ||
| options.pem_private_key = pem_private_key.c_str(); | ||
| options.pem_cert_chain = pem_cert_chain.c_str(); | ||
| options.pem_root_certs = pem_root_certs.c_str(); | ||
| } | ||
|
|
||
| ate_client_ptr ate_client; | ||
| if (CreateClient(&ate_client, &options) != 0) { | ||
| return absl::InternalError("Failed to create ATE client."); | ||
| } | ||
| return ate_client; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| int main(int argc, char **argv) { | ||
| // Parse cmd line args. | ||
| absl::FlagsUsageConfig config; | ||
| absl::SetFlagsUsageConfig(config); | ||
| absl::ParseCommandLine(argc, argv); | ||
|
|
||
| // Set version string. | ||
| config.version_string = &VersionFormatted; | ||
| LOG(INFO) << VersionFormatted(); | ||
|
|
||
| // Instantiate an ATE client (gateway to PA). | ||
| auto ate_client_result = AteClientNew(); | ||
| if (!ate_client_result.ok()) { | ||
| LOG(ERROR) << ate_client_result.status().message() << std::endl; | ||
| return -1; | ||
| } | ||
| ate_client_ptr ate_client = ate_client_result.value(); | ||
|
|
||
| // Init session with PA. | ||
| if (InitSession(ate_client, absl::GetFlag(FLAGS_sku).c_str(), | ||
| absl::GetFlag(FLAGS_sku_auth_pw).c_str()) != 0) { | ||
| LOG(ERROR) << "InitSession with PA failed."; | ||
| return -1; | ||
| } | ||
|
|
||
| LOG(INFO) << "TLS Connection to PA established successfully."; | ||
|
|
||
| // Close session with PA. | ||
| if (CloseSession(ate_client) != 0) { | ||
| LOG(ERROR) << "CloseSession with PA failed."; | ||
| return -1; | ||
| } | ||
| DestroyClient(ate_client); | ||
| return 0; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.