00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __UT_BlowfishIO__
00021 #define __UT_BlowfishIO__
00022
00023 #include "UT_API.h"
00024 #include "UT_NTStreamUtil.h"
00025
00026 class UT_Blowfish;
00027
00028
00029
00030 class UT_API UT_BlowfishEncryptFilter : public UT_StreamBufferFilter
00031 {
00032 public:
00033
00034 UT_BlowfishEncryptFilter( const uint8* key_bytes,
00035 int key_size );
00036 virtual ~UT_BlowfishEncryptFilter();
00037
00038
00039
00040 static int getFilteredSize( int original_size );
00041
00042
00043
00044
00045 virtual int getDataChunkLength( int buffer_size );
00046
00047
00048
00049 virtual int beginFilter(char *buffer, int buffer_size, int stream_size);
00050
00051
00052 virtual int doFilterChunk(char *buffer, int data_size, int buffer_size);
00053
00054
00055
00056 virtual int endFilter( char *buffer, int buffer_size );
00057
00058 private:
00059 UT_Blowfish * myEncryptor;
00060 bool myFullBlocksFlag;
00061 };
00062
00063
00064 class UT_API UT_BlowfishStreamDecryptor
00065 {
00066 public:
00067
00068 UT_BlowfishStreamDecryptor( const uint8 * key,
00069 int key_length );
00070 ~UT_BlowfishStreamDecryptor();
00071
00072
00073 static int getEncryptedSize( int plain_text_size );
00074
00075
00076 static int getCryptBufferSize( int max_buffer_size );
00077
00078
00079 static int getBlockSize();
00080
00081
00082
00083 static int getPreambleSize();
00084
00085
00086 static bool getVersion( const char * preamble, int preamble_length,
00087 int & version );
00088
00089
00090 static bool getPlainTextLength( const char * preamble,
00091 int preamble_length, int64 & length );
00092
00093
00094
00095
00096 bool decrypt( const uint8 * input, uint8 * output,
00097 int input_size );
00098
00099 private:
00100 UT_Blowfish * myDecryptor;
00101 };
00102
00103 #endif // __UT_BlowfishIO__
00104
00105
00106