Public Member Functions | List of all members
ndn::FilePrivateKeyStorage Class Reference

FilePrivateKeyStorage extends PrivateKeyStorage to implement private key storage using files. More...

#include <file-private-key-storage.hpp>

Inheritance diagram for ndn::FilePrivateKeyStorage:
ndn::PrivateKeyStorage

Public Member Functions

 FilePrivateKeyStorage ()
 Create a new FilePrivateKeyStorage to connect to the default directory.
 
virtual ~FilePrivateKeyStorage ()
 The virtual Destructor.
 
virtual void generateKeyPair (const Name &keyName, const KeyParams &params)
 Generate a pair of asymmetric keys. More...
 
virtual void deleteKeyPair (const Name &keyName)
 Delete a pair of asymmetric keys. More...
 
virtual ptr_lib::shared_ptr< PublicKeygetPublicKey (const Name &keyName)
 Get the public key. More...
 
virtual Blob sign (const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm=DIGEST_ALGORITHM_SHA256)
 Fetch the private key for keyName and sign the data, returning a signature Blob. More...
 
virtual Blob decrypt (const Name &keyName, const uint8_t *data, size_t dataLength, bool isSymmetric=false)
 Decrypt data. More...
 
virtual Blob encrypt (const Name &keyName, const uint8_t *data, size_t dataLength, bool isSymmetric=false)
 Encrypt data. More...
 
virtual void generateKey (const Name &keyName, const KeyParams &params)
 Generate a symmetric key. More...
 
virtual bool doesKeyExist (const Name &keyName, KeyClass keyClass)
 Check if a particular key exists. More...
 
- Public Member Functions inherited from ndn::PrivateKeyStorage
virtual ~PrivateKeyStorage ()
 The virtual destructor.
 
Blob sign (const Blob &data, const Name &keyName, DigestAlgorithm digestAlgorithm=DIGEST_ALGORITHM_SHA256)
 
Blob decrypt (const Name &keyName, const Blob &data, bool isSymmetric=false)
 
Blob encrypt (const Name &keyName, const Blob &data, bool isSymmetric=false)
 

Additional Inherited Members

- Static Protected Member Functions inherited from ndn::PrivateKeyStorage
static Blob encodePkcs8PrivateKey (const std::vector< uint8_t > &privateKeyDer, const OID &oid, const ptr_lib::shared_ptr< DerNode > &parameters)
 Encode the private key to a PKCS #8 private key. More...
 
static Blob encodeSubjectPublicKeyInfo (const OID &oid, const ptr_lib::shared_ptr< DerNode > &parameters, const ptr_lib::shared_ptr< DerNode > &bitString)
 Encode the bitString into a SubjectPublicKeyInfo. More...
 
static ec_key_st * decodeEcPrivateKey (const ptr_lib::shared_ptr< DerNode > &algorithmParameters, const Blob &privateKeyDer)
 Create an EC key using the curve in the algorithmParameters, decode the privateKeyDer and set the private key value. More...
 

Detailed Description

FilePrivateKeyStorage extends PrivateKeyStorage to implement private key storage using files.

Member Function Documentation

Blob ndn::FilePrivateKeyStorage::decrypt ( const Name keyName,
const uint8_t *  data,
size_t  dataLength,
bool  isSymmetric = false 
)
virtual

Decrypt data.

Parameters
keyNameThe name of the decrypting key.
dataThe byte to be decrypted.
dataLengththe length of data.
isSymmetricIf true symmetric encryption is used, otherwise asymmetric encryption is used.
Returns
The decrypted data.

Implements ndn::PrivateKeyStorage.

void ndn::FilePrivateKeyStorage::deleteKeyPair ( const Name keyName)
virtual

Delete a pair of asymmetric keys.

If the key doesn't exist, do nothing.

Parameters
keyNameThe name of the key pair.

Implements ndn::PrivateKeyStorage.

bool ndn::FilePrivateKeyStorage::doesKeyExist ( const Name keyName,
KeyClass  keyClass 
)
virtual

Check if a particular key exists.

Parameters
keyNameThe name of the key.
keyClassThe class of the key, e.g. KEY_CLASS_PUBLIC, KEY_CLASS_PRIVATE, or KEY_CLASS_SYMMETRIC.
Returns
True if the key exists, otherwise false.

Implements ndn::PrivateKeyStorage.

Blob ndn::FilePrivateKeyStorage::encrypt ( const Name keyName,
const uint8_t *  data,
size_t  dataLength,
bool  isSymmetric = false 
)
virtual

Encrypt data.

Parameters
keyNameThe name of the encrypting key.
dataThe byte to be encrypted.
dataLengththe length of data.
isSymmetricIf true symmetric encryption is used, otherwise asymmetric encryption is used.
Returns
The encrypted data.

Implements ndn::PrivateKeyStorage.

void ndn::FilePrivateKeyStorage::generateKey ( const Name keyName,
const KeyParams params 
)
virtual

Generate a symmetric key.

Parameters
keyNameThe name of the key.
paramsThe parameters of the key.

Implements ndn::PrivateKeyStorage.

void ndn::FilePrivateKeyStorage::generateKeyPair ( const Name keyName,
const KeyParams params 
)
virtual

Generate a pair of asymmetric keys.

Parameters
keyNameThe name of the key pair.
paramsThe parameters of the key.

Implements ndn::PrivateKeyStorage.

ptr_lib::shared_ptr< PublicKey > ndn::FilePrivateKeyStorage::getPublicKey ( const Name keyName)
virtual

Get the public key.

Parameters
keyNameThe name of public key.
Returns
The public key.

Implements ndn::PrivateKeyStorage.

Blob ndn::FilePrivateKeyStorage::sign ( const uint8_t *  data,
size_t  dataLength,
const Name keyName,
DigestAlgorithm  digestAlgorithm = DIGEST_ALGORITHM_SHA256 
)
virtual

Fetch the private key for keyName and sign the data, returning a signature Blob.

Parameters
dataPointer to the input byte array.
dataLengthThe length of data.
keyNameThe name of the signing key.
digestAlgorithmthe digest algorithm.
Returns
The signature Blob.

Implements ndn::PrivateKeyStorage.


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