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>
45 using SigNonce = std::vector<uint8_t>;
146 checkPolicy(
const Data& data,
const shared_ptr<ValidationState>& state,
155 checkIncomingInterest(
const shared_ptr<ValidationState>& state,
const Interest& interest);
158 insertRecord(
const Name& keyName,
159 std::optional<time::system_clock::time_point> timestamp,
160 std::optional<uint64_t> seqNum,
161 std::optional<SigNonce> nonce);
166 using NonceContainer = boost::multi_index_container<
168 boost::multi_index::indexed_by<
169 boost::multi_index::hashed_unique<
170 boost::multi_index::tag<NonceSet>,
171 boost::multi_index::identity<SigNonce>
173 boost::multi_index::sequenced<
174 boost::multi_index::tag<NonceList>
179 struct LastInterestRecord
181 LastInterestRecord(
const Name& keyName,
182 std::optional<time::system_clock::time_point> timestamp,
183 std::optional<uint64_t> seqNum)
185 , timestamp(timestamp)
187 , lastRefreshed(time::steady_clock::now())
192 std::optional<time::system_clock::time_point> timestamp;
193 std::optional<uint64_t> seqNum;
194 NonceContainer observedNonces;
198 using Container = boost::multi_index_container<
200 boost::multi_index::indexed_by<
201 boost::multi_index::ordered_unique<
202 boost::multi_index::member<LastInterestRecord, Name, &LastInterestRecord::keyName>
204 boost::multi_index::ordered_non_unique<
206 &LastInterestRecord::lastRefreshed>
211 Container m_container;
212 Container::nth_index<0>::type& m_byKeyName;
213 Container::nth_index<1>::type& m_byLastRefreshed;
Represents a Data packet.
Represents an Interest packet.
Represents an absolute name.
bool shouldValidateSeqNums
Whether to validate sequence numbers in signed Interests by ensuring they are present and are strictl...
ssize_t maxNonceRecordCount
Number of previous nonces to track for each public key.
time::nanoseconds timestampGracePeriod
Tolerance of timestamp differences from the current time.
ssize_t maxRecordCount
Max number of distinct public keys to track.
bool shouldValidateNonces
Whether to validate nonces by ensuring that they are present and do not overlap with one of the last ...
bool shouldValidateTimestamps
Whether to validate timestamps in signed Interests by ensuring they are not reordered for a given pub...
Validation policy for signed Interests.
ValidationPolicySignedInterest(unique_ptr< ValidationPolicy > inner, const Options &options={})
Constructor.
void checkPolicy(const Data &data, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Check data against the policy.
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::time_point< steady_clock > time_point
Contains the ndn-cxx security framework.
::boost::chrono::nanoseconds nanoseconds