client-cpp  0.8.1
KeyUtils.hpp
Go to the documentation of this file.
1 
17 #ifndef KEYUTILS_HPP_
18 #define KEYUTILS_HPP_
19 
20 #include <botan/botan.h>
21 #include <string>
22 #include <utility>
23 #include <cstdint>
24 #include <memory>
25 #include <boost/scoped_array.hpp>
27 
28 namespace kaa {
29 
30 class KeyUtils {
31 public:
38  KeyPair generateKeyPair(std::size_t length);
39 
46  SessionKey generateSessionKey(std::size_t length);
47 
55  bool checkKeyPair(const KeyPair &keys);
56 
57  static PublicKey loadPublicKey(const std::string& fileName);
58 
59  static PrivateKey loadPrivateKey(const std::string& fileName);
60 
61  static KeyPair loadKeyPair(const std::string& pubFileName, const std::string& privFileName);
62 
63  static void saveKeyPair(const KeyPair& pair, const std::string& pubFileName, const std::string& privFileName);
64 
65  static void savePublicKey(const PublicKey& key, const std::string& pubFileName);
66 
67  static void savePrivateKey(const PrivateKey& key, const std::string& privFileName);
68 
69 private:
70  static void readFile(const std::string& fileName, boost::scoped_array<char>& buf, std::size_t& len);
71 
72 private:
73  Botan::AutoSeeded_RNG rng_;
74 };
75 
76 }
77 
78 #endif /* KEYUTILS_HPP_ */
Botan::secure_vector< std::uint8_t > PublicKey
static void savePublicKey(const PublicKey &key, const std::string &pubFileName)
SessionKey generateSessionKey(std::size_t length)
static KeyPair loadKeyPair(const std::string &pubFileName, const std::string &privFileName)
static PrivateKey loadPrivateKey(const std::string &fileName)
KeyPair generateKeyPair(std::size_t length)
bool checkKeyPair(const KeyPair &keys)
Botan::SymmetricKey SessionKey
static PublicKey loadPublicKey(const std::string &fileName)
static void savePrivateKey(const PrivateKey &key, const std::string &privFileName)
std::string PrivateKey
static void saveKeyPair(const KeyPair &pair, const std::string &pubFileName, const std::string &privFileName)