Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

iblowfishstream.hpp

00001 /************************************************************************************
00002  *    This file is part of the MynahSA streaming and archiving toolkit              *
00003  *    Copyright (C) 2006 Mynah-Software Ltd. All Rights Reserved.                   *
00004  *                                                                                  *
00005  *    This program is free software; you can redistribute it and/or modify          *
00006  *    it under the terms of the GNU General Public License, version 2               *
00007  *    as published by the Free Software Foundation.                                 *
00008  *                                                                                  *
00009  *    This program is distributed in the hope that it will be useful,               *
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00012  *    GNU General Public License for more details.                                  *
00013  *                                                                                  *
00014  *    You should have received a copy of the GNU General Public License along       *
00015  *    with this program; if not, write to the Free Software Foundation, Inc.,       *
00016  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                   *
00017  *                                                                                  *
00018  ************************************************************************************/
00019 
00020 #ifndef __i_blowfish_stream_hpp
00021 #define __i_blowfish_stream_hpp
00022 
00023 #include <mynahsa/istreambase.hpp>
00024 
00025 #include <openssl/blowfish.h>
00026 
00027 #include <iostream>
00028 
00029 #include <string>
00030 
00031 namespace MynahSA { 
00032   class IBlowfishStream : public IStreamBase { 
00033   public:
00034   
00040     IBlowfishStream(std::istream& is, const std::string& key);
00041     
00046     IBlowfishStream(const IBlowfishStream& is);
00047     
00049     virtual ~IBlowfishStream();
00050     
00052     virtual IStreamBase& operator>>(char&);
00053     
00055     virtual IStreamBase& operator>>(unsigned char&);
00056     
00058     virtual IStreamBase& operator>>(short&);
00059     
00061     virtual IStreamBase& operator>>(unsigned short&);
00062     
00064     virtual IStreamBase& operator>>(bool&);
00065     
00067     virtual IStreamBase& operator>>(int&);
00068     
00070     virtual IStreamBase& operator>>(unsigned int&);
00071     
00073     virtual IStreamBase& operator>>(long long&);
00074     
00076     virtual IStreamBase& operator>>(unsigned long long&);
00077     
00079     virtual IStreamBase& operator>>(double&);
00080     
00082     virtual IStreamBase& operator>>(float&);
00083     
00084    
00086     virtual void get(char& c);
00087     
00088     
00089     // using declaration to make base string method accessible
00090     using IStreamBase::operator>>;
00091     
00092   private:
00093   
00097     void fillBuffer();
00098   
00099   
00101     std::istream& _is;
00102     
00104     BF_KEY _bfKey;
00105     
00106     unsigned int _buffPtr;
00107     
00109     unsigned char _inBuffer[8];
00110     
00112     unsigned char _outBuffer[8];
00113     
00115     unsigned char _ivec[8];
00116     
00117 
00118   };  // class IBlowfishStream
00119 };  // namespace MynahSA
00120 
00121 #endif