IBR-DTNSuite  0.8
ibrcommon/ibrcommon/ssl/HMacStream.h
Go to the documentation of this file.
00001 /*
00002  * HMacStream.h
00003  *
00004  *  Created on: 22.06.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef HMACSTREAM_H_
00009 #define HMACSTREAM_H_
00010 
00011 #include "ibrcommon/ssl/HashStream.h"
00012 #include <openssl/hmac.h>
00013 
00014 namespace ibrcommon
00015 {
00016         class HMacStream : public ibrcommon::HashStream
00017         {
00018         public:
00019                 // The size of the input and output buffers.
00020                 static const size_t BUFF_SIZE = 2048;
00021 
00022                 HMacStream(const unsigned char * const key, const size_t key_size);
00023                 virtual ~HMacStream();
00024 
00025         protected:
00026                 virtual void update(char *buf, const size_t size);
00027                 virtual void finalize(char * hash, unsigned int &size);
00028 
00029         private:
00030                 const unsigned char * const key_;
00031                 const size_t key_size_;
00032 
00033                 HMAC_CTX ctx_;
00034         };
00035 }
00036 
00037 #endif /* HMACSTREAM_H_ */