@appzung/react-native-code-push 5.7.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 (191) hide show
  1. package/AlertAdapter.js +24 -0
  2. package/CONTRIBUTING.md +136 -0
  3. package/CodePush.js +666 -0
  4. package/CodePush.podspec +27 -0
  5. package/LICENSE.md +13 -0
  6. package/README.md +386 -0
  7. package/RestartManager.js +59 -0
  8. package/android/app/build.gradle +31 -0
  9. package/android/app/proguard-rules.pro +25 -0
  10. package/android/app/src/main/AndroidManifest.xml +10 -0
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +395 -0
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +37 -0
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +34 -0
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +102 -0
  15. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +16 -0
  16. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
  17. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +7 -0
  18. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +12 -0
  19. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +641 -0
  20. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +12 -0
  21. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +175 -0
  22. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +12 -0
  23. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +369 -0
  24. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +15 -0
  25. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +267 -0
  26. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +236 -0
  27. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +30 -0
  28. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +5 -0
  29. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +190 -0
  30. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +17 -0
  31. package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +173 -0
  32. package/android/build.gradle +20 -0
  33. package/android/codepush.gradle +113 -0
  34. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  35. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  36. package/android/gradle.properties +20 -0
  37. package/android/gradlew +164 -0
  38. package/android/gradlew.bat +90 -0
  39. package/android/settings.gradle +1 -0
  40. package/docs/api-android.md +65 -0
  41. package/docs/api-ios.md +31 -0
  42. package/docs/api-js.md +592 -0
  43. package/docs/multi-deployment-testing-android.md +107 -0
  44. package/docs/multi-deployment-testing-ios.md +53 -0
  45. package/docs/setup-android.md +406 -0
  46. package/docs/setup-ios.md +229 -0
  47. package/docs/setup-windows.md +65 -0
  48. package/gulpfile.js +302 -0
  49. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
  50. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
  51. package/ios/CodePush/Base64/README.md +47 -0
  52. package/ios/CodePush/CodePush.h +235 -0
  53. package/ios/CodePush/CodePush.m +1041 -0
  54. package/ios/CodePush/CodePushConfig.m +116 -0
  55. package/ios/CodePush/CodePushDownloadHandler.m +130 -0
  56. package/ios/CodePush/CodePushErrorUtils.m +20 -0
  57. package/ios/CodePush/CodePushPackage.m +598 -0
  58. package/ios/CodePush/CodePushTelemetryManager.m +175 -0
  59. package/ios/CodePush/CodePushUpdateUtils.m +376 -0
  60. package/ios/CodePush/CodePushUtils.m +9 -0
  61. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
  62. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
  63. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
  64. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
  65. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
  66. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
  67. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
  68. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
  69. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
  70. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
  71. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
  72. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
  73. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
  74. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
  75. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
  76. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
  77. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
  78. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
  79. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
  80. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
  81. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
  82. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
  83. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
  84. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
  85. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
  86. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
  87. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
  88. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
  89. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
  90. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
  91. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
  92. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
  93. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
  94. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
  95. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
  96. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
  97. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
  98. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
  99. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
  100. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
  101. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
  102. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
  103. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
  104. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
  105. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
  106. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
  107. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
  108. package/ios/CodePush/JWT/LICENSE +19 -0
  109. package/ios/CodePush/JWT/README.md +489 -0
  110. package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
  111. package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
  112. package/ios/CodePush/SSZipArchive/Common.h +81 -0
  113. package/ios/CodePush/SSZipArchive/README.md +1 -0
  114. package/ios/CodePush/SSZipArchive/SSZipArchive.h +76 -0
  115. package/ios/CodePush/SSZipArchive/SSZipArchive.m +691 -0
  116. package/ios/CodePush/SSZipArchive/aes/aes.h +198 -0
  117. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +541 -0
  118. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +294 -0
  119. package/ios/CodePush/SSZipArchive/aes/aeskey.c +548 -0
  120. package/ios/CodePush/SSZipArchive/aes/aesopt.h +739 -0
  121. package/ios/CodePush/SSZipArchive/aes/aestab.c +391 -0
  122. package/ios/CodePush/SSZipArchive/aes/aestab.h +173 -0
  123. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +126 -0
  124. package/ios/CodePush/SSZipArchive/aes/brg_types.h +219 -0
  125. package/ios/CodePush/SSZipArchive/aes/entropy.c +54 -0
  126. package/ios/CodePush/SSZipArchive/aes/entropy.h +16 -0
  127. package/ios/CodePush/SSZipArchive/aes/fileenc.c +144 -0
  128. package/ios/CodePush/SSZipArchive/aes/fileenc.h +121 -0
  129. package/ios/CodePush/SSZipArchive/aes/hmac.c +145 -0
  130. package/ios/CodePush/SSZipArchive/aes/hmac.h +103 -0
  131. package/ios/CodePush/SSZipArchive/aes/prng.c +155 -0
  132. package/ios/CodePush/SSZipArchive/aes/prng.h +82 -0
  133. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +103 -0
  134. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +57 -0
  135. package/ios/CodePush/SSZipArchive/aes/sha1.c +258 -0
  136. package/ios/CodePush/SSZipArchive/aes/sha1.h +73 -0
  137. package/ios/CodePush/SSZipArchive/minizip/crypt.h +130 -0
  138. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +369 -0
  139. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +175 -0
  140. package/ios/CodePush/SSZipArchive/minizip/mztools.c +284 -0
  141. package/ios/CodePush/SSZipArchive/minizip/mztools.h +31 -0
  142. package/ios/CodePush/SSZipArchive/minizip/unzip.c +1839 -0
  143. package/ios/CodePush/SSZipArchive/minizip/unzip.h +248 -0
  144. package/ios/CodePush/SSZipArchive/minizip/zip.c +1910 -0
  145. package/ios/CodePush/SSZipArchive/minizip/zip.h +202 -0
  146. package/ios/CodePush.xcodeproj/project.pbxproj +937 -0
  147. package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  148. package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  149. package/logging.js +6 -0
  150. package/package-mixins.js +69 -0
  151. package/package.json +47 -0
  152. package/request-fetch-adapter.js +52 -0
  153. package/scripts/generateBundledResourcesHash.js +125 -0
  154. package/scripts/getFilesInFolder.js +19 -0
  155. package/scripts/postlink/android/postlink.js +87 -0
  156. package/scripts/postlink/ios/postlink.js +116 -0
  157. package/scripts/postlink/run.js +11 -0
  158. package/scripts/postunlink/android/postunlink.js +74 -0
  159. package/scripts/postunlink/ios/postunlink.js +87 -0
  160. package/scripts/postunlink/run.js +11 -0
  161. package/scripts/recordFilesBeforeBundleCommand.js +41 -0
  162. package/scripts/tools/linkToolsAndroid.js +57 -0
  163. package/scripts/tools/linkToolsIos.js +130 -0
  164. package/typings/react-native-code-push.d.ts +446 -0
  165. package/windows/CodePush/CodePush.csproj +128 -0
  166. package/windows/CodePush/CodePushUtils.cs +47 -0
  167. package/windows/CodePush/FileUtils.cs +40 -0
  168. package/windows/CodePush/Properties/AssemblyInfo.cs +29 -0
  169. package/windows/CodePush/Properties/CodePush.rd.xml +33 -0
  170. package/windows/CodePush/UpdateManager.cs +305 -0
  171. package/windows/CodePush/UpdateUtils.cs +46 -0
  172. package/windows/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
  173. package/windows/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
  174. package/windows/CodePush.Net46/CodePush.Net46.csproj +103 -0
  175. package/windows/CodePush.Net46/CodePushUtils.cs +158 -0
  176. package/windows/CodePush.Net46/FileUtils.cs +55 -0
  177. package/windows/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
  178. package/windows/CodePush.Net46/UpdateManager.cs +330 -0
  179. package/windows/CodePush.Net46/UpdateUtils.cs +70 -0
  180. package/windows/CodePush.Net46/packages.config +5 -0
  181. package/windows/CodePush.Shared/CodePush.Shared.projitems +22 -0
  182. package/windows/CodePush.Shared/CodePush.Shared.shproj +13 -0
  183. package/windows/CodePush.Shared/CodePushConstants.cs +35 -0
  184. package/windows/CodePush.Shared/CodePushNativeModule.cs +329 -0
  185. package/windows/CodePush.Shared/CodePushReactPackage.cs +235 -0
  186. package/windows/CodePush.Shared/CodePushUtils.cs +70 -0
  187. package/windows/CodePush.Shared/InstallMode.cs +9 -0
  188. package/windows/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
  189. package/windows/CodePush.Shared/SettingsManager.cs +148 -0
  190. package/windows/CodePush.Shared/TelemetryManager.cs +250 -0
  191. package/windows/CodePush.Shared/UpdateState.cs +9 -0
