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:
43 
47  virtual
49 
55  virtual void
56  generateKeyPair(const Name& keyName, const KeyParams& params);
57 
62  virtual void
63  deleteKeyPair(const Name& keyName);
64 
70  virtual ptr_lib::shared_ptr<PublicKey>
71  getPublicKey(const Name& keyName);
72 
81  virtual Blob
82  sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256);
83 
92  virtual Blob
93  decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric = false);
94 
103  virtual Blob
104  encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric = false);
105 
111  virtual void
112  generateKey(const Name& keyName, const KeyParams& params);
113 
120  virtual bool
121  doesKeyExist(const Name& keyName, KeyClass keyClass);
122 
123 private:
124  std::string
125  nameTransform(const std::string& keyName, const std::string& extension);
126 
127  std::string keyStorePath_;
128 };
129 
130 }
131 
132 #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:299
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
FilePrivateKeyStorage extends PrivateKeyStorage to implement private key storage using files...
Definition: file-private-key-storage.hpp:37
virtual ~FilePrivateKeyStorage()
The virtual Destructor.
Definition: file-private-key-storage.cpp:63
virtual void generateKey(const Name &keyName, const KeyParams &params)
Generate a symmetric key.
Definition: file-private-key-storage.cpp:314
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:320
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
virtual ptr_lib::shared_ptr< PublicKey > getPublicKey(const Name &keyName)
Get the public key.
Definition: file-private-key-storage.cpp:199
virtual void generateKeyPair(const Name &keyName, const KeyParams &params)
Generate a pair of asymmetric keys.
Definition: file-private-key-storage.cpp:69
virtual Blob encrypt(const Name &keyName, const uint8_t *data, size_t dataLength, bool isSymmetric=false)
Encrypt data.
Definition: file-private-key-storage.cpp:307
KeyParams is a base class for key parameters.
Definition: key-params.hpp:34
FilePrivateKeyStorage()
Create a new FilePrivateKeyStorage to connect to the default directory.
Definition: file-private-key-storage.cpp:44
virtual void deleteKeyPair(const Name &keyName)
Delete a pair of asymmetric keys.
Definition: file-private-key-storage.cpp:190
Definition: private-key-storage.hpp:40
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:220