identt
CryptoBase.hpp
Go to the documentation of this file.
1 
33 #ifndef _IDENTT_CRYPTO_CRYPTO_BASE_HPP_
34 #define _IDENTT_CRYPTO_CRYPTO_BASE_HPP_
35 
36 // #define IDENTT_CRYPTO_B64_STRIP(X) while (X.back()=='=') X.pop_back();
37 // #define IDENTT_CRYPTO_B64_PAD(X) if( 3 - ((X.length() + 3) % 4) ) X.resize((3 - ((X.length() + 3) % 4))+X.length(),'=');
38 
39 #define IDENTT_CRYPTO_SCOPE_ENCODE 0x0001
40 #define IDENTT_CRYPTO_SCOPE_DECODE 0x0002
41 #define IDENTT_CRYPTO_SCOPE_SIGNIT 0x0004
42 #define IDENTT_CRYPTO_SCOPE_VERIFY 0x0008
43 #define IDENTT_CRYPTO_SCOPE_ENCODE_DECODE IDENTT_CRYPTO_SCOPE_ENCODE + IDENTT_CRYPTO_SCOPE_DECODE
44 #define IDENTT_CRYPTO_SCOPE_SIGNIT_VERIFY IDENTT_CRYPTO_SCOPE_SIGNIT + IDENTT_CRYPTO_SCOPE_VERIFY
45 #define IDENTT_CRYPTO_SCOPE_ALL IDENTT_CRYPTO_SCOPE_ENCODE_DECODE + IDENTT_CRYPTO_SCOPE_SIGNIT_VERIFY
46 
47 #include <utils/BaseUtils.hpp>
48 
49 namespace identt {
50 namespace crypto {
51 class CryptoBase {
52 public:
53 
60  const static std::string GetAlgo();
61 
66  CryptoBase();
67 
72  CryptoBase(const CryptoBase&) = delete;
73  CryptoBase& operator=(const CryptoBase&) = delete;
74 
81  virtual std::string GetSeed() const;
82 
89  virtual std::string GetPublicKey() const;
90 
97  virtual std::string GetSecretKey() const;
98 
108  virtual std::string GetSignature(const std::string& input) const;
109 
122  virtual bool VerifySignature(const std::string& signature, const std::string& input) const;
123 
136  virtual bool Encode(const std::string& input, std::string& output) const;
137 
150  virtual bool Decode(const std::string& input, std::string& output) const;
151 
152 protected:
153  unsigned int scope;
154  std::string pubkey;
155  std::string seckey;
156 
157 };
158 } // namespace crypto
159 } // namespace identt
160 #endif /* _IDENTT_CRYPTO_CRYPTO_BASE_HPP_ */
virtual std::string GetPublicKey() const
GetPublicKey : return public key.
Definition: CryptoBase.cc:65
virtual bool Decode(const std::string &input, std::string &output) const
Decode : return decoded.
Definition: CryptoBase.cc:110
Definition: CryptoBase.hpp:51
virtual bool Encode(const std::string &input, std::string &output) const
Encode : return encoded.
Definition: CryptoBase.cc:101
virtual bool VerifySignature(const std::string &signature, const std::string &input) const
VerifySignature : return signature valid status.
Definition: CryptoBase.cc:92
Definition: CryptoBase.hpp:49
virtual std::string GetSecretKey() const
GetSecretKey : return private key.
Definition: CryptoBase.cc:74
virtual std::string GetSeed() const
GetSeed : return seed of private key.
Definition: CryptoBase.cc:56
static const std::string GetAlgo()
GetAlgo : get key algo.
Definition: CryptoBase.cc:47
virtual std::string GetSignature(const std::string &input) const
GetSignature : return signature.
Definition: CryptoBase.cc:83
CryptoBase()
CryptoBase : constructor.
Definition: CryptoBase.cc:41