All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ndn::KeyChainImpl< Info, Tpm > Class Template Reference

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

#include <key-chain.hpp>

Inheritance diagram for ndn::KeyChainImpl< Info, Tpm >:
[legend]
Collaboration diagram for ndn::KeyChainImpl< Info, Tpm >:
[legend]

Public Member Functions

Name createIdentity (const Name &identityName)
 Create an identity by creating a pair of Key-Signing-Key (KSK) for this identity and a self-signed certificate of the KSK. More...
 
Name generateRSAKeyPair (const Name &identityName, bool isKsk=false, int keySize=2048)
 Generate a pair of RSA keys for the specified identity. More...
 
Name generateRSAKeyPairAsDefault (const Name &identityName, bool isKsk=false, int keySize=2048)
 Generate a pair of RSA keys for the specified identity and set it as default key for the identity. More...
 
shared_ptr< IdentityCertificateprepareUnsignedIdentityCertificate (const Name &keyName, const Name &signingIdentity, const time::system_clock::TimePoint &notBefore, const time::system_clock::TimePoint &notAfter, const std::vector< CertificateSubjectDescription > &subjectDescription)
 prepare an unsigned identity certificate More...
 
template<typename T >
void sign (T &packet)
 Sign packet with default identity. More...
 
template<typename T >
void sign (T &packet, const Name &certificateName)
 Sign packet with a particular certificate. More...
 
Signature sign (const uint8_t *buffer, size_t bufferLength, const Name &certificateName)
 Sign the byte array using a particular certificate. More...
 
template<typename T >
void signByIdentity (T &packet, const Name &identityName)
 Sign packet using the default certificate of a particular identity. More...
 
Signature signByIdentity (const uint8_t *buffer, size_t bufferLength, const Name &identityName)
 Sign the byte array using the default certificate of a particular identity. More...
 
void signWithSha256 (Data &data)
 Set Sha256 weak signature. More...
 
shared_ptr< IdentityCertificateselfSign (const Name &keyName)
 Generate a self-signed certificate for a public key. More...
 
void selfSign (IdentityCertificate &cert)
 Self-sign the supplied identity certificate. More...
 
void deleteCertificate (const Name &certificateName)
 delete a certificate. More...
 
void deleteKey (const Name &keyName)
 delete a key. More...
 
void deleteIdentity (const Name &identity)
 delete an identity. More...
 
shared_ptr< SecuredBagexportIdentity (const Name &identity, const std::string &passwordStr)
 export an identity. More...
 
void importIdentity (const SecuredBag &securedBag, const std::string &passwordStr)
 import an identity. More...
 

Detailed Description

template<class Info, class Tpm>
class ndn::KeyChainImpl< Info, Tpm >

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

The KeyChain class provides a set of interfaces of identity management and private key related operations.

Definition at line 42 of file key-chain.hpp.

Member Function Documentation

template<class Info, class Tpm>
Name ndn::KeyChainImpl< Info, Tpm >::createIdentity ( const Name identityName)
inline

Create an identity by creating a pair of Key-Signing-Key (KSK) for this identity and a self-signed certificate of the KSK.

Parameters
identityNameThe name of the identity.
Returns
The name of the default certificate of the identity.

Definition at line 55 of file key-chain.hpp.

template<class Info, class Tpm>
void ndn::KeyChainImpl< Info, Tpm >::deleteCertificate ( const Name certificateName)
inline

delete a certificate.

If the certificate to be deleted is current default system default, the method will not delete the certificate and return immediately.

Parameters
certificateNameThe certificate to be deleted.

Definition at line 426 of file key-chain.hpp.

template<class Info, class Tpm>
void ndn::KeyChainImpl< Info, Tpm >::deleteIdentity ( const Name identity)
inline

delete an identity.

If the identity to be deleted is current default system default, the method will not delete the identity and return immediately.

Parameters
identityThe identity to be deleted.

Definition at line 475 of file key-chain.hpp.

template<class Info, class Tpm>
void ndn::KeyChainImpl< Info, Tpm >::deleteKey ( const Name keyName)
inline

delete a key.

If the key to be deleted is current default system default, the method will not delete the key and return immediately.

Parameters
keyNameThe key to be deleted.

Definition at line 450 of file key-chain.hpp.

template<class Info, class Tpm>
shared_ptr<SecuredBag> ndn::KeyChainImpl< Info, Tpm >::exportIdentity ( const Name identity,
const std::string &  passwordStr 
)
inline

export an identity.

Parameters
identityThe identity to export.
passwordStrThe password to secure the private key.
Returns
The encoded export data.
Exceptions
InfoErrorif anything goes wrong in exporting.

Definition at line 507 of file key-chain.hpp.

template<class Info, class Tpm>
Name ndn::KeyChainImpl< Info, Tpm >::generateRSAKeyPair ( const Name identityName,
bool  isKsk = false,
int  keySize = 2048 
)
inline

Generate a pair of RSA keys for the specified identity.

