cordova-plugin-mserviceinterface-2.0 1.0.21 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +28 -28
  2. package/plugin.xml +153 -153
  3. package/src/android/CallbackProgressDialog.java +53 -53
  4. package/src/android/FileProvider.java +7 -7
  5. package/src/android/backgroundNotification.java +120 -120
  6. package/src/android/doubleogradle.gradle +5 -5
  7. package/src/android/mInterface.java +2087 -2066
  8. package/src/android/mInterfaceReceiver.java +59 -59
  9. package/src/android/mInterfaceService.java +749 -749
  10. package/src/android/mInterfaceUtil.java +1686 -1688
  11. package/src/android/res/xml/network_security_config.xml +8 -8
  12. package/src/android/res/xml/opener_paths.xml +16 -16
  13. package/src/ios/InternetConnection.h +64 -64
  14. package/src/ios/InternetConnection.m +242 -242
  15. package/src/ios/SSZipArchive.h +146 -146
  16. package/src/ios/SSZipArchive.m +1180 -1180
  17. package/src/ios/SSZipCommon.h +66 -66
  18. package/src/ios/UICKeyChainStore.h +64 -64
  19. package/src/ios/UICKeyChainStore.m +434 -434
  20. package/src/ios/XMLConverter.h +61 -61
  21. package/src/ios/XMLConverter.m +243 -243
  22. package/src/ios/ZipArchive.h +19 -19
  23. package/src/ios/aes/aes.h +270 -270
  24. package/src/ios/aes/aes_ni.c +687 -687
  25. package/src/ios/aes/aes_ni.h +59 -59
  26. package/src/ios/aes/aescrypt.c +301 -301
  27. package/src/ios/aes/aeskey.c +554 -554
  28. package/src/ios/aes/aesopt.h +776 -776
  29. package/src/ios/aes/aestab.c +418 -418
  30. package/src/ios/aes/aestab.h +173 -173
  31. package/src/ios/aes/brg_endian.h +127 -127
  32. package/src/ios/aes/brg_types.h +191 -191
  33. package/src/ios/aes/fileenc.c +145 -145
  34. package/src/ios/aes/fileenc.h +121 -121
  35. package/src/ios/aes/hmac.c +209 -209
  36. package/src/ios/aes/hmac.h +119 -119
  37. package/src/ios/aes/prng.c +155 -155
  38. package/src/ios/aes/prng.h +82 -82
  39. package/src/ios/aes/pwd2key.c +181 -181
  40. package/src/ios/aes/pwd2key.h +45 -45
  41. package/src/ios/aes/sha1.c +283 -283
  42. package/src/ios/aes/sha1.h +72 -72
  43. package/src/ios/mInterface.h +2 -0
  44. package/src/ios/mInterface.m +18 -1
  45. package/src/ios/minizip/crypt.c +146 -146
  46. package/src/ios/minizip/crypt.h +66 -66
  47. package/src/ios/minizip/ioapi.c +353 -353
  48. package/src/ios/minizip/ioapi.h +154 -154
  49. package/src/ios/minizip/ioapi_buf.c +452 -452
  50. package/src/ios/minizip/ioapi_buf.h +52 -52
  51. package/src/ios/minizip/ioapi_mem.c +167 -167
  52. package/src/ios/minizip/ioapi_mem.h +52 -52
  53. package/src/ios/minizip/minishared.c +292 -292
  54. package/src/ios/minizip/minishared.h +50 -50
  55. package/src/ios/minizip/unzip.c +2007 -2007
  56. package/src/ios/minizip/unzip.h +254 -254
  57. package/src/ios/minizip/zip.c +2007 -2007
  58. package/src/ios/minizip/zip.h +215 -215
  59. package/www/mInterface.js +3 -3
