26 #ifndef CRYPTO_SYM_HPP
27 #define CRYPTO_SYM_HPP
32 #ifndef GCRYPT_NO_DEPRECATED
33 #define GCRYPT_NO_DEPRECATED
39 #include "../my_config.h"
55 inline bool crypto_min_ver_libgcrypt_no_bug()
58 return gcry_check_version(MIN_VERSION_GCRYPT_HASH_BUG);
72 const std::string & salt,
80 crypto_sym & operator = (
crypto_sym && ref) noexcept {
try { detruit(); move_from(std::move(ref)); }
catch(...) {}
return *
this; };
81 virtual ~
crypto_sym() noexcept {
try { detruit(); }
catch(...) {} };
85 virtual U_32 encrypted_block_size_for(U_32 clear_block_size)
override;
86 virtual U_32 clear_block_allocated_size_for(U_32 clear_block_size)
override;
87 virtual U_32 encrypt_data(
const infinint & block_num,
88 const char *clear_buf,
89 const U_32 clear_size,
90 const U_32 clear_allocated,
91 char *crypt_buf, U_32 crypt_size)
override;
92 virtual U_32 decrypt_data(
const infinint & block_num,
93 const char *crypt_buf,
94 const U_32 crypt_size,
96 U_32 clear_size)
override;
97 virtual std::unique_ptr<crypto_module> clone()
const override;
119 gcry_cipher_hd_t main_clef;
120 gcry_cipher_hd_t essiv_clef;
121 size_t algo_block_size;
124 void init_hashed_password(
const secu_string & password,
126 const std::string & salt,
131 unsigned int IV_hashing);
135 void init_essiv_clef(
const secu_string & essiv_password,
137 U_I main_cipher_algo_block_size);
139 void init_ivec(
crypto_algo algo,
size_t algo_block_size);
149 static void get_IV_cipher_and_hashing(
const archive_version & ver, U_I main_cipher, U_I & cipher, U_I & hashing);
158 static void make_ivec(
const infinint & ref,
161 const gcry_cipher_hd_t & IVkey);
165 const std::string & salt,
172 const std::string & salt,
180 static std::string generate_salt(U_I size);
182 #ifdef LIBDAR_NO_OPTIMIZATION
183 static bool self_tested;
184 static void self_test(
void);
188 void detruit() {
throw Ecompilation(gettext(
"Strong encryption support (libgcrypt)")); };
189 void copy_from(
const crypto_sym & ref) {
throw Ecompilation(gettext(
"Strong encryption support (libgcrypt)")); };
190 void move_from(
crypto_sym && ref) {
throw Ecompilation(gettext(
"Strong encryption support (libgcrypt)")); };
set of datastructures used to interact with a catalogue object
class archive_version that rules which archive format to follow
exception used when a requested fearture has not beed activated at compilation time
class archive_version manages the version of the archive format
symetrical strong encryption, interface to grypt library
crypto_sym(const secu_string &password, const archive_version &reading_ver, crypto_algo algo, const std::string &salt, const infinint &iteration_count, hash_algo kdf_hash, bool use_pkcs5)
const std::string & get_salt() const
give access to the calculated or provided salt
static size_t max_key_len_libdar(crypto_algo algo)
returns the max key length in octets to use to compute a key from a user provided password
static bool is_a_strong_password(crypto_algo algo, const secu_string &password)
check whether the given password is reported as strong in regard to the given cipher
static size_t max_key_len(crypto_algo algo)
returns the max key length in octets for the given algorithm
the arbitrary large positive integer class
the crypto algoritm definition
per block cryptography implementation
hash_algo
hashing algorithm available
crypto_algo
the different cypher available for encryption (strong or weak)
libdar namespace encapsulate all libdar symbols
this file contains the definition of secu_string class, a std::string like class but allocated in sec...