00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "common.h"
00022
00023 #ifdef USE_LIBMCRYPT
00024
00025 #ifndef SH_MCRYPTPP_H
00026 #define SH_MCRYPTPP_H
00027
00028 #include <string>
00029
00030 #include <mcrypt.h>
00031
00032 class BitString ;
00033 class EncryptionAlgorithm ;
00034 class EncryptionMode ;
00035
00036 #ifdef WIN32
00037 #define MCRYPTPP_LIBDIR "./modules/"
00038 #else
00039 #define MCRYPTPP_LIBDIR NULL
00040 #endif
00041
00042 class MCryptPP {
00043 public:
00044 MCryptPP (void) ;
00045 MCryptPP (EncryptionAlgorithm a, EncryptionMode m) ;
00046
00047 ~MCryptPP (void) ;
00048
00054 void open (EncryptionAlgorithm a, EncryptionMode m) ;
00055
00059 void close (void) ;
00060
00067 BitString encrypt (BitString p, std::string pp) ;
00068
00075 BitString decrypt (BitString c, std::string pp) ;
00076
00077 EncryptionAlgorithm getAlgorithm (void) const ;
00078 EncryptionMode getMode (void) const ;
00079
00087 static unsigned long getEncryptedSize (EncryptionAlgorithm a, EncryptionMode m, unsigned long plnsize) ;
00088
00089 static std::vector<std::string> getListModes (void) ;
00090 static std::vector<std::string> getListAlgorithms (void) ;
00091
00092 static bool AlgoSupportsMode (EncryptionAlgorithm a, EncryptionMode m) ;
00093
00094 protected:
00095 void *createKey (std::string pp) ;
00096
00105 std::vector<BYTE> _encrypt (std::vector<unsigned char> p, std::string pp) ;
00106
00115 std::vector<BYTE> _decrypt (std::vector<unsigned char> c, std::string pp) ;
00116
00117 private:
00119 bool ModuleOpen ;
00120 MCRYPT MCryptD ;
00121
00122 void *s_malloc (size_t size) ;
00123 } ;
00124
00125 #endif // ndef SH_MCRYPTPP_H
00126
00127 #endif // def USE_LIBMCRYPT