Public Member Functions | Static Protected Member Functions | List of all members
ndn::PolicyManager Class Referenceabstract

A PolicyManager is an abstract base class to represent the policy for verifying data packets. More...

#include <policy-manager.hpp>

Inheritance diagram for ndn::PolicyManager:
ndn::ConfigPolicyManager ndn::NoVerifyPolicyManager ndn::SelfVerifyPolicyManager

Public Member Functions

virtual ~PolicyManager ()
 The virtual destructor.
 
virtual bool skipVerifyAndTrust (const Data &data)=0
 Check if the received data packet can escape from verification and be trusted as valid. More...
 
virtual bool skipVerifyAndTrust (const Interest &interest)=0
 Check if the received signed interest can escape from verification and be trusted as valid. More...
 
virtual bool requireVerify (const Data &data)=0
 Check if this PolicyManager has a verification rule for the received data. More...
 
virtual bool requireVerify (const Interest &interest)=0
 Check if this PolicyManager has a verification rule for the received signed interest. More...
 
virtual ptr_lib::shared_ptr< ValidationRequestcheckVerificationPolicy (const ptr_lib::shared_ptr< Data > &data, int stepCount, const OnVerified &onVerified, const OnVerifyFailed &onVerifyFailed)=0
 Check whether the received data packet complies with the verification policy, and get the indication of the next verification step. More...
 
virtual ptr_lib::shared_ptr< ValidationRequestcheckVerificationPolicy (const ptr_lib::shared_ptr< Interest > &interest, int stepCount, const OnVerifiedInterest &onVerified, const OnVerifyInterestFailed &onVerifyFailed, WireFormat &wireFormat)=0
 Check whether the received signed interest complies with the verification policy, and get the indication of the next verification step. More...
 
virtual bool checkSigningPolicy (const Name &dataName, const Name &certificateName)=0
 Check if the signing certificate name and data name satisfy the signing policy. More...
 
virtual Name inferSigningIdentity (const Name &dataName)=0
 Infer the signing identity name according to the policy. More...
 

Static Protected Member Functions

static bool verifySignature (const Signature *signature, const SignedBlob &signedBlob, const Blob &publicKeyDer)
 Check the type of signature and use the publicKeyDer to verify the signedBlob using the appropriate signature algorithm. More...
 
static bool verifySha256WithEcdsaSignature (const Blob &signature, const SignedBlob &signedBlob, const Blob &publicKeyDer)
 Verify the ECDSA signature on the SignedBlob using the given public key. More...
 
static bool verifySha256WithRsaSignature (const Blob &signature, const SignedBlob &signedBlob, const Blob &publicKeyDer)
 Verify the RSA signature on the SignedBlob using the given public key. More...
 
static bool verifyDigestSha256Signature (const Blob &signature, const SignedBlob &signedBlob)
 Verify the DigestSha256 signature on the SignedBlob by verifying that the digest of SignedBlob equals the signature. More...
 

Detailed Description

A PolicyManager is an abstract base class to represent the policy for verifying data packets.

You must create an object of a subclass.

Member Function Documentation

virtual bool ndn::PolicyManager::checkSigningPolicy ( const Name dataName,
const Name certificateName 
)
pure virtual

Check if the signing certificate name and data name satisfy the signing policy.

Parameters
dataNameThe name of data to be signed.
certificateNameThe name of signing certificate.
Returns
true if the signing certificate can be used to sign the data, otherwise false.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

virtual ptr_lib::shared_ptr<ValidationRequest> ndn::PolicyManager::checkVerificationPolicy ( const ptr_lib::shared_ptr< Data > &  data,
int  stepCount,
const OnVerified onVerified,
const OnVerifyFailed onVerifyFailed 
)
pure virtual

Check whether the received data packet complies with the verification policy, and get the indication of the next verification step.

Parameters
dataThe Data object with the signature to check.
stepCountThe number of verification steps that have been done, used to track the verification progress.
onVerifiedIf the signature is verified, this calls onVerified(data). NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
onVerifyFailedIf the signature check fails, this calls onVerifyFailed(data). NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
Returns
the indication of next verification step, null if there is no further step.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

virtual ptr_lib::shared_ptr<ValidationRequest> ndn::PolicyManager::checkVerificationPolicy ( const ptr_lib::shared_ptr< Interest > &  interest,
int  stepCount,
const OnVerifiedInterest onVerified,
const OnVerifyInterestFailed onVerifyFailed,
WireFormat wireFormat 
)
pure virtual

