@appzung/react-native-code-push 7.1.1 → 9.0.2
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.
- package/.azurepipelines/build-rn-code-push-1es.yml +104 -0
- package/.azurepipelines/test-rn-code-push.yml +94 -0
- package/.config/CredScanSuppressions.json +14 -0
- package/CONTRIBUTING.md +3 -3
- package/CodePush.js +20 -21
- package/CodePush.podspec +3 -3
- package/README.md +7 -5
- package/android/app/build.gradle +3 -1
- package/android/app/src/main/AndroidManifest.xml +2 -7
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +14 -5
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +9 -1
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +18 -10
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +3 -1
- package/android/build.gradle +6 -2
- package/android/codepush.gradle +72 -26
- package/docs/api-js.md +1 -1
- package/docs/setup-android.md +27 -3
- package/docs/setup-ios.md +1 -1
- package/docs/setup-windows.md +23 -0
- package/ios/CodePush/CodePush.m +2 -1
- package/ios/CodePush/CodePushPackage.m +4 -0
- package/ios/CodePush/SSZipArchive/Info.plist +26 -0
- package/ios/CodePush/SSZipArchive/README.md +1 -1
- package/ios/CodePush/SSZipArchive/SSZipArchive.h +129 -27
- package/ios/CodePush/SSZipArchive/SSZipArchive.m +1119 -314
- package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
- package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
- package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
- package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
- package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
- package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +245 -130
- package/ios/PrivacyInfo.xcprivacy +31 -0
- package/package.json +2 -2
- package/typings/react-native-code-push.d.ts +1 -1
- package/windows/CodePush/CodePush.vcxproj +2 -3
- package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +2 -2
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +2 -2
- package/ios/CodePush/SSZipArchive/Common.h +0 -81
- package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
- package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
- package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
- package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
- package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
- package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
- package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
- package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
- package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
- package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
- package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
- package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
- package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
- package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
- package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
- package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
- package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
- package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
- package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
- package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
- package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
- package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
- package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
- package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
- package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
- package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
- package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
- package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
- package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
- package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
---------------------------------------------------------------------------
|
|
3
|
-
Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved.
|
|
4
|
-
|
|
5
|
-
LICENSE TERMS
|
|
6
|
-
|
|
7
|
-
The free distribution and use of this software in both source and binary
|
|
8
|
-
form is allowed (with or without changes) provided that:
|
|
9
|
-
|
|
10
|
-
1. distributions of this source code include the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer;
|
|
12
|
-
|
|
13
|
-
2. distributions in binary form include the above copyright
|
|
14
|
-
notice, this list of conditions and the following disclaimer
|
|
15
|
-
in the documentation and/or other associated materials;
|
|
16
|
-
|
|
17
|
-
3. the copyright holder's name is not used to endorse products
|
|
18
|
-
built using this software without specific written permission.
|
|
19
|
-
|
|
20
|
-
ALTERNATIVELY, provided that this notice is retained in full, this product
|
|
21
|
-
may be distributed under the terms of the GNU General Public License (GPL),
|
|
22
|
-
in which case the provisions of the GPL apply INSTEAD OF those given above.
|
|
23
|
-
|
|
24
|
-
DISCLAIMER
|
|
25
|
-
|
|
26
|
-
This software is provided 'as is' with no explicit or implied warranties
|
|
27
|
-
in respect of its properties, including, but not limited to, correctness
|
|
28
|
-
and/or fitness for purpose.
|
|
29
|
-
---------------------------------------------------------------------------
|
|
30
|
-
Issue Date: 01/08/2005
|
|
31
|
-
|
|
32
|
-
This is a byte oriented version of SHA1 that operates on arrays of bytes
|
|
33
|
-
stored in memory.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
#include <string.h> /* for memcpy() etc. */
|
|
37
|
-
|
|
38
|
-
#include "sha1.h"
|
|
39
|
-
#include "brg_endian.h"
|
|
40
|
-
|
|
41
|
-
#if defined(__cplusplus)
|
|
42
|
-
extern "C"
|
|
43
|
-
{
|
|
44
|
-
#endif
|
|
45
|
-
|
|
46
|
-
#if defined( _MSC_VER ) && ( _MSC_VER > 800 )
|
|
47
|
-
#pragma intrinsic(memcpy)
|
|
48
|
-
#endif
|
|
49
|
-
|
|
50
|
-
#if 0 && defined(_MSC_VER)
|
|
51
|
-
#define rotl32 _lrotl
|
|
52
|
-
#define rotr32 _lrotr
|
|
53
|
-
#else
|
|
54
|
-
#define rotl32(x,n) (((x) << n) | ((x) >> (32 - n)))
|
|
55
|
-
#define rotr32(x,n) (((x) >> n) | ((x) << (32 - n)))
|
|
56
|
-
#endif
|
|
57
|
-
|
|
58
|
-
#if !defined(bswap_32)
|
|
59
|
-
#define bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00))
|
|
60
|
-
#endif
|
|
61
|
-
|
|
62
|
-
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
|
63
|
-
#define SWAP_BYTES
|
|
64
|
-
#else
|
|
65
|
-
#undef SWAP_BYTES
|
|
66
|
-
#endif
|
|
67
|
-
|
|
68
|
-
#if defined(SWAP_BYTES)
|
|
69
|
-
#define bsw_32(p,n) \
|
|
70
|
-
{ int _i = (n); while(_i--) ((uint_32t*)p)[_i] = bswap_32(((uint_32t*)p)[_i]); }
|
|
71
|
-
#else
|
|
72
|
-
#define bsw_32(p,n)
|
|
73
|
-
#endif
|
|
74
|
-
|
|
75
|
-
#define SHA1_MASK (SHA1_BLOCK_SIZE - 1)
|
|
76
|
-
|
|
77
|
-
#if 0
|
|
78
|
-
|
|
79
|
-
#define ch(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
|
|
80
|
-
#define parity(x,y,z) ((x) ^ (y) ^ (z))
|
|
81
|
-
#define maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
|
82
|
-
|
|
83
|
-
#else /* Discovered by Rich Schroeppel and Colin Plumb */
|
|
84
|
-
|
|
85
|
-
#define ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
|
86
|
-
#define parity(x,y,z) ((x) ^ (y) ^ (z))
|
|
87
|
-
#define maj(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
|
|
88
|
-
|
|
89
|
-
#endif
|
|
90
|
-
|
|
91
|
-
/* Compile 64 bytes of hash data into SHA1 context. Note */
|
|
92
|
-
/* that this routine assumes that the byte order in the */
|
|
93
|
-
/* ctx->wbuf[] at this point is in such an order that low */
|
|
94
|
-
/* address bytes in the ORIGINAL byte stream will go in */
|
|
95
|
-
/* this buffer to the high end of 32-bit words on BOTH big */
|
|
96
|
-
/* and little endian systems */
|
|
97
|
-
|
|
98
|
-
#ifdef ARRAY
|
|
99
|
-
#define q(v,n) v[n]
|
|
100
|
-
#else
|
|
101
|
-
#define q(v,n) v##n
|
|
102
|
-
#endif
|
|
103
|
-
|
|
104
|
-
#define one_cycle(v,a,b,c,d,e,f,k,h) \
|
|
105
|
-
q(v,e) += rotr32(q(v,a),27) + \
|
|
106
|
-
f(q(v,b),q(v,c),q(v,d)) + k + h; \
|
|
107
|
-
q(v,b) = rotr32(q(v,b), 2)
|
|
108
|
-
|
|
109
|
-
#define five_cycle(v,f,k,i) \
|
|
110
|
-
one_cycle(v, 0,1,2,3,4, f,k,hf(i )); \
|
|
111
|
-
one_cycle(v, 4,0,1,2,3, f,k,hf(i+1)); \
|
|
112
|
-
one_cycle(v, 3,4,0,1,2, f,k,hf(i+2)); \
|
|
113
|
-
one_cycle(v, 2,3,4,0,1, f,k,hf(i+3)); \
|
|
114
|
-
one_cycle(v, 1,2,3,4,0, f,k,hf(i+4))
|
|
115
|
-
|
|
116
|
-
VOID_RETURN sha1_compile(sha1_ctx ctx[1])
|
|
117
|
-
{ uint_32t *w = ctx->wbuf;
|
|
118
|
-
|
|
119
|
-
#ifdef ARRAY
|
|
120
|
-
uint_32t v[5];
|
|
121
|
-
memcpy(v, ctx->hash, 5 * sizeof(uint_32t));
|
|
122
|
-
#else
|
|
123
|
-
uint_32t v0, v1, v2, v3, v4;
|
|
124
|
-
v0 = ctx->hash[0]; v1 = ctx->hash[1];
|
|
125
|
-
v2 = ctx->hash[2]; v3 = ctx->hash[3];
|
|
126
|
-
v4 = ctx->hash[4];
|
|
127
|
-
#endif
|
|
128
|
-
|
|
129
|
-
#define hf(i) w[i]
|
|
130
|
-
|
|
131
|
-
five_cycle(v, ch, 0x5a827999, 0);
|
|
132
|
-
five_cycle(v, ch, 0x5a827999, 5);
|
|
133
|
-
five_cycle(v, ch, 0x5a827999, 10);
|
|
134
|
-
one_cycle(v,0,1,2,3,4, ch, 0x5a827999, hf(15)); \
|
|
135
|
-
|
|
136
|
-
#undef hf
|
|
137
|
-
#define hf(i) (w[(i) & 15] = rotl32( \
|
|
138
|
-
w[((i) + 13) & 15] ^ w[((i) + 8) & 15] \
|
|
139
|
-
^ w[((i) + 2) & 15] ^ w[(i) & 15], 1))
|
|
140
|
-
|
|
141
|
-
one_cycle(v,4,0,1,2,3, ch, 0x5a827999, hf(16));
|
|
142
|
-
one_cycle(v,3,4,0,1,2, ch, 0x5a827999, hf(17));
|
|
143
|
-
one_cycle(v,2,3,4,0,1, ch, 0x5a827999, hf(18));
|
|
144
|
-
one_cycle(v,1,2,3,4,0, ch, 0x5a827999, hf(19));
|
|
145
|
-
|
|
146
|
-
five_cycle(v, parity, 0x6ed9eba1, 20);
|
|
147
|
-
five_cycle(v, parity, 0x6ed9eba1, 25);
|
|
148
|
-
five_cycle(v, parity, 0x6ed9eba1, 30);
|
|
149
|
-
five_cycle(v, parity, 0x6ed9eba1, 35);
|
|
150
|
-
|
|
151
|
-
five_cycle(v, maj, 0x8f1bbcdc, 40);
|
|
152
|
-
five_cycle(v, maj, 0x8f1bbcdc, 45);
|
|
153
|
-
five_cycle(v, maj, 0x8f1bbcdc, 50);
|
|
154
|
-
five_cycle(v, maj, 0x8f1bbcdc, 55);
|
|
155
|
-
|
|
156
|
-
five_cycle(v, parity, 0xca62c1d6, 60);
|
|
157
|
-
five_cycle(v, parity, 0xca62c1d6, 65);
|
|
158
|
-
five_cycle(v, parity, 0xca62c1d6, 70);
|
|
159
|
-
five_cycle(v, parity, 0xca62c1d6, 75);
|
|
160
|
-
|
|
161
|
-
#ifdef ARRAY
|
|
162
|
-
ctx->hash[0] += v[0]; ctx->hash[1] += v[1];
|
|
163
|
-
ctx->hash[2] += v[2]; ctx->hash[3] += v[3];
|
|
164
|
-
ctx->hash[4] += v[4];
|
|
165
|
-
#else
|
|
166
|
-
ctx->hash[0] += v0; ctx->hash[1] += v1;
|
|
167
|
-
ctx->hash[2] += v2; ctx->hash[3] += v3;
|
|
168
|
-
ctx->hash[4] += v4;
|
|
169
|
-
#endif
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
VOID_RETURN sha1_begin(sha1_ctx ctx[1])
|
|
173
|
-
{
|
|
174
|
-
ctx->count[0] = ctx->count[1] = 0;
|
|
175
|
-
ctx->hash[0] = 0x67452301;
|
|
176
|
-
ctx->hash[1] = 0xefcdab89;
|
|
177
|
-
ctx->hash[2] = 0x98badcfe;
|
|
178
|
-
ctx->hash[3] = 0x10325476;
|
|
179
|
-
ctx->hash[4] = 0xc3d2e1f0;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/* SHA1 hash data in an array of bytes into hash buffer and */
|
|
183
|
-
/* call the hash_compile function as required. */
|
|
184
|
-
|
|
185
|
-
VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1])
|
|
186
|
-
{ uint_32t pos = (uint_32t)(ctx->count[0] & SHA1_MASK),
|
|
187
|
-
space = SHA1_BLOCK_SIZE - pos;
|
|
188
|
-
const unsigned char *sp = data;
|
|
189
|
-
|
|
190
|
-
if((ctx->count[0] += len) < len)
|
|
191
|
-
++(ctx->count[1]);
|
|
192
|
-
|
|
193
|
-
while(len >= space) /* tranfer whole blocks if possible */
|
|
194
|
-
{
|
|
195
|
-
memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space);
|
|
196
|
-
sp += space; len -= space; space = SHA1_BLOCK_SIZE; pos = 0;
|
|
197
|
-
bsw_32(ctx->wbuf, SHA1_BLOCK_SIZE >> 2);
|
|
198
|
-
sha1_compile(ctx);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
memcpy(((unsigned char*)ctx->wbuf) + pos, sp, len);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/* SHA1 final padding and digest calculation */
|
|
205
|
-
|
|
206
|
-
VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1])
|
|
207
|
-
{ uint_32t i = (uint_32t)(ctx->count[0] & SHA1_MASK);
|
|
208
|
-
|
|
209
|
-
/* put bytes in the buffer in an order in which references to */
|
|
210
|
-
/* 32-bit words will put bytes with lower addresses into the */
|
|
211
|
-
/* top of 32 bit words on BOTH big and little endian machines */
|
|
212
|
-
bsw_32(ctx->wbuf, (i + 3) >> 2);
|
|
213
|
-
|
|
214
|
-
/* we now need to mask valid bytes and add the padding which is */
|
|
215
|
-
/* a single 1 bit and as many zero bits as necessary. Note that */
|
|
216
|
-
/* we can always add the first padding byte here because the */
|
|
217
|
-
/* buffer always has at least one empty slot */
|
|
218
|
-
ctx->wbuf[i >> 2] &= 0xffffff80 << 8 * (~i & 3);
|
|
219
|
-
ctx->wbuf[i >> 2] |= 0x00000080 << 8 * (~i & 3);
|
|
220
|
-
|
|
221
|
-
/* we need 9 or more empty positions, one for the padding byte */
|
|
222
|
-
/* (above) and eight for the length count. If there is not */
|
|
223
|
-
/* enough space, pad and empty the buffer */
|
|
224
|
-
if(i > SHA1_BLOCK_SIZE - 9)
|
|
225
|
-
{
|
|
226
|
-
if(i < 60) ctx->wbuf[15] = 0;
|
|
227
|
-
sha1_compile(ctx);
|
|
228
|
-
i = 0;
|
|
229
|
-
}
|
|
230
|
-
else /* compute a word index for the empty buffer positions */
|
|
231
|
-
i = (i >> 2) + 1;
|
|
232
|
-
|
|
233
|
-
while(i < 14) /* and zero pad all but last two positions */
|
|
234
|
-
ctx->wbuf[i++] = 0;
|
|
235
|
-
|
|
236
|
-
/* the following 32-bit length fields are assembled in the */
|
|
237
|
-
/* wrong byte order on little endian machines but this is */
|
|
238
|
-
/* corrected later since they are only ever used as 32-bit */
|
|
239
|
-
/* word values. */
|
|
240
|
-
ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 29);
|
|
241
|
-
ctx->wbuf[15] = ctx->count[0] << 3;
|
|
242
|
-
sha1_compile(ctx);
|
|
243
|
-
|
|
244
|
-
/* extract the hash value as bytes in case the hash buffer is */
|
|
245
|
-
/* misaligned for 32-bit words */
|
|
246
|
-
for(i = 0; i < SHA1_DIGEST_SIZE; ++i)
|
|
247
|
-
hval[i] = (unsigned char)(ctx->hash[i >> 2] >> (8 * (~i & 3)));
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len)
|
|
251
|
-
{ sha1_ctx cx[1];
|
|
252
|
-
|
|
253
|
-
sha1_begin(cx); sha1_hash(data, len, cx); sha1_end(hval, cx);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
#if defined(__cplusplus)
|
|
257
|
-
}
|
|
258
|
-
#endif
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
---------------------------------------------------------------------------
|
|
3
|
-
Copyright (c) 2002, Dr Brian Gladman, Worcester, UK. All rights reserved.
|
|
4
|
-
|
|
5
|
-
LICENSE TERMS
|
|
6
|
-
|
|
7
|
-
The free distribution and use of this software in both source and binary
|
|
8
|
-
form is allowed (with or without changes) provided that:
|
|
9
|
-
|
|
10
|
-
1. distributions of this source code include the above copyright
|
|
11
|
-
notice, this list of conditions and the following disclaimer;
|
|
12
|
-
|
|
13
|
-
2. distributions in binary form include the above copyright
|
|
14
|
-
notice, this list of conditions and the following disclaimer
|
|
15
|
-
in the documentation and/or other associated materials;
|
|
16
|
-
|
|
17
|
-
3. the copyright holder's name is not used to endorse products
|
|
18
|
-
built using this software without specific written permission.
|
|
19
|
-
|
|
20
|
-
ALTERNATIVELY, provided that this notice is retained in full, this product
|
|
21
|
-
may be distributed under the terms of the GNU General Public License (GPL),
|
|
22
|
-
in which case the provisions of the GPL apply INSTEAD OF those given above.
|
|
23
|
-
|
|
24
|
-
DISCLAIMER
|
|
25
|
-
|
|
26
|
-
This software is provided 'as is' with no explicit or implied warranties
|
|
27
|
-
in respect of its properties, including, but not limited to, correctness
|
|
28
|
-
and/or fitness for purpose.
|
|
29
|
-
---------------------------------------------------------------------------
|
|
30
|
-
Issue Date: 01/08/2005
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
#ifndef _SHA1_H
|
|
34
|
-
#define _SHA1_H
|
|
35
|
-
|
|
36
|
-
#include <stdlib.h>
|
|
37
|
-
#include "brg_types.h"
|
|
38
|
-
|
|
39
|
-
#define SHA1_BLOCK_SIZE 64
|
|
40
|
-
#define SHA1_DIGEST_SIZE 20
|
|
41
|
-
|
|
42
|
-
#if defined(__cplusplus)
|
|
43
|
-
extern "C"
|
|
44
|
-
{
|
|
45
|
-
#endif
|
|
46
|
-
|
|
47
|
-
/* type to hold the SHA256 context */
|
|
48
|
-
|
|
49
|
-
typedef struct
|
|
50
|
-
{ uint_32t count[2];
|
|
51
|
-
uint_32t hash[5];
|
|
52
|
-
uint_32t wbuf[16];
|
|
53
|
-
} sha1_ctx;
|
|
54
|
-
|
|
55
|
-
/* Note that these prototypes are the same for both bit and */
|
|
56
|
-
/* byte oriented implementations. However the length fields */
|
|
57
|
-
/* are in bytes or bits as appropriate for the version used */
|
|
58
|
-
/* and bit sequences are input as arrays of bytes in which */
|
|
59
|
-
/* bit sequences run from the most to the least significant */
|
|
60
|
-
/* end of each byte */
|
|
61
|
-
|
|
62
|
-
VOID_RETURN sha1_compile(sha1_ctx ctx[1]);
|
|
63
|
-
|
|
64
|
-
VOID_RETURN sha1_begin(sha1_ctx ctx[1]);
|
|
65
|
-
VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]);
|
|
66
|
-
VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
|
|
67
|
-
VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len);
|
|
68
|
-
|
|
69
|
-
#if defined(__cplusplus)
|
|
70
|
-
}
|
|
71
|
-
#endif
|
|
72
|
-
|
|
73
|
-
#endif
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/* crypt.h -- base code for traditional PKWARE encryption
|
|
2
|
-
Version 1.01e, February 12th, 2005
|
|
3
|
-
|
|
4
|
-
Copyright (C) 1998-2005 Gilles Vollant
|
|
5
|
-
Modifications for Info-ZIP crypting
|
|
6
|
-
Copyright (C) 2003 Terry Thorsen
|
|
7
|
-
|
|
8
|
-
This code is a modified version of crypting code in Info-ZIP distribution
|
|
9
|
-
|
|
10
|
-
Copyright (C) 1990-2000 Info-ZIP. All rights reserved.
|
|
11
|
-
|
|
12
|
-
See the Info-ZIP LICENSE file version 2000-Apr-09 or later for terms of use
|
|
13
|
-
which also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
|
|
14
|
-
|
|
15
|
-
The encryption/decryption parts of this source code (as opposed to the
|
|
16
|
-
non-echoing password parts) were originally written in Europe. The
|
|
17
|
-
whole source package can be freely distributed, including from the USA.
|
|
18
|
-
(Prior to January 2000, re-export from the US was a violation of US law.)
|
|
19
|
-
|
|
20
|
-
This encryption code is a direct transcription of the algorithm from
|
|
21
|
-
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
|
22
|
-
file (appnote.txt) is distributed with the PKZIP program (even in the
|
|
23
|
-
version without encryption capabilities).
|
|
24
|
-
|
|
25
|
-
If you don't need crypting in your application, just define symbols
|
|
26
|
-
NOCRYPT and NOUNCRYPT.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
|
30
|
-
|
|
31
|
-
/***********************************************************************
|
|
32
|
-
* Return the next byte in the pseudo-random sequence
|
|
33
|
-
*/
|
|
34
|
-
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
|
|
35
|
-
{
|
|
36
|
-
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
|
37
|
-
* unpredictable manner on 16-bit systems; not a problem
|
|
38
|
-
* with any known compiler so far, though */
|
|
39
|
-
|
|
40
|
-
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
|
|
41
|
-
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/***********************************************************************
|
|
45
|
-
* Update the encryption keys with the next byte of plain text
|
|
46
|
-
*/
|
|
47
|
-
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
|
|
48
|
-
{
|
|
49
|
-
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
|
50
|
-
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
|
51
|
-
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
|
|
52
|
-
{
|
|
53
|
-
register int keyshift = (int)((*(pkeys+1)) >> 24);
|
|
54
|
-
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
|
|
55
|
-
}
|
|
56
|
-
return c;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/***********************************************************************
|
|
61
|
-
* Initialize the encryption keys and the random header according to
|
|
62
|
-
* the given password.
|
|
63
|
-
*/
|
|
64
|
-
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
|
|
65
|
-
{
|
|
66
|
-
*(pkeys+0) = 305419896L;
|
|
67
|
-
*(pkeys+1) = 591751049L;
|
|
68
|
-
*(pkeys+2) = 878082192L;
|
|
69
|
-
while (*passwd != 0) {
|
|
70
|
-
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
|
|
71
|
-
passwd++;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
#define zdecode(pkeys,pcrc_32_tab,c) \
|
|
76
|
-
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
|
|
77
|
-
|
|
78
|
-
#define zencode(pkeys,pcrc_32_tab,c,t) \
|
|
79
|
-
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
|
|
80
|
-
|
|
81
|
-
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
|
|
82
|
-
|
|
83
|
-
#define RAND_HEAD_LEN 12
|
|
84
|
-
/* "last resort" source for second part of crypt seed pattern */
|
|
85
|
-
# ifndef ZCR_SEED2
|
|
86
|
-
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
|
87
|
-
# endif
|
|
88
|
-
|
|
89
|
-
static int crypthead(const char* passwd, /* password string */
|
|
90
|
-
unsigned char* buf, /* where to write header */
|
|
91
|
-
int bufSize,
|
|
92
|
-
unsigned long* pkeys,
|
|
93
|
-
const unsigned long* pcrc_32_tab,
|
|
94
|
-
unsigned long crcForCrypting)
|
|
95
|
-
{
|
|
96
|
-
int n; /* index in random header */
|
|
97
|
-
int t; /* temporary */
|
|
98
|
-
int c; /* random byte */
|
|
99
|
-
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
|
|
100
|
-
static unsigned calls = 0; /* ensure different random header each time */
|
|
101
|
-
|
|
102
|
-
if (bufSize<RAND_HEAD_LEN)
|
|
103
|
-
return 0;
|
|
104
|
-
|
|
105
|
-
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
|
|
106
|
-
* output of rand() to get less predictability, since rand() is
|
|
107
|
-
* often poorly implemented.
|
|
108
|
-
*/
|
|
109
|
-
if (++calls == 1)
|
|
110
|
-
{
|
|
111
|
-
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
|
|
112
|
-
}
|
|
113
|
-
init_keys(passwd, pkeys, pcrc_32_tab);
|
|
114
|
-
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
|
115
|
-
{
|
|
116
|
-
c = (rand() >> 7) & 0xff;
|
|
117
|
-
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
|
|
118
|
-
}
|
|
119
|
-
/* Encrypt random header (last two bytes is high word of crc) */
|
|
120
|
-
init_keys(passwd, pkeys, pcrc_32_tab);
|
|
121
|
-
for (n = 0; n < RAND_HEAD_LEN-2; n++)
|
|
122
|
-
{
|
|
123
|
-
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
|
124
|
-
}
|
|
125
|
-
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
|
126
|
-
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
|
127
|
-
return n;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
#endif
|