Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "ibrcommon/ssl/HMacStream.h"
00009
00010 namespace ibrcommon
00011 {
00012 HMacStream::HMacStream(const unsigned char * const key, const size_t key_size)
00013 : HashStream(BUFF_SIZE, EVP_MAX_MD_SIZE), key_(key), key_size_(key_size)
00014 {
00015 HMAC_CTX_init(&ctx_);
00016 HMAC_Init_ex(&ctx_, key_, key_size_, EVP_sha1(), NULL);
00017 }
00018
00019 HMacStream::~HMacStream()
00020 {
00021 HMAC_CTX_cleanup(&ctx_);
00022 }
00023
00024 void HMacStream::update(char *buf, const size_t size)
00025 {
00026
00027 HMAC_Update(&ctx_, (unsigned char*)buf, size);
00028 }
00029
00030 void HMacStream::finalize(char * hash, unsigned int &size)
00031 {
00032 HMAC_Final(&ctx_, (unsigned char*)hash, &size);
00033 }
00034 }