NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::Validator Class Referenceabstract

Validator is one of the main classes of the security library. More...

#include <validator.hpp>

Inheritance diagram for ndn::Validator:
Collaboration diagram for ndn::Validator:

Classes

class  Error
 

Public Member Functions

 Validator (Face *face=nullptr)
 Validator constructor. More...
 
 Validator (Face &face)
 
void validate (const Data &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed)
 Validate Data and call either onValidated or onValidationFailed. More...
 
void validate (const Interest &interest, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed)
 Validate Interest and call either onValidated or onValidationFailed. More...
 

Static Public Member Functions

static bool verifySignature (const Data &data, const PublicKey &publicKey)
 Verify the data using the publicKey. More...
 
static bool verifySignature (const Interest &interest, const PublicKey &publicKey)
 Verify the signed Interest using the publicKey. More...
 
static bool verifySignature (const Buffer &blob, const Signature &sig, const PublicKey &publicKey)
 Verify the blob using the publicKey against the signature. More...
 
static bool verifySignature (const Data &data, const Signature &sig, const PublicKey &publicKey)
 Verify the data using the publicKey against the SHA256-RSA signature. More...
 
static bool verifySignature (const Interest &interest, const Signature &sig, const PublicKey &publicKey)
 Verify the interest using the publicKey against the SHA256-RSA signature. More...
 
static bool verifySignature (const uint8_t *buf, const size_t size, const Signature &sig, const PublicKey &publicKey)
 Verify the blob using the publicKey against the SHA256-RSA signature. More...
 
static bool verifySignature (const Data &data, const DigestSha256 &sig)
 Verify the data against the SHA256 signature. More...
 
static bool verifySignature (const Interest &interest, const DigestSha256 &sig)
 Verify the interest against the SHA256 signature. More...
 
static bool verifySignature (const Buffer &blob, const DigestSha256 &sig)
 Verify the blob against the SHA256 signature. More...
 
static bool verifySignature (const uint8_t *buf, const size_t size, const DigestSha256 &sig)
 Verify the blob against the SHA256 signature. More...
 

Protected Types

typedef function< void(const std::string &)> OnFailure
 

Protected Member Functions

virtual void checkPolicy (const Data &data, int nSteps, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)=0
 Check the Data against policy and return the next validation step if necessary. More...
 
virtual void checkPolicy (const Interest &interest, int nSteps, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)=0
 Check the Interest against validation policy and return the next validation step if necessary. More...
 
void onData (const Interest &interest, const Data &data, const shared_ptr< ValidationRequest > &nextStep)
 Process the received certificate. More...
 
void validate (const Data &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, int nSteps)
 
void validate (const Interest &interest, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed, int nSteps)
 
virtual shared_ptr< const DatapreCertificateValidation (const Data &data)
 Hooks. More...
 
virtual void onTimeout (const Interest &interest, int nRemainingRetries, const OnFailure &onFailure, const shared_ptr< ValidationRequest > &validationRequest)
 trigger when interest for certificate times out. More...
 
virtual void afterCheckPolicy (const std::vector< shared_ptr< ValidationRequest > > &nextSteps, const OnFailure &onFailure)
 trigger after checkPolicy is done. More...
 

Protected Attributes

Facem_face
 

Detailed Description

Validator is one of the main classes of the security library.

The Validator class provides the interfaces for packet validation.

Definition at line 46 of file validator.hpp.

Member Typedef Documentation

◆ OnFailure

typedef function<void(const std::string&)> ndn::Validator::OnFailure
protected

Definition at line 243 of file validator.hpp.

Constructor & Destructor Documentation

◆ Validator() [1/2]

ndn::Validator::Validator ( Face face = nullptr)
explicit

Validator constructor.

Parameters
facePointer to face through which validator may retrieve certificates. Passing a null pointer implies the validator is in offline mode.
Note
Make sure the lifetime of the passed Face is longer than validator.

Definition at line 37 of file validator.cpp.

◆ Validator() [2/2]

ndn::Validator::Validator ( Face face)
explicit
Deprecated:
Use the constructor taking Face* as parameter.

Definition at line 42 of file validator.cpp.

Member Function Documentation

◆ validate() [1/4]

void ndn::Validator::validate ( const Data data,
const OnDataValidated onValidated,
const OnDataValidationFailed onValidationFailed 
)
inline

Validate Data and call either onValidated or onValidationFailed.

Parameters
dataThe Data with the signature to check.
onValidatedIf the Data is validated, this calls onValidated(data).
onValidationFailedIf validation fails, this calls onValidationFailed(data).

