Zero Trust IoT library
Loading...
Searching...
No Matches
CertificateAuthority Class Reference

Issues and signs certificates for Zero Trust identity validation. More...

#include <zt-certificate.h>

Collaboration diagram for CertificateAuthority:

Public Member Functions

 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.
 
CryptoPP::RSA::PublicKey GetPublicKey () const
 Retrieves the public RSA key of the CA.
 

Private Attributes

CryptoPP::RSA::PrivateKey privateKey
 RSA private key used for signing certificates.
 
CryptoPP::RSA::PublicKey publicKey
 RSA public key distributed for verification.
 

Detailed Description

Issues and signs certificates for Zero Trust identity validation.

Simulates a Certificate Authority (CA) that issues and signs identity certificates.

The CA generates a public-private RSA key pair and uses it to sign certificates for nodes, which include identity, role, and expiry information.

Definition at line 17 of file zt-certificate.h.

Constructor & Destructor Documentation

◆ CertificateAuthority()

CertificateAuthority::CertificateAuthority ( )

Constructor that initializes and generates RSA key pair.

Definition at line 16 of file zt-certificate.cc.

16 {
17 AutoSeededRandomPool prng;
18 privateKey.GenerateRandomWithKeySize(prng, 1024);
20}
CryptoPP::RSA::PublicKey publicKey
RSA public key distributed for verification.
CryptoPP::RSA::PrivateKey privateKey
RSA private key used for signing certificates.

Member Function Documentation

◆ GetPublicKey()

RSA::PublicKey CertificateAuthority::GetPublicKey ( ) const

Retrieves the public RSA key of the CA.

Returns the public key of the Certificate Authority.

Returns
The public key corresponding to the CA's private key.
RSA public key

Definition at line 52 of file zt-certificate.cc.

52 {
53 return publicKey;
54}
Here is the caller graph for this function:

◆ SignIdentity()

std::string CertificateAuthority::SignIdentity ( uint32_t  nodeId,
const std::string &  role,
time_t  expiry 
)

Signs an identity certificate with node ID, role, and expiry.

Signs a certificate with node ID, role, and expiry.

Parameters
nodeIdThe unique identifier of the node.
roleThe assigned role of the node (e.g., "sensor", "gateway").
expiryExpiry timestamp for the certificate.
Returns
A signed certificate string in plain format with a base64-encoded signature.
Parameters
nodeIdID of the node requesting certificate
roleRole assigned to the node (e.g., sensor, gateway)
expiryExpiry timestamp of the certificate
Returns
Signed certificate string with base64-encoded signature

Definition at line 29 of file zt-certificate.cc.

29 {
30 AutoSeededRandomPool prng;
31
32 std::ostringstream cert;
33 cert << "ID:" << nodeId << "|ROLE:" << role << "|EXP:" << expiry;
34
35 RSASS<PSSR, SHA1>::Signer signer(privateKey);
36 std::string signature;
37 StringSource(cert.str(), true,
38 new SignerFilter(prng, signer,
39 new StringSink(signature)));
40
41 std::string encodedSig;
42 StringSource(signature, true,
43 new Base64Encoder(new StringSink(encodedSig), false));
44
45 return cert.str() + "|SIG:" + encodedSig;
46}
Here is the caller graph for this function:

Field Documentation

◆ privateKey

CryptoPP::RSA::PrivateKey CertificateAuthority::privateKey
private

RSA private key used for signing certificates.

Definition at line 40 of file zt-certificate.h.

◆ publicKey

CryptoPP::RSA::PublicKey CertificateAuthority::publicKey
private

RSA public key distributed for verification.

Definition at line 41 of file zt-certificate.h.


The documentation for this class was generated from the following files: