All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ndn::CertificateV2 Class Reference

CertificateV2 represents a certificate following the certificate format naming convention. More...

#include <certificate-v2.hpp>

Inheritance diagram for ndn::CertificateV2:
ndn::Data

Classes

class  Error
 A CertificateV2::Error extends runtime_error and represents errors for not complying with the certificate format. More...
 

Public Member Functions

 CertificateV2 ()
 Create a CertificateV2 with content type KEY and default or unspecified values.
 
 CertificateV2 (const Data &data)
 Create a CertificateV2 from the content in the Data packet. More...
 
Name getKeyName () const
 Get key name from the certificate name. More...
 
Name getIdentity () const
 Get the identity name from the certificate name. More...
 
Name::Component getKeyId () const
 Get the key ID component from the certificate name. More...
 
Name::Component getIssuerId () const
 Get issuer ID component from the certificate name. More...
 
const BlobgetPublicKey () const
 Get the public key DER encoding. More...
 
ValidityPeriodgetValidityPeriod ()
 Get the certificate validity period from the SignatureInfo. More...
 
const ValidityPeriodgetValidityPeriod () const
 
bool isValid (MillisecondsSince1970 time=-1.0) const
 Check if the time falls within the validity period. More...
 
void printCertificate (std::ostream &output) const
 Print the certificate information to the given output stream. More...
 
void printCertificate () const
 Print the certificate information to std::cout.
 
