• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ibrcommon/ibrcommon/ssl/HashStream.h

Go to the documentation of this file.
00001 /*
00002  * HashStream.h
00003  *
00004  *  Created on: 12.07.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef HASHSTREAM_H_
00009 #define HASHSTREAM_H_
00010 
00011 #include "ibrcommon/Exceptions.h"
00012 #include <streambuf>
00013 #include <iostream>
00014 
00015 namespace ibrcommon
00016 {
00017         class HashStream : public std::basic_streambuf<char, std::char_traits<char> >, public std::iostream
00018         {
00019         public:
00020                 HashStream(const size_t hash, const size_t buffer = 2048);
00021                 virtual ~HashStream();
00022 
00023         protected:
00024                 virtual void update(char *buf, const size_t size) = 0;
00025                 virtual void finalize(char * hash, unsigned int &size) = 0;
00026 
00027                 virtual int sync();
00028                 virtual int overflow(int = std::char_traits<char>::eof());
00029                 virtual int underflow();
00030 
00031         private:
00032                 // Output buffer
00033                 char *data_buf_;
00034 
00035                 // length of the data buffer
00036                 size_t data_size_;
00037 
00038                 // Input buffer (contains the hash after finalize)
00039                 char *hash_buf_;
00040 
00041                 // length of the hash
00042                 unsigned int hash_size_;
00043 
00044                 bool final_;
00045         };
00046 }
00047 
00048 #endif /* HASHSTREAM_H_ */

Generated on Thu Nov 11 2010 09:49:47 for IBR-DTNSuite by  doxygen 1.7.1