Zero Trust IoT library
Loading...
Searching...
No Matches
zt-certificate.h
Go to the documentation of this file.
1#ifndef ZT_CERTIFICATE_H
2#define ZT_CERTIFICATE_H
3
4#include <string>
5#include <ctime>
6#include <unordered_set>
7#include <cryptopp/rsa.h>
8#include <cryptopp/base64.h>
9
18public:
23
31 std::string SignIdentity(uint32_t nodeId, const std::string& role, time_t expiry);
32
37 CryptoPP::RSA::PublicKey GetPublicKey() const;
38
39private:
40 CryptoPP::RSA::PrivateKey privateKey;
41 CryptoPP::RSA::PublicKey publicKey;
42};
43
52public:
57 void SetCaPublicKey(CryptoPP::RSA::PublicKey pub);
58
63 void Revoke(uint32_t nodeId);
64
72 bool Authorize(uint32_t nodeId, const std::string& role, const std::string& certStr);
73
74private:
75 CryptoPP::RSA::PublicKey caPublicKey;
76 std::unordered_set<uint32_t> revoke;
77};
78
79#endif // ZT_CERTIFICATE_H
80
Issues and signs certificates for Zero Trust identity validation.
CryptoPP::RSA::PublicKey GetPublicKey() const
Retrieves the public RSA key of the CA.
CryptoPP::RSA::PublicKey publicKey
RSA public key distributed for verification.
CryptoPP::RSA::PrivateKey privateKey
RSA private key used for signing certificates.
CertificateAuthority()
Constructor that initializes and generates RSA key pair.
std::string SignIdentity(uint32_t nodeId, const std::string &role, time_t expiry)
Signs an identity certificate with node ID, role, and expiry.
Simulates a Zero Trust policy engine that enforces access control using certificates.
void Revoke(uint32_t nodeId)
Revokes a node by its ID, preventing it from being authorized.
CryptoPP::RSA::PublicKey caPublicKey
Trusted public key used for signature verification.
bool Authorize(uint32_t nodeId, const std::string &role, const std::string &certStr)
Authorizes a node based on its certificate.
std::unordered_set< uint32_t > revoke
Set of node IDs that are explicitly revoked.
void SetCaPublicKey(CryptoPP::RSA::PublicKey pub)
Sets the CA's public key used for certificate verification.