Definition at line 82 of file validator.hpp.

Referenced by onData(), nfd::CommandValidator::validate(), and validate().

◆ validate() [2/4]

void ndn::Validator::validate ( const Interest interest,
const OnInterestValidated onValidated,
const OnInterestValidationFailed onValidationFailed 
)
inline

Validate Interest and call either onValidated or onValidationFailed.

Parameters
interestThe Interest with the signature to check.
onValidatedIf the Interest is validated, this calls onValidated(interest).
onValidationFailedIf validation fails, this calls onValidationFailed(interest).

Definition at line 97 of file validator.hpp.

References validate().

◆ verifySignature() [1/10]

bool ndn::Validator::verifySignature ( const Data data,
const PublicKey publicKey 
)
static

◆ verifySignature() [2/10]

bool ndn::Validator::verifySignature ( const Interest interest,
const PublicKey publicKey 
)
static

Verify the signed Interest using the publicKey.

(Note the signature covers the first n-2 name components).

Definition at line 118 of file validator.cpp.

References ndn::Interest::getName(), ndn::Signature::hasKeyLocator(), ndn::Name::size(), ndn::Block::value(), ndn::Block::value_size(), verifySignature(), and ndn::Name::wireEncode().

◆ verifySignature() [3/10]

static bool ndn::Validator::verifySignature ( const Buffer blob,
const Signature sig,
const PublicKey publicKey 
)
inlinestatic

Verify the blob using the publicKey against the signature.

Definition at line 122 of file validator.hpp.

References ndn::Buffer::buf(), and verifySignature().

◆ verifySignature() [4/10]

static bool ndn::Validator::verifySignature ( const Data data,
const Signature sig,
const PublicKey publicKey 
)
inlinestatic

Verify the data using the publicKey against the SHA256-RSA signature.

Definition at line 129 of file validator.hpp.

References ndn::Data::getSignature(), ndn::Signature::getValue(), ndn::Block::size(), verifySignature(), and ndn::Data::wireEncode().

◆ verifySignature() [5/10]

static bool ndn::Validator::verifySignature ( const Interest interest,
const Signature sig,
const PublicKey publicKey 
)
inlinestatic

Verify the interest using the publicKey against the SHA256-RSA signature.

(Note the signature covers the first n-2 name components).

Definition at line 143 of file validator.hpp.

References ndn::Interest::getName(), ndn::Name::size(), and verifySignature().

◆ verifySignature() [6/10]

bool ndn::Validator::verifySignature ( const uint8_t *  buf,
const size_t  size,
const Signature sig,
const PublicKey publicKey 
)
static

◆ verifySignature() [7/10]

static bool ndn::Validator::verifySignature ( const Data data,
const DigestSha256 sig 
)
inlinestatic

Verify the data against the SHA256 signature.

Definition at line 167 of file validator.hpp.

References ndn::Data::getSignature(), ndn::Signature::getValue(), ndn::Block::size(), verifySignature(), and ndn::Data::wireEncode().

◆ verifySignature() [8/10]

static bool ndn::Validator::verifySignature ( const Interest interest,
const DigestSha256 sig 
)
inlinestatic

Verify the interest against the SHA256 signature.

(Note the signature covers the first n-2 name components).

Definition at line 180 of file validator.hpp.

References ndn::Interest::getName(), ndn::Name::size(), and verifySignature().

◆ verifySignature() [9/10]

static bool ndn::Validator::verifySignature ( const Buffer blob,
const DigestSha256 sig 
)
inlinestatic

Verify the blob against the SHA256 signature.

Definition at line 194 of file validator.hpp.

References ndn::Buffer::buf(), and verifySignature().

◆ verifySignature() [10/10]

bool ndn::Validator::verifySignature ( const uint8_t *  buf,
const size_t  size,
const DigestSha256 sig 
)
static

Verify the blob against the SHA256 signature.

Definition at line 242 of file validator.cpp.

References ndn::Signature::getValue(), ndn::crypto::sha256(), ndn::crypto::SHA256_DIGEST_SIZE, ndn::Block::value(), and ndn::Block::value_size().

◆ checkPolicy() [1/2]

virtual void ndn::Validator::checkPolicy ( const Data data,
int  nSteps,
const OnDataValidated onValidated,
const OnDataValidationFailed onValidationFailed,
std::vector< shared_ptr< ValidationRequest > > &  nextSteps 
)
protectedpure virtual

Check the Data against policy and return the next validation step if necessary.

