Skip to content
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

Support for tpm CSR request #27

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14)

project(everest-evse_security VERSION 0.3.0
project(everest-evse_security VERSION 0.4.0
DESCRIPTION "Implementation of EVSE related security operations"
LANGUAGES CXX C
)
Expand Down
14 changes: 13 additions & 1 deletion include/evse_security/evse_security.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,19 @@ class EvseSecurity {
bool is_ca_certificate_installed(CaCertificateType certificate_type);

/// @brief Generates a certificate signing request for the given \p certificate_type , \p country , \p organization
/// and \p common
/// and \p common , uses the TPM if \p use_tpm is true
/// @param certificate_type
/// @param country
/// @param organization
/// @param common
/// @param use_tpm If the TPM should be used for the CSR request
/// @return the PEM formatted certificate signing request
std::string generate_certificate_signing_request(LeafCertificateType certificate_type, const std::string& country,
const std::string& organization, const std::string& common,
bool use_tpm);

/// @brief Generates a certificate signing request for the given \p certificate_type , \p country , \p organization
/// and \p common without using the TPM
/// @param certificate_type
/// @param country
/// @param organization
Expand Down
12 changes: 8 additions & 4 deletions lib/evse_security/evse_security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ bool EvseSecurity::is_ca_certificate_installed(CaCertificateType certificate_typ
std::string EvseSecurity::generate_certificate_signing_request(LeafCertificateType certificate_type,
const std::string& country,
const std::string& organization,
const std::string& common) {
const std::string& common, bool use_tpm) {
fs::path key_path;

const auto file_name = std::string("SECC_LEAF_") + filesystem_utils::get_random_file_name(KEY_EXTENSION.string());
Expand All @@ -574,9 +574,6 @@ std::string EvseSecurity::generate_certificate_signing_request(LeafCertificateTy
std::string csr;
CertificateSigningRequestInfo info;

// TODO(ioan): get this from the parameter when the interface will support it
bool use_tpm = false;

info.n_version = 0;
info.commonName = common;
info.country = country;
Expand All @@ -598,6 +595,13 @@ std::string EvseSecurity::generate_certificate_signing_request(LeafCertificateTy
return csr;
}

std::string EvseSecurity::generate_certificate_signing_request(LeafCertificateType certificate_type,
const std::string& country,
const std::string& organization,
const std::string& common) {
return generate_certificate_signing_request(certificate_type, country, organization, common, false);
}

GetKeyPairResult EvseSecurity::get_key_pair(LeafCertificateType certificate_type, EncodingFormat encoding) {
EVLOG_debug << "Requesting key/pair: " << conversions::leaf_certificate_type_to_string(certificate_type);

Expand Down