Skip to content

Commit

Permalink
fix: QA tweeks
Browse files Browse the repository at this point in the history
  • Loading branch information
james-ctc committed Feb 15, 2024
1 parent 59d9f6f commit b95ee81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
3 changes: 2 additions & 1 deletion lib/evse_security/crypto/openssl/openssl_supplier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ static bool s_generate_key(const KeyGenerationInfo& key_info, KeyHandle_ptr& out
}

#if EVSE_OPENSSL_VER_3
OSSL_PARAM params[2] = {NULL, NULL};
OSSL_PARAM params[2];
std::memset(&params[0], 0, sizeof(params));

if (bEC) {
params[0] = OSSL_PARAM_construct_utf8_string("group", group, group_sz);
Expand Down
3 changes: 2 additions & 1 deletion lib/evse_security/crypto/openssl/openssl_tpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void OpenSSLProvider::cleanup() {
s_flags = 0;
}

#else // USING_OPENSSL_3_TPM
#else // USING_OPENSSL_3_TPM
// ----------------------------------------------------------------------------
// class OpenSSLProvider dummy where OpenSSL 3 is not available

Expand Down Expand Up @@ -255,3 +255,4 @@ void OpenSSLProvider::cleanup() {
#endif // USING_OPENSSL_3_TPM

} // namespace evse_security

34 changes: 0 additions & 34 deletions tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,40 +201,6 @@ TEST_F(EvseSecurityTests, verify_expired_csr_deletion) {
ASSERT_FALSE(fs::exists(csr_key_path));
}

TEST_F(EvseSecurityTests, verify_expired_leaf_deletion) {
// Copy many expired certificates
std::set<fs::path> existing;

for (int i = 0; i < 30; i++) {
std::string key_filename = std::string("certs/client/cso/SECC_LEAF_EXPIRED_") + std::to_string(i) + ".key";
std::string cert_filename = std::string("certs/client/cso/SECC_LEAF_EXPIRED_") + std::to_string(i) + ".pem";

existing.emplace(key_filename);
existing.emplace(cert_filename);

std::filesystem::copy("expired_leaf/SECC_LEAF_EXPIRED.key", key_filename);
std::filesystem::copy("expired_leaf/SECC_LEAF_EXPIRED.pem", cert_filename);
}

// Check that the FS is not full
ASSERT_FALSE(evse_security->is_filesystem_full());

// Fill the disk
evse_security->max_fs_certificate_store_entries = 20;

// Garbage collect
evse_security->garbage_collect();

// Assert the files/keys do not exist any more
std::size_t existing_count = 0;
for (const auto& path : existing) {
existing_count += fs::exists(path) ? 1 : 0;
}

// Only 10 should be kept (key + certificate)
ASSERT_EQ(existing_count, 20);
}

TEST_F(EvseSecurityTests, verify_basics) {
// Check that we have the default provider
ASSERT_TRUE(check_openssl_providers({PROVIDER_DEFAULT}));
Expand Down

0 comments on commit b95ee81

Please sign in to comment.