33 #define NDN_LOG_DEBUG_DEPTH(x) NDN_LOG_DEBUG(std::string(this->getDepth() + 1, '>') << " " << x)
34 #define NDN_LOG_TRACE_DEPTH(x) NDN_LOG_TRACE(std::string(this->getDepth() + 1, '>') << " " << x)
39 BOOST_ASSERT(!boost::logic::indeterminate(
m_outcome));
45 return !m_seenCertificateNames.insert(certName).second;
51 m_certificateChain.push_front(cert);
55 ValidationState::verifyCertificateChain(
const Certificate& trustedCert)
58 for (
auto it = m_certificateChain.begin(); it != m_certificateChain.end(); ++it) {
59 const auto& certToValidate = *it;
63 m_certificateChain.erase(it, m_certificateChain.end());
68 validatedCert = &certToValidate;
79 , m_successCb(successCb)
80 , m_failureCb(failureCb)
82 BOOST_ASSERT(m_successCb !=
nullptr);
83 BOOST_ASSERT(m_failureCb !=
nullptr);
88 if (boost::logic::indeterminate(
m_outcome)) {
90 "Validator/policy did not invoke success or failure callback"});
95 DataValidationState::verifyOriginalPacket(
const optional<Certificate>& trustedCert)
100 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
109 DataValidationState::bypassValidation()
113 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
121 m_failureCb(m_data, error);
122 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
131 : m_interest(interest)
132 , m_failureCb(failureCb)
135 BOOST_ASSERT(successCb !=
nullptr);
136 BOOST_ASSERT(m_failureCb !=
nullptr);
141 if (boost::logic::indeterminate(
m_outcome)) {
143 "Validator/policy did not invoke success or failure callback"});
148 InterestValidationState::verifyOriginalPacket(
const optional<Certificate>& trustedCert)
153 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
162 InterestValidationState::bypassValidation()
166 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
174 m_failureCb(m_interest, error);
175 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
Represents a Data packet.
const Name & getName() const noexcept
Get the data name.
Represents an Interest packet.
const Name & getName() const noexcept
Represents an absolute name.
Represents an NDN certificate.
~DataValidationState() final
Destructor.
void fail(const ValidationError &error) final
Call the failure callback.
DataValidationState(const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
Create validation state for data.
InterestValidationState(const Interest &interest, const InterestValidationSuccessCallback &successCb, const InterestValidationFailureCallback &failureCb)
Create validation state for interest.
~InterestValidationState() final
Destructor.
util::Signal< InterestValidationState, Interest > afterSuccess
void fail(const ValidationError &error) final
Call the failure callback.
Validation error code and optional detailed error message.
@ IMPLEMENTATION_ERROR
Internal implementation error.
@ INVALID_SIGNATURE
Signature verification failed.
virtual ~ValidationState()
bool hasSeenCertificateName(const Name &certName)
Check if certName has been previously seen and record the supplied name.
virtual void fail(const ValidationError &error)=0
Call the failure callback.
void addCertificate(const Certificate &cert)
Add cert to the top of the certificate chain.
boost::logic::tribool m_outcome
#define NDN_LOG_TRACE(expression)
Log at TRACE level.
#define NDN_LOG_INIT(name)
Define a non-member log module.
std::function< void(const Data &)> DataValidationSuccessCallback
Callback to report a successful Data validation.
std::function< void(const Data &, const ValidationError &)> DataValidationFailureCallback
Callback to report a failed Data validation.
std::function< void(const Interest &)> InterestValidationSuccessCallback
Callback to report a successful Interest validation.
std::function< void(const Interest &, const ValidationError &)> InterestValidationFailureCallback
Callback to report a failed Interest validation.
bool verifySignature(const InputBuffers &blobs, span< const uint8_t > sig, const transform::PublicKey &key)
Verify blobs using key against sig.
#define NDN_LOG_DEBUG_DEPTH(x)
#define NDN_LOG_TRACE_DEPTH(x)