Check whether the received signed interest complies with the verification policy, and get the indication of the next verification step.

Parameters
interestThe interest with the signature to check.
stepCountThe number of verification steps that have been done, used to track the verification progress.
onVerifiedIf the signature is verified, this calls onVerified(interest). NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
onVerifyFailedIf the signature check fails, this calls onVerifyFailed(interest). NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
Returns
the indication of next verification step, null if there is no further step.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

virtual Name ndn::PolicyManager::inferSigningIdentity ( const Name dataName)
pure virtual

Infer the signing identity name according to the policy.

If the signing identity cannot be inferred, return an empty name.

Parameters
dataNameThe name of data to be signed.
Returns
The signing identity or an empty name if cannot infer.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

virtual bool ndn::PolicyManager::requireVerify ( const Data data)
pure virtual

Check if this PolicyManager has a verification rule for the received data.

Parameters
dataThe received data packet.
Returns
true if the data must be verified, otherwise false.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

virtual bool ndn::PolicyManager::requireVerify ( const Interest interest)
pure virtual

Check if this PolicyManager has a verification rule for the received signed interest.

Parameters
interestThe received interest.
Returns
true if the interest must be verified, otherwise false.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

virtual bool ndn::PolicyManager::skipVerifyAndTrust ( const Data data)
pure virtual

Check if the received data packet can escape from verification and be trusted as valid.

Parameters
dataThe received data packet.
Returns
true if the data does not need to be verified to be trusted as valid, otherwise false.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

virtual bool ndn::PolicyManager::skipVerifyAndTrust ( const Interest interest)
pure virtual

Check if the received signed interest can escape from verification and be trusted as valid.

Parameters
interestThe received interest.
Returns
true if the interest does not need to be verified to be trusted as valid, otherwise false.

Implemented in ndn::ConfigPolicyManager, ndn::SelfVerifyPolicyManager, and ndn::NoVerifyPolicyManager.

bool ndn::PolicyManager::verifyDigestSha256Signature ( const Blob signature,
const SignedBlob signedBlob 
)
staticprotected

Verify the DigestSha256 signature on the SignedBlob by verifying that the digest of SignedBlob equals the signature.

Parameters
signatureThe signature bits.
signedBlobthe SignedBlob with the signed portion to verify.
Returns
true if the signature verifies, false if not.
static bool ndn::PolicyManager::verifySha256WithEcdsaSignature ( const Blob signature,
const SignedBlob signedBlob,
const Blob publicKeyDer 
)
staticprotected

Verify the ECDSA signature on the SignedBlob using the given public key.

Parameters
signatureThe signature bits.
signedBlobthe SignedBlob with the signed portion to verify.
publicKeyDerThe DER-encoded public key used to verify the signature.
Returns
true if the signature verifies, false if not.
Exceptions
UnrecognizedKeyFormatExceptionif publicKeyDer can't be decoded as an ECDSA public key.
static bool ndn::PolicyManager::verifySha256WithRsaSignature ( const Blob signature,
const SignedBlob signedBlob,
const Blob publicKeyDer 
)
staticprotected

Verify the RSA signature on the SignedBlob using the given public key.

Parameters
signatureThe signature bits.
signedBlobthe SignedBlob with the signed portion to verify.
publicKeyDerThe DER-encoded public key used to verify the signature.
Returns
true if the signature verifies, false if not.
Exceptions
UnrecognizedKeyFormatExceptionif publicKeyDer can't be decoded as an RSA public key.
bool ndn::PolicyManager::verifySignature ( const Signature signature,
const SignedBlob signedBlob,
const Blob publicKeyDer 
)
staticprotected

Check the type of signature and use the publicKeyDer to verify the signedBlob using the appropriate signature algorithm.

Parameters
signatureAn object of a subclass of Signature, e.g. Sha256WithRsaSignature.
signedBlobthe SignedBlob with the signed portion to verify.
publicKeyDerThe DER-encoded public key used to verify the signature. This may be null if the signature type does not require a public key.
Returns
True if the signature is verified, false if failed.
Exceptions
SecurityExceptionif the signature type is not recognized or if publicKeyDer can't be decoded.

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