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

Refactoring TLS 1.3 support #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*build
.vscode
pki
/pki
test/sample_data
10 changes: 8 additions & 2 deletions include/iso15118/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright 2023 Pionix GmbH and Contributors to EVerest
#pragma once

#include <filesystem>
#include <optional>
#include <string>

Expand All @@ -17,16 +18,21 @@
EVEREST_LAYOUT,
JOSEPPA_LAYOUT,
};

struct SSLConfig {
CertificateBackend backend;
CertificateBackend backend{CertificateBackend::EVEREST_LAYOUT};

Check notice on line 23 in include/iso15118/config.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/iso15118/config.hpp#L23

struct member 'SSLConfig::backend' is never used.
// Used by the JOSEPPA_LAYOUT
std::string config_string;
// Used by the EVEREST_LAYOUT
std::string path_certificate_chain;
std::string path_certificate_key;
std::optional<std::string> private_key_password;
std::optional<std::string> private_key_password{};
std::string path_certificate_v2g_root;

Check notice on line 30 in include/iso15118/config.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/iso15118/config.hpp#L30

struct member 'SSLConfig::path_certificate_v2g_root' is never used.
std::string path_certificate_mo_root;

Check notice on line 31 in include/iso15118/config.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/iso15118/config.hpp#L31

struct member 'SSLConfig::path_certificate_mo_root' is never used.
bool enable_ssl_logging{false};
bool enable_tls_key_logging{false};
bool enforce_tls_1_3{false};

Check notice on line 34 in include/iso15118/config.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/iso15118/config.hpp#L34

struct member 'SSLConfig::enforce_tls_1_3' is never used.
std::filesystem::path tls_key_logging_path{};
};

} // namespace iso15118::config
13 changes: 13 additions & 0 deletions include/iso15118/detail/io/sha_hash.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024 Pionix GmbH and Contributors to EVerest
#pragma once

#include <array>
#include <cstdint>

namespace iso15118::io {

constexpr std::size_t sha_512_hash_size = 64;
using sha512_hash_t = std::array<uint8_t, sha_512_hash_size>;

} // namespace iso15118::io
5 changes: 5 additions & 0 deletions include/iso15118/io/connection_abstract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

#include <cstddef>
#include <functional>
#include <optional>

#include "ipv6_endpoint.hpp"

#include <iso15118/detail/io/sha_hash.hpp>

namespace iso15118::io {

enum class ConnectionEvent {
Expand All @@ -33,6 +36,8 @@ struct IConnection {

virtual void close() = 0;

virtual std::optional<sha512_hash_t> get_vehicle_cert_hash() const = 0;

virtual ~IConnection() = default;
};
} // namespace iso15118::io
4 changes: 4 additions & 0 deletions include/iso15118/io/connection_plain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class ConnectionPlain : public IConnection {

void close() final;

std::optional<sha512_hash_t> get_vehicle_cert_hash() const final {
return std::nullopt;
}

~ConnectionPlain();

private:
Expand Down
4 changes: 4 additions & 0 deletions include/iso15118/io/connection_ssl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#include "connection_abstract.hpp"

#include <memory>
#include <optional>

#include <iso15118/config.hpp>
#include <iso15118/detail/io/sha_hash.hpp>
#include <iso15118/io/poll_manager.hpp>

namespace iso15118::io {
Expand All @@ -24,6 +26,8 @@ class ConnectionSSL : public IConnection {

void close() final;

std::optional<sha512_hash_t> get_vehicle_cert_hash() const final;

~ConnectionSSL();

private:
Expand Down
5 changes: 5 additions & 0 deletions include/iso15118/io/sdp_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ class TlsKeyLoggingServer {
return fd;
}

auto get_port() const {
return port;
}

private:
int fd{-1};
uint16_t port{0};
sockaddr_in6 destination_address{};
};

Expand Down
2 changes: 1 addition & 1 deletion include/iso15118/tbd_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace iso15118 {

struct TbdConfig {
config::SSLConfig ssl{config::CertificateBackend::EVEREST_LAYOUT, {}, {}, {}, {}};
config::SSLConfig ssl{config::CertificateBackend::EVEREST_LAYOUT, {}, {}, {}, {}, {}, {}};
std::string interface_name;
config::TlsNegotiationStrategy tls_negotiation_strategy{config::TlsNegotiationStrategy::ACCEPT_CLIENT_OFFER};
bool enable_sdp_server{true};
Expand Down
Loading