@appzung/react-native-code-push 8.3.2 → 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/CodePush.podspec +3 -3
- package/README.md +3 -1
- package/android/app/build.gradle +2 -0
- package/android/app/src/main/AndroidManifest.xml +1 -2
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +15 -8
- package/android/build.gradle +3 -0
- package/ios/CodePush/CodePush.m +2 -1
- 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/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,219 +0,0 @@
|
|
|
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
|
-
The unsigned integer types defined here are of the form uint_<nn>t where
|
|
21
|
-
<nn> is the length of the type; for example, the unsigned 32-bit type is
|
|
22
|
-
'uint_32t'. These are NOT the same as the 'C99 integer types' that are
|
|
23
|
-
defined in the inttypes.h and stdint.h headers since attempts to use these
|
|
24
|
-
types have shown that support for them is still highly variable. However,
|
|
25
|
-
since the latter are of the form uint<nn>_t, a regular expression search
|
|
26
|
-
and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t')
|
|
27
|
-
can be used to convert the types used here to the C99 standard types.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#ifndef _BRG_TYPES_H
|
|
31
|
-
#define _BRG_TYPES_H
|
|
32
|
-
|
|
33
|
-
#if defined(__cplusplus)
|
|
34
|
-
extern "C" {
|
|
35
|
-
#endif
|
|
36
|
-
|
|
37
|
-
#include <limits.h>
|
|
38
|
-
|
|
39
|
-
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
|
|
40
|
-
# include <stddef.h>
|
|
41
|
-
# define ptrint_t intptr_t
|
|
42
|
-
#elif defined( __ECOS__ )
|
|
43
|
-
# define intptr_t unsigned int
|
|
44
|
-
# define ptrint_t intptr_t
|
|
45
|
-
#elif defined( __GNUC__ ) && ( __GNUC__ >= 3 )
|
|
46
|
-
# include <stdint.h>
|
|
47
|
-
# define ptrint_t intptr_t
|
|
48
|
-
#else
|
|
49
|
-
# define ptrint_t int
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
#ifndef BRG_UI8
|
|
53
|
-
# define BRG_UI8
|
|
54
|
-
# if UCHAR_MAX == 255u
|
|
55
|
-
typedef unsigned char uint_8t;
|
|
56
|
-
# else
|
|
57
|
-
# error Please define uint_8t as an 8-bit unsigned integer type in brg_types.h
|
|
58
|
-
# endif
|
|
59
|
-
#endif
|
|
60
|
-
|
|
61
|
-
#ifndef BRG_UI16
|
|
62
|
-
# define BRG_UI16
|
|
63
|
-
# if USHRT_MAX == 65535u
|
|
64
|
-
typedef unsigned short uint_16t;
|
|
65
|
-
# else
|
|
66
|
-
# error Please define uint_16t as a 16-bit unsigned short type in brg_types.h
|
|
67
|
-
# endif
|
|
68
|
-
#endif
|
|
69
|
-
|
|
70
|
-
#ifndef BRG_UI32
|
|
71
|
-
# define BRG_UI32
|
|
72
|
-
# if UINT_MAX == 4294967295u
|
|
73
|
-
# define li_32(h) 0x##h##u
|
|
74
|
-
typedef unsigned int uint_32t;
|
|
75
|
-
# elif ULONG_MAX == 4294967295u
|
|
76
|
-
# define li_32(h) 0x##h##ul
|
|
77
|
-
typedef unsigned long uint_32t;
|
|
78
|
-
# elif defined( _CRAY )
|
|
79
|
-
# error This code needs 32-bit data types, which Cray machines do not provide
|
|
80
|
-
# else
|
|
81
|
-
# error Please define uint_32t as a 32-bit unsigned integer type in brg_types.h
|
|
82
|
-
# endif
|
|
83
|
-
#endif
|
|
84
|
-
|
|
85
|
-
#ifndef BRG_UI64
|
|
86
|
-
# if defined( __BORLANDC__ ) && !defined( __MSDOS__ )
|
|
87
|
-
# define BRG_UI64
|
|
88
|
-
# define li_64(h) 0x##h##ui64
|
|
89
|
-
typedef unsigned __int64 uint_64t;
|
|
90
|
-
# elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */
|
|
91
|
-
# define BRG_UI64
|
|
92
|
-
# define li_64(h) 0x##h##ui64
|
|
93
|
-
typedef unsigned __int64 uint_64t;
|
|
94
|
-
# elif defined( __sun ) && defined( ULONG_MAX ) && ULONG_MAX == 0xfffffffful
|
|
95
|
-
# define BRG_UI64
|
|
96
|
-
# define li_64(h) 0x##h##ull
|
|
97
|
-
typedef unsigned long long uint_64t;
|
|
98
|
-
# elif defined( __MVS__ )
|
|
99
|
-
# define BRG_UI64
|
|
100
|
-
# define li_64(h) 0x##h##ull
|
|
101
|
-
typedef unsigned int long long uint_64t;
|
|
102
|
-
# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u
|
|
103
|
-
# if UINT_MAX == 18446744073709551615u
|
|
104
|
-
# define BRG_UI64
|
|
105
|
-
# define li_64(h) 0x##h##u
|
|
106
|
-
typedef unsigned int uint_64t;
|
|
107
|
-
# endif
|
|
108
|
-
# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u
|
|
109
|
-
# if ULONG_MAX == 18446744073709551615ul
|
|
110
|
-
# define BRG_UI64
|
|
111
|
-
# define li_64(h) 0x##h##ul
|
|
112
|
-
typedef unsigned long uint_64t;
|
|
113
|
-
# endif
|
|
114
|
-
# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u
|
|
115
|
-
# if ULLONG_MAX == 18446744073709551615ull
|
|
116
|
-
# define BRG_UI64
|
|
117
|
-
# define li_64(h) 0x##h##ull
|
|
118
|
-
typedef unsigned long long uint_64t;
|
|
119
|
-
# endif
|
|
120
|
-
# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u
|
|
121
|
-
# if ULONG_LONG_MAX == 18446744073709551615ull
|
|
122
|
-
# define BRG_UI64
|
|
123
|
-
# define li_64(h) 0x##h##ull
|
|
124
|
-
typedef unsigned long long uint_64t;
|
|
125
|
-
# endif
|
|
126
|
-
# endif
|
|
127
|
-
#endif
|
|
128
|
-
|
|
129
|
-
#if !defined( BRG_UI64 )
|
|
130
|
-
# if defined( NEED_UINT_64T )
|
|
131
|
-
# error Please define uint_64t as an unsigned 64 bit type in brg_types.h
|
|
132
|
-
# endif
|
|
133
|
-
#endif
|
|
134
|
-
|
|
135
|
-
#ifndef RETURN_VALUES
|
|
136
|
-
# define RETURN_VALUES
|
|
137
|
-
# if defined( DLL_EXPORT )
|
|
138
|
-
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
|
|
139
|
-
# define VOID_RETURN __declspec( dllexport ) void __stdcall
|
|
140
|
-
# define INT_RETURN __declspec( dllexport ) int __stdcall
|
|
141
|
-
# elif defined( __GNUC__ )
|
|
142
|
-
# define VOID_RETURN __declspec( __dllexport__ ) void
|
|
143
|
-
# define INT_RETURN __declspec( __dllexport__ ) int
|
|
144
|
-
# else
|
|
145
|
-
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
|
|
146
|
-
# endif
|
|
147
|
-
# elif defined( DLL_IMPORT )
|
|
148
|
-
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
|
|
149
|
-
# define VOID_RETURN __declspec( dllimport ) void __stdcall
|
|
150
|
-
# define INT_RETURN __declspec( dllimport ) int __stdcall
|
|
151
|
-
# elif defined( __GNUC__ )
|
|
152
|
-
# define VOID_RETURN __declspec( __dllimport__ ) void
|
|
153
|
-
# define INT_RETURN __declspec( __dllimport__ ) int
|
|
154
|
-
# else
|
|
155
|
-
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
|
|
156
|
-
# endif
|
|
157
|
-
# elif defined( __WATCOMC__ )
|
|
158
|
-
# define VOID_RETURN void __cdecl
|
|
159
|
-
# define INT_RETURN int __cdecl
|
|
160
|
-
# else
|
|
161
|
-
# define VOID_RETURN void
|
|
162
|
-
# define INT_RETURN int
|
|
163
|
-
# endif
|
|
164
|
-
#endif
|
|
165
|
-
|
|
166
|
-
/* These defines are used to detect and set the memory alignment of pointers.
|
|
167
|
-
Note that offsets are in bytes.
|
|
168
|
-
|
|
169
|
-
ALIGN_OFFSET(x,n) return the positive or zero offset of
|
|
170
|
-
the memory addressed by the pointer 'x'
|
|
171
|
-
from an address that is aligned on an
|
|
172
|
-
'n' byte boundary ('n' is a power of 2)
|
|
173
|
-
|
|
174
|
-
ALIGN_FLOOR(x,n) return a pointer that points to memory
|
|
175
|
-
that is aligned on an 'n' byte boundary
|
|
176
|
-
and is not higher than the memory address
|
|
177
|
-
pointed to by 'x' ('n' is a power of 2)
|
|
178
|
-
|
|
179
|
-
ALIGN_CEIL(x,n) return a pointer that points to memory
|
|
180
|
-
that is aligned on an 'n' byte boundary
|
|
181
|
-
and is not lower than the memory address
|
|
182
|
-
pointed to by 'x' ('n' is a power of 2)
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
|
-
#define ALIGN_OFFSET(x,n) (((ptrint_t)(x)) & ((n) - 1))
|
|
186
|
-
#define ALIGN_FLOOR(x,n) ((uint_8t*)(x) - ( ((ptrint_t)(x)) & ((n) - 1)))
|
|
187
|
-
#define ALIGN_CEIL(x,n) ((uint_8t*)(x) + (-((ptrint_t)(x)) & ((n) - 1)))
|
|
188
|
-
|
|
189
|
-
/* These defines are used to declare buffers in a way that allows
|
|
190
|
-
faster operations on longer variables to be used. In all these
|
|
191
|
-
defines 'size' must be a power of 2 and >= 8. NOTE that the
|
|
192
|
-
buffer size is in bytes but the type length is in bits
|
|
193
|
-
|
|
194
|
-
UNIT_TYPEDEF(x,size) declares a variable 'x' of length
|
|
195
|
-
'size' bits
|
|
196
|
-
|
|
197
|
-
BUFR_TYPEDEF(x,size,bsize) declares a buffer 'x' of length 'bsize'
|
|
198
|
-
bytes defined as an array of variables
|
|
199
|
-
each of 'size' bits (bsize must be a
|
|
200
|
-
multiple of size / 8)
|
|
201
|
-
|
|
202
|
-
UNIT_CAST(x,size) casts a variable to a type of
|
|
203
|
-
length 'size' bits
|
|
204
|
-
|
|
205
|
-
UPTR_CAST(x,size) casts a pointer to a pointer to a
|
|
206
|
-
varaiable of length 'size' bits
|
|
207
|
-
*/
|
|
208
|
-
|
|
209
|
-
#define UI_TYPE(size) uint_##size##t
|
|
210
|
-
#define UNIT_TYPEDEF(x,size) typedef UI_TYPE(size) x
|
|
211
|
-
#define BUFR_TYPEDEF(x,size,bsize) typedef UI_TYPE(size) x[bsize / (size >> 3)]
|
|
212
|
-
#define UNIT_CAST(x,size) ((UI_TYPE(size) )(x))
|
|
213
|
-
#define UPTR_CAST(x,size) ((UI_TYPE(size)*)(x))
|
|
214
|
-
|
|
215
|
-
#if defined(__cplusplus)
|
|
216
|
-
}
|
|
217
|
-
#endif
|
|
218
|
-
|
|
219
|
-
#endif
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#ifdef _WIN32
|
|
2
|
-
#include <windows.h>
|
|
3
|
-
#else
|
|
4
|
-
#include <sys/stat.h>
|
|
5
|
-
#include <fcntl.h>
|
|
6
|
-
#include <unistd.h>
|
|
7
|
-
#endif
|
|
8
|
-
|
|
9
|
-
#if defined(__cplusplus)
|
|
10
|
-
extern "C"
|
|
11
|
-
{
|
|
12
|
-
#endif
|
|
13
|
-
|
|
14
|
-
#ifdef _WIN32
|
|
15
|
-
int entropy_fun(unsigned char buf[], unsigned int len)
|
|
16
|
-
{
|
|
17
|
-
HCRYPTPROV provider;
|
|
18
|
-
unsigned __int64 pentium_tsc[1];
|
|
19
|
-
unsigned int i;
|
|
20
|
-
int result = 0;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
|
|
24
|
-
{
|
|
25
|
-
result = CryptGenRandom(provider, len, buf);
|
|
26
|
-
CryptReleaseContext(provider, 0);
|
|
27
|
-
if (result)
|
|
28
|
-
return len;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc);
|
|
32
|
-
|
|
33
|
-
for(i = 0; i < 8 && i < len; ++i)
|
|
34
|
-
buf[i] = ((unsigned char*)pentium_tsc)[i];
|
|
35
|
-
|
|
36
|
-
return i;
|
|
37
|
-
}
|
|
38
|
-
#else
|
|
39
|
-
int entropy_fun(unsigned char buf[], unsigned int len)
|
|
40
|
-
{
|
|
41
|
-
int frand = open("/dev/random", O_RDONLY);
|
|
42
|
-
int rlen = 0;
|
|
43
|
-
if (frand != -1)
|
|
44
|
-
{
|
|
45
|
-
rlen = (int)read(frand, buf, len);
|
|
46
|
-
close(frand);
|
|
47
|
-
}
|
|
48
|
-
return rlen;
|
|
49
|
-
}
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
#if defined(__cplusplus)
|
|
53
|
-
}
|
|
54
|
-
#endif
|
|
@@ -1,144 +0,0 @@
|
|
|
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: 24/01/2003
|
|
32
|
-
|
|
33
|
-
This file implements password based file encryption and authentication
|
|
34
|
-
using AES in CTR mode, HMAC-SHA1 authentication and RFC2898 password
|
|
35
|
-
based key derivation.
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
#include <memory.h>
|
|
40
|
-
|
|
41
|
-
#include "fileenc.h"
|
|
42
|
-
|
|
43
|
-
#if defined(__cplusplus)
|
|
44
|
-
extern "C"
|
|
45
|
-
{
|
|
46
|
-
#endif
|
|
47
|
-
|
|
48
|
-
/* subroutine for data encryption/decryption */
|
|
49
|
-
/* this could be speeded up a lot by aligning */
|
|
50
|
-
/* buffers and using 32 bit operations */
|
|
51
|
-
|
|
52
|
-
static void encr_data(unsigned char data[], unsigned long d_len, fcrypt_ctx cx[1])
|
|
53
|
-
{
|
|
54
|
-
unsigned long i = 0, pos = cx->encr_pos;
|
|
55
|
-
|
|
56
|
-
while (i < d_len) {
|
|
57
|
-
if (pos == AES_BLOCK_SIZE) {
|
|
58
|
-
unsigned int j = 0;
|
|
59
|
-
/* increment encryption nonce */
|
|
60
|
-
while (j < 8 && !++cx->nonce[j])
|
|
61
|
-
++j;
|
|
62
|
-
/* encrypt the nonce to form next xor buffer */
|
|
63
|
-
aes_encrypt(cx->nonce, cx->encr_bfr, cx->encr_ctx);
|
|
64
|
-
pos = 0;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
data[i++] ^= cx->encr_bfr[pos++];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
cx->encr_pos = (unsigned int)pos;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
int fcrypt_init(
|
|
74
|
-
int mode, /* the mode to be used (input) */
|
|
75
|
-
const unsigned char pwd[], /* the user specified password (input) */
|
|
76
|
-
unsigned int pwd_len, /* the length of the password (input) */
|
|
77
|
-
const unsigned char salt[], /* the salt (input) */
|
|
78
|
-
#ifdef PASSWORD_VERIFIER
|
|
79
|
-
unsigned char pwd_ver[PWD_VER_LENGTH], /* 2 byte password verifier (output) */
|
|
80
|
-
#endif
|
|
81
|
-
fcrypt_ctx cx[1]) /* the file encryption context (output) */
|
|
82
|
-
{
|
|
83
|
-
unsigned char kbuf[2 * MAX_KEY_LENGTH + PWD_VER_LENGTH];
|
|
84
|
-
|
|
85
|
-
if (pwd_len > MAX_PWD_LENGTH)
|
|
86
|
-
return PASSWORD_TOO_LONG;
|
|
87
|
-
|
|
88
|
-
if (mode < 1 || mode > 3)
|
|
89
|
-
return BAD_MODE;
|
|
90
|
-
|
|
91
|
-
cx->mode = mode;
|
|
92
|
-
cx->pwd_len = pwd_len;
|
|
93
|
-
|
|
94
|
-
/* derive the encryption and authentication keys and the password verifier */
|
|
95
|
-
derive_key(pwd, pwd_len, salt, SALT_LENGTH(mode), KEYING_ITERATIONS,
|
|
96
|
-
kbuf, 2 * KEY_LENGTH(mode) + PWD_VER_LENGTH);
|
|
97
|
-
|
|
98
|
-
/* initialise the encryption nonce and buffer pos */
|
|
99
|
-
cx->encr_pos = AES_BLOCK_SIZE;
|
|
100
|
-
/* if we need a random component in the encryption */
|
|
101
|
-
/* nonce, this is where it would have to be set */
|
|
102
|
-
memset(cx->nonce, 0, AES_BLOCK_SIZE * sizeof(unsigned char));
|
|
103
|
-
|
|
104
|
-
/* initialise for encryption using key 1 */
|
|
105
|
-
aes_encrypt_key(kbuf, KEY_LENGTH(mode), cx->encr_ctx);
|
|
106
|
-
|
|
107
|
-
/* initialise for authentication using key 2 */
|
|
108
|
-
hmac_sha_begin(cx->auth_ctx);
|
|
109
|
-
hmac_sha_key(kbuf + KEY_LENGTH(mode), KEY_LENGTH(mode), cx->auth_ctx);
|
|
110
|
-
|
|
111
|
-
#ifdef PASSWORD_VERIFIER
|
|
112
|
-
memcpy(pwd_ver, kbuf + 2 * KEY_LENGTH(mode), PWD_VER_LENGTH);
|
|
113
|
-
#endif
|
|
114
|
-
|
|
115
|
-
return GOOD_RETURN;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/* perform 'in place' encryption and authentication */
|
|
119
|
-
|
|
120
|
-
void fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
|
|
121
|
-
{
|
|
122
|
-
encr_data(data, data_len, cx);
|
|
123
|
-
hmac_sha_data(data, data_len, cx->auth_ctx);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* perform 'in place' authentication and decryption */
|
|
127
|
-
|
|
128
|
-
void fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1])
|
|
129
|
-
{
|
|
130
|
-
hmac_sha_data(data, data_len, cx->auth_ctx);
|
|
131
|
-
encr_data(data, data_len, cx);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/* close encryption/decryption and return the MAC value */
|
|
135
|
-
|
|
136
|
-
int fcrypt_end(unsigned char mac[], fcrypt_ctx cx[1])
|
|
137
|
-
{
|
|
138
|
-
hmac_sha_end(mac, MAC_LENGTH(cx->mode), cx->auth_ctx);
|
|
139
|
-
return MAC_LENGTH(cx->mode); /* return MAC length in bytes */
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
#if defined(__cplusplus)
|
|
143
|
-
}
|
|
144
|
-
#endif
|
|
@@ -1,121 +0,0 @@
|
|
|
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: 24/01/2003
|
|
32
|
-
|
|
33
|
-
This file contains the header file for fileenc.c, which implements password
|
|
34
|
-
based file encryption and authentication using AES in CTR mode, HMAC-SHA1
|
|
35
|
-
authentication and RFC2898 password based key derivation.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
#ifndef _FENC_H
|
|
39
|
-
#define _FENC_H
|
|
40
|
-
|
|
41
|
-
#include "aes.h"
|
|
42
|
-
#include "hmac.h"
|
|
43
|
-
#include "pwd2key.h"
|
|
44
|
-
|
|
45
|
-
#define PASSWORD_VERIFIER
|
|
46
|
-
|
|
47
|
-
#define MAX_KEY_LENGTH 32
|
|
48
|
-
#define MAX_PWD_LENGTH 128
|
|
49
|
-
#define MAX_SALT_LENGTH 16
|
|
50
|
-
#define KEYING_ITERATIONS 1000
|
|
51
|
-
|
|
52
|
-
#ifdef PASSWORD_VERIFIER
|
|
53
|
-
#define PWD_VER_LENGTH 2
|
|
54
|
-
#else
|
|
55
|
-
#define PWD_VER_LENGTH 0
|
|
56
|
-
#endif
|
|
57
|
-
|
|
58
|
-
#define GOOD_RETURN 0
|
|
59
|
-
#define PASSWORD_TOO_LONG -100
|
|
60
|
-
#define BAD_MODE -101
|
|
61
|
-
|
|
62
|
-
/*
|
|
63
|
-
Field lengths (in bytes) versus File Encryption Mode (0 < mode < 4)
|
|
64
|
-
|
|
65
|
-
Mode Key Salt MAC Overhead
|
|
66
|
-
1 16 8 10 18
|
|
67
|
-
2 24 12 10 22
|
|
68
|
-
3 32 16 10 26
|
|
69
|
-
|
|
70
|
-
The following macros assume that the mode value is correct.
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
#define KEY_LENGTH(mode) (8 * (mode & 3) + 8)
|
|
74
|
-
#define SALT_LENGTH(mode) (4 * (mode & 3) + 4)
|
|
75
|
-
#define MAC_LENGTH(mode) (10)
|
|
76
|
-
|
|
77
|
-
/* the context for file encryption */
|
|
78
|
-
|
|
79
|
-
#if defined(__cplusplus)
|
|
80
|
-
extern "C"
|
|
81
|
-
{
|
|
82
|
-
#endif
|
|
83
|
-
|
|
84
|
-
typedef struct
|
|
85
|
-
{ unsigned char nonce[AES_BLOCK_SIZE]; /* the CTR nonce */
|
|
86
|
-
unsigned char encr_bfr[AES_BLOCK_SIZE]; /* encrypt buffer */
|
|
87
|
-
aes_encrypt_ctx encr_ctx[1]; /* encryption context */
|
|
88
|
-
hmac_ctx auth_ctx[1]; /* authentication context */
|
|
89
|
-
unsigned int encr_pos; /* block position (enc) */
|
|
90
|
-
unsigned int pwd_len; /* password length */
|
|
91
|
-
unsigned int mode; /* File encryption mode */
|
|
92
|
-
} fcrypt_ctx;
|
|
93
|
-
|
|
94
|
-
/* initialise file encryption or decryption */
|
|
95
|
-
|
|
96
|
-
int fcrypt_init(
|
|
97
|
-
int mode, /* the mode to be used (input) */
|
|
98
|
-
const unsigned char pwd[], /* the user specified password (input) */
|
|
99
|
-
unsigned int pwd_len, /* the length of the password (input) */
|
|
100
|
-
const unsigned char salt[], /* the salt (input) */
|
|
101
|
-
#ifdef PASSWORD_VERIFIER
|
|
102
|
-
unsigned char pwd_ver[PWD_VER_LENGTH], /* 2 byte password verifier (output) */
|
|
103
|
-
#endif
|
|
104
|
-
fcrypt_ctx cx[1]); /* the file encryption context (output) */
|
|
105
|
-
|
|
106
|
-
/* perform 'in place' encryption or decryption and authentication */
|
|
107
|
-
|
|
108
|
-
void fcrypt_encrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
|
|
109
|
-
void fcrypt_decrypt(unsigned char data[], unsigned int data_len, fcrypt_ctx cx[1]);
|
|
110
|
-
|
|
111
|
-
/* close encryption/decryption and return the MAC value */
|
|
112
|
-
/* the return value is the length of the MAC */
|
|
113
|
-
|
|
114
|
-
int fcrypt_end(unsigned char mac[], /* the MAC value (output) */
|
|
115
|
-
fcrypt_ctx cx[1]); /* the context (input) */
|
|
116
|
-
|
|
117
|
-
#if defined(__cplusplus)
|
|
118
|
-
}
|
|
119
|
-
#endif
|
|
120
|
-
|
|
121
|
-
#endif
|
|
@@ -1,145 +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: 26/08/2003
|
|
31
|
-
|
|
32
|
-
This is an implementation of HMAC, the FIPS standard keyed hash function
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
#include "hmac.h"
|
|
36
|
-
#include "brg_types.h"
|
|
37
|
-
|
|
38
|
-
#if defined(__cplusplus)
|
|
39
|
-
extern "C"
|
|
40
|
-
{
|
|
41
|
-
#endif
|
|
42
|
-
|
|
43
|
-
/* initialise the HMAC context to zero */
|
|
44
|
-
void hmac_sha_begin(hmac_ctx cx[1])
|
|
45
|
-
{
|
|
46
|
-
memset(cx, 0, sizeof(hmac_ctx));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/* input the HMAC key (can be called multiple times) */
|
|
50
|
-
int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1])
|
|
51
|
-
{
|
|
52
|
-
if(cx->klen == HMAC_IN_DATA) /* error if further key input */
|
|
53
|
-
return HMAC_BAD_MODE; /* is attempted in data mode */
|
|
54
|
-
|
|
55
|
-
if(cx->klen + key_len > HASH_INPUT_SIZE) /* if the key has to be hashed */
|
|
56
|
-
{
|
|
57
|
-
if(cx->klen <= HASH_INPUT_SIZE) /* if the hash has not yet been */
|
|
58
|
-
{ /* started, initialise it and */
|
|
59
|
-
sha_begin(cx->ctx); /* hash stored key characters */
|
|
60
|
-
sha_hash(cx->key, cx->klen, cx->ctx);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
sha_hash(key, key_len, cx->ctx); /* hash long key data into hash */
|
|
64
|
-
}
|
|
65
|
-
else /* otherwise store key data */
|
|
66
|
-
memcpy(cx->key + cx->klen, key, key_len);
|
|
67
|
-
|
|
68
|
-
cx->klen += key_len; /* update the key length count */
|
|
69
|
-
return HMAC_OK;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/* input the HMAC data (can be called multiple times) - */
|
|
73
|
-
/* note that this call terminates the key input phase */
|
|
74
|
-
void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1])
|
|
75
|
-
{ unsigned int i;
|
|
76
|
-
|
|
77
|
-
if(cx->klen != HMAC_IN_DATA) /* if not yet in data phase */
|
|
78
|
-
{
|
|
79
|
-
if(cx->klen > HASH_INPUT_SIZE) /* if key is being hashed */
|
|
80
|
-
{ /* complete the hash and */
|
|
81
|
-
sha_end(cx->key, cx->ctx); /* store the result as the */
|
|
82
|
-
cx->klen = HASH_OUTPUT_SIZE; /* key and set new length */
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/* pad the key if necessary */
|
|
86
|
-
memset(cx->key + cx->klen, 0, HASH_INPUT_SIZE - cx->klen);
|
|
87
|
-
|
|
88
|
-
/* xor ipad into key value */
|
|
89
|
-
for(i = 0; i < (HASH_INPUT_SIZE >> 2); ++i)
|
|
90
|
-
((uint_32t*)cx->key)[i] ^= 0x36363636;
|
|
91
|
-
|
|
92
|
-
/* and start hash operation */
|
|
93
|
-
sha_begin(cx->ctx);
|
|
94
|
-
sha_hash(cx->key, HASH_INPUT_SIZE, cx->ctx);
|
|
95
|
-
|
|
96
|
-
/* mark as now in data mode */
|
|
97
|
-
cx->klen = HMAC_IN_DATA;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/* hash the data (if any) */
|
|
101
|
-
if(data_len)
|
|
102
|
-
sha_hash(data, data_len, cx->ctx);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/* compute and output the MAC value */
|
|
106
|
-
void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1])
|
|
107
|
-
{ unsigned char dig[HASH_OUTPUT_SIZE];
|
|
108
|
-
unsigned int i;
|
|
109
|
-
|
|
110
|
-
/* if no data has been entered perform a null data phase */
|
|
111
|
-
if(cx->klen != HMAC_IN_DATA)
|
|
112
|
-
hmac_sha_data((const unsigned char*)0, 0, cx);
|
|
113
|
-
|
|
114
|
-
sha_end(dig, cx->ctx); /* complete the inner hash */
|
|
115
|
-
|
|
116
|
-
/* set outer key value using opad and removing ipad */
|
|
117
|
-
for(i = 0; i < (HASH_INPUT_SIZE >> 2); ++i)
|
|
118
|
-
((uint_32t*)cx->key)[i] ^= 0x36363636 ^ 0x5c5c5c5c;
|
|
119
|
-
|
|
120
|
-
/* perform the outer hash operation */
|
|
121
|
-
sha_begin(cx->ctx);
|
|
122
|
-
sha_hash(cx->key, HASH_INPUT_SIZE, cx->ctx);
|
|
123
|
-
sha_hash(dig, HASH_OUTPUT_SIZE, cx->ctx);
|
|
124
|
-
sha_end(dig, cx->ctx);
|
|
125
|
-
|
|
126
|
-
/* output the hash value */
|
|
127
|
-
for(i = 0; i < mac_len; ++i)
|
|
128
|
-
mac[i] = dig[i];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/* 'do it all in one go' subroutine */
|
|
132
|
-
void hmac_sha(const unsigned char key[], unsigned long key_len,
|
|
133
|
-
const unsigned char data[], unsigned long data_len,
|
|
134
|
-
unsigned char mac[], unsigned long mac_len)
|
|
135
|
-
{ hmac_ctx cx[1];
|
|
136
|
-
|
|
137
|
-
hmac_sha_begin(cx);
|
|
138
|
-
hmac_sha_key(key, key_len, cx);
|
|
139
|
-
hmac_sha_data(data, data_len, cx);
|
|
140
|
-
hmac_sha_end(mac, mac_len, cx);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
#if defined(__cplusplus)
|
|
144
|
-
}
|
|
145
|
-
#endif
|