1 /* 2 --------------------------------------------------------------------------- 3 Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. 4 All rights reserved. 5 6 LICENSE TERMS 7 8 The free distribution and use of this software in both source and binary 9 form is allowed (with or without changes) provided that: 10 11 1. distributions of this source code include the above copyright 12 notice, this list of conditions and the following disclaimer; 13 14 2. distributions in binary form include the above copyright 15 notice, this list of conditions and the following disclaimer 16 in the documentation and/or other associated materials; 17 18 3. the copyright holder's name is not used to endorse products 19 built using this software without specific written permission. 20 21 ALTERNATIVELY, provided that this notice is retained in full, this product 22 may be distributed under the terms of the GNU General Public License (GPL), 23 in which case the provisions of the GPL apply INSTEAD OF those given above. 24 25 DISCLAIMER 26 27 This software is provided 'as is' with no explicit or implied warranties 28 in respect of its properties, including, but not limited to, correctness 29 and/or fitness for purpose. 30 --------------------------------------------------------------------------- 31 Issue Date: 26/08/2003 32 */ 33 34 #ifndef _SHA1_H 35 #define _SHA1_H 36 37 #include <limits.h> 38 39 #define SHA1_BLOCK_SIZE 64 40 #define SHA1_DIGEST_SIZE 20 41 42 /* define an unsigned 32-bit type */ 43 44 #if UINT_MAX == 0xffffffff 45 typedef unsigned int sha1_32t; 46 #elif ULONG_MAX == 0xffffffff 47 typedef unsigned long sha1_32t; 48 #else 49 #error Please define sha1_32t as an unsigned 32 bit type in sha2.h 50 #endif 51 52 /* type to hold the SHA256 context */ 53 54 typedef struct 55 { sha1_32t count[2]; 56 sha1_32t hash[5]; 57 sha1_32t wbuf[16]; 58 } sha1_ctx; 59 60 void sha1_compile(sha1_ctx ctx[1]); 61 62 void sha1_begin(sha1_ctx ctx[1]); 63 void sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]); 64 void sha1_end(unsigned char hval[], sha1_ctx ctx[1]); 65 void sha1(unsigned char hval[], const unsigned char data[], unsigned long len); 66 67 #endif 68 69