react-native-mmkv-dz 2.5.1

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 (138) hide show
  1. package/LICENSE +219 -0
  2. package/MMKV/CHANGELOG.md +553 -0
  3. package/MMKV/Core/CMakeLists.txt +153 -0
  4. package/MMKV/Core/CodedInputData.cpp +228 -0
  5. package/MMKV/Core/CodedInputData.h +83 -0
  6. package/MMKV/Core/CodedInputDataCrypt.cpp +280 -0
  7. package/MMKV/Core/CodedInputDataCrypt.h +87 -0
  8. package/MMKV/Core/CodedInputDataCrypt_OSX.cpp +62 -0
  9. package/MMKV/Core/CodedInputData_OSX.cpp +92 -0
  10. package/MMKV/Core/CodedOutputData.cpp +174 -0
  11. package/MMKV/Core/CodedOutputData.h +82 -0
  12. package/MMKV/Core/Core.xcodeproj/project.pbxproj +702 -0
  13. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  14. package/MMKV/Core/Core.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  15. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/Core.xcscheme +67 -0
  16. package/MMKV/Core/Core.xcodeproj/xcshareddata/xcschemes/MMKVWatchCore.xcscheme +67 -0
  17. package/MMKV/Core/InterProcessLock.cpp +186 -0
  18. package/MMKV/Core/InterProcessLock.h +119 -0
  19. package/MMKV/Core/InterProcessLock_Android.cpp +103 -0
  20. package/MMKV/Core/InterProcessLock_Win32.cpp +108 -0
  21. package/MMKV/Core/KeyValueHolder.cpp +236 -0
  22. package/MMKV/Core/KeyValueHolder.h +118 -0
  23. package/MMKV/Core/MMBuffer.cpp +185 -0
  24. package/MMKV/Core/MMBuffer.h +107 -0
  25. package/MMKV/Core/MMKV.cpp +1418 -0
  26. package/MMKV/Core/MMKV.h +386 -0
  27. package/MMKV/Core/MMKVLog.cpp +127 -0
  28. package/MMKV/Core/MMKVLog.h +86 -0
  29. package/MMKV/Core/MMKVLog_Android.cpp +79 -0
  30. package/MMKV/Core/MMKVMetaInfo.hpp +81 -0
  31. package/MMKV/Core/MMKVPredef.h +245 -0
  32. package/MMKV/Core/MMKV_Android.cpp +259 -0
  33. package/MMKV/Core/MMKV_IO.cpp +1119 -0
  34. package/MMKV/Core/MMKV_IO.h +57 -0
  35. package/MMKV/Core/MMKV_OSX.cpp +347 -0
  36. package/MMKV/Core/MMKV_OSX.h +51 -0
  37. package/MMKV/Core/MemoryFile.cpp +537 -0
  38. package/MMKV/Core/MemoryFile.h +182 -0
  39. package/MMKV/Core/MemoryFile_Android.cpp +211 -0
  40. package/MMKV/Core/MemoryFile_Linux.cpp +120 -0
  41. package/MMKV/Core/MemoryFile_OSX.cpp +142 -0
  42. package/MMKV/Core/MemoryFile_Win32.cpp +536 -0
  43. package/MMKV/Core/MiniPBCoder.cpp +366 -0
  44. package/MMKV/Core/MiniPBCoder.h +129 -0
  45. package/MMKV/Core/MiniPBCoder_OSX.cpp +228 -0
  46. package/MMKV/Core/PBEncodeItem.hpp +86 -0
  47. package/MMKV/Core/PBUtility.cpp +61 -0
  48. package/MMKV/Core/PBUtility.h +153 -0
  49. package/MMKV/Core/ScopedLock.hpp +69 -0
  50. package/MMKV/Core/ThreadLock.cpp +68 -0
  51. package/MMKV/Core/ThreadLock.h +78 -0
  52. package/MMKV/Core/ThreadLock_Win32.cpp +89 -0
  53. package/MMKV/Core/aes/AESCrypt.cpp +256 -0
  54. package/MMKV/Core/aes/AESCrypt.h +107 -0
  55. package/MMKV/Core/aes/openssl/openssl_aes-armv4.S +1231 -0
  56. package/MMKV/Core/aes/openssl/openssl_aes.h +118 -0
  57. package/MMKV/Core/aes/openssl/openssl_aes_core.cpp +1044 -0
  58. package/MMKV/Core/aes/openssl/openssl_aes_locl.h +38 -0
  59. package/MMKV/Core/aes/openssl/openssl_aesv8-armx.S +308 -0
  60. package/MMKV/Core/aes/openssl/openssl_arm_arch.h +84 -0
  61. package/MMKV/Core/aes/openssl/openssl_cfb128.cpp +97 -0
  62. package/MMKV/Core/aes/openssl/openssl_md32_common.h +254 -0
  63. package/MMKV/Core/aes/openssl/openssl_md5.h +49 -0
  64. package/MMKV/Core/aes/openssl/openssl_md5_dgst.cpp +166 -0
  65. package/MMKV/Core/aes/openssl/openssl_md5_locl.h +75 -0
  66. package/MMKV/Core/aes/openssl/openssl_md5_one.cpp +30 -0
  67. package/MMKV/Core/aes/openssl/openssl_opensslconf.h +271 -0
  68. package/MMKV/Core/core.vcxproj +186 -0
  69. package/MMKV/Core/core.vcxproj.filters +150 -0
  70. package/MMKV/Core/crc32/Checksum.h +67 -0
  71. package/MMKV/Core/crc32/crc32_armv8.cpp +132 -0
  72. package/MMKV/Core/crc32/zlib/crc32.cpp +55 -0
  73. package/MMKV/Core/crc32/zlib/crc32.h +48 -0
  74. package/MMKV/Core/crc32/zlib/zconf.h +380 -0
  75. package/MMKV/Core/crc32/zlib/zutil.h +25 -0
  76. package/MMKV/LICENSE.TXT +193 -0
  77. package/MMKV/README.md +288 -0
  78. package/README.md +221 -0
  79. package/android/CMakeLists.txt +71 -0
  80. package/android/build.gradle +371 -0
  81. package/android/gradle.properties +4 -0
  82. package/android/src/main/AndroidManifest.xml +4 -0
  83. package/android/src/main/cpp/MmkvHostObject.cpp +302 -0
  84. package/android/src/main/cpp/MmkvHostObject.h +26 -0
  85. package/android/src/main/cpp/cpp-adapter.cpp +65 -0
  86. package/android/src/main/java/com/reactnativemmkv/MmkvModule.java +49 -0
  87. package/android/src/main/java/com/reactnativemmkv/MmkvPackage.java +26 -0
  88. package/cpp/TypedArray.cpp +341 -0
  89. package/cpp/TypedArray.h +175 -0
  90. package/ios/JSIUtils.h +50 -0
  91. package/ios/JSIUtils.mm +194 -0
  92. package/ios/Mmkv.xcodeproj/project.pbxproj +291 -0
  93. package/ios/MmkvHostObject.h +27 -0
  94. package/ios/MmkvHostObject.mm +299 -0
  95. package/ios/MmkvModule.h +5 -0
  96. package/ios/MmkvModule.mm +73 -0
  97. package/lib/commonjs/MMKV.js +146 -0
  98. package/lib/commonjs/MMKV.js.map +1 -0
  99. package/lib/commonjs/PlatformChecker.js +16 -0
  100. package/lib/commonjs/PlatformChecker.js.map +1 -0
  101. package/lib/commonjs/createMMKV.js +66 -0
  102. package/lib/commonjs/createMMKV.js.map +1 -0
  103. package/lib/commonjs/createMMKV.mock.js +40 -0
  104. package/lib/commonjs/createMMKV.mock.js.map +1 -0
  105. package/lib/commonjs/createMMKV.web.js +77 -0
  106. package/lib/commonjs/createMMKV.web.js.map +1 -0
  107. package/lib/commonjs/createTextEncoder.js +24 -0
  108. package/lib/commonjs/createTextEncoder.js.map +1 -0
  109. package/lib/commonjs/hooks.js +200 -0
  110. package/lib/commonjs/hooks.js.map +1 -0
  111. package/lib/commonjs/index.js +32 -0
  112. package/lib/commonjs/index.js.map +1 -0
  113. package/lib/module/MMKV.js +134 -0
  114. package/lib/module/MMKV.js.map +1 -0
  115. package/lib/module/PlatformChecker.js +9 -0
  116. package/lib/module/PlatformChecker.js.map +1 -0
  117. package/lib/module/createMMKV.js +55 -0
  118. package/lib/module/createMMKV.js.map +1 -0
  119. package/lib/module/createMMKV.mock.js +31 -0
  120. package/lib/module/createMMKV.mock.js.map +1 -0
  121. package/lib/module/createMMKV.web.js +67 -0
  122. package/lib/module/createMMKV.web.js.map +1 -0
  123. package/lib/module/createTextEncoder.js +17 -0
  124. package/lib/module/createTextEncoder.js.map +1 -0
  125. package/lib/module/hooks.js +181 -0
  126. package/lib/module/hooks.js.map +1 -0
  127. package/lib/module/index.js +3 -0
  128. package/lib/module/index.js.map +1 -0
  129. package/lib/typescript/MMKV.d.ts +137 -0
  130. package/lib/typescript/PlatformChecker.d.ts +1 -0
  131. package/lib/typescript/createMMKV.d.ts +6 -0
  132. package/lib/typescript/createMMKV.mock.d.ts +2 -0
  133. package/lib/typescript/createMMKV.web.d.ts +2 -0
  134. package/lib/typescript/createTextEncoder.d.ts +1 -0
  135. package/lib/typescript/hooks.d.ts +81 -0
  136. package/lib/typescript/index.d.ts +2 -0
  137. package/package.json +168 -0
  138. package/react-native-mmkv.podspec +32 -0
