13 #ifndef CVMFS_CRYPTO_ENCRYPT_H_
14 #define CVMFS_CRYPTO_ENCRYPT_H_
22 #include "gtest/gtest_prod.h"
40 static const unsigned kMaxSize = 64;
42 static Key *CreateRandomly(
const unsigned size);
43 static Key *CreateFromFile(
const std::string &path);
44 static Key *CreateFromString(
const std::string &key);
45 bool SaveToFile(
const std::string &path);
48 unsigned size()
const {
return size_; }
49 const unsigned char *
data()
const {
return data_; }
50 std::string ToBase64()
const;
53 Key() : data_(NULL), size_(0) { }
66 virtual bool StoreNew(
const Key *key, std::string *
id) = 0;
67 virtual const Key *Find(
const std::string &
id) = 0;
75 virtual bool StoreNew(
const Key *key, std::string *
id);
76 virtual const Key *Find(
const std::string &
id);
94 bool Encrypt(
const std::string &plaintext,
const Key &key,
95 std::string *ciphertext);
96 static bool Decrypt(
const std::string &ciphertext,
const Key &key,
97 std::string *plaintext);
99 virtual std::string name()
const = 0;
101 virtual unsigned key_size()
const = 0;
102 virtual unsigned iv_size()
const = 0;
103 virtual unsigned block_size()
const = 0;
107 virtual std::string DoEncrypt(
const std::string &plaintext,
109 virtual std::string DoDecrypt(
const std::string &ciphertext,
118 FRIEND_TEST(T_Encrypt, Aes_256_Cbc_Iv);
121 static const unsigned kKeySize = 256/8;
122 static const unsigned kIvSize = 128/8;
123 static const unsigned kBlockSize = 128/8;
127 virtual std::string
name()
const {
return "AES-256-CBC"; }
129 virtual unsigned key_size()
const {
return kKeySize; }
130 virtual unsigned iv_size()
const {
return kIvSize; }
134 virtual std::string DoEncrypt(
const std::string &plaintext,
const Key &key);
135 virtual std::string DoDecrypt(
const std::string &ciphertext,
const Key &key);
149 virtual std::string
name()
const {
return "FOR TESTING ONLY"; }
151 virtual unsigned key_size()
const {
return 256/8; }
152 virtual unsigned iv_size()
const {
return 128/8; }
156 virtual std::string DoEncrypt(
const std::string &plaintext,
const Key &key);
157 virtual std::string DoDecrypt(
const std::string &ciphertext,
const Key &key);
162 #endif // CVMFS_CRYPTO_ENCRYPT_H_
virtual unsigned block_size() const
static Publisher * Create(const SettingsPublisher &settings)
virtual unsigned iv_size() const
std::map< std::string, const Key * > database_
virtual unsigned key_size() const
virtual std::string name() const
virtual unsigned block_size() const
virtual std::string name() const
virtual ~CipherAes256Cbc()
const unsigned char * data() const
virtual Algorithms algorithm() const
virtual unsigned key_size() const
virtual ~AbstractKeyDatabase()
virtual Algorithms algorithm() const
virtual unsigned iv_size() const