22 #ifndef NDN_CXX_SECURITY_VALIDATION_POLICY_SIGNED_INTEREST_HPP
23 #define NDN_CXX_SECURITY_VALIDATION_POLICY_SIGNED_INTEREST_HPP
27 #include <boost/multi_index_container.hpp>
28 #include <boost/multi_index/hashed_index.hpp>
29 #include <boost/multi_index/key_extractors.hpp>
30 #include <boost/multi_index/ordered_index.hpp>
31 #include <boost/multi_index/sequenced_index.hpp>
44 using SigNonce = std::vector<uint8_t>;
145 checkPolicy(
const Data& data,
const shared_ptr<ValidationState>& state,
154 checkIncomingInterest(
const shared_ptr<ValidationState>& state,
const Interest& interest);
157 insertRecord(
const Name& keyName,
158 optional<time::system_clock::TimePoint> timestamp,
159 optional<uint64_t> seqNum,
160 optional<SigNonce> nonce);
165 using NonceContainer = boost::multi_index_container<
167 boost::multi_index::indexed_by<
168 boost::multi_index::hashed_unique<
169 boost::multi_index::tag<NonceSet>,
170 boost::multi_index::identity<SigNonce>
172 boost::multi_index::sequenced<
173 boost::multi_index::tag<NonceList>
178 struct LastInterestRecord
180 LastInterestRecord(
const Name& keyName,
181 optional<time::system_clock::TimePoint> timestamp,
182 optional<uint64_t> seqNum)
184 , timestamp(timestamp)
186 , lastRefreshed(time::steady_clock::now())
191 optional<time::system_clock::TimePoint> timestamp;
192 optional<uint64_t> seqNum;
193 NonceContainer observedNonces;
197 using Container = boost::multi_index_container<
199 boost::multi_index::indexed_by<
200 boost::multi_index::ordered_unique<
201 boost::multi_index::member<LastInterestRecord, Name, &LastInterestRecord::keyName>
203 boost::multi_index::ordered_non_unique<
205 &LastInterestRecord::lastRefreshed>
210 Container m_container;
211 Container::nth_index<0>::type& m_byKeyName;
212 Container::nth_index<1>::type& m_byLastRefreshed;
Represents a Data packet.
Represents an Interest packet.
Represents an absolute name.
ssize_t maxNonceRecordCount
Number of previous nonces to track for each public key.
bool shouldValidateSeqNums
Whether to validate sequence numbers in signed Interests by ensuring they are present and are strictl...
ssize_t maxRecordCount
Max number of distinct public keys to track.
time::nanoseconds timestampGracePeriod
Tolerance of timestamp differences from the current time.
bool shouldValidateTimestamps
Whether to validate timestamps in signed Interests by ensuring they are not reordered for a given pub...
bool shouldValidateNonces
Whether to validate nonces by ensuring that they are present and do not overlap with one of the last ...
Validation policy for signed Interests.
void checkPolicy(const Data &data, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Check data against the policy.
ValidationPolicySignedInterest(unique_ptr< ValidationPolicy > inner, const Options &options={})
Constructor.
Abstraction that implements validation policy for Data and Interest packets.
std::function< void(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state)> ValidationContinuation
boost::chrono::nanoseconds nanoseconds