virtual void wireDecode (const Blob &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 Override to call the base class wireDecode then check the certificate format. More...
 
void wireDecode (const uint8_t *input, size_t inputLength, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 
void wireDecode (const std::vector< uint8_t > &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 
- Public Member Functions inherited from ndn::Data
 Data ()
 Create a new Data object with default values and where the signature is a blank Sha256WithRsaSignature.
 
 Data (const Name &name)
 Create a new Data object with the given name and default values and where the signature is a blank Sha256WithRsaSignature. More...
 
 Data (const Data &data)
 The copy constructor: Create a deep copy of the given data object, including a clone of the signature object. More...
 
virtual ~Data ()
 The virtual destructor.
 
Dataoperator= (const Data &data)
 The assignment operator: Copy fields and make a clone of the signature. More...
 
SignedBlob wireEncode (WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
 Encode this Data for a particular wire format. More...
 
void wireDecode (const uint8_t *input, size_t inputLength, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 Decode the input using a particular wire format and update this Data. More...
 
void wireDecode (const std::vector< uint8_t > &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 Decode the input using a particular wire format and update this Data. More...
 
void get (DataLite &dataLite) const
 Set dataLite to point to the values in this Data object, without copying any memory. More...
 
void set (const DataLite &dataLite)
 Clear this data object, and set the values by copying from dataLite. More...
 
const SignaturegetSignature () const
 
SignaturegetSignature ()
 
const NamegetName () const
 
NamegetName ()
 
const MetaInfogetMetaInfo () const
 
MetaInfogetMetaInfo ()
 
const BlobgetContent () const
 
uint64_t getIncomingFaceId () const
 Get the incoming face ID according to the incoming packet header. More...
 
uint64_t getCongestionMark () const
 Get the congestion mark according to the incoming packet header. More...
 
ptr_lib::shared_ptr< NamegetFullName (WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
 Get the Data packet's full name, which includes the final ImplicitSha256Digest component based on the wire encoding for a particular wire format. More...
 
const SignedBlobgetDefaultWireEncoding () const
 Return a reference to the defaultWireEncoding, which was encoded with getDefaultWireEncodingFormat(). More...
 
WireFormatgetDefaultWireEncodingFormat () const
 Get the WireFormat which is used by getDefaultWireEncoding(). More...
 
DatasetSignature (const Signature &signature)
 Set the signature to a copy of the given signature. More...
 
virtual DatasetName (const Name &name)
 Set name to a copy of the given Name. More...
 
DatasetMetaInfo (const MetaInfo &metaInfo)
 Set metaInfo to a copy of the given MetaInfo. More...
 
DatasetContent (const std::vector< uint8_t > &content)
 Set the content to a copy of the data in the vector. More...
 
DatasetContent (const uint8_t *content, size_t contentLength)
 
DatasetContent (const Blob &content)
 
DatasetLpPacket (const ptr_lib::shared_ptr< LpPacket > &lpPacket)
 An internal library method to set the LpPacket for an incoming packet. More...
 
uint64_t getChangeCount () const
 Get the change count, which is incremented each time this object (or a child object) is changed. More...
 

Static Public Member Functions

static bool isValidName (const Name &certificateName)
 Check if certificateName follows the naming convention for a certificate. More...
 
static Name extractIdentityFromCertName (const Name &certificateName)
 Extract the identity namespace from certificateName. More...
 
static Name extractKeyNameFromCertName (const Name &certificateName)
 Extract key name from certificateName. More...
 
static const Name::ComponentgetKEY_COMPONENT ()
 Get the name component for "KEY". More...
 

Static Public Attributes

static const int VERSION_OFFSET = -1
 
static const int ISSUER_ID_OFFSET = -2
 
static const int KEY_ID_OFFSET = -3
 
static const int KEY_COMPONENT_OFFSET = -4
 
static const int MIN_CERT_NAME_LENGTH = 4
 
static const int MIN_KEY_NAME_LENGTH = 2
 

Detailed Description

CertificateV2 represents a certificate following the certificate format naming convention.

Overview of the NDN certificate format:

CertificateV2 ::= DATA-TLV TLV-LENGTH
                    Name      (= /<NameSpace>/KEY/[KeyId]/[IssuerId]/[Version])
                    MetaInfo  (.ContentType = KEY)
                    Content   (= X509PublicKeyContent)
                    SignatureInfo (= CertificateV2SignatureInfo)
                    SignatureValue

X509PublicKeyContent ::= CONTENT-TLV TLV-LENGTH
                           BYTE+ (= public key bits in PKCS#8 format)

CertificateV2SignatureInfo ::= SIGNATURE-INFO-TYPE TLV-LENGTH
                                 SignatureType
                                 KeyLocator
                                 ValidityPeriod
                                 ... optional critical or non-critical extension blocks ...

An example of NDN certificate name:

/edu/ucla/cs/yingdi/KEY/%03%CD...%F1/%9F%D3...%B7/%FD%d2...%8E
\_________________/    \___________/ \___________/\___________/

Certificate Namespace Key Id Issuer Id Version (Identity) __________________________________/ Key Name

Notes:

See Also
https://github.com/named-data/ndn-cxx/blob/master/docs/specs/certificate-format.rst

Constructor & Destructor Documentation

ndn::CertificateV2::CertificateV2 ( const Data data)

Create a CertificateV2 from the content in the Data packet.

Parameters
dataThe data packet with the content to copy.
Exceptions
CertificateV2::ErrorIf data does not follow the certificate format.

Member Function Documentation

Name ndn::CertificateV2::extractIdentityFromCertName ( const Name certificateName)
static

Extract the identity namespace from certificateName.

Parameters
certificateNameThe name of the certificate.
Returns
The identity namespace as a new Name.
Name ndn::CertificateV2::extractKeyNameFromCertName ( const Name certificateName)
static

Extract key name from certificateName.

Parameters
certificateNameThe name of the certificate.
Returns
The key name as a new Name.
Name ndn::CertificateV2::getIdentity ( ) const
inline

Get the identity name from the certificate name.

Returns
The identity name as a new Name.
Name::Component ndn::CertificateV2::getIssuerId ( ) const
inline

Get issuer ID component from the certificate name.

Returns
The issuer ID component.
const Name::Component & ndn::CertificateV2::getKEY_COMPONENT ( )
static

Get the name component for "KEY".

This is a method because not all C++ environments support static constructors.

Returns
The name component for "KEY".
Name::Component ndn::CertificateV2::getKeyId ( ) const
inline

Get the key ID component from the certificate name.

Returns
The key ID name component.
Name ndn::CertificateV2::getKeyName ( ) const
inline

Get key name from the certificate name.

Returns
The key name as a new Name.
const Blob & ndn::CertificateV2::getPublicKey ( ) const

Get the public key DER encoding.

Returns
The DER encoding Blob.
Exceptions
CertificateV2::ErrorIf the public key is not set.
ValidityPeriod & ndn::CertificateV2::getValidityPeriod ( )

Get the certificate validity period from the SignatureInfo.

Returns
The ValidityPeriod object.
Exceptions
runtime_errorIf the SignatureInfo doesn't have a ValidityPeriod.
bool ndn::CertificateV2::isValid ( MillisecondsSince1970  time = -1.0) const
inline

Check if the time falls within the validity period.

Parameters
time(optional) The time to check as milliseconds since Jan 1, 1970 UTC. If omitted, use the current time.
Returns
True if the beginning of the validity period is less than or equal to time and time is less than or equal to the end of the validity period.
Exceptions
runtime_errorIf the SignatureInfo doesn't have a ValidityPeriod.
bool ndn::CertificateV2::isValidName ( const Name certificateName)
static

Check if certificateName follows the naming convention for a certificate.

Parameters
certificateNameThe name of the certificate.
Returns
True if certificateName follows the naming convention.
void ndn::CertificateV2::printCertificate ( std::ostream &  output) const

Print the certificate information to the given output stream.

Parameters
outputThe output stream.
void ndn::CertificateV2::wireDecode ( const Blob input,
WireFormat wireFormat = *WireFormat::getDefaultWireFormat() 
)
virtual

Override to call the base class wireDecode then check the certificate format.

Parameters
inputThe input byte array to be decoded as an immutable Blob.
wireFormatA WireFormat object used to decode the input. If omitted, use WireFormat getDefaultWireFormat().

Reimplemented from ndn::Data.


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