@@ -0,0 +1,548 @@
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
+
21
+ #include "aesopt.h"
22
+ #include "aestab.h"
23
+
24
+ #ifdef USE_VIA_ACE_IF_PRESENT
25
+ # include "aes_via_ace.h"
26
+ #endif
27
+
28
+ #if defined(__cplusplus)
29
+ extern "C"
30
+ {
31
+ #endif
32
+
33
+ /* Initialise the key schedule from the user supplied key. The key
34
+ length can be specified in bytes, with legal values of 16, 24
35
+ and 32, or in bits, with legal values of 128, 192 and 256. These
36
+ values correspond with Nk values of 4, 6 and 8 respectively.
37
+
38
+ The following macros implement a single cycle in the key
39
+ schedule generation process. The number of cycles needed
40
+ for each cx->n_col and nk value is:
41
+
42
+ nk = 4 5 6 7 8
43
+ ------------------------------
44
+ cx->n_col = 4 10 9 8 7 7
45
+ cx->n_col = 5 14 11 10 9 9
46
+ cx->n_col = 6 19 15 12 11 11
47
+ cx->n_col = 7 21 19 16 13 14
48
+ cx->n_col = 8 29 23 19 17 14
49
+ */
50
+
51
+ #if defined( REDUCE_CODE_SIZE )
52
+ # define ls_box ls_sub
53
+ uint_32t ls_sub(const uint_32t t, const uint_32t n);
54
+ # define inv_mcol im_sub
55
+ uint_32t im_sub(const uint_32t x);
56
+ # ifdef ENC_KS_UNROLL
57
+ # undef ENC_KS_UNROLL
58
+ # endif
59
+ # ifdef DEC_KS_UNROLL
60
+ # undef DEC_KS_UNROLL
61
+ # endif
62
+ #endif
63
+
64
+ #if (FUNCS_IN_C & ENC_KEYING_IN_C)
65
+
66
+ #if defined(AES_128) || defined( AES_VAR )
67
+
68
+ #define ke4(k,i) \
69
+ { k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \
70
+ k[4*(i)+5] = ss[1] ^= ss[0]; \
71
+ k[4*(i)+6] = ss[2] ^= ss[1]; \
72
+ k[4*(i)+7] = ss[3] ^= ss[2]; \
73
+ }
74
+
75
+ AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1])
76
+ { uint_32t ss[4];
77
+
78
+ cx->ks[0] = ss[0] = word_in(key, 0);
79
+ cx->ks[1] = ss[1] = word_in(key, 1);
80
+ cx->ks[2] = ss[2] = word_in(key, 2);
81
+ cx->ks[3] = ss[3] = word_in(key, 3);
82
+
83
+ #ifdef ENC_KS_UNROLL
84
+ ke4(cx->ks, 0); ke4(cx->ks, 1);
85
+ ke4(cx->ks, 2); ke4(cx->ks, 3);
86
+ ke4(cx->ks, 4); ke4(cx->ks, 5);
87
+ ke4(cx->ks, 6); ke4(cx->ks, 7);
88
+ ke4(cx->ks, 8);
89
+ #else
90
+ { uint_32t i;
91
+ for(i = 0; i < 9; ++i)
92
+ ke4(cx->ks, i);
93
+ }
94
+ #endif
95
+ ke4(cx->ks, 9);
96
+ cx->inf.l = 0;
97
+ cx->inf.b[0] = 10 * 16;
98
+
99
+ #ifdef USE_VIA_ACE_IF_PRESENT
100
+ if(VIA_ACE_AVAILABLE)
101
+ cx->inf.b[1] = 0xff;
102
+ #endif
103
+ return EXIT_SUCCESS;
104
+ }
105
+
106
+ #endif
107
+
108
+ #if defined(AES_192) || defined( AES_VAR )
109
+
110
+ #define kef6(k,i) \
111
+ { k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \
112
+ k[6*(i)+ 7] = ss[1] ^= ss[0]; \
113
+ k[6*(i)+ 8] = ss[2] ^= ss[1]; \
114
+ k[6*(i)+ 9] = ss[3] ^= ss[2]; \
115
+ }
116
+
117
+ #define ke6(k,i) \
118
+ { kef6(k,i); \
119
+ k[6*(i)+10] = ss[4] ^= ss[3]; \
120
+ k[6*(i)+11] = ss[5] ^= ss[4]; \
121
+ }
122
+
123
+ AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1])
124
+ { uint_32t ss[6];
125
+
126
+ cx->ks[0] = ss[0] = word_in(key, 0);
127
+ cx->ks[1] = ss[1] = word_in(key, 1);
128
+ cx->ks[2] = ss[2] = word_in(key, 2);
129
+ cx->ks[3] = ss[3] = word_in(key, 3);
130
+ cx->ks[4] = ss[4] = word_in(key, 4);
131
+ cx->ks[5] = ss[5] = word_in(key, 5);
132
+
133
+ #ifdef ENC_KS_UNROLL
134
+ ke6(cx->ks, 0); ke6(cx->ks, 1);
135
+ ke6(cx->ks, 2); ke6(cx->ks, 3);
136
+ ke6(cx->ks, 4); ke6(cx->ks, 5);
137
+ ke6(cx->ks, 6);
138
+ #else
139
+ { uint_32t i;
140
+ for(i = 0; i < 7; ++i)
141
+ ke6(cx->ks, i);
142
+ }
143
+ #endif
144
+ kef6(cx->ks, 7);
145
+ cx->inf.l = 0;
146
+ cx->inf.b[0] = 12 * 16;
147
+
148
+ #ifdef USE_VIA_ACE_IF_PRESENT
149
+ if(VIA_ACE_AVAILABLE)
150
+ cx->inf.b[1] = 0xff;
151
+ #endif
152
+ return EXIT_SUCCESS;
153
+ }
154
+
155
+ #endif
156
+
157
+ #if defined(AES_256) || defined( AES_VAR )
158
+
159
+ #define kef8(k,i) \
160
+ { k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \
161
+ k[8*(i)+ 9] = ss[1] ^= ss[0]; \
162
+ k[8*(i)+10] = ss[2] ^= ss[1]; \
163
+ k[8*(i)+11] = ss[3] ^= ss[2]; \
164
+ }
165
+
166
+ #define ke8(k,i) \
167
+ { kef8(k,i); \
168
+ k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0); \
169
+ k[8*(i)+13] = ss[5] ^= ss[4]; \
170
+ k[8*(i)+14] = ss[6] ^= ss[5]; \
171
+ k[8*(i)+15] = ss[7] ^= ss[6]; \
172
+ }
173
+
174
+ AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1])
175
+ { uint_32t ss[8];
176
+
177
+ cx->ks[0] = ss[0] = word_in(key, 0);
178
+ cx->ks[1] = ss[1] = word_in(key, 1);
179
+ cx->ks[2] = ss[2] = word_in(key, 2);
180
+ cx->ks[3] = ss[3] = word_in(key, 3);
181
+ cx->ks[4] = ss[4] = word_in(key, 4);
182
+ cx->ks[5] = ss[5] = word_in(key, 5);
183
+ cx->ks[6] = ss[6] = word_in(key, 6);
184
+ cx->ks[7] = ss[7] = word_in(key, 7);
185
+
186
+ #ifdef ENC_KS_UNROLL
187
+ ke8(cx->ks, 0); ke8(cx->ks, 1);
188
+ ke8(cx->ks, 2); ke8(cx->ks, 3);
189
+ ke8(cx->ks, 4); ke8(cx->ks, 5);
190
+ #else
191
+ { uint_32t i;
192
+ for(i = 0; i < 6; ++i)
193
+ ke8(cx->ks, i);
194
+ }
195
+ #endif
196
+ kef8(cx->ks, 6);
197
+ cx->inf.l = 0;
198
+ cx->inf.b[0] = 14 * 16;
199
+
200
+ #ifdef USE_VIA_ACE_IF_PRESENT
201
+ if(VIA_ACE_AVAILABLE)
202
+ cx->inf.b[1] = 0xff;
203
+ #endif
204
+ return EXIT_SUCCESS;
205
+ }
206
+
207
+ #endif
208
+
209
+ #if defined( AES_VAR )
210
+
211
+ AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1])
212
+ {
213
+ switch(key_len)
214
+ {
215
+ case 16: case 128: return aes_encrypt_key128(key, cx);
216
+ case 24: case 192: return aes_encrypt_key192(key, cx);
217
+ case 32: case 256: return aes_encrypt_key256(key, cx);
218
+ default: return EXIT_FAILURE;
219
+ }
220
+ }
221
+
222
+ #endif
223
+
224
+ #endif
225
+
226
+ #if (FUNCS_IN_C & DEC_KEYING_IN_C)
227
+
228
+ /* this is used to store the decryption round keys */
229
+ /* in forward or reverse order */
230
+
231
+ #ifdef AES_REV_DKS
232
+ #define v(n,i) ((n) - (i) + 2 * ((i) & 3))
233
+ #else
234
+ #define v(n,i) (i)
235
+ #endif
236
+
237
+ #if DEC_ROUND == NO_TABLES
238
+ #define ff(x) (x)
239
+ #else
240
+ #define ff(x) inv_mcol(x)
241
+ #if defined( dec_imvars )
242
+ #define d_vars dec_imvars
243
+ #endif
244
+ #endif
245
+
246
+ #if defined(AES_128) || defined( AES_VAR )
247
+
248
+ #define k4e(k,i) \
249
+ { k[v(40,(4*(i))+4)] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \
250
+ k[v(40,(4*(i))+5)] = ss[1] ^= ss[0]; \
251
+ k[v(40,(4*(i))+6)] = ss[2] ^= ss[1]; \
252
+ k[v(40,(4*(i))+7)] = ss[3] ^= ss[2]; \
253
+ }
254
+
255
+ #if 1
256
+
257
+ #define kdf4(k,i) \
258
+ { ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3]; \
259
+ ss[1] = ss[1] ^ ss[3]; \
260
+ ss[2] = ss[2] ^ ss[3]; \
261
+ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \
262
+ ss[i % 4] ^= ss[4]; \
263
+ ss[4] ^= k[v(40,(4*(i)))]; k[v(40,(4*(i))+4)] = ff(ss[4]); \
264
+ ss[4] ^= k[v(40,(4*(i))+1)]; k[v(40,(4*(i))+5)] = ff(ss[4]); \
265
+ ss[4] ^= k[v(40,(4*(i))+2)]; k[v(40,(4*(i))+6)] = ff(ss[4]); \
266
+ ss[4] ^= k[v(40,(4*(i))+3)]; k[v(40,(4*(i))+7)] = ff(ss[4]); \
267
+ }
268
+
269
+ #define kd4(k,i) \
270
+ { ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \
271
+ ss[i % 4] ^= ss[4]; ss[4] = ff(ss[4]); \
272
+ k[v(40,(4*(i))+4)] = ss[4] ^= k[v(40,(4*(i)))]; \
273
+ k[v(40,(4*(i))+5)] = ss[4] ^= k[v(40,(4*(i))+1)]; \
274
+ k[v(40,(4*(i))+6)] = ss[4] ^= k[v(40,(4*(i))+2)]; \
275
+ k[v(40,(4*(i))+7)] = ss[4] ^= k[v(40,(4*(i))+3)]; \
276
+ }
277
+
278
+ #define kdl4(k,i) \
279
+ { ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; ss[i % 4] ^= ss[4]; \
280
+ k[v(40,(4*(i))+4)] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3]; \
281
+ k[v(40,(4*(i))+5)] = ss[1] ^ ss[3]; \
282
+ k[v(40,(4*(i))+6)] = ss[0]; \
283
+ k[v(40,(4*(i))+7)] = ss[1]; \
284
+ }
285
+
286
+ #else
287
+
288
+ #define kdf4(k,i) \
289
+ { ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ff(ss[0]); \
290
+ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ff(ss[1]); \
291
+ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ff(ss[2]); \
292
+ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ff(ss[3]); \
293
+ }
294
+
295
+ #define kd4(k,i) \
296
+ { ss[4] = ls_box(ss[3],3) ^ t_use(r,c)[i]; \
297
+ ss[0] ^= ss[4]; ss[4] = ff(ss[4]); k[v(40,(4*(i))+ 4)] = ss[4] ^= k[v(40,(4*(i)))]; \
298
+ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[4] ^= k[v(40,(4*(i))+ 1)]; \
299
+ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[4] ^= k[v(40,(4*(i))+ 2)]; \
300
+ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[4] ^= k[v(40,(4*(i))+ 3)]; \
301
+ }
302
+
303
+ #define kdl4(k,i) \
304
+ { ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ss[0]; \
305
+ ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[1]; \
306
+ ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[2]; \
307
+ ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[3]; \
308
+ }
309
+
310
+ #endif
311
+
312
+ AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1])
313
+ { uint_32t ss[5];
314
+ #if defined( d_vars )
315
+ d_vars;
316
+ #endif
317
+ cx->ks[v(40,(0))] = ss[0] = word_in(key, 0);
318
+ cx->ks[v(40,(1))] = ss[1] = word_in(key, 1);
319
+ cx->ks[v(40,(2))] = ss[2] = word_in(key, 2);
320
+ cx->ks[v(40,(3))] = ss[3] = word_in(key, 3);
321
+
322
+ #ifdef DEC_KS_UNROLL
323
+ kdf4(cx->ks, 0); kd4(cx->ks, 1);
324
+ kd4(cx->ks, 2); kd4(cx->ks, 3);
325
+ kd4(cx->ks, 4); kd4(cx->ks, 5);
326
+ kd4(cx->ks, 6); kd4(cx->ks, 7);
327
+ kd4(cx->ks, 8); kdl4(cx->ks, 9);
328
+ #else
329
+ { uint_32t i;
330
+ for(i = 0; i < 10; ++i)
331
+ k4e(cx->ks, i);
332
+ #if !(DEC_ROUND == NO_TABLES)
333
+ for(i = N_COLS; i < 10 * N_COLS; ++i)
334
+ cx->ks[i] = inv_mcol(cx->ks[i]);
335
+ #endif
336
+ }
337
+ #endif
338
+ cx->inf.l = 0;
339
+ cx->inf.b[0] = 10 * 16;
340
+
341
+ #ifdef USE_VIA_ACE_IF_PRESENT
342
+ if(VIA_ACE_AVAILABLE)
343
+ cx->inf.b[1] = 0xff;
344
+ #endif
345
+ return EXIT_SUCCESS;
346
+ }
347
+
348
+ #endif
349
+
350
+ #if defined(AES_192) || defined( AES_VAR )
351
+
352
+ #define k6ef(k,i) \
353
+ { k[v(48,(6*(i))+ 6)] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \
354
+ k[v(48,(6*(i))+ 7)] = ss[1] ^= ss[0]; \
355
+ k[v(48,(6*(i))+ 8)] = ss[2] ^= ss[1]; \
356
+ k[v(48,(6*(i))+ 9)] = ss[3] ^= ss[2]; \
357
+ }
358
+
359
+ #define k6e(k,i) \
360
+ { k6ef(k,i); \
361
+ k[v(48,(6*(i))+10)] = ss[4] ^= ss[3]; \
362
+ k[v(48,(6*(i))+11)] = ss[5] ^= ss[4]; \
363
+ }
364
+
365
+ #define kdf6(k,i) \
366
+ { ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ff(ss[0]); \
367
+ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ff(ss[1]); \
368
+ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ff(ss[2]); \
369
+ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ff(ss[3]); \
370
+ ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ff(ss[4]); \
371
+ ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ff(ss[5]); \
372
+ }
373
+
374
+ #define kd6(k,i) \
375
+ { ss[6] = ls_box(ss[5],3) ^ t_use(r,c)[i]; \
376
+ ss[0] ^= ss[6]; ss[6] = ff(ss[6]); k[v(48,(6*(i))+ 6)] = ss[6] ^= k[v(48,(6*(i)))]; \
377
+ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[6] ^= k[v(48,(6*(i))+ 1)]; \
378
+ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[6] ^= k[v(48,(6*(i))+ 2)]; \
379
+ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[6] ^= k[v(48,(6*(i))+ 3)]; \
380
+ ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ss[6] ^= k[v(48,(6*(i))+ 4)]; \
381
+ ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ss[6] ^= k[v(48,(6*(i))+ 5)]; \
382
+ }
383
+
384
+ #define kdl6(k,i) \
385
+ { ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ss[0]; \
386
+ ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[1]; \
387
+ ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[2]; \
388
+ ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[3]; \
389
+ }
390
+
391
+ AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1])
392
+ { uint_32t ss[7];
393
+ #if defined( d_vars )
394
+ d_vars;
395
+ #endif
396
+ cx->ks[v(48,(0))] = ss[0] = word_in(key, 0);
397
+ cx->ks[v(48,(1))] = ss[1] = word_in(key, 1);
398
+ cx->ks[v(48,(2))] = ss[2] = word_in(key, 2);
399
+ cx->ks[v(48,(3))] = ss[3] = word_in(key, 3);
400
+
401
+ #ifdef DEC_KS_UNROLL
402
+ cx->ks[v(48,(4))] = ff(ss[4] = word_in(key, 4));
403
+ cx->ks[v(48,(5))] = ff(ss[5] = word_in(key, 5));
404
+ kdf6(cx->ks, 0); kd6(cx->ks, 1);
405
+ kd6(cx->ks, 2); kd6(cx->ks, 3);
406
+ kd6(cx->ks, 4); kd6(cx->ks, 5);
407
+ kd6(cx->ks, 6); kdl6(cx->ks, 7);
408
+ #else
409
+ cx->ks[v(48,(4))] = ss[4] = word_in(key, 4);
410
+ cx->ks[v(48,(5))] = ss[5] = word_in(key, 5);
411
+ { uint_32t i;
412
+
413
+ for(i = 0; i < 7; ++i)
414
+ k6e(cx->ks, i);
415
+ k6ef(cx->ks, 7);
416
+ #if !(DEC_ROUND == NO_TABLES)
417
+ for(i = N_COLS; i < 12 * N_COLS; ++i)
418
+ cx->ks[i] = inv_mcol(cx->ks[i]);
419
+ #endif
420
+ }
421
+ #endif
422
+ cx->inf.l = 0;
423
+ cx->inf.b[0] = 12 * 16;
424
+
425
+ #ifdef USE_VIA_ACE_IF_PRESENT
426
+ if(VIA_ACE_AVAILABLE)
427
+ cx->inf.b[1] = 0xff;
428
+ #endif
429
+ return EXIT_SUCCESS;
430
+ }
431
+
432
+ #endif
433
+
434
+ #if defined(AES_256) || defined( AES_VAR )
435
+
436
+ #define k8ef(k,i) \
437
+ { k[v(56,(8*(i))+ 8)] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \
438
+ k[v(56,(8*(i))+ 9)] = ss[1] ^= ss[0]; \
439
+ k[v(56,(8*(i))+10)] = ss[2] ^= ss[1]; \
440
+ k[v(56,(8*(i))+11)] = ss[3] ^= ss[2]; \
441
+ }
442
+
443
+ #define k8e(k,i) \
444
+ { k8ef(k,i); \
445
+ k[v(56,(8*(i))+12)] = ss[4] ^= ls_box(ss[3],0); \
446
+ k[v(56,(8*(i))+13)] = ss[5] ^= ss[4]; \
447
+ k[v(56,(8*(i))+14)] = ss[6] ^= ss[5]; \
448
+ k[v(56,(8*(i))+15)] = ss[7] ^= ss[6]; \
449
+ }
450
+
451
+ #define kdf8(k,i) \
452
+ { ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ff(ss[0]); \
453
+ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ff(ss[1]); \
454
+ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ff(ss[2]); \
455
+ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ff(ss[3]); \
456
+ ss[4] ^= ls_box(ss[3],0); k[v(56,(8*(i))+12)] = ff(ss[4]); \
457
+ ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ff(ss[5]); \
458
+ ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ff(ss[6]); \
459
+ ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ff(ss[7]); \
460
+ }
461
+
462
+ #define kd8(k,i) \
463
+ { ss[8] = ls_box(ss[7],3) ^ t_use(r,c)[i]; \
464
+ ss[0] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+ 8)] = ss[8] ^= k[v(56,(8*(i)))]; \
465
+ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[8] ^= k[v(56,(8*(i))+ 1)]; \
466
+ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[8] ^= k[v(56,(8*(i))+ 2)]; \
467
+ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[8] ^= k[v(56,(8*(i))+ 3)]; \
468
+ ss[8] = ls_box(ss[3],0); \
469
+ ss[4] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+12)] = ss[8] ^= k[v(56,(8*(i))+ 4)]; \
470
+ ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ss[8] ^= k[v(56,(8*(i))+ 5)]; \
471
+ ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ss[8] ^= k[v(56,(8*(i))+ 6)]; \
472
+ ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ss[8] ^= k[v(56,(8*(i))+ 7)]; \
473
+ }
474
+
475
+ #define kdl8(k,i) \
476
+ { ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ss[0]; \
477
+ ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[1]; \
478
+ ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[2]; \
479
+ ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[3]; \
480
+ }
481
+
482
+ AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1])
483
+ { uint_32t ss[9];
484
+ #if defined( d_vars )
485
+ d_vars;
486
+ #endif
487
+ cx->ks[v(56,(0))] = ss[0] = word_in(key, 0);
488
+ cx->ks[v(56,(1))] = ss[1] = word_in(key, 1);
489
+ cx->ks[v(56,(2))] = ss[2] = word_in(key, 2);
490
+ cx->ks[v(56,(3))] = ss[3] = word_in(key, 3);
491
+
492
+ #ifdef DEC_KS_UNROLL
493
+ cx->ks[v(56,(4))] = ff(ss[4] = word_in(key, 4));
494
+ cx->ks[v(56,(5))] = ff(ss[5] = word_in(key, 5));
495
+ cx->ks[v(56,(6))] = ff(ss[6] = word_in(key, 6));
496
+ cx->ks[v(56,(7))] = ff(ss[7] = word_in(key, 7));
497
+ kdf8(cx->ks, 0); kd8(cx->ks, 1);
498
+ kd8(cx->ks, 2); kd8(cx->ks, 3);
499
+ kd8(cx->ks, 4); kd8(cx->ks, 5);
500
+ kdl8(cx->ks, 6);
501
+ #else
502
+ cx->ks[v(56,(4))] = ss[4] = word_in(key, 4);
503
+ cx->ks[v(56,(5))] = ss[5] = word_in(key, 5);
504
+ cx->ks[v(56,(6))] = ss[6] = word_in(key, 6);
505
+ cx->ks[v(56,(7))] = ss[7] = word_in(key, 7);
506
+ { uint_32t i;
507
+
508
+ for(i = 0; i < 6; ++i)
509
+ k8e(cx->ks, i);
510
+ k8ef(cx->ks, 6);
511
+ #if !(DEC_ROUND == NO_TABLES)
512
+ for(i = N_COLS; i < 14 * N_COLS; ++i)
513
+ cx->ks[i] = inv_mcol(cx->ks[i]);
514
+ #endif
515
+ }
516
+ #endif
517
+ cx->inf.l = 0;
518
+ cx->inf.b[0] = 14 * 16;
519
+
520
+ #ifdef USE_VIA_ACE_IF_PRESENT
521
+ if(VIA_ACE_AVAILABLE)
522
+ cx->inf.b[1] = 0xff;
523
+ #endif
524
+ return EXIT_SUCCESS;
525
+ }
526
+
527
+ #endif
528
+
529
+ #if defined( AES_VAR )
530
+
531
+ AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1])
532
+ {
533
+ switch(key_len)
534
+ {
535
+ case 16: case 128: return aes_decrypt_key128(key, cx);
536
+ case 24: case 192: return aes_decrypt_key192(key, cx);
537
+ case 32: case 256: return aes_decrypt_key256(key, cx);
538
+ default: return EXIT_FAILURE;
539
+ }
540
+ }
541
+
542
+ #endif
543
+
544
+ #endif
545
+
546
+ #if defined(__cplusplus)
547
+ }
548
+ #endif