Zero Trust IoT library
Loading...
Searching...
No Matches
zt-tls-handshake.h
Go to the documentation of this file.
1// zt-tls-handshake.h
2
3#ifndef ZT_TLS_HANDSHAKE_H
4#define ZT_TLS_HANDSHAKE_H
5
6#include "ns3/object.h"
7#include "ns3/node.h"
8#include <map>
9#include <string>
10#include <functional>
11
12namespace ns3 {
13
23class ZtTlsHandshake : public Object {
24public:
29 static TypeId GetTypeId();
30
35
47 void StartHandshake(Ptr<Node> client, Ptr<Node> server, uint32_t clientId, uint32_t serverId);
48
54 bool HasSession(uint32_t peerId) const;
55
61 std::string GetSessionKey(uint32_t peerId) const;
62
67 void SetExternalLogger(std::function<void(std::string)> logger);
68
73 void SetPolicyValidator(std::function<bool(uint32_t, std::string)> validator);
74
75private:
80 void Log(const std::string& msg) const;
81
82 std::map<uint32_t, std::string> m_sessionKeys;
83 std::function<void(std::string)> m_logger;
84 std::function<bool(uint32_t, std::string)> m_policyValidator;
85};
86
87} // namespace ns3
88
89#endif // ZT_TLS_HANDSHAKE_H
90
Simulates a Zero Trust-based TLS handshake mechanism between NS-3 nodes.
void StartHandshake(Ptr< Node > client, Ptr< Node > server, uint32_t clientId, uint32_t serverId)
Start a simulated TLS handshake between client and server nodes.
void SetExternalLogger(std::function< void(std::string)> logger)
Set an external logger for emitting TLS logs.
ZtTlsHandshake()
Constructor.
std::function< void(std::string)> m_logger
Optional external logger.
static TypeId GetTypeId()
Get the NS-3 TypeId.
std::string GetSessionKey(uint32_t peerId) const
Retrieve the session key for a peer in hexadecimal string format.
std::map< uint32_t, std::string > m_sessionKeys
Maps node IDs to session keys.
std::function< bool(uint32_t, std::string)> m_policyValidator
Optional external policy validator.
bool HasSession(uint32_t peerId) const
Check if a session exists for a given peer.
void Log(const std::string &msg) const
Emit a log message using the external logger or NS_LOG fallback.
void SetPolicyValidator(std::function< bool(uint32_t, std::string)> validator)
Set a policy validator for enforcing Zero Trust identity checks.