@@ -0,0 +1,254 @@
1
+ /*
2
+ * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
3
+ *
4
+ * Licensed under the OpenSSL license (the "License"). You may not use
5
+ * this file except in compliance with the License. You can obtain a copy
6
+ * in the file LICENSE in the source distribution or at
7
+ * https://www.openssl.org/source/license.html
8
+ */
9
+
10
+ /*-
11
+ * This is a generic 32 bit "collector" for message digest algorithms.
12
+ * Whenever needed it collects input character stream into chunks of
13
+ * 32 bit values and invokes a block function that performs actual hash
14
+ * calculations.
15
+ *
16
+ * Porting guide.
17
+ *
18
+ * Obligatory macros:
19
+ *
20
+ * DATA_ORDER_IS_BIG_ENDIAN or DATA_ORDER_IS_LITTLE_ENDIAN
21
+ * this macro defines byte order of input stream.
22
+ * HASH_CBLOCK
23
+ * size of a unit chunk HASH_BLOCK operates on.
24
+ * HASH_LONG
25
+ * has to be at least 32 bit wide.
26
+ * HASH_CTX
27
+ * context structure that at least contains following
28
+ * members:
29
+ * typedef struct {
30
+ * ...
31
+ * HASH_LONG Nl,Nh;
32
+ * either {
33
+ * HASH_LONG data[HASH_LBLOCK];
34
+ * unsigned char data[HASH_CBLOCK];
35
+ * };
36
+ * unsigned int num;
37
+ * ...
38
+ * } HASH_CTX;
39
+ * data[] vector is expected to be zeroed upon first call to
40
+ * HASH_UPDATE.
41
+ * HASH_UPDATE
42
+ * name of "Update" function, implemented here.
43
+ * HASH_TRANSFORM
44
+ * name of "Transform" function, implemented here.
45
+ * HASH_FINAL
46
+ * name of "Final" function, implemented here.
47
+ * HASH_BLOCK_DATA_ORDER
48
+ * name of "block" function capable of treating *unaligned* input
49
+ * message in original (data) byte order, implemented externally.
50
+ * HASH_MAKE_STRING
51
+ * macro converting context variables to an ASCII hash string.
52
+ *
53
+ * MD5 example:
54
+ *
55
+ * #define DATA_ORDER_IS_LITTLE_ENDIAN
56
+ *
57
+ * #define HASH_LONG MD5_LONG
58
+ * #define HASH_CTX MD5_CTX
59
+ * #define HASH_CBLOCK MD5_CBLOCK
60
+ * #define HASH_UPDATE MD5_Update
61
+ * #define HASH_TRANSFORM MD5_Transform
62
+ * #define HASH_FINAL MD5_Final
63
+ * #define HASH_BLOCK_DATA_ORDER md5_block_data_order
64
+ */
65
+
66
+
67
+ #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)
68
+ # error "DATA_ORDER must be defined!"
69
+ #endif
70
+
71
+ #ifndef HASH_CBLOCK
72
+ # error "HASH_CBLOCK must be defined!"
73
+ #endif
74
+ #ifndef HASH_LONG
75
+ # error "HASH_LONG must be defined!"
76
+ #endif
77
+ #ifndef HASH_CTX
78
+ # error "HASH_CTX must be defined!"
79
+ #endif
80
+
81
+ #ifndef HASH_UPDATE
82
+ # error "HASH_UPDATE must be defined!"
83
+ #endif
84
+ //#ifndef HASH_TRANSFORM
85
+ //# error "HASH_TRANSFORM must be defined!"
86
+ //#endif
87
+ #ifndef HASH_FINAL
88
+ # error "HASH_FINAL must be defined!"
89
+ #endif
90
+
91
+ #ifndef HASH_BLOCK_DATA_ORDER
92
+ # error "HASH_BLOCK_DATA_ORDER must be defined!"
93
+ #endif
94
+
95
+ #define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
96
+
97
+ #if defined(DATA_ORDER_IS_BIG_ENDIAN)
98
+
99
+ # define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
100
+ l|=(((unsigned long)(*((c)++)))<<16), \
101
+ l|=(((unsigned long)(*((c)++)))<< 8), \
102
+ l|=(((unsigned long)(*((c)++))) ) )
103
+ # define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
104
+ *((c)++)=(unsigned char)(((l)>>16)&0xff), \
105
+ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
106
+ *((c)++)=(unsigned char)(((l) )&0xff), \
107
+ l)
108
+
109
+ #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
110
+
111
+ # define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
112
+ l|=(((unsigned long)(*((c)++)))<< 8), \
113
+ l|=(((unsigned long)(*((c)++)))<<16), \
114
+ l|=(((unsigned long)(*((c)++)))<<24) )
115
+ # define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
116
+ *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
117
+ *((c)++)=(unsigned char)(((l)>>16)&0xff), \
118
+ *((c)++)=(unsigned char)(((l)>>24)&0xff), \
119
+ l)
120
+
121
+ #endif
122
+
123
+ /*
124
+ * Time for some action :-)
125
+ */
126
+
127
+ int HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)
128
+ {
129
+ auto data = (const unsigned char *) data_;
130
+ unsigned char *p;
131
+ HASH_LONG l;
132
+ size_t n;
133
+
134
+ if (len == 0)
135
+ return 1;
136
+
137
+ l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;
138
+ if (l < c->Nl) /* overflow */
139
+ c->Nh++;
140
+ c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on
141
+ * 16-bit */
142
+ c->Nl = l;
143
+
144
+ n = c->num;
145
+ if (n != 0) {
146
+ p = (unsigned char *)c->data;
147
+
148
+ if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {
149
+ memcpy(p + n, data, HASH_CBLOCK - n);
150
+ HASH_BLOCK_DATA_ORDER(c, p, 1);
151
+ n = HASH_CBLOCK - n;
152
+ data += n;
153
+ len -= n;
154
+ c->num = 0;
155
+ /*
156
+ * We use memset rather than OPENSSL_cleanse() here deliberately.
157
+ * Using OPENSSL_cleanse() here could be a performance issue. It
158
+ * will get properly cleansed on finalisation so this isn't a
159
+ * security problem.
160
+ */
161
+ memset(p, 0, HASH_CBLOCK); /* keep it zeroed */
162
+ } else {
163
+ memcpy(p + n, data, len);
164
+ c->num += (unsigned int)len;
165
+ return 1;
166
+ }
167
+ }
168
+
169
+ n = len / HASH_CBLOCK;
170
+ if (n > 0) {
171
+ HASH_BLOCK_DATA_ORDER(c, data, n);
172
+ n *= HASH_CBLOCK;
173
+ data += n;
174
+ len -= n;
175
+ }
176
+
177
+ if (len != 0) {
178
+ p = (unsigned char *)c->data;
179
+ c->num = (unsigned int)len;
180
+ memcpy(p, data, len);
181
+ }
182
+ return 1;
183
+ }
184
+
185
+ //void HASH_TRANSFORM(HASH_CTX *c, const unsigned char *data)
186
+ //{
187
+ // HASH_BLOCK_DATA_ORDER(c, data, 1);
188
+ //}
189
+
190
+ int HASH_FINAL(unsigned char *md, HASH_CTX *c)
191
+ {
192
+ unsigned char *p = (unsigned char *)c->data;
193
+ size_t n = c->num;
194
+
195
+ p[n] = 0x80; /* there is always room for one */
196
+ n++;
197
+
198
+ if (n > (HASH_CBLOCK - 8)) {
199
+ memset(p + n, 0, HASH_CBLOCK - n);
200
+ n = 0;
201
+ HASH_BLOCK_DATA_ORDER(c, p, 1);
202
+ }
203
+ memset(p + n, 0, HASH_CBLOCK - 8 - n);
204
+
205
+ p += HASH_CBLOCK - 8;
206
+ #if defined(DATA_ORDER_IS_BIG_ENDIAN)
207
+ (void)HOST_l2c(c->Nh, p);
208
+ (void)HOST_l2c(c->Nl, p);
209
+ #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
210
+ (void)HOST_l2c(c->Nl, p);
211
+ (void)HOST_l2c(c->Nh, p);
212
+ #endif
213
+ p -= HASH_CBLOCK;
214
+ HASH_BLOCK_DATA_ORDER(c, p, 1);
215
+ c->num = 0;
216
+
217
+ #ifndef HASH_MAKE_STRING
218
+ # error "HASH_MAKE_STRING must be defined!"
219
+ #else
220
+ HASH_MAKE_STRING(c, md);
221
+ #endif
222
+
223
+ return 1;
224
+ }
225
+
226
+ #ifndef MD32_REG_T
227
+ # if (defined(_LP64) && _LP64)
228
+ # define MD32_REG_T long
229
+ /*
230
+ * This comment was originally written for MD5, which is why it
231
+ * discusses A-D. But it basically applies to all 32-bit digests,
232
+ * which is why it was moved to common header file.
233
+ *
234
+ * In case you wonder why A-D are declared as long and not
235
+ * as MD5_LONG. Doing so results in slight performance
236
+ * boost on LP64 architectures. The catch is we don't
237
+ * really care if 32 MSBs of a 64-bit register get polluted
238
+ * with eventual overflows as we *save* only 32 LSBs in
239
+ * *either* case. Now declaring 'em long excuses the compiler
240
+ * from keeping 32 MSBs zeroed resulting in 13% performance
241
+ * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
242
+ * Well, to be honest it should say that this *prevents*
243
+ * performance degradation.
244
+ */
245
+ # else
246
+ /*
247
+ * Above is not absolute and there are LP64 compilers that
248
+ * generate better code if MD32_REG_T is defined int. The above
249
+ * pre-processor condition reflects the circumstances under which
250
+ * the conclusion was made and is subject to further extension.
251
+ */
252
+ # define MD32_REG_T int
253
+ # endif
254
+ #endif
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3
+ *
4
+ * Licensed under the OpenSSL license (the "License"). You may not use
5
+ * this file except in compliance with the License. You can obtain a copy
6
+ * in the file LICENSE in the source distribution or at
7
+ * https://www.openssl.org/source/license.html
8
+ */
9
+
10
+ #ifndef HEADER_MD5_H
11
+ # define HEADER_MD5_H
12
+ #ifdef __cplusplus
13
+
14
+ # include "openssl_opensslconf.h"
15
+
16
+ # ifndef OPENSSL_NO_MD5
17
+ # include <stddef.h>
18
+
19
+ namespace openssl {
20
+
21
+ /*
22
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23
+ * ! MD5_LONG has to be at least 32 bits wide. !
24
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25
+ */
26
+ # define MD5_LONG unsigned int
27
+
28
+ # define MD5_CBLOCK 64
29
+ # define MD5_LBLOCK (MD5_CBLOCK/4)
30
+ # define MD5_DIGEST_LENGTH 16
31
+
32
+ typedef struct MD5state_st {
33
+ MD5_LONG A, B, C, D;
34
+ MD5_LONG Nl, Nh;
35
+ MD5_LONG data[MD5_LBLOCK];
36
+ unsigned int num;
37
+ } MD5_CTX;
38
+
39
+ int MD5_Init(MD5_CTX *c);
40
+ int MD5_Update(MD5_CTX *c, const void *data, size_t len);
41
+ int MD5_Final(unsigned char *md, MD5_CTX *c);
42
+ unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
43
+ //void MD5_Transform(MD5_CTX *c, const unsigned char *b);
44
+
45
+ } // namespace openssl
46
+ # endif
47
+
48
+ #endif
49
+ #endif
@@ -0,0 +1,166 @@
1
+ /*
2
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3
+ *
4
+ * Licensed under the OpenSSL license (the "License"). You may not use
5
+ * this file except in compliance with the License. You can obtain a copy
6
+ * in the file LICENSE in the source distribution or at
7
+ * https://www.openssl.org/source/license.html
8
+ */
9
+
10
+ #include <stdio.h>
11
+ #include "openssl_md5_locl.h"
12
+
13
+ namespace openssl {
14
+ /*
15
+ * Implemented from RFC1321 The MD5 Message-Digest Algorithm
16
+ */
17
+
18
+ #define INIT_DATA_A (unsigned long)0x67452301L
19
+ #define INIT_DATA_B (unsigned long)0xefcdab89L
20
+ #define INIT_DATA_C (unsigned long)0x98badcfeL
21
+ #define INIT_DATA_D (unsigned long)0x10325476L
22
+
23
+ int MD5_Init(MD5_CTX *c)
24
+ {
25
+ memset(c, 0, sizeof(*c));
26
+ c->A = INIT_DATA_A;
27
+ c->B = INIT_DATA_B;
28
+ c->C = INIT_DATA_C;
29
+ c->D = INIT_DATA_D;
30
+ return 1;
31
+ }
32
+
33
+ #ifndef md5_block_data_order
34
+ # ifdef X
35
+ # undef X
36
+ # endif
37
+ void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num)
38
+ {
39
+ auto data = (const unsigned char *) data_;
40
+ unsigned MD32_REG_T A, B, C, D, l;
41
+ # ifndef MD32_XARRAY
42
+ /* See comment in crypto/sha/sha_locl.h for details. */
43
+ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
44
+ XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
45
+ # define X(i) XX##i
46
+ # else
47
+ MD5_LONG XX[MD5_LBLOCK];
48
+ # define X(i) XX[i]
49
+ # endif
50
+
51
+ A = c->A;
52
+ B = c->B;
53
+ C = c->C;
54
+ D = c->D;
55
+
56
+ for (; num--;) {
57
+ (void)HOST_c2l(data, l);
58
+ X(0) = l;
59
+ (void)HOST_c2l(data, l);
60
+ X(1) = l;
61
+ /* Round 0 */
62
+ R0(A, B, C, D, X(0), 7, 0xd76aa478L);
63
+ (void)HOST_c2l(data, l);
64
+ X(2) = l;
65
+ R0(D, A, B, C, X(1), 12, 0xe8c7b756L);
66
+ (void)HOST_c2l(data, l);
67
+ X(3) = l;
68
+ R0(C, D, A, B, X(2), 17, 0x242070dbL);
69
+ (void)HOST_c2l(data, l);
70
+ X(4) = l;
71
+ R0(B, C, D, A, X(3), 22, 0xc1bdceeeL);
72
+ (void)HOST_c2l(data, l);
73
+ X(5) = l;
74
+ R0(A, B, C, D, X(4), 7, 0xf57c0fafL);
75
+ (void)HOST_c2l(data, l);
76
+ X(6) = l;
77
+ R0(D, A, B, C, X(5), 12, 0x4787c62aL);
78
+ (void)HOST_c2l(data, l);
79
+ X(7) = l;
80
+ R0(C, D, A, B, X(6), 17, 0xa8304613L);
81
+ (void)HOST_c2l(data, l);
82
+ X(8) = l;
83
+ R0(B, C, D, A, X(7), 22, 0xfd469501L);
84
+ (void)HOST_c2l(data, l);
85
+ X(9) = l;
86
+ R0(A, B, C, D, X(8), 7, 0x698098d8L);
87
+ (void)HOST_c2l(data, l);
88
+ X(10) = l;
89
+ R0(D, A, B, C, X(9), 12, 0x8b44f7afL);
90
+ (void)HOST_c2l(data, l);
91
+ X(11) = l;
92
+ R0(C, D, A, B, X(10), 17, 0xffff5bb1L);
93
+ (void)HOST_c2l(data, l);
94
+ X(12) = l;
95
+ R0(B, C, D, A, X(11), 22, 0x895cd7beL);
96
+ (void)HOST_c2l(data, l);
97
+ X(13) = l;
98
+ R0(A, B, C, D, X(12), 7, 0x6b901122L);
99
+ (void)HOST_c2l(data, l);
100
+ X(14) = l;
101
+ R0(D, A, B, C, X(13), 12, 0xfd987193L);
102
+ (void)HOST_c2l(data, l);
103
+ X(15) = l;
104
+ R0(C, D, A, B, X(14), 17, 0xa679438eL);
105
+ R0(B, C, D, A, X(15), 22, 0x49b40821L);
106
+ /* Round 1 */
107
+ R1(A, B, C, D, X(1), 5, 0xf61e2562L);
108
+ R1(D, A, B, C, X(6), 9, 0xc040b340L);
109
+ R1(C, D, A, B, X(11), 14, 0x265e5a51L);
110
+ R1(B, C, D, A, X(0), 20, 0xe9b6c7aaL);
111
+ R1(A, B, C, D, X(5), 5, 0xd62f105dL);
112
+ R1(D, A, B, C, X(10), 9, 0x02441453L);
113
+ R1(C, D, A, B, X(15), 14, 0xd8a1e681L);
114
+ R1(B, C, D, A, X(4), 20, 0xe7d3fbc8L);
115
+ R1(A, B, C, D, X(9), 5, 0x21e1cde6L);
116
+ R1(D, A, B, C, X(14), 9, 0xc33707d6L);
117
+ R1(C, D, A, B, X(3), 14, 0xf4d50d87L);
118
+ R1(B, C, D, A, X(8), 20, 0x455a14edL);
119
+ R1(A, B, C, D, X(13), 5, 0xa9e3e905L);
120
+ R1(D, A, B, C, X(2), 9, 0xfcefa3f8L);
121
+ R1(C, D, A, B, X(7), 14, 0x676f02d9L);
122
+ R1(B, C, D, A, X(12), 20, 0x8d2a4c8aL);
123
+ /* Round 2 */
124
+ R2(A, B, C, D, X(5), 4, 0xfffa3942L);
125
+ R2(D, A, B, C, X(8), 11, 0x8771f681L);
126
+ R2(C, D, A, B, X(11), 16, 0x6d9d6122L);
127
+ R2(B, C, D, A, X(14), 23, 0xfde5380cL);
128
+ R2(A, B, C, D, X(1), 4, 0xa4beea44L);
129
+ R2(D, A, B, C, X(4), 11, 0x4bdecfa9L);
130
+ R2(C, D, A, B, X(7), 16, 0xf6bb4b60L);
131
+ R2(B, C, D, A, X(10), 23, 0xbebfbc70L);
132
+ R2(A, B, C, D, X(13), 4, 0x289b7ec6L);
133
+ R2(D, A, B, C, X(0), 11, 0xeaa127faL);
134
+ R2(C, D, A, B, X(3), 16, 0xd4ef3085L);
135
+ R2(B, C, D, A, X(6), 23, 0x04881d05L);
136
+ R2(A, B, C, D, X(9), 4, 0xd9d4d039L);
137
+ R2(D, A, B, C, X(12), 11, 0xe6db99e5L);
138
+ R2(C, D, A, B, X(15), 16, 0x1fa27cf8L);
139
+ R2(B, C, D, A, X(2), 23, 0xc4ac5665L);
140
+ /* Round 3 */
141
+ R3(A, B, C, D, X(0), 6, 0xf4292244L);
142
+ R3(D, A, B, C, X(7), 10, 0x432aff97L);
143
+ R3(C, D, A, B, X(14), 15, 0xab9423a7L);
144
+ R3(B, C, D, A, X(5), 21, 0xfc93a039L);
145
+ R3(A, B, C, D, X(12), 6, 0x655b59c3L);
146
+ R3(D, A, B, C, X(3), 10, 0x8f0ccc92L);
147
+ R3(C, D, A, B, X(10), 15, 0xffeff47dL);
148
+ R3(B, C, D, A, X(1), 21, 0x85845dd1L);
149
+ R3(A, B, C, D, X(8), 6, 0x6fa87e4fL);
150
+ R3(D, A, B, C, X(15), 10, 0xfe2ce6e0L);
151
+ R3(C, D, A, B, X(6), 15, 0xa3014314L);
152
+ R3(B, C, D, A, X(13), 21, 0x4e0811a1L);
153
+ R3(A, B, C, D, X(4), 6, 0xf7537e82L);
154
+ R3(D, A, B, C, X(11), 10, 0xbd3af235L);
155
+ R3(C, D, A, B, X(2), 15, 0x2ad7d2bbL);
156
+ R3(B, C, D, A, X(9), 21, 0xeb86d391L);
157
+
158
+ A = c->A += A;
159
+ B = c->B += B;
160
+ C = c->C += C;
161
+ D = c->D += D;
162
+ }
163
+ }
164
+ #endif
165
+
166
+ } // namespace openssl
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3
+ *
4
+ * Licensed under the OpenSSL license (the "License"). You may not use
5
+ * this file except in compliance with the License. You can obtain a copy
6
+ * in the file LICENSE in the source distribution or at
7
+ * https://www.openssl.org/source/license.html
8
+ */
9
+ #ifdef __cplusplus
10
+
11
+ #include <stdlib.h>
12
+ #include <string.h>
13
+ #include "openssl_md5.h"
14
+
15
+ namespace openssl {
16
+
17
+ void md5_block_data_order(MD5_CTX *c, const void *p, size_t num);
18
+
19
+ #define DATA_ORDER_IS_LITTLE_ENDIAN
20
+
21
+ #define HASH_LONG MD5_LONG
22
+ #define HASH_CTX MD5_CTX
23
+ #define HASH_CBLOCK MD5_CBLOCK
24
+ #define HASH_UPDATE MD5_Update
25
+ //#define HASH_TRANSFORM MD5_Transform
26
+ #define HASH_FINAL MD5_Final
27
+ #define HASH_MAKE_STRING(c,s) do { \
28
+ unsigned long ll; \
29
+ ll=(c)->A; (void)HOST_l2c(ll,(s)); \
30
+ ll=(c)->B; (void)HOST_l2c(ll,(s)); \
31
+ ll=(c)->C; (void)HOST_l2c(ll,(s)); \
32
+ ll=(c)->D; (void)HOST_l2c(ll,(s)); \
33
+ } while (0)
34
+ #define HASH_BLOCK_DATA_ORDER md5_block_data_order
35
+
36
+ #include "openssl_md32_common.h"
37
+
38
+ /*-
39
+ #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
40
+ #define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
41
+ */
42
+
43
+ /*
44
+ * As pointed out by Wei Dai, the above can be simplified to the code
45
+ * below. Wei attributes these optimizations to Peter Gutmann's
46
+ * SHS code, and he attributes it to Rich Schroeppel.
47
+ */
48
+ #define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
49
+ #define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c))
50
+ #define H(b,c,d) ((b) ^ (c) ^ (d))
51
+ #define I(b,c,d) (((~(d)) | (b)) ^ (c))
52
+
53
+ #define R0(a,b,c,d,k,s,t) { \
54
+ a+=((k)+(t)+F((b),(c),(d))); \
55
+ a=ROTATE(a,s); \
56
+ a+=b; };\
57
+
58
+ #define R1(a,b,c,d,k,s,t) { \
59
+ a+=((k)+(t)+G((b),(c),(d))); \
60
+ a=ROTATE(a,s); \
61
+ a+=b; };
62
+
63
+ #define R2(a,b,c,d,k,s,t) { \
64
+ a+=((k)+(t)+H((b),(c),(d))); \
65
+ a=ROTATE(a,s); \
66
+ a+=b; };
67
+
68
+ #define R3(a,b,c,d,k,s,t) { \
69
+ a+=((k)+(t)+I((b),(c),(d))); \
70
+ a=ROTATE(a,s); \
71
+ a+=b; };
72
+
73
+ } // namespace openssl
74
+
75
+ #endif
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3
+ *
4
+ * Licensed under the OpenSSL license (the "License"). You may not use
5
+ * this file except in compliance with the License. You can obtain a copy
6
+ * in the file LICENSE in the source distribution or at
7
+ * https://www.openssl.org/source/license.html
8
+ */
9
+
10
+ #include <stdio.h>
11
+ #include <string.h>
12
+ #include "openssl_md5.h"
13
+
14
+ namespace openssl {
15
+
16
+ unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
17
+ {
18
+ MD5_CTX c;
19
+ static unsigned char m[MD5_DIGEST_LENGTH];
20
+
21
+ if (md == nullptr)
22
+ md = m;
23
+ if (!MD5_Init(&c))
24
+ return nullptr;
25
+ MD5_Update(&c, d, n);
26
+ MD5_Final(md, &c);
27
+ return md;
28
+ }
29
+
30
+ } // namespace openssl