identt
CryptoTraits.hpp
Go to the documentation of this file.
1 
33 #ifndef _IDENTT_CRYPTO_CRYPTO_TRAITS_HPP_
34 #define _IDENTT_CRYPTO_CRYPTO_TRAITS_HPP_
35 
36 #include <memory>
37 #include <crypto/Ed25519.hpp>
38 
39 namespace identt {
40 namespace crypto {
41 class CryptoTraits {
42 public:
43  using pointer = std::shared_ptr<CryptoBase>;
44 
55  static pointer Create(const std::string ctype)
56  {
57  if (ctype==Ed25519::GetAlgo()) return std::make_shared<Ed25519>();
58  throw ::identt::BadCodeException("Bogus Algo");
59  }
60 
74  static pointer CreateFromSeed(const std::string ctype, const std::string& seed)
75  {
76  if (ctype==Ed25519::GetAlgo()) return std::make_shared<Ed25519>(seed);
77  throw ::identt::BadCodeException("Bogus Algo");
78  }
79 
96  static pointer Create(const std::string ctype, unsigned int scope, const std::string& key)
97  {
98  if (ctype==Ed25519::GetAlgo()) return std::make_shared<Ed25519>(scope,key);
99  throw ::identt::BadCodeException("Bogus Algo");
100  }
101 
118  static pointer Create(const std::string ctype, const std::string& pkey, const std::string& skey)
119  {
120  if (ctype==Ed25519::GetAlgo()) return std::make_shared<Ed25519>(pkey,skey);
121  throw ::identt::BadCodeException("Bogus Algo");
122  }
123 
124 };
125 } // namespace crypto
126 } // namespace identt
127 #endif /* _IDENTT_CRYPTO_CRYPTO_TRAITS_HPP_ */
Definition: CryptoTraits.hpp:41
static const std::string GetAlgo()
GetAlgo : get key algo.
Definition: Ed25519.cc:43
static pointer Create(const std::string ctype)
Create : create new keys.
Definition: CryptoTraits.hpp:55
static pointer CreateFromSeed(const std::string ctype, const std::string &seed)
CreateFromSeed : create from seed.
Definition: CryptoTraits.hpp:74
Definition: CryptoBase.hpp:49
static pointer Create(const std::string ctype, const std::string &pkey, const std::string &skey)
Create : only operator.
Definition: CryptoTraits.hpp:118
static pointer Create(const std::string ctype, unsigned int scope, const std::string &key)
Create : create single purpose key.
Definition: CryptoTraits.hpp:96