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>
47 using SigNonce = std::vector<uint8_t>;
148 checkPolicy(
const Data& data,
const shared_ptr<ValidationState>& state,
157 checkIncomingInterest(
const shared_ptr<ValidationState>& state,
const Interest& interest);
160 insertRecord(
const Name& keyName,
161 optional<time::system_clock::TimePoint> timestamp,
162 optional<uint64_t> seqNum,
163 optional<SigNonce> nonce);
168 using NonceContainer = boost::multi_index_container<
170 boost::multi_index::indexed_by<
171 boost::multi_index::hashed_unique<
172 boost::multi_index::tag<NonceSet>,
173 boost::multi_index::identity<SigNonce>
175 boost::multi_index::sequenced<
176 boost::multi_index::tag<NonceList>
181 struct LastInterestRecord
183 LastInterestRecord(
const Name& keyName,
184 optional<time::system_clock::TimePoint> timestamp,
185 optional<uint64_t> seqNum)
187 , timestamp(timestamp)
189 , lastRefreshed(time::steady_clock::now())
194 optional<time::system_clock::TimePoint> timestamp;
195 optional<uint64_t> seqNum;
196 NonceContainer observedNonces;
200 using Container = boost::multi_index_container<
202 boost::multi_index::indexed_by<
203 boost::multi_index::ordered_unique<
204 boost::multi_index::member<LastInterestRecord, Name, &LastInterestRecord::keyName>
206 boost::multi_index::ordered_non_unique<
208 &LastInterestRecord::lastRefreshed>
213 Container m_container;
214 Container::nth_index<0>::type& m_byKeyName;
215 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 a validation policy for Interest and Data packets.
std::function< void(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state)> ValidationContinuation
boost::chrono::nanoseconds nanoseconds