Skip to content

Commit

Permalink
Updated interfaces (#586)
Browse files Browse the repository at this point in the history
* Updated interfaces
* Update dependency
---------

Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn authored Mar 15, 2024
1 parent 6b8a26e commit c144d56
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ libcurl:
# OCPP
libocpp:
git: https://github.com/EVerest/libocpp.git
git_tag: 10bb269
git_tag: 86adda6
cmake_condition: "EVEREST_DEPENDENCY_ENABLED_LIBOCPP"
# Josev
Josev:
Expand Down
2 changes: 1 addition & 1 deletion interfaces/evse_security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cmds:
result:
description: Result of the verification
type: string
$ref: /evse_security#/InstallCertificateResult
$ref: /evse_security#/CertificateValidationResult
get_installed_certificates:
description: Command to retrieve installed certificates of the EVSE
arguments:
Expand Down
23 changes: 22 additions & 1 deletion lib/staging/ocpp/evse_security_ocpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ EvseSecurity::update_leaf_certificate(const std::string& certificate_chain,
this->r_security.call_update_leaf_certificate(certificate_chain, conversions::from_ocpp(certificate_type)));
}

ocpp::InstallCertificateResult
ocpp::CertificateValidationResult
EvseSecurity::verify_certificate(const std::string& certificate_chain,
const ocpp::CertificateSigningUseEnum& certificate_type) {
return conversions::to_ocpp(
Expand Down Expand Up @@ -194,6 +194,27 @@ ocpp::InstallCertificateResult to_ocpp(types::evse_security::InstallCertificateR
}
}

ocpp::CertificateValidationResult to_ocpp(types::evse_security::CertificateValidationResult other) {
switch (other) {
case types::evse_security::CertificateValidationResult::Valid:
return ocpp::CertificateValidationResult::Valid;
case types::evse_security::CertificateValidationResult::InvalidSignature:
return ocpp::CertificateValidationResult::InvalidSignature;
case types::evse_security::CertificateValidationResult::IssuerNotFound:
return ocpp::CertificateValidationResult::IssuerNotFound;
case types::evse_security::CertificateValidationResult::InvalidLeafSignature:
return ocpp::CertificateValidationResult::InvalidLeafSignature;
case types::evse_security::CertificateValidationResult::InvalidChain:
return ocpp::CertificateValidationResult::InvalidChain;
case types::evse_security::CertificateValidationResult::Unknown:
return ocpp::CertificateValidationResult::Unknown;
;
default:
throw std::runtime_error("Could not convert types::evse_security::CertificateValidationResult to "
"ocpp::CertificateValidationResult");
}
}

ocpp::DeleteCertificateResult to_ocpp(types::evse_security::DeleteCertificateResult other) {
switch (other) {
case types::evse_security::DeleteCertificateResult::Accepted:
Expand Down
6 changes: 4 additions & 2 deletions lib/staging/ocpp/evse_security_ocpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class EvseSecurity : public ocpp::EvseSecurity {
const ocpp::CaCertificateType& certificate_type) override;
ocpp::DeleteCertificateResult
delete_certificate(const ocpp::CertificateHashDataType& certificate_hash_data) override;
ocpp::InstallCertificateResult verify_certificate(const std::string& certificate_chain,
const ocpp::CertificateSigningUseEnum& certificate_type) override;
ocpp::CertificateValidationResult
verify_certificate(const std::string& certificate_chain,
const ocpp::CertificateSigningUseEnum& certificate_type) override;
ocpp::InstallCertificateResult
update_leaf_certificate(const std::string& certificate_chain,
const ocpp::CertificateSigningUseEnum& certificate_type) override;
Expand All @@ -47,6 +48,7 @@ ocpp::CertificateSigningUseEnum to_ocpp(types::evse_security::LeafCertificateTyp
ocpp::CertificateType to_ocpp(types::evse_security::CertificateType other);
ocpp::HashAlgorithmEnumType to_ocpp(types::evse_security::HashAlgorithm other);
ocpp::InstallCertificateResult to_ocpp(types::evse_security::InstallCertificateResult other);
ocpp::CertificateValidationResult to_ocpp(types::evse_security::CertificateValidationResult other);
ocpp::DeleteCertificateResult to_ocpp(types::evse_security::DeleteCertificateResult other);

ocpp::CertificateHashDataType to_ocpp(types::evse_security::CertificateHashData other);
Expand Down
21 changes: 21 additions & 0 deletions modules/EvseSecurity/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,27 @@ types::evse_security::InstallCertificateResult to_everest(evse_security::Install
}
}

types::evse_security::CertificateValidationResult to_everest(evse_security::CertificateValidationResult other) {
switch (other) {
case evse_security::CertificateValidationResult::Valid:
return types::evse_security::CertificateValidationResult::Valid;
case evse_security::CertificateValidationResult::InvalidSignature:
return types::evse_security::CertificateValidationResult::InvalidSignature;
case evse_security::CertificateValidationResult::IssuerNotFound:
return types::evse_security::CertificateValidationResult::IssuerNotFound;
case evse_security::CertificateValidationResult::InvalidLeafSignature:
return types::evse_security::CertificateValidationResult::InvalidLeafSignature;
case evse_security::CertificateValidationResult::InvalidChain:
return types::evse_security::CertificateValidationResult::InvalidChain;
case evse_security::CertificateValidationResult::Unknown:
return types::evse_security::CertificateValidationResult::Unknown;
;
default:
throw std::runtime_error("Could not convert evse_security::CertificateValidationResult to "
"types::evse_security::CertificateValidationResult");
}
}

types::evse_security::DeleteCertificateResult to_everest(evse_security::DeleteCertificateResult other) {
switch (other) {
case evse_security::DeleteCertificateResult::Accepted:
Expand Down
1 change: 1 addition & 0 deletions modules/EvseSecurity/conversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ types::evse_security::LeafCertificateType to_everest(evse_security::LeafCertific
types::evse_security::CertificateType to_everest(evse_security::CertificateType other);
types::evse_security::HashAlgorithm to_everest(evse_security::HashAlgorithm other);
types::evse_security::InstallCertificateResult to_everest(evse_security::InstallCertificateResult other);
types::evse_security::CertificateValidationResult to_everest(evse_security::CertificateValidationResult other);
types::evse_security::DeleteCertificateResult to_everest(evse_security::DeleteCertificateResult other);
types::evse_security::GetInstalledCertificatesStatus to_everest(evse_security::GetInstalledCertificatesStatus other);
types::evse_security::GetKeyPairStatus to_everest(evse_security::GetKeyPairStatus other);
Expand Down
2 changes: 1 addition & 1 deletion modules/EvseSecurity/main/evse_securityImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ evse_securityImpl::handle_update_leaf_certificate(std::string& certificate_chain
this->evse_security->update_leaf_certificate(certificate_chain, conversions::from_everest(certificate_type)));
}

types::evse_security::InstallCertificateResult
types::evse_security::CertificateValidationResult
evse_securityImpl::handle_verify_certificate(std::string& certificate_chain,
types::evse_security::LeafCertificateType& certificate_type) {
return conversions::to_everest(
Expand Down
2 changes: 1 addition & 1 deletion modules/EvseSecurity/main/evse_securityImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class evse_securityImpl : public evse_securityImplBase {
virtual types::evse_security::InstallCertificateResult
handle_update_leaf_certificate(std::string& certificate_chain,
types::evse_security::LeafCertificateType& certificate_type) override;
virtual types::evse_security::InstallCertificateResult
virtual types::evse_security::CertificateValidationResult
handle_verify_certificate(std::string& certificate_chain,
types::evse_security::LeafCertificateType& certificate_type) override;
virtual types::evse_security::GetInstalledCertificatesResult
Expand Down
12 changes: 12 additions & 0 deletions types/evse_security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ types:
- CertificateStoreMaxLengthExceeded
- WriteError
- Accepted
CertificateValidationResult:
description: Result of the attempt to validate a certificate
type: string
enum:
- Valid
- Expired
- InvalidSignature
- IssuerNotFound
- InvalidLeafSignature
- InvalidChain
- Unknown

DeleteCertificateResult:
description: Result of the attempt to delete a certificate
type: string
Expand Down

0 comments on commit c144d56

Please sign in to comment.