All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
file-private-key-storage.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_FILE_PRIVATE_KEY_STORAGE_HPP
24 #define NDN_FILE_PRIVATE_KEY_STORAGE_HPP
25 
26 #include <string>
27 #include "private-key-storage.hpp"
28 
29 namespace ndn {
30 
31 class DerNode;
32 
38 public:
46  FilePrivateKeyStorage(const std::string& keyStoreDirectoryPath = "");
47 
51  virtual
53 
59  virtual void
60  generateKeyPair(const Name& keyName, const KeyParams& params);
61 
66  virtual void
67  deleteKeyPair(const Name& keyName);
68 
74  virtual ptr_lib::shared_ptr<PublicKey>
75  getPublicKey(const Name& keyName);
76 
85  virtual Blob
86  sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256);
87 
96  virtual Blob
97  decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric = false);
98 
107  virtual Blob
108  encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric = false);
109 
115  virtual void
116  generateKey(const Name& keyName, const KeyParams& params);
117 
124  virtual bool
125  doesKeyExist(const Name& keyName, KeyClass keyClass);
126 
127 private:
128  std::string
129  nameTransform(const std::string& keyName, const std::string& extension);
130 
137  std::string
138  maintainMapping(const std::string& keyName);
139 
140  std::string keyStorePath_;
141 };
142 
143 }
144 
145 #endif
virtual Blob decrypt(const Name &keyName, const uint8_t *data, size_t dataLength, bool isSymmetric=false)
Decrypt data.
Definition: file-private-key-storage.cpp:167
FilePrivateKeyStorage extends PrivateKeyStorage to implement private key storage using files...
Definition: file-private-key-storage.hpp:37
FilePrivateKeyStorage(const std::string &keyStoreDirectoryPath="")
Create a new FilePrivateKeyStorage to connect to the given or default directory.
Definition: file-private-key-storage.cpp:42
virtual ~FilePrivateKeyStorage()
The virtual Destructor.
Definition: file-private-key-storage.cpp:71
virtual void generateKey(const Name &keyName, const KeyParams &params)
Generate a symmetric key.
Definition: file-private-key-storage.cpp:182
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
virtual bool doesKeyExist(const Name &keyName, KeyClass keyClass)
Check if a particular key exists.
Definition: file-private-key-storage.cpp:188
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
virtual ptr_lib::shared_ptr< PublicKey > getPublicKey(const Name &keyName)
Get the public key.
Definition: file-private-key-storage.cpp:119
virtual void generateKeyPair(const Name &keyName, const KeyParams &params)
Generate a pair of asymmetric keys.
Definition: file-private-key-storage.cpp:77
virtual Blob encrypt(const Name &keyName, const uint8_t *data, size_t dataLength, bool isSymmetric=false)
Encrypt data.
Definition: file-private-key-storage.cpp:175
KeyParams is a base class for key parameters.
Definition: key-params.hpp:36
virtual void deleteKeyPair(const Name &keyName)
Delete a pair of asymmetric keys.
Definition: file-private-key-storage.cpp:110
Definition: private-key-storage.hpp:39
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.
Definition: file-private-key-storage.cpp:140