crypto.hpp

Go to the documentation of this file.
00001 //*********************************************************************/
00002 // dar - disk archive - a backup/restoration program
00003 // Copyright (C) 2002-2052 Denis Corbin
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 // to contact the author : dar.linux@free.fr
00020 /*********************************************************************/
00021 // $Id: crypto.hpp,v 1.8 2006/01/08 16:33:42 edrusb Rel $
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             // destructor does not seems to be required for BF_KEY
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 } // end of namespace
00090 
00091 #endif

Generated on Fri Jul 21 19:31:19 2006 for Disk ARchive by  doxygen 1.4.7