TigerHash.h

Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2006-2010 Jacek Sieka, arnetheduck on gmail point com
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
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
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef ADCHPP_TIGER_HASH_H
00020 #define ADCHPP_TIGER_HASH_H
00021 
00022 namespace adchpp { 
00023 
00024 class TigerHash : private boost::noncopyable {
00025 public:
00027     static const size_t BITS = 192;
00028     static const size_t BYTES = BITS / 8;
00029 
00030     TigerHash() : pos(0) {
00031         res[0]=_ULL(0x0123456789ABCDEF);
00032         res[1]=_ULL(0xFEDCBA9876543210);
00033         res[2]=_ULL(0xF096A5B4C3B2E187);
00034     }
00035 
00036     ~TigerHash() { }
00037 
00039     ADCHPP_DLL void update(const void* data, size_t len);
00041     ADCHPP_DLL uint8_t* finalize();
00042 
00043     uint8_t* getResult() { return (uint8_t*) res; }
00044 private:
00045     enum { BLOCK_SIZE = 512/8 };
00047     uint8_t tmp[512/8];
00049     uint64_t res[3];
00051     uint64_t pos;
00053     static uint64_t table[];
00054 
00055     void tigerCompress(const uint64_t* data, uint64_t state[3]);
00056 };
00057 
00058 }
00059 
00060 #endif // _TIGER_HASH
Generated on Sat Nov 27 23:37:53 2010 for adchpp by  doxygen 1.6.3