@@ -1,209 +1,209 @@
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
- #include "hmac.h"
24
-
25
- #if defined(__cplusplus)
26
- extern "C"
27
- {
28
- #endif
29
-
30
- /* initialise the HMAC context to zero */
31
- int hmac_sha_begin(enum hmac_hash hash, hmac_ctx cx[1])
32
- {
33
- memset(cx, 0, sizeof(hmac_ctx));
34
- switch(hash)
35
- {
36
- #ifdef SHA_1
37
- case HMAC_SHA1:
38
- cx->f_begin = (hf_begin *)sha1_begin;
39
- cx->f_hash = (hf_hash *)sha1_hash;
40
- cx->f_end = (hf_end *)sha1_end;
41
- cx->input_len = SHA1_BLOCK_SIZE;
42
- cx->output_len = SHA1_DIGEST_SIZE;
43
- break;
44
- #endif
45
- #ifdef SHA_224
46
- case HMAC_SHA224:
47
- cx->f_begin = (hf_begin *)sha224_begin;
48
- cx->f_hash = (hf_hash *)sha224_hash;
49
- cx->f_end = (hf_end *)sha224_end;
50
- cx->input_len = SHA224_BLOCK_SIZE;
51
- cx->output_len = SHA224_DIGEST_SIZE;
52
- break;
53
- #endif
54
- #ifdef SHA_256
55
- case HMAC_SHA256:
56
- cx->f_begin = (hf_begin *)sha256_begin;
57
- cx->f_hash = (hf_hash *)sha256_hash;
58
- cx->f_end = (hf_end *)sha256_end;
59
- cx->input_len = SHA256_BLOCK_SIZE;
60
- cx->output_len = SHA256_DIGEST_SIZE;
61
- break;
62
- #endif
63
- #ifdef SHA_384
64
- case HMAC_SHA384:
65
- cx->f_begin = (hf_begin *)sha384_begin;
66
- cx->f_hash = (hf_hash *)sha384_hash;
67
- cx->f_end = (hf_end *)sha384_end;
68
- cx->input_len = SHA384_BLOCK_SIZE;
69
- cx->output_len = SHA384_DIGEST_SIZE;
70
- break;
71
- #endif
72
- #ifdef SHA_512
73
- case HMAC_SHA512:
74
- cx->f_begin = (hf_begin *)sha512_begin;
75
- cx->f_hash = (hf_hash *)sha512_hash;
76
- cx->f_end = (hf_end *)sha512_end;
77
- cx->input_len = SHA512_BLOCK_SIZE;
78
- cx->output_len = SHA512_DIGEST_SIZE;
79
- break;
80
- case HMAC_SHA512_256:
81
- cx->f_begin = (hf_begin *)sha512_256_begin;
82
- cx->f_hash = (hf_hash *)sha512_256_hash;
83
- cx->f_end = (hf_end *)sha512_256_end;
84
- cx->input_len = SHA512_256_BLOCK_SIZE;
85
- cx->output_len = SHA512_256_DIGEST_SIZE;
86
- break;
87
- case HMAC_SHA512_224:
88
- cx->f_begin = (hf_begin *)sha512_224_begin;
89
- cx->f_hash = (hf_hash *)sha512_224_hash;
90
- cx->f_end = (hf_end *)sha512_224_end;
91
- cx->input_len = SHA512_224_BLOCK_SIZE;
92
- cx->output_len = SHA512_224_DIGEST_SIZE;
93
- break;
94
- case HMAC_SHA512_192:
95
- cx->f_begin = (hf_begin *)sha512_192_begin;
96
- cx->f_hash = (hf_hash *)sha512_192_hash;
97
- cx->f_end = (hf_end *)sha512_192_end;
98
- cx->input_len = SHA512_192_BLOCK_SIZE;
99
- cx->output_len = SHA512_192_DIGEST_SIZE;
100
- break;
101
- case HMAC_SHA512_128:
102
- cx->f_begin = (hf_begin *)sha512_128_begin;
103
- cx->f_hash = (hf_hash *)sha512_128_hash;
104
- cx->f_end = (hf_begin *)sha512_128_end;
105
- cx->input_len = SHA512_128_BLOCK_SIZE;
106
- cx->output_len = SHA512_128_DIGEST_SIZE;
107
- break;
108
- #endif
109
- }
110
- return (int)cx->output_len;
111
- }
112
-
113
- /* input the HMAC key (can be called multiple times) */
114
- int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1])
115
- {
116
- if(cx->klen == HMAC_IN_DATA) /* error if further key input */
117
- return EXIT_FAILURE; /* is attempted in data mode */
118
-
119
- if(cx->klen + key_len > cx->input_len) /* if the key has to be hashed */
120
- {
121
- if(cx->klen <= cx->input_len) /* if the hash has not yet been */
122
- { /* started, initialise it and */
123
- cx->f_begin(cx->sha_ctx); /* hash stored key characters */
124
- cx->f_hash(cx->key, cx->klen, cx->sha_ctx);
125
- }
126
-
127
- cx->f_hash(key, key_len, cx->sha_ctx); /* hash long key data into hash */
128
- }
129
- else /* otherwise store key data */
130
- memcpy(cx->key + cx->klen, key, key_len);
131
-
132
- cx->klen += key_len; /* update the key length count */
133
- return EXIT_SUCCESS;
134
- }
135
-
136
- /* input the HMAC data (can be called multiple times) - */
137
- /* note that this call terminates the key input phase */
138
- void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1])
139
- { unsigned int i;
140
-
141
- if(cx->klen != HMAC_IN_DATA) /* if not yet in data phase */
142
- {
143
- if(cx->klen > cx->input_len) /* if key is being hashed */
144
- { /* complete the hash and */
145
- cx->f_end(cx->key, cx->sha_ctx); /* store the result as the */
146
- cx->klen = cx->output_len; /* key and set new length */
147
- }
148
-
149
- /* pad the key if necessary */
150
- memset(cx->key + cx->klen, 0, cx->input_len - cx->klen);
151
-
152
- /* xor ipad into key value */
153
- for(i = 0; i < (cx->input_len >> 2); ++i)
154
- ((uint32_t*)cx->key)[i] ^= 0x36363636;
155
-
156
- /* and start hash operation */
157
- cx->f_begin(cx->sha_ctx);
158
- cx->f_hash(cx->key, cx->input_len, cx->sha_ctx);
159
-
160
- /* mark as now in data mode */
161
- cx->klen = HMAC_IN_DATA;
162
- }
163
-
164
- /* hash the data (if any) */
165
- if(data_len)
166
- cx->f_hash(data, data_len, cx->sha_ctx);
167
- }
168
-
169
- /* compute and output the MAC value */
170
- void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1])
171
- { unsigned char dig[HMAC_MAX_OUTPUT_SIZE];
172
- unsigned int i;
173
-
174
- /* if no data has been entered perform a null data phase */
175
- if(cx->klen != HMAC_IN_DATA)
176
- hmac_sha_data((const unsigned char*)0, 0, cx);
177
-
178
- cx->f_end(dig, cx->sha_ctx); /* complete the inner hash */
179
-
180
- /* set outer key value using opad and removing ipad */
181
- for(i = 0; i < (cx->input_len >> 2); ++i)
182
- ((uint32_t*)cx->key)[i] ^= 0x36363636 ^ 0x5c5c5c5c;
183
-
184
- /* perform the outer hash operation */
185
- cx->f_begin(cx->sha_ctx);
186
- cx->f_hash(cx->key, cx->input_len, cx->sha_ctx);
187
- cx->f_hash(dig, cx->output_len, cx->sha_ctx);
188
- cx->f_end(dig, cx->sha_ctx);
189
-
190
- /* output the hash value */
191
- for(i = 0; i < mac_len; ++i)
192
- mac[i] = dig[i];
193
- }
194
-
195
- /* 'do it all in one go' subroutine */
196
- void hmac_sha(enum hmac_hash hash, const unsigned char key[], unsigned long key_len,
197
- const unsigned char data[], unsigned long data_len,
198
- unsigned char mac[], unsigned long mac_len)
199
- { hmac_ctx cx[1];
200
-
201
- hmac_sha_begin(hash, cx);
202
- hmac_sha_key(key, key_len, cx);
203
- hmac_sha_data(data, data_len, cx);
204
- hmac_sha_end(mac, mac_len, cx);
205
- }
206
-
207
- #if defined(__cplusplus)
208
- }
209
- #endif
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
+ #include "hmac.h"
24
+
25
+ #if defined(__cplusplus)
26
+ extern "C"
27
+ {
28
+ #endif
29
+
30
+ /* initialise the HMAC context to zero */
31
+ int hmac_sha_begin(enum hmac_hash hash, hmac_ctx cx[1])
32
+ {
33
+ memset(cx, 0, sizeof(hmac_ctx));
34
+ switch(hash)
35
+ {
36
+ #ifdef SHA_1
37
+ case HMAC_SHA1:
38
+ cx->f_begin = (hf_begin *)sha1_begin;
39
+ cx->f_hash = (hf_hash *)sha1_hash;
40
+ cx->f_end = (hf_end *)sha1_end;
41
+ cx->input_len = SHA1_BLOCK_SIZE;
42
+ cx->output_len = SHA1_DIGEST_SIZE;
43
+ break;
44
+ #endif
45
+ #ifdef SHA_224
46
+ case HMAC_SHA224:
47
+ cx->f_begin = (hf_begin *)sha224_begin;
48
+ cx->f_hash = (hf_hash *)sha224_hash;
49
+ cx->f_end = (hf_end *)sha224_end;
50
+ cx->input_len = SHA224_BLOCK_SIZE;
51
+ cx->output_len = SHA224_DIGEST_SIZE;
52
+ break;
53
+ #endif
54
+ #ifdef SHA_256
55
+ case HMAC_SHA256:
56
+ cx->f_begin = (hf_begin *)sha256_begin;
57
+ cx->f_hash = (hf_hash *)sha256_hash;
58
+ cx->f_end = (hf_end *)sha256_end;
59
+ cx->input_len = SHA256_BLOCK_SIZE;
60
+ cx->output_len = SHA256_DIGEST_SIZE;
61
+ break;
62
+ #endif
63
+ #ifdef SHA_384
64
+ case HMAC_SHA384:
65
+ cx->f_begin = (hf_begin *)sha384_begin;
66
+ cx->f_hash = (hf_hash *)sha384_hash;
67
+ cx->f_end = (hf_end *)sha384_end;
68
+ cx->input_len = SHA384_BLOCK_SIZE;
69
+ cx->output_len = SHA384_DIGEST_SIZE;
70
+ break;
71
+ #endif
72
+ #ifdef SHA_512
73
+ case HMAC_SHA512:
74
+ cx->f_begin = (hf_begin *)sha512_begin;
75
+ cx->f_hash = (hf_hash *)sha512_hash;
76
+ cx->f_end = (hf_end *)sha512_end;
77
+ cx->input_len = SHA512_BLOCK_SIZE;
78
+ cx->output_len = SHA512_DIGEST_SIZE;
79
+ break;
80
+ case HMAC_SHA512_256:
81
+ cx->f_begin = (hf_begin *)sha512_256_begin;
82
+ cx->f_hash = (hf_hash *)sha512_256_hash;
83
+ cx->f_end = (hf_end *)sha512_256_end;
84
+ cx->input_len = SHA512_256_BLOCK_SIZE;
85
+ cx->output_len = SHA512_256_DIGEST_SIZE;
86
+ break;
87
+ case HMAC_SHA512_224:
88
+ cx->f_begin = (hf_begin *)sha512_224_begin;
89
+ cx->f_hash = (hf_hash *)sha512_224_hash;
90
+ cx->f_end = (hf_end *)sha512_224_end;
91
+ cx->input_len = SHA512_224_BLOCK_SIZE;
92
+ cx->output_len = SHA512_224_DIGEST_SIZE;
93
+ break;
94
+ case HMAC_SHA512_192:
95
+ cx->f_begin = (hf_begin *)sha512_192_begin;
96
+ cx->f_hash = (hf_hash *)sha512_192_hash;
97
+ cx->f_end = (hf_end *)sha512_192_end;
98
+ cx->input_len = SHA512_192_BLOCK_SIZE;
99
+ cx->output_len = SHA512_192_DIGEST_SIZE;
100
+ break;
101
+ case HMAC_SHA512_128:
102
+ cx->f_begin = (hf_begin *)sha512_128_begin;
103
+ cx->f_hash = (hf_hash *)sha512_128_hash;
104
+ cx->f_end = (hf_begin *)sha512_128_end;
105
+ cx->input_len = SHA512_128_BLOCK_SIZE;
106
+ cx->output_len = SHA512_128_DIGEST_SIZE;
107
+ break;
108
+ #endif
109
+ }
110
+ return (int)cx->output_len;
111
+ }
112
+
113
+ /* input the HMAC key (can be called multiple times) */
114
+ int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1])
115
+ {
116
+ if(cx->klen == HMAC_IN_DATA) /* error if further key input */
117
+ return EXIT_FAILURE; /* is attempted in data mode */
118
+
119
+ if(cx->klen + key_len > cx->input_len) /* if the key has to be hashed */
120
+ {
121
+ if(cx->klen <= cx->input_len) /* if the hash has not yet been */
122
+ { /* started, initialise it and */
123
+ cx->f_begin(cx->sha_ctx); /* hash stored key characters */
124
+ cx->f_hash(cx->key, cx->klen, cx->sha_ctx);
125
+ }
126
+
127
+ cx->f_hash(key, key_len, cx->sha_ctx); /* hash long key data into hash */
128
+ }
129
+ else /* otherwise store key data */
130
+ memcpy(cx->key + cx->klen, key, key_len);
131
+
132
+ cx->klen += key_len; /* update the key length count */
133
+ return EXIT_SUCCESS;
134
+ }
135
+
136
+ /* input the HMAC data (can be called multiple times) - */
137
+ /* note that this call terminates the key input phase */
138
+ void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1])
139
+ { unsigned int i;
140
+
141
+ if(cx->klen != HMAC_IN_DATA) /* if not yet in data phase */
142
+ {
143
+ if(cx->klen > cx->input_len) /* if key is being hashed */
144
+ { /* complete the hash and */
145
+ cx->f_end(cx->key, cx->sha_ctx); /* store the result as the */
146
+ cx->klen = cx->output_len; /* key and set new length */
147
+ }
148
+
149
+ /* pad the key if necessary */
150
+ memset(cx->key + cx->klen, 0, cx->input_len - cx->klen);
151
+
152
+ /* xor ipad into key value */
153
+ for(i = 0; i < (cx->input_len >> 2); ++i)
154
+ ((uint32_t*)cx->key)[i] ^= 0x36363636;
155
+
156
+ /* and start hash operation */
157
+ cx->f_begin(cx->sha_ctx);
158
+ cx->f_hash(cx->key, cx->input_len, cx->sha_ctx);
159
+
160
+ /* mark as now in data mode */
161
+ cx->klen = HMAC_IN_DATA;
162
+ }
163
+
164
+ /* hash the data (if any) */
165
+ if(data_len)
166
+ cx->f_hash(data, data_len, cx->sha_ctx);
167
+ }
168
+
169
+ /* compute and output the MAC value */
170
+ void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1])
171
+ { unsigned char dig[HMAC_MAX_OUTPUT_SIZE];
172
+ unsigned int i;
173
+
174
+ /* if no data has been entered perform a null data phase */
175
+ if(cx->klen != HMAC_IN_DATA)
176
+ hmac_sha_data((const unsigned char*)0, 0, cx);
177
+
178
+ cx->f_end(dig, cx->sha_ctx); /* complete the inner hash */
179
+
180
+ /* set outer key value using opad and removing ipad */
181
+ for(i = 0; i < (cx->input_len >> 2); ++i)
182
+ ((uint32_t*)cx->key)[i] ^= 0x36363636 ^ 0x5c5c5c5c;
183
+
184
+ /* perform the outer hash operation */
185
+ cx->f_begin(cx->sha_ctx);
186
+ cx->f_hash(cx->key, cx->input_len, cx->sha_ctx);
187
+ cx->f_hash(dig, cx->output_len, cx->sha_ctx);
188
+ cx->f_end(dig, cx->sha_ctx);
189
+
190
+ /* output the hash value */
191
+ for(i = 0; i < mac_len; ++i)
192
+ mac[i] = dig[i];
193
+ }
194
+
195
+ /* 'do it all in one go' subroutine */
196
+ void hmac_sha(enum hmac_hash hash, const unsigned char key[], unsigned long key_len,
197
+ const unsigned char data[], unsigned long data_len,
198
+ unsigned char mac[], unsigned long mac_len)
199
+ { hmac_ctx cx[1];
200
+
201
+ hmac_sha_begin(hash, cx);
202
+ hmac_sha_key(key, key_len, cx);
203
+ hmac_sha_data(data, data_len, cx);
204
+ hmac_sha_end(mac, mac_len, cx);
205
+ }
206
+
207
+ #if defined(__cplusplus)
208
+ }
209
+ #endif
@@ -1,119 +1,119 @@
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
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