added iOS source code
[wl-app.git] / iOS / Pods / SSZipArchive / SSZipArchive / minizip / aes / hmac.h
1 /*
2 ---------------------------------------------------------------------------
3 Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
4
5 The redistribution and use of this software (with or without changes)
6 is allowed without the payment of fees or royalties provided that:
7
8   source code distributions include the above copyright notice, this
9   list of conditions and the following disclaimer;
10
11   binary distributions include the above copyright notice, this list
12   of conditions and the following disclaimer in their documentation.
13
14 This software is provided 'as is' with no explicit or implied warranties
15 in respect of its operation, including, but not limited to, correctness
16 and fitness for purpose.
17 ---------------------------------------------------------------------------
18 Issue Date: 20/12/2007
19
20 This is an implementation of HMAC, the FIPS standard keyed hash function
21 */
22
23 #ifndef _HMAC2_H
24 #define _HMAC2_H
25
26 #include <stdlib.h>
27 #include <string.h>
28
29 #if defined(__cplusplus)
30 extern "C"
31 {
32 #endif
33
34 #include "sha1.h"
35
36 #if defined(SHA_224) || defined(SHA_256) || defined(SHA_384) || defined(SHA_512)
37 #define HMAC_MAX_OUTPUT_SIZE SHA2_MAX_DIGEST_SIZE
38 #define HMAC_MAX_BLOCK_SIZE SHA2_MAX_BLOCK_SIZE
39 #else 
40 #define HMAC_MAX_OUTPUT_SIZE SHA1_DIGEST_SIZE
41 #define HMAC_MAX_BLOCK_SIZE SHA1_BLOCK_SIZE
42 #endif
43
44 #define HMAC_IN_DATA  0xffffffff
45
46 enum hmac_hash  
47
48 #ifdef SHA_1
49     HMAC_SHA1, 
50 #endif
51 #ifdef SHA_224 
52     HMAC_SHA224, 
53 #endif
54 #ifdef SHA_256
55     HMAC_SHA256, 
56 #endif
57 #ifdef SHA_384
58     HMAC_SHA384, 
59 #endif
60 #ifdef SHA_512
61     HMAC_SHA512, 
62     HMAC_SHA512_256,
63     HMAC_SHA512_224,
64     HMAC_SHA512_192,
65     HMAC_SHA512_128
66 #endif
67 };
68
69 typedef VOID_RETURN hf_begin(void*);
70 typedef VOID_RETURN hf_hash(const void*, unsigned long len, void*);
71 typedef VOID_RETURN hf_end(void*, void*);
72
73 typedef struct
74 {   hf_begin        *f_begin;
75     hf_hash         *f_hash;
76     hf_end          *f_end;
77     unsigned char   key[HMAC_MAX_BLOCK_SIZE];
78     union
79     {
80 #ifdef SHA_1
81        sha1_ctx    u_sha1;
82 #endif
83 #ifdef SHA_224
84         sha224_ctx  u_sha224;
85 #endif
86 #ifdef SHA_256
87         sha256_ctx  u_sha256;
88 #endif
89 #ifdef SHA_384
90         sha384_ctx  u_sha384;
91 #endif
92 #ifdef SHA_512
93         sha512_ctx  u_sha512;
94 #endif
95     } sha_ctx[1];
96     unsigned long   input_len;
97     unsigned long   output_len;
98     unsigned long   klen;
99 } hmac_ctx;
100
101 /* returns the length of hash digest for the hash used  */
102 /* mac_len must not be greater than this                */
103 int hmac_sha_begin(enum hmac_hash hash, hmac_ctx cx[1]);
104
105 int  hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]);
106
107 void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]);
108
109 void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]);
110
111 void hmac_sha(enum hmac_hash hash, const unsigned char key[], unsigned long key_len,
112           const unsigned char data[], unsigned long data_len,
113           unsigned char mac[], unsigned long mac_len);
114
115 #if defined(__cplusplus)
116 }
117 #endif
118
119 #endif