2 ---------------------------------------------------------------------------
\r
3 Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
\r
8 The free distribution and use of this software in both source and binary
\r
9 form is allowed (with or without changes) provided that:
\r
11 1. distributions of this source code include the above copyright
\r
12 notice, this list of conditions and the following disclaimer;
\r
14 2. distributions in binary form include the above copyright
\r
15 notice, this list of conditions and the following disclaimer
\r
16 in the documentation and/or other associated materials;
\r
18 3. the copyright holder's name is not used to endorse products
\r
19 built using this software without specific written permission.
\r
21 ALTERNATIVELY, provided that this notice is retained in full, this product
\r
22 may be distributed under the terms of the GNU General Public License (GPL),
\r
23 in which case the provisions of the GPL apply INSTEAD OF those given above.
\r
27 This software is provided 'as is' with no explicit or implied warranties
\r
28 in respect of its properties, including, but not limited to, correctness
\r
29 and/or fitness for purpose.
\r
30 ---------------------------------------------------------------------------
\r
31 Issue Date: 26/08/2003
\r
32 Includes a bugfix from Dr Brian Gladman made on 16/04/2012 for compiling on 64-bit
\r
34 This is an implementation of HMAC, the FIPS standard keyed hash function
\r
42 #define USE_SHA1 // Irrlicht only cares about SHA1 for now
\r
43 #if !defined(USE_SHA1) && !defined(USE_SHA256)
\r
44 #error define USE_SHA1 or USE_SHA256 to set the HMAC hash algorithm
\r
51 #define HMAC_HASH_INPUT_SIZE SHA1_BLOCK_SIZE
\r
52 #define HMAC_HASH_OUTPUT_SIZE SHA1_DIGEST_SIZE
\r
53 #define sha_ctx sha1_ctx
\r
54 #define sha_begin sha1_begin
\r
55 #define sha_hash sha1_hash
\r
56 #define sha_end sha1_end
\r
64 #define HMAC_HASH_INPUT_SIZE SHA256_BLOCK_SIZE
\r
65 #define HMAC_HASH_OUTPUT_SIZE SHA256_DIGEST_SIZE
\r
66 #define sha_ctx sha256_ctx
\r
67 #define sha_begin sha256_begin
\r
68 #define sha_hash sha256_hash
\r
69 #define sha_end sha256_end
\r
74 #define HMAC_BAD_MODE -1
\r
75 #define HMAC_IN_DATA 0xffffffff
\r
78 { unsigned char key[HMAC_HASH_INPUT_SIZE];
\r
83 void hmac_sha_begin(hmac_ctx cx[1]);
\r
85 int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]);
\r
87 void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]);
\r
89 void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]);
\r
91 void hmac_sha(const unsigned char key[], unsigned long key_len,
\r
92 const unsigned char data[], unsigned long data_len,
\r
93 unsigned char mac[], unsigned long mac_len);
\r