1 2 /****************************************************************************** 3 * 4 * Project: OpenCPN 5 * Purpose: Hash of arbitrary length 6 * Author: Anton Samsonov 7 * 8 *************************************************************************** 9 * Copyright (C) 2010 by David S. Register * 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 * This program is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 19 * GNU General Public License for more details. * 20 * * 21 * You should have received a copy of the GNU General Public License * 22 * along with this program; if not, write to the * 23 * Free Software Foundation, Inc., * 24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 25 *************************************************************************** 26 * 27 */ 28 29 #ifndef __FLEXHASH_H__ 30 #define __FLEXHASH_H__ 31 32 #include <vector> 33 #include "ssl/sha1.h" 34 35 class FlexHash { 36 37 public: 38 39 FlexHash( size_t output_octets ); 40 41 void Reset( void ); 42 void Update( const void* input, size_t input_octets ); 43 void Finish( void ); 44 void Receive( void* output ); 45 46 void Compute( const void* input, size_t input_octets, void* output ); 47 static void Compute( const void* input, size_t input_octets, void* output, size_t output_octets ); 48 49 static bool Test( void ); 50 51 protected: 52 53 sha1_context m_Context; 54 std::vector<unsigned char> m_Output; 55 56 }; 57 58 #endif 59