Parameters
identityNameThe name of the identity.
isKsktrue for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
keySizeThe size of the key.
Returns
The generated key name.

Definition at line 93 of file key-chain.hpp.

template<class Info, class Tpm>
Name ndn::KeyChainImpl< Info, Tpm >::generateRSAKeyPairAsDefault ( const Name identityName,
bool  isKsk = false,
int  keySize = 2048 
)
inline

Generate a pair of RSA keys for the specified identity and set it as default key for the identity.

Parameters
identityNameThe name of the identity.
isKsktrue for generating a Key-Signing-Key (KSK), false for a Data-Signing-Key (KSK).
keySizeThe size of the key.
Returns
The generated key name.

Definition at line 108 of file key-chain.hpp.

template<class Info, class Tpm>
void ndn::KeyChainImpl< Info, Tpm >::importIdentity ( const SecuredBag securedBag,
const std::string &  passwordStr 
)
inline

import an identity.

Parameters
securedBagThe encoded import data.
passwordStrThe password to secure the private key.

Definition at line 548 of file key-chain.hpp.

template<class Info, class Tpm>
shared_ptr<IdentityCertificate> ndn::KeyChainImpl< Info, Tpm >::prepareUnsignedIdentityCertificate ( const Name keyName,
const Name signingIdentity,
const time::system_clock::TimePoint notBefore,
const time::system_clock::TimePoint notAfter,
const std::vector< CertificateSubjectDescription > &  subjectDescription 
)
inline

prepare an unsigned identity certificate

Parameters
keyNameKey name, e.g., /<identity_name>/ksk-123456.
signingIdentityThe signing identity.
notBeforeRefer to IdentityCertificate.
notAfterRefer to IdentityCertificate.
subjectDescriptionRefer to IdentityCertificate.
Returns
IdentityCertificate.

Definition at line 128 of file key-chain.hpp.

template<class Info, class Tpm>
shared_ptr<IdentityCertificate> ndn::KeyChainImpl< Info, Tpm >::selfSign ( const Name keyName)
inline

Generate a self-signed certificate for a public key.

Parameters
keyNameThe name of the public key.
Returns
The generated certificate, NULL if selfSign fails.

Definition at line 369 of file key-chain.hpp.

template<class Info, class Tpm>
void ndn::KeyChainImpl< Info, Tpm >::selfSign ( IdentityCertificate cert)
inline

Self-sign the supplied identity certificate.

Parameters
certThe supplied cert.
Exceptions
SecTpm::Errorif the private key does not exist.

Definition at line 404 of file key-chain.hpp.

template<class Info, class Tpm>
template<typename T >
void ndn::KeyChainImpl< Info, Tpm >::sign ( T &  packet)
inline

Sign packet with default identity.

On return, signatureInfo and signatureValue in the packet are set. If default identity does not exist, a temporary identity will be created and set as default.

Parameters
packetThe packet to be signed

Definition at line 208 of file key-chain.hpp.

template<class Info, class Tpm>
template<typename T >
void ndn::KeyChainImpl< Info, Tpm >::sign ( T &  packet,
const Name certificateName 
)
inline

Sign packet with a particular certificate.

Parameters
packetThe packet to be signed.
certificateNameThe certificate name of the key to use for signing.
Exceptions
SecPublicInfo::Errorif certificate does not exist.

Definition at line 245 of file key-chain.hpp.

template<class Info, class Tpm>
Signature ndn::KeyChainImpl< Info, Tpm >::sign ( const uint8_t *  buffer,
size_t  bufferLength,
const Name certificateName 
)
inline

Sign the byte array using a particular certificate.

Parameters
bufferThe byte array to be signed.
bufferLengththe length of buffer.
certificateNameThe certificate name of the signing key.
Returns
The Signature.
Exceptions
SecPublicInfo::Errorif certificate does not exist.

Definition at line 270 of file key-chain.hpp.

template<class Info, class Tpm>
template<typename T >
void ndn::KeyChainImpl< Info, Tpm >::signByIdentity ( T &  packet,
const Name identityName 
)
inline

Sign packet using the default certificate of a particular identity.

If there is no default certificate of that identity, this method will create a self-signed certificate.

Parameters
packetThe packet to be signed.
identityNameThe signing identity name.

Definition at line 297 of file key-chain.hpp.

template<class Info, class Tpm>
Signature ndn::KeyChainImpl< Info, Tpm >::signByIdentity ( const uint8_t *  buffer,
size_t  bufferLength,
const Name identityName 
)
inline

Sign the byte array using the default certificate of a particular identity.

Parameters
bufferThe byte array to be signed.
bufferLengththe length of buffer.
identityNameThe identity name.
Returns
The Signature.

Definition at line 325 of file key-chain.hpp.

template<class Info, class Tpm>
void ndn::KeyChainImpl< Info, Tpm >::signWithSha256 ( Data data)
inline

Set Sha256 weak signature.

Parameters
data.

Definition at line 350 of file key-chain.hpp.