|
ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
|
Validity period. More...
#include <ndn/certificate.hpp>
Public Member Functions | |
| ValidityPeriod ()=default | |
| Default constructor. | |
| Error | encode (uint8_t *buf, size_t bufSize, size_t &encodedLen) const |
| Encode the ValidityPeriod to TLV wire format. | |
| bool | isValidAt (std::string_view currentTimestamp) const |
| Check if the current time is within the validity period. | |
| bool | equals (const ValidityPeriod &other) const |
| Check equality of two validity periods. | |
NotBefore | |
| Error | setNotBefore (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) |
| Set the NotBefore time from date/time components. | |
| Error | setNotBefore (std::string_view timestamp) |
| Set the NotBefore time from an ISO 8601 string. | |
| const char * | notBefore () const |
| Get the NotBefore time as an ISO 8601 string. | |
NotAfter | |
| Error | setNotAfter (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) |
| Set the NotAfter time from date/time components. | |
| Error | setNotAfter (std::string_view timestamp) |
| Set the NotAfter time from an ISO 8601 string. | |
| const char * | notAfter () const |
| Get the NotAfter time as an ISO 8601 string. | |
Static Public Member Functions | |
| static Result< ValidityPeriod > | fromStrings (std::string_view notBefore, std::string_view notAfter) |
| Create a ValidityPeriod from ISO 8601 format strings. | |
| static Result< ValidityPeriod > | fromWire (const uint8_t *buf, size_t len, size_t *bytesRead=nullptr) |
| Decode a ValidityPeriod from TLV wire format. | |
Validity period.
Represents a certificate's validity period. Consists of two timestamps: NotBefore and NotAfter. Timestamps are expressed in ISO 8601-1:2019 compact format (YYYYMMDDThhmmss).
Definition at line 43 of file certificate.hpp.
|
default |
Default constructor.
Initialized with NotBefore=approximate current time, NotAfter=approximate 1 year later
Encode the ValidityPeriod to TLV wire format.
| buf | Output buffer |
| bufSize | Buffer size |
| encodedLen | Stores the number of encoded bytes |
Definition at line 145 of file certificate.cpp.
References ndn::tlv::NotAfter, ndn::tlv::NotBefore, ndn::TlvEncoder::size(), ndn::VALIDITY_TIMESTAMP_SIZE, ndn::tlv::ValidityPeriod, and ndn::TlvEncoder::writeTlv().
| bool ndn::ValidityPeriod::equals | ( | const ValidityPeriod & | other | ) | const |
Check equality of two validity periods.
Definition at line 213 of file certificate.cpp.
References ndn::VALIDITY_TIMESTAMP_SIZE.
|
static |
Create a ValidityPeriod from ISO 8601 format strings.
| notBefore | Start time (YYYYMMDDThhmmss format) |
| notAfter | End time (YYYYMMDDThhmmss format) |
Definition at line 76 of file certificate.cpp.
References notAfter(), notBefore(), and ndn::VALIDITY_TIMESTAMP_SIZE.
|
static |
Decode a ValidityPeriod from TLV wire format.
| buf | Input buffer |
| len | Buffer length |
| bytesRead | Stores the number of bytes read (ignored if nullptr) |
Definition at line 90 of file certificate.cpp.
References ndn::tlv::NotAfter, ndn::tlv::NotBefore, ndn::TlvDecoder::position(), ndn::TlvDecoder::readBytes(), ndn::TlvDecoder::readTlvHeader(), ndn::VALIDITY_TIMESTAMP_SIZE, and ndn::tlv::ValidityPeriod.
| bool ndn::ValidityPeriod::isValidAt | ( | std::string_view | currentTimestamp | ) | const |
Check if the current time is within the validity period.
| currentTimestamp | Current time (YYYYMMDDThhmmss format) |
Definition at line 204 of file certificate.cpp.
References ndn::VALIDITY_TIMESTAMP_SIZE.
Referenced by ndn::Certificate::isValidAt().
Get the NotAfter time as an ISO 8601 string.
Definition at line 136 of file certificate.hpp.
Referenced by fromStrings().
Get the NotBefore time as an ISO 8601 string.
Definition at line 112 of file certificate.hpp.
Referenced by fromStrings().
| Error ndn::ValidityPeriod::setNotAfter | ( | std::string_view | timestamp | ) |
Set the NotAfter time from an ISO 8601 string.
| timestamp | String in YYYYMMDDThhmmss format |
Definition at line 196 of file certificate.cpp.
References ndn::VALIDITY_TIMESTAMP_SIZE.
| Error ndn::ValidityPeriod::setNotAfter | ( | uint16_t | year, |
| uint8_t | month, | ||
| uint8_t | day, | ||
| uint8_t | hour, | ||
| uint8_t | minute, | ||
| uint8_t | second | ||
| ) |
Set the NotAfter time from date/time components.
Definition at line 190 of file certificate.cpp.
| Error ndn::ValidityPeriod::setNotBefore | ( | std::string_view | timestamp | ) |
Set the NotBefore time from an ISO 8601 string.
| timestamp | String in YYYYMMDDThhmmss format |
Definition at line 182 of file certificate.cpp.
References ndn::VALIDITY_TIMESTAMP_SIZE.
| Error ndn::ValidityPeriod::setNotBefore | ( | uint16_t | year, |
| uint8_t | month, | ||
| uint8_t | day, | ||
| uint8_t | hour, | ||
| uint8_t | minute, | ||
| uint8_t | second | ||
| ) |
Set the NotBefore time from date/time components.
| year | Year (e.g., 2024) |
| month | Month (1-12) |
| day | Day (1-31) |
| hour | Hour (0-23) |
| minute | Minute (0-59) |
| second | Second (0-59) |
Definition at line 176 of file certificate.cpp.