ndn::security::SigningInfo Class Reference

Signing parameters passed to KeyChain. More...

#include <ndn-cxx/security/signing-info.hpp>

Classes

class  Error
 

Public Types

enum  SignerType {
  SIGNER_TYPE_NULL = 0 ,
  SIGNER_TYPE_ID = 1 ,
  SIGNER_TYPE_KEY = 2 ,
  SIGNER_TYPE_CERT = 3 ,
  SIGNER_TYPE_SHA256 = 4 ,
  SIGNER_TYPE_HMAC = 5
}
 

Public Member Functions

 SigningInfo (const Identity &identity)
 Construct from a PIB identity. More...
 
 SigningInfo (const Key &key)
 Construct from a PIB key. More...
 
 SigningInfo (const std::string &signingStr)
 Construct SigningInfo from its string representation. More...
 
 SigningInfo (SignerType signerType=SIGNER_TYPE_NULL, const Name &signerName=Name(), const SignatureInfo &signatureInfo=SignatureInfo())
 Constructor. More...
 
DigestAlgorithm getDigestAlgorithm () const
 Get the digest algorithm for signing operations. More...
 
shared_ptr< transform::PrivateKeygetHmacKey () const
 
const IdentitygetPibIdentity () const
 
const KeygetPibKey () const
 
const SignatureInfogetSignatureInfo () const
 Get a semi-prepared SignatureInfo. More...
 
SignedInterestFormat getSignedInterestFormat () const
 Get the signed Interest format. More...
 
const NamegetSignerName () const
 
SignerType getSignerType () const
 Return the signer type. More...
 
SigningInfosetDigestAlgorithm (const DigestAlgorithm &algorithm)
 Set the digest algorithm for signing operations. More...
 
SigningInfosetPibIdentity (const Identity &identity)
 Set signer as a PIB identity handle identity. More...
 
SigningInfosetPibKey (const Key &key)
 Set signer as a PIB key handle key. More...
 
SigningInfosetSha256Signing ()
 Set SHA-256 as the signing method. More...
 
SigningInfosetSignatureInfo (const SignatureInfo &signatureInfo)
 Set a semi-prepared SignatureInfo. More...
 
SigningInfosetSignedInterestFormat (SignedInterestFormat signedInterestFormat)
 Set the signed Interest format. More...
 
SigningInfosetSigningCertName (const Name &certificateName)
 Set signer as a certificate with name certificateName. More...
 
SigningInfosetSigningHmacKey (const std::string &hmacKey)
 Set signer to a base64-encoded HMAC key. More...
 
SigningInfosetSigningIdentity (const Name &identity)
 Set signer as an identity with name identity. More...
 
SigningInfosetSigningKeyName (const Name &keyName)
 Set signer as a key with name keyName. More...
 

Static Public Member Functions

static const NamegetDigestSha256Identity ()
 A localhost identity to indicate that the signature is generated using SHA-256. More...
 
static const NamegetHmacIdentity ()
 A localhost identity to indicate that the signature is generated using an HMAC key. More...
 

Friends

bool operator!= (const SigningInfo &lhs, const SigningInfo &rhs)
 
bool operator== (const SigningInfo &lhs, const SigningInfo &rhs)
 

Detailed Description

Signing parameters passed to KeyChain.

A SigningInfo is invalid if the specified identity/key/certificate does not exist, or the PIB Identity or Key instance is not valid.

Definition at line 52 of file signing-info.hpp.

Member Enumeration Documentation

◆ SignerType

Enumerator
SIGNER_TYPE_NULL 

No signer is specified, use default setting or follow the trust schema.

SIGNER_TYPE_ID 

Signer is an identity, use its default key and default certificate.

SIGNER_TYPE_KEY 

Signer is a key, use its default certificate.

SIGNER_TYPE_CERT 

Signer is a certificate, use it directly.

SIGNER_TYPE_SHA256 

Use a SHA-256 digest only, no signer needs to be specified.

SIGNER_TYPE_HMAC 

Signer is a HMAC key.

Definition at line 61 of file signing-info.hpp.

Constructor & Destructor Documentation

◆ SigningInfo() [1/4]

ndn::security::SigningInfo::SigningInfo ( SignerType  signerType = SIGNER_TYPE_NULL,
const Name signerName = Name(),
const SignatureInfo signatureInfo = SignatureInfo() 
)
explicit

Constructor.

Parameters
signerTypeThe type of signer
signerNameThe name of the signer; interpretation differs with the type of signer
signatureInfoA semi-prepared SignatureInfo that contains all necessary information except SignatureType and KeyLocator. If SignatureType and/or KeyLocator is set, they will be overwritten by KeyChain::sign().

Definition at line 47 of file signing-info.cpp.

◆ SigningInfo() [2/4]

ndn::security::SigningInfo::SigningInfo ( const Identity identity)
explicit

Construct from a PIB identity.

Definition at line 59 of file signing-info.cpp.

◆ SigningInfo() [3/4]

ndn::security::SigningInfo::SigningInfo ( const Key key)
explicit

Construct from a PIB key.

Definition at line 65 of file signing-info.cpp.

◆ SigningInfo() [4/4]

ndn::security::SigningInfo::SigningInfo ( const std::string &  signingStr)
explicit

Construct SigningInfo from its string representation.

Parameters
signingStrThe representative signing string for SigningInfo signing method

Syntax of the representative string is as follows:

  • default signing: "" (empty string)
  • sign with the default certificate of the default key of an identity: id:/<my-identity>
  • sign with the default certificate of a specific key: key:/<my-identity>/ksk-1
  • sign with a specific certificate: cert:/<my-identity>/KEY/ksk-1/ID-CERT/FD%01
  • sign with HMAC-SHA-256: hmac-sha256:<base64-encoded-key>
  • sign with SHA-256 (digest only): id:/localhost/identity/digest-sha256

