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,38 @@
1
+ /*
2
+ * Copyright 2002-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_AES_LOCL_H
11
+ # define HEADER_AES_LOCL_H
12
+ #ifdef __cplusplus
13
+
14
+ # include "openssl_opensslconf.h"
15
+ # include <stdio.h>
16
+ # include <stdlib.h>
17
+ # include <string.h>
18
+ # include <stdint.h>
19
+
20
+ # if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))
21
+ # define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
22
+ # define GETU32(p) SWAP(*((u32 *)(p)))
23
+ # define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
24
+ # else
25
+ # define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
26
+ # define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
27
+ # endif
28
+
29
+ # ifdef AES_LONG
30
+ typedef unsigned long u32;
31
+ # else
32
+ typedef unsigned int u32;
33
+ # endif
34
+ typedef unsigned short u16;
35
+ typedef unsigned char u8;
36
+
37
+ #endif
38
+ #endif /* !HEADER_AES_LOCL_H */
@@ -0,0 +1,308 @@
1
+ #include "openssl_arm_arch.h"
2
+ #include "../../MMKVPredef.h"
3
+
4
+ #if (__ARM_MAX_ARCH__ > 7) && !defined(MMKV_DISABLE_CRYPT)
5
+
6
+ .text
7
+
8
+ .align 5
9
+ Lrcon:
10
+ .long 0x01,0x01,0x01,0x01
11
+ .long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d // rotate-n-splat
12
+ .long 0x1b,0x1b,0x1b,0x1b
13
+
14
+ #ifndef __linux__
15
+ .globl _openssl_aes_arm_set_encrypt_key
16
+
17
+ .align 5
18
+ _openssl_aes_arm_set_encrypt_key:
19
+ #else // __linux__
20
+ .globl openssl_aes_armv8_set_encrypt_key
21
+
22
+ .align 5
23
+ openssl_aes_armv8_set_encrypt_key:
24
+ #endif // __linux__
25
+
26
+ Lenc_key:
27
+ stp x29,x30,[sp,#-16]!
28
+ add x29,sp,#0
29
+ mov x3,#-1
30
+ cmp x0,#0
31
+ b.eq Lenc_key_abort
32
+ cmp x2,#0
33
+ b.eq Lenc_key_abort
34
+ mov x3,#-2
35
+ cmp w1,#128
36
+ b.lt Lenc_key_abort
37
+ cmp w1,#256
38
+ b.gt Lenc_key_abort
39
+ tst w1,#0x3f
40
+ b.ne Lenc_key_abort
41
+
42
+ adr x3,Lrcon
43
+ cmp w1,#192
44
+
45
+ eor v0.16b,v0.16b,v0.16b
46
+ ld1 {v3.16b},[x0],#16
47
+ mov w1,#8 // reuse w1
48
+ ld1 {v1.4s,v2.4s},[x3],#32
49
+
50
+ b.lt Loop128
51
+ b.eq L192
52
+ b L256
53
+
54
+ .align 4
55
+ Loop128:
56
+ tbl v6.16b,{v3.16b},v2.16b
57
+ ext v5.16b,v0.16b,v3.16b,#12
58
+ st1 {v3.4s},[x2],#16
59
+ aese v6.16b,v0.16b
60
+ subs w1,w1,#1
61
+
62
+ eor v3.16b,v3.16b,v5.16b
63
+ ext v5.16b,v0.16b,v5.16b,#12
64
+ eor v3.16b,v3.16b,v5.16b
65
+ ext v5.16b,v0.16b,v5.16b,#12
66
+ eor v6.16b,v6.16b,v1.16b
67
+ eor v3.16b,v3.16b,v5.16b
68
+ shl v1.16b,v1.16b,#1
69
+ eor v3.16b,v3.16b,v6.16b
70
+ b.ne Loop128
71
+
72
+ ld1 {v1.4s},[x3]
73
+
74
+ tbl v6.16b,{v3.16b},v2.16b
75
+ ext v5.16b,v0.16b,v3.16b,#12
76
+ st1 {v3.4s},[x2],#16
77
+ aese v6.16b,v0.16b
78
+
79
+ eor v3.16b,v3.16b,v5.16b
80
+ ext v5.16b,v0.16b,v5.16b,#12
81
+ eor v3.16b,v3.16b,v5.16b
82
+ ext v5.16b,v0.16b,v5.16b,#12
83
+ eor v6.16b,v6.16b,v1.16b
84
+ eor v3.16b,v3.16b,v5.16b
85
+ shl v1.16b,v1.16b,#1
86
+ eor v3.16b,v3.16b,v6.16b
87
+
88
+ tbl v6.16b,{v3.16b},v2.16b
89
+ ext v5.16b,v0.16b,v3.16b,#12
90
+ st1 {v3.4s},[x2],#16
91
+ aese v6.16b,v0.16b
92
+
93
+ eor v3.16b,v3.16b,v5.16b
94
+ ext v5.16b,v0.16b,v5.16b,#12
95
+ eor v3.16b,v3.16b,v5.16b
96
+ ext v5.16b,v0.16b,v5.16b,#12
97
+ eor v6.16b,v6.16b,v1.16b
98
+ eor v3.16b,v3.16b,v5.16b
99
+ eor v3.16b,v3.16b,v6.16b
100
+ st1 {v3.4s},[x2]
101
+ add x2,x2,#0x50
102
+
103
+ mov w12,#10
104
+ b Ldone
105
+
106
+ .align 4
107
+ L192:
108
+ ld1 {v4.8b},[x0],#8
109
+ movi v6.16b,#8 // borrow v6.16b
110
+ st1 {v3.4s},[x2],#16
111
+ sub v2.16b,v2.16b,v6.16b // adjust the mask
112
+
113
+ Loop192:
114
+ tbl v6.16b,{v4.16b},v2.16b
115
+ ext v5.16b,v0.16b,v3.16b,#12
116
+ st1 {v4.8b},[x2],#8
117
+ aese v6.16b,v0.16b
118
+ subs w1,w1,#1
119
+
120
+ eor v3.16b,v3.16b,v5.16b
121
+ ext v5.16b,v0.16b,v5.16b,#12
122
+ eor v3.16b,v3.16b,v5.16b
123
+ ext v5.16b,v0.16b,v5.16b,#12
124
+ eor v3.16b,v3.16b,v5.16b
125
+
126
+ dup v5.4s,v3.s[3]
127
+ eor v5.16b,v5.16b,v4.16b
128
+ eor v6.16b,v6.16b,v1.16b
129
+ ext v4.16b,v0.16b,v4.16b,#12
130
+ shl v1.16b,v1.16b,#1
131
+ eor v4.16b,v4.16b,v5.16b
132
+ eor v3.16b,v3.16b,v6.16b
133
+ eor v4.16b,v4.16b,v6.16b
134
+ st1 {v3.4s},[x2],#16
135
+ b.ne Loop192
136
+
137
+ mov w12,#12
138
+ add x2,x2,#0x20
139
+ b Ldone
140
+
141
+ .align 4
142
+ L256:
143
+ ld1 {v4.16b},[x0]
144
+ mov w1,#7
145
+ mov w12,#14
146
+ st1 {v3.4s},[x2],#16
147
+
148
+ Loop256:
149
+ tbl v6.16b,{v4.16b},v2.16b
150
+ ext v5.16b,v0.16b,v3.16b,#12
151
+ st1 {v4.4s},[x2],#16
152
+ aese v6.16b,v0.16b
153
+ subs w1,w1,#1
154
+
155
+ eor v3.16b,v3.16b,v5.16b
156
+ ext v5.16b,v0.16b,v5.16b,#12
157
+ eor v3.16b,v3.16b,v5.16b
158
+ ext v5.16b,v0.16b,v5.16b,#12
159
+ eor v6.16b,v6.16b,v1.16b
160
+ eor v3.16b,v3.16b,v5.16b
161
+ shl v1.16b,v1.16b,#1
162
+ eor v3.16b,v3.16b,v6.16b
163
+ st1 {v3.4s},[x2],#16
164
+ b.eq Ldone
165
+
166
+ dup v6.4s,v3.s[3] // just splat
167
+ ext v5.16b,v0.16b,v4.16b,#12
168
+ aese v6.16b,v0.16b
169
+
170
+ eor v4.16b,v4.16b,v5.16b
171
+ ext v5.16b,v0.16b,v5.16b,#12
172
+ eor v4.16b,v4.16b,v5.16b
173
+ ext v5.16b,v0.16b,v5.16b,#12
174
+ eor v4.16b,v4.16b,v5.16b
175
+
176
+ eor v4.16b,v4.16b,v6.16b
177
+ b Loop256
178
+
179
+ Ldone:
180
+ str w12,[x2]
181
+ mov x3,#0
182
+
183
+ Lenc_key_abort:
184
+ mov x0,x3 // return value
185
+ ldr x29,[sp],#16
186
+ ret
187
+
188
+ #ifndef __linux__
189
+ .globl _openssl_aes_arm_set_decrypt_key
190
+
191
+ .align 5
192
+ _openssl_aes_arm_set_decrypt_key:
193
+ #else // __linux__
194
+ .globl openssl_aes_armv8_set_decrypt_key
195
+
196
+ .align 5
197
+ openssl_aes_armv8_set_decrypt_key:
198
+ #endif // __linux__
199
+ stp x29,x30,[sp,#-16]!
200
+ add x29,sp,#0
201
+ bl Lenc_key
202
+
203
+ cmp x0,#0
204
+ b.ne Ldec_key_abort
205
+
206
+ sub x2,x2,#240 // restore original x2
207
+ mov x4,#-16
208
+ add x0,x2,x12,lsl#4 // end of key schedule
209
+
210
+ ld1 {v0.4s},[x2]
211
+ ld1 {v1.4s},[x0]
212
+ st1 {v0.4s},[x0],x4
213
+ st1 {v1.4s},[x2],#16
214
+
215
+ Loop_imc:
216
+ ld1 {v0.4s},[x2]
217
+ ld1 {v1.4s},[x0]
218
+ aesimc v0.16b,v0.16b
219
+ aesimc v1.16b,v1.16b
220
+ st1 {v0.4s},[x0],x4
221
+ st1 {v1.4s},[x2],#16
222
+ cmp x0,x2
223
+ b.hi Loop_imc
224
+
225
+ ld1 {v0.4s},[x2]
226
+ aesimc v0.16b,v0.16b
227
+ st1 {v0.4s},[x0]
228
+
229
+ eor x0,x0,x0 // return value
230
+ Ldec_key_abort:
231
+ ldp x29,x30,[sp],#16
232
+ ret
233
+
234
+ #ifndef __linux__
235
+ .globl _openssl_aes_arm_encrypt
236
+
237
+ .align 5
238
+ _openssl_aes_arm_encrypt:
239
+ #else // __linux__
240
+ .globl openssl_aes_armv8_encrypt
241
+
242
+ .align 5
243
+ openssl_aes_armv8_encrypt:
244
+ #endif // __linux__
245
+
246
+ ldr w3,[x2,#240]
247
+ ld1 {v0.4s},[x2],#16
248
+ ld1 {v2.16b},[x0]
249
+ sub w3,w3,#2
250
+ ld1 {v1.4s},[x2],#16
251
+
252
+ Loop_enc:
253
+ aese v2.16b,v0.16b
254
+ aesmc v2.16b,v2.16b
255
+ ld1 {v0.4s},[x2],#16
256
+ subs w3,w3,#2
257
+ aese v2.16b,v1.16b
258
+ aesmc v2.16b,v2.16b
259
+ ld1 {v1.4s},[x2],#16
260
+ b.gt Loop_enc
261
+
262
+ aese v2.16b,v0.16b
263
+ aesmc v2.16b,v2.16b
264
+ ld1 {v0.4s},[x2]
265
+ aese v2.16b,v1.16b
266
+ eor v2.16b,v2.16b,v0.16b
267
+
268
+ st1 {v2.16b},[x1]
269
+ ret
270
+
271
+ #ifndef __linux__
272
+ .globl _openssl_aes_arm_decrypt
273
+
274
+ .align 5
275
+ _openssl_aes_arm_decrypt:
276
+ #else // __linux__
277
+ .globl openssl_aes_armv8_decrypt
278
+
279
+ .align 5
280
+ openssl_aes_armv8_decrypt:
281
+ #endif // __linux__
282
+
283
+ ldr w3,[x2,#240]
284
+ ld1 {v0.4s},[x2],#16
285
+ ld1 {v2.16b},[x0]
286
+ sub w3,w3,#2
287
+ ld1 {v1.4s},[x2],#16
288
+
289
+ Loop_dec:
290
+ aesd v2.16b,v0.16b
291
+ aesimc v2.16b,v2.16b
292
+ ld1 {v0.4s},[x2],#16
293
+ subs w3,w3,#2
294
+ aesd v2.16b,v1.16b
295
+ aesimc v2.16b,v2.16b
296
+ ld1 {v1.4s},[x2],#16
297
+ b.gt Loop_dec
298
+
299
+ aesd v2.16b,v0.16b
300
+ aesimc v2.16b,v2.16b
301
+ ld1 {v0.4s},[x2]
302
+ aesd v2.16b,v1.16b
303
+ eor v2.16b,v2.16b,v0.16b
304
+
305
+ st1 {v2.16b},[x1]
306
+ ret
307
+
308
+ #endif
@@ -0,0 +1,84 @@
1
+ /*
2
+ * Copyright 2011-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
+ #ifndef __ARM_ARCH_H__
11
+ # define __ARM_ARCH_H__
12
+
13
+ # if !defined(__ARM_ARCH__)
14
+ # if defined(__CC_ARM)
15
+ # define __ARM_ARCH__ __TARGET_ARCH_ARM
16
+ # if defined(__BIG_ENDIAN)
17
+ # define __ARMEB__
18
+ # else
19
+ # define __ARMEL__
20
+ # endif
21
+ # elif defined(__GNUC__)
22
+ # if defined(__aarch64__)
23
+ # define __ARM_ARCH__ 8
24
+ # if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
25
+ # define __ARMEB__
26
+ # else
27
+ # define __ARMEL__
28
+ # endif
29
+ /*
30
+ * Why doesn't gcc define __ARM_ARCH__? Instead it defines
31
+ * bunch of below macros. See all_architectires[] table in
32
+ * gcc/config/arm/arm.c. On a side note it defines
33
+ * __ARMEL__/__ARMEB__ for little-/big-endian.
34
+ */
35
+ # elif defined(__ARM_ARCH)
36
+ # define __ARM_ARCH__ __ARM_ARCH
37
+ # elif defined(__ARM_ARCH_8A__)
38
+ # define __ARM_ARCH__ 8
39
+ # elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
40
+ defined(__ARM_ARCH_7R__)|| defined(__ARM_ARCH_7M__) || \
41
+ defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7K__)
42
+ # define __ARM_ARCH__ 7
43
+ # elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
44
+ defined(__ARM_ARCH_6K__)|| defined(__ARM_ARCH_6M__) || \
45
+ defined(__ARM_ARCH_6Z__)|| defined(__ARM_ARCH_6ZK__) || \
46
+ defined(__ARM_ARCH_6T2__)
47
+ # define __ARM_ARCH__ 6
48
+ # elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
49
+ defined(__ARM_ARCH_5E__)|| defined(__ARM_ARCH_5TE__) || \
50
+ defined(__ARM_ARCH_5TEJ__)
51
+ # define __ARM_ARCH__ 5
52
+ # elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
53
+ # define __ARM_ARCH__ 4
54
+ # else
55
+ //# error "unsupported ARM architecture"
56
+ # define __ARM_ARCH__ 0
57
+ # endif
58
+ # endif
59
+ # endif
60
+
61
+ # if !defined(__ARM_MAX_ARCH__)
62
+ # define __ARM_MAX_ARCH__ __ARM_ARCH__
63
+ # endif
64
+
65
+ # if __ARM_MAX_ARCH__<__ARM_ARCH__
66
+ # error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
67
+ # elif __ARM_MAX_ARCH__!=__ARM_ARCH__
68
+ # if __ARM_ARCH__<7 && __ARM_MAX_ARCH__>=7 && defined(__ARMEB__)
69
+ # error "can't build universal big-endian binary"
70
+ # endif
71
+ # endif
72
+
73
+ # ifndef __ASSEMBLER__
74
+ extern unsigned int OPENSSL_armcap_P;
75
+ # endif
76
+
77
+ # define ARMV7_NEON (1<<0)
78
+ # define ARMV7_TICK (1<<1)
79
+ # define ARMV8_AES (1<<2)
80
+ # define ARMV8_SHA1 (1<<3)
81
+ # define ARMV8_SHA256 (1<<4)
82
+ # define ARMV8_PMULL (1<<5)
83
+
84
+ #endif
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Copyright 2008-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 "openssl_aes.h"
11
+ #include "../../MMKVPredef.h"
12
+ #include <cstring>
13
+
14
+ #ifndef MMKV_DISABLE_CRYPT
15
+
16
+ namespace openssl {
17
+
18
+ /*
19
+ * The input and output encrypted as though 128bit cfb mode is being used.
20
+ * The extra state information to record how much of the 128bit block we have
21
+ * used is contained in *num;
22
+ */
23
+ void AES_cfb128_encrypt(const uint8_t *in, uint8_t *out, size_t len, const AES_KEY *key, uint8_t ivec[16], uint32_t *num)
24
+ {
25
+ auto n = *num;
26
+
27
+ while (n && len) {
28
+ *(out++) = ivec[n] ^= *(in++);
29
+ --len;
30
+ n = (n + 1) % 16;
31
+ }
32
+ while (len >= 16) {
33
+ AES_encrypt(ivec, ivec, key);
34
+ for (; n < 16; n += sizeof(size_t)) {
35
+ *(size_t *)(out + n) =
36
+ *(size_t *)(ivec + n) ^= *(size_t *)(in + n);
37
+ }
38
+ len -= 16;
39
+ out += 16;
40
+ in += 16;
41
+ n = 0;
42
+ }
43
+ if (len) {
44
+ AES_encrypt(ivec, ivec, key);
45
+ while (len--) {
46
+ out[n] = ivec[n] ^= in[n];
47
+ ++n;
48
+ }
49
+ }
50
+
51
+ *num = n;
52
+ }
53
+
54
+ /*
55
+ * The input and output encrypted as though 128bit cfb mode is being used.
56
+ * The extra state information to record how much of the 128bit block we have
57
+ * used is contained in *num;
58
+ */
59
+ void AES_cfb128_decrypt(const uint8_t *in, uint8_t *out, size_t len, const AES_KEY *key, uint8_t ivec[16], uint32_t *num)
60
+ {
61
+ auto n = *num;
62
+
63
+ while (n && len) {
64
+ uint8_t c = *(in++);
65
+ *(out++) = ivec[n] ^ c;
66
+ ivec[n] = c;
67
+ --len;
68
+ n = (n + 1) % 16;
69
+ }
70
+ while (len >= 16) {
71
+ AES_encrypt(ivec, ivec, key);
72
+ for (; n < 16; n += sizeof(size_t)) {
73
+ size_t t = *(size_t *)(in + n);
74
+ *(size_t *)(out + n) = *(size_t *)(ivec + n) ^ t;
75
+ *(size_t *)(ivec + n) = t;
76
+ }
77
+ len -= 16;
78
+ out += 16;
79
+ in += 16;
80
+ n = 0;
81
+ }
82
+ if (len) {
83
+ AES_encrypt(ivec, ivec, key);
84
+ while (len--) {
85
+ uint8_t c = in[n];
86
+ out[n] = ivec[n] ^ c;
87
+ ivec[n] = c;
88
+ ++n;
89
+ }
90
+ }
91
+
92
+ *num = n;
93
+ }
94
+
95
+ } // namespace openssl
96
+
97
+ #endif // MMKV_DISABLE_CRYPT