00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00028
00029 #ifndef CRYPTO_HPP
00030 #define CRYPTO_HPP
00031
00032 extern "C"
00033 {
00034 #if HAVE_OPENSSL_BLOWFISH_H
00035 #include <openssl/blowfish.h>
00036 #endif
00037 }
00038
00039 #include "../my_config.h"
00040 #include <string>
00041
00042 #include "tronconneuse.hpp"
00043
00044 namespace libdar
00045 {
00046
00048
00051 enum crypto_algo
00052 {
00053 crypto_none,
00054 crypto_scrambling,
00055 crypto_blowfish
00056 };
00057
00058 extern void crypto_split_algo_pass(const std::string & all, crypto_algo & algo, std::string & pass);
00059
00061
00064 class blowfish : public tronconneuse
00065 {
00066 public:
00067 blowfish(user_interaction & dialog, U_32 block_size, const std::string & key, generic_file & encrypted_side);
00068
00069
00070 protected:
00071 U_32 encrypted_block_size_for(U_32 clear_block_size);
00072 U_32 clear_block_allocated_size_for(U_32 clear_block_size);
00073 U_32 encrypt_data(const infinint & block_num,
00074 const char *clear_buf, const U_32 clear_size, const U_32 clear_allocated,
00075 char *crypt_buf, U_32 crypt_size);
00076 U_32 decrypt_data(const infinint & block_num,
00077 const char *crypt_buf, const U_32 crypt_size,
00078 char *clear_buf, U_32 clear_size);
00079
00080 private:
00081 #if HAVE_OPENSSL_BLOWFISH_H
00082 BF_KEY clef;
00083 #endif
00084
00085 void make_ivec(const infinint & ref, unsigned char ivec[8]);
00086
00087 };
00088
00089 }
00090
00091 #endif