Definition at line 71 of file signing-info.cpp.

Member Function Documentation

◆ getDigestAlgorithm()

DigestAlgorithm ndn::security::SigningInfo::getDigestAlgorithm ( ) const
inline

Get the digest algorithm for signing operations.

Definition at line 230 of file signing-info.hpp.

◆ getDigestSha256Identity()

const Name & ndn::security::SigningInfo::getDigestSha256Identity ( )
static

A localhost identity to indicate that the signature is generated using SHA-256.

Definition at line 34 of file signing-info.cpp.

◆ getHmacIdentity()

const Name & ndn::security::SigningInfo::getHmacIdentity ( )
static

A localhost identity to indicate that the signature is generated using an HMAC key.

Definition at line 41 of file signing-info.cpp.

◆ getHmacKey()

shared_ptr<transform::PrivateKey> ndn::security::SigningInfo::getHmacKey ( ) const
inline

Definition at line 210 of file signing-info.hpp.

◆ getPibIdentity()

const Identity& ndn::security::SigningInfo::getPibIdentity ( ) const
inline
Precondition
signerType must be SIGNER_TYPE_ID
Returns
The identity handle of signer, or Identity() if getSignerName() should be used to find the identity.

Definition at line 192 of file signing-info.hpp.

◆ getPibKey()

const Key& ndn::security::SigningInfo::getPibKey ( ) const
inline
Precondition
signerType must be SIGNER_TYPE_KEY
Returns
The key handle of signer, or Key() if getSignerName() should be used to find the key.

Definition at line 203 of file signing-info.hpp.

◆ getSignatureInfo()

const SignatureInfo& ndn::security::SigningInfo::getSignatureInfo ( ) const
inline

Get a semi-prepared SignatureInfo.

Definition at line 245 of file signing-info.hpp.

◆ getSignedInterestFormat()

SignedInterestFormat ndn::security::SigningInfo::getSignedInterestFormat ( ) const
inline

Get the signed Interest format.

Note
This is a transitional API to handle the change in signed Interest format and will disappear after a few releases.

Definition at line 268 of file signing-info.hpp.

◆ getSignerName()

const Name& ndn::security::SigningInfo::getSignerName ( ) const
inline
Returns
Name of signer; interpretation differs per signerType.

Definition at line 181 of file signing-info.hpp.

◆ getSignerType()

SignerType ndn::security::SigningInfo::getSignerType ( ) const
inline

Return the signer type.

Definition at line 172 of file signing-info.hpp.

◆ setDigestAlgorithm()

SigningInfo& ndn::security::SigningInfo::setDigestAlgorithm ( const DigestAlgorithm algorithm)
inline

Set the digest algorithm for signing operations.

Definition at line 220 of file signing-info.hpp.

◆ setPibIdentity()

SigningInfo & ndn::security::SigningInfo::setPibIdentity ( const Identity identity)

Set signer as a PIB identity handle identity.

Postcondition
Change the signerType to SIGNER_TYPE_ID

Definition at line 163 of file signing-info.cpp.

◆ setPibKey()

SigningInfo & ndn::security::SigningInfo::setPibKey ( const Key key)

Set signer as a PIB key handle key.

Postcondition
Change the signerType to SIGNER_TYPE_KEY

Definition at line 172 of file signing-info.cpp.

◆ setSha256Signing()

SigningInfo & ndn::security::SigningInfo::setSha256Signing ( )

Set SHA-256 as the signing method.

Postcondition
Reset signerName, also change the signerType to SIGNER_TYPE_SHA256

Definition at line 155 of file signing-info.cpp.

◆ setSignatureInfo()

SigningInfo & ndn::security::SigningInfo::setSignatureInfo ( const SignatureInfo signatureInfo)

Set a semi-prepared SignatureInfo.

Definition at line 181 of file signing-info.cpp.

◆ setSignedInterestFormat()

SigningInfo& ndn::security::SigningInfo::setSignedInterestFormat ( SignedInterestFormat  signedInterestFormat)
inline

Set the signed Interest format.

Note
This is a transitional API to handle the change in signed Interest format and will disappear after a few releases.

Definition at line 256 of file signing-info.hpp.

◆ setSigningCertName()

SigningInfo & ndn::security::SigningInfo::setSigningCertName ( const Name certificateName)

Set signer as a certificate with name certificateName.

Postcondition
Change the signerType to SIGNER_TYPE_CERT

Definition at line 128 of file signing-info.cpp.

◆ setSigningHmacKey()

SigningInfo & ndn::security::SigningInfo::setSigningHmacKey ( const std::string &  hmacKey)

Set signer to a base64-encoded HMAC key.

Postcondition
Change the signerType to SIGNER_TYPE_HMAC

Definition at line 136 of file signing-info.cpp.

◆ setSigningIdentity()

SigningInfo & ndn::security::SigningInfo::setSigningIdentity ( const Name identity)

Set signer as an identity with name identity.

Postcondition
Change the signerType to SIGNER_TYPE_ID

Definition at line 110 of file signing-info.cpp.

◆ setSigningKeyName()

SigningInfo & ndn::security::SigningInfo::setSigningKeyName ( const Name keyName)

Set signer as a key with name keyName.

Postcondition
Change the signerType to SIGNER_TYPE_KEY

Definition at line 119 of file signing-info.cpp.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const SigningInfo lhs,
const SigningInfo rhs 
)
friend

Definition at line 297 of file signing-info.hpp.

◆ operator==

bool operator== ( const SigningInfo lhs,
const SigningInfo rhs 
)
friend

Definition at line 291 of file signing-info.hpp.