If there is no next validation step, that validation MUST have been done. i.e., either onValidated or onValidationFailed callback is invoked.

Parameters
dataThe Data to check.
nStepsThe number of validation steps that have been done.
onValidatedIf the Data is validated, this calls onValidated(data)
onValidationFailedIf validation fails, this calls onValidationFailed(data)
nextStepsOn return, contains the next validation step

Implemented in ndn::CommandInterestValidator, ndn::ValidatorConfig, ndn::ValidatorRegex, and ndn::ValidatorNull.

Referenced by validate().

◆ checkPolicy() [2/2]

virtual void ndn::Validator::checkPolicy ( const Interest interest,
int  nSteps,
const OnInterestValidated onValidated,
const OnInterestValidationFailed onValidationFailed,
std::vector< shared_ptr< ValidationRequest > > &  nextSteps 
)
protectedpure virtual

Check the Interest against validation policy and return the next validation step if necessary.

If there is no next validation step, that validation MUST have been done. i.e., either onValidated or onValidationFailed callback is invoked.

Parameters
interestThe Interest to check.
nStepsThe number of validation steps that have been done.
onValidatedIf the Interest is validated, this calls onValidated(data)
onValidationFailedIf validation fails, this calls onValidationFailed(data)
nextStepsOn return, contains the next validation step

Implemented in ndn::CommandInterestValidator, ndn::ValidatorConfig, ndn::ValidatorRegex, and ndn::ValidatorNull.

◆ onData()

void ndn::Validator::onData ( const Interest interest,
const Data data,
const shared_ptr< ValidationRequest > &  nextStep 
)
protected

Process the received certificate.

Definition at line 90 of file validator.cpp.

References ndn::Data::getName(), preCertificateValidation(), ndn::Name::toUri(), and validate().

Referenced by afterCheckPolicy(), and onTimeout().

◆ validate() [3/4]

void ndn::Validator::validate ( const Data data,
const OnDataValidated onValidated,
const OnDataValidationFailed onValidationFailed,
int  nSteps 
)
protected

Definition at line 69 of file validator.cpp.

References afterCheckPolicy(), and checkPolicy().

◆ validate() [4/4]

void ndn::Validator::validate ( const Interest interest,
const OnInterestValidated onValidated,
const OnInterestValidationFailed onValidationFailed,
int  nSteps 
)
protected

Definition at line 48 of file validator.cpp.

References afterCheckPolicy(), and checkPolicy().

◆ preCertificateValidation()

virtual shared_ptr<const Data> ndn::Validator::preCertificateValidation ( const Data data)
inlineprotectedvirtual

Hooks.

trigger before validating requested certificate.

The Data:

  • matches the interest in the validation-request.
  • may be certificate or a data encapsulating certificate.

This method returns a data (actually certificate) that is will be passed as Data into: Validator::validate(const Data& data, const OnDataValidated& onValidated, const OnDataValidationFailed& onValidationFailed, int nSteps);

Definition at line 279 of file validator.hpp.

Referenced by onData().

◆ onTimeout()

void ndn::Validator::onTimeout ( const Interest interest,
int  nRemainingRetries,
const OnFailure onFailure,
const shared_ptr< ValidationRequest > &  validationRequest 
)
protectedvirtual

trigger when interest for certificate times out.

Validator can decide how to handle the timeout, either call onFailure, or retry.

Parameters
interestThe interest that times out.
nRemainingRetriesThe number of retries left.
onFailureFailure callback when there is no more retries remaining.
validationRequestThe validationRequest containing the context of the interest.

Definition at line 269 of file validator.cpp.

References ndn::Face::expressInterest(), ndn::Interest::getName(), m_face, onData(), and ndn::Name::toUri().

Referenced by afterCheckPolicy().

◆ afterCheckPolicy()

void ndn::Validator::afterCheckPolicy ( const std::vector< shared_ptr< ValidationRequest > > &  nextSteps,
const OnFailure onFailure 
)
protectedvirtual

trigger after checkPolicy is done.

Validator can decide how to handle the set of validation requests according to the trust model.

Parameters
nextStepsA set of validation request made by checkPolicy.
onFailureFailure callback when errors happen in processing nextSteps.

Definition at line 286 of file validator.cpp.

References ndn::Face::expressInterest(), m_face, onData(), and onTimeout().

Referenced by validate().

Member Data Documentation

◆ m_face

Face* ndn::Validator::m_face
protected

Definition at line 315 of file validator.hpp.

Referenced by afterCheckPolicy(), and onTimeout().


The documentation for this class was generated from the following files: