@appzung/react-native-code-push 8.3.2 → 10.0.0-rc1

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/CodePush.js +22 -19
  2. package/CodePush.podspec +3 -3
  3. package/LICENSE.md +1 -1
  4. package/README.md +159 -296
  5. package/android/app/.gradle/config.properties +2 -0
  6. package/android/app/build.gradle +2 -0
  7. package/android/app/local.properties +8 -0
  8. package/android/app/src/main/AndroidManifest.xml +1 -2
  9. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +27 -21
  10. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBuilder.java +5 -5
  11. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +1 -1
  12. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +1 -1
  13. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInstallMode.java +2 -2
  14. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidPublicKeyException.java +2 -2
  15. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushInvalidUpdateException.java +1 -1
  16. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushMalformedDataException.java +2 -2
  17. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +5 -5
  18. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNotInitializedException.java +2 -2
  19. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushTelemetryManager.java +14 -14
  20. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUnknownException.java +2 -2
  21. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +1 -1
  22. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateState.java +2 -2
  23. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +16 -9
  24. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUtils.java +1 -1
  25. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgress.java +1 -1
  26. package/android/app/src/main/java/com/microsoft/codepush/react/DownloadProgressCallback.java +1 -1
  27. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +1 -1
  28. package/android/app/src/main/java/com/microsoft/codepush/react/ReactInstanceHolder.java +1 -1
  29. package/android/app/src/main/java/com/microsoft/codepush/react/SettingsManager.java +1 -1
  30. package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +1 -1
  31. package/android/build.gradle +3 -0
  32. package/android/codepush.gradle +3 -3
  33. package/docs/advanced-usage.md +56 -0
  34. package/docs/api-android.md +12 -75
  35. package/docs/api-ios.md +5 -17
  36. package/docs/api-js.md +18 -55
  37. package/docs/setup-android.md +15 -397
  38. package/docs/setup-ios.md +24 -198
  39. package/docs/setup-windows.md +7 -74
  40. package/ios/CodePush/CodePush.h +4 -4
  41. package/ios/CodePush/CodePush.m +10 -9
  42. package/ios/CodePush/CodePushConfig.m +14 -11
  43. package/ios/CodePush/CodePushPackage.m +60 -60
  44. package/ios/CodePush/CodePushTelemetryManager.m +13 -13
  45. package/ios/CodePush.xcodeproj/project.pbxproj +24 -470
  46. package/ios/PrivacyInfo.xcprivacy +31 -0
  47. package/package.json +27 -24
  48. package/react-native.config.js +1 -1
  49. package/scripts/generateBundledResourcesHash.js +1 -1
  50. package/scripts/getFilesInFolder.js +1 -1
  51. package/scripts/recordFilesBeforeBundleCommand.js +1 -1
  52. package/typings/react-native-code-push.d.ts +22 -22
  53. package/windows/CodePush/CodePushConfig.cpp +3 -3
  54. package/windows/CodePush/CodePushConfig.h +3 -3
  55. package/windows/CodePush/CodePushNativeModule.cpp +27 -27
  56. package/windows/CodePush/CodePushNativeModule.h +4 -4
  57. package/windows/CodePush/CodePushTelemetryManager.cpp +12 -12
  58. package/windows/CodePush/CodePushTelemetryManager.h +1 -1
  59. package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
  60. package/.azurepipelines/test-rn-code-push.yml +0 -94
  61. package/.config/CredScanSuppressions.json +0 -14
  62. package/SECURITY.md +0 -41
  63. package/docs/multi-deployment-testing-android.md +0 -148
  64. package/docs/multi-deployment-testing-ios.md +0 -59
  65. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +0 -34
  66. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +0 -252
  67. package/ios/CodePush/Base64/README.md +0 -47
  68. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +0 -69
  69. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +0 -16
  70. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +0 -51
  71. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +0 -15
  72. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +0 -55
  73. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +0 -24
  74. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +0 -41
  75. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +0 -28
  76. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +0 -205
  77. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +0 -103
  78. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +0 -322
  79. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +0 -37
  80. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +0 -145
  81. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +0 -35
  82. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +0 -551
  83. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +0 -23
  84. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +0 -43
  85. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +0 -230
  86. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +0 -31
  87. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +0 -113
  88. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +0 -38
  89. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +0 -500
  90. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +0 -18
  91. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +0 -214
  92. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +0 -23
  93. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +0 -29
  94. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +0 -19
  95. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +0 -68
  96. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +0 -18
  97. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +0 -72
  98. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +0 -67
  99. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +0 -111
  100. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +0 -119
  101. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +0 -307
  102. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +0 -94
  103. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +0 -619
  104. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +0 -164
  105. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +0 -514
  106. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +0 -24
  107. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +0 -11
  108. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +0 -52
  109. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +0 -5
  110. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +0 -28
  111. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +0 -70
  112. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +0 -22
  113. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +0 -34
  114. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +0 -73
  115. package/ios/CodePush/JWT/LICENSE +0 -19
  116. package/ios/CodePush/JWT/README.md +0 -489
  117. package/ios/CodePush/SSZipArchive/Common.h +0 -81
  118. package/ios/CodePush/SSZipArchive/README.md +0 -1
  119. package/ios/CodePush/SSZipArchive/SSZipArchive.h +0 -76
  120. package/ios/CodePush/SSZipArchive/SSZipArchive.m +0 -691
  121. package/ios/CodePush/SSZipArchive/aes/aes.h +0 -198
  122. package/ios/CodePush/SSZipArchive/aes/aes_via_ace.h +0 -541
  123. package/ios/CodePush/SSZipArchive/aes/aescrypt.c +0 -294
  124. package/ios/CodePush/SSZipArchive/aes/aeskey.c +0 -548
  125. package/ios/CodePush/SSZipArchive/aes/aesopt.h +0 -739
  126. package/ios/CodePush/SSZipArchive/aes/aestab.c +0 -391
  127. package/ios/CodePush/SSZipArchive/aes/aestab.h +0 -173
  128. package/ios/CodePush/SSZipArchive/aes/brg_endian.h +0 -126
  129. package/ios/CodePush/SSZipArchive/aes/brg_types.h +0 -219
  130. package/ios/CodePush/SSZipArchive/aes/entropy.c +0 -54
  131. package/ios/CodePush/SSZipArchive/aes/entropy.h +0 -16
  132. package/ios/CodePush/SSZipArchive/aes/fileenc.c +0 -144
  133. package/ios/CodePush/SSZipArchive/aes/fileenc.h +0 -121
  134. package/ios/CodePush/SSZipArchive/aes/hmac.c +0 -145
  135. package/ios/CodePush/SSZipArchive/aes/hmac.h +0 -103
  136. package/ios/CodePush/SSZipArchive/aes/prng.c +0 -155
  137. package/ios/CodePush/SSZipArchive/aes/prng.h +0 -82
  138. package/ios/CodePush/SSZipArchive/aes/pwd2key.c +0 -103
  139. package/ios/CodePush/SSZipArchive/aes/pwd2key.h +0 -57
  140. package/ios/CodePush/SSZipArchive/aes/sha1.c +0 -258
  141. package/ios/CodePush/SSZipArchive/aes/sha1.h +0 -73
  142. package/ios/CodePush/SSZipArchive/minizip/crypt.h +0 -130
  143. package/ios/CodePush/SSZipArchive/minizip/ioapi.c +0 -369
  144. package/ios/CodePush/SSZipArchive/minizip/ioapi.h +0 -175
  145. package/ios/CodePush/SSZipArchive/minizip/mztools.c +0 -284
  146. package/ios/CodePush/SSZipArchive/minizip/mztools.h +0 -31
  147. package/ios/CodePush/SSZipArchive/minizip/unzip.c +0 -1839
  148. package/ios/CodePush/SSZipArchive/minizip/unzip.h +0 -248
  149. package/ios/CodePush/SSZipArchive/minizip/zip.c +0 -1910
  150. package/ios/CodePush/SSZipArchive/minizip/zip.h +0 -202
  151. package/scripts/postlink/android/postlink.js +0 -87
  152. package/scripts/postlink/ios/postlink.js +0 -116
  153. package/scripts/postlink/run.js +0 -11
  154. package/scripts/postunlink/android/postunlink.js +0 -74
  155. package/scripts/postunlink/ios/postunlink.js +0 -87
  156. package/scripts/postunlink/run.js +0 -11
  157. package/scripts/tools/linkToolsAndroid.js +0 -57
  158. package/scripts/tools/linkToolsIos.js +0 -130
  159. package/windows-legacy/CodePush/CodePush.csproj +0 -128
  160. package/windows-legacy/CodePush/CodePushUtils.cs +0 -47
  161. package/windows-legacy/CodePush/FileUtils.cs +0 -40
  162. package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +0 -29
  163. package/windows-legacy/CodePush/Properties/CodePush.rd.xml +0 -33
  164. package/windows-legacy/CodePush/UpdateManager.cs +0 -305
  165. package/windows-legacy/CodePush/UpdateUtils.cs +0 -46
  166. package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -28
  167. package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -106
  168. package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +0 -103
  169. package/windows-legacy/CodePush.Net46/CodePushUtils.cs +0 -158
  170. package/windows-legacy/CodePush.Net46/FileUtils.cs +0 -55
  171. package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +0 -36
  172. package/windows-legacy/CodePush.Net46/UpdateManager.cs +0 -330
  173. package/windows-legacy/CodePush.Net46/UpdateUtils.cs +0 -70
  174. package/windows-legacy/CodePush.Net46/packages.config +0 -5
  175. package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +0 -105
  176. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +0 -137
  177. package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +0 -36
  178. package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +0 -117
  179. package/windows-legacy/CodePush.Net46.Test/app.config +0 -11
  180. package/windows-legacy/CodePush.Net46.Test/packages.config +0 -4
  181. package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +0 -22
  182. package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +0 -13
  183. package/windows-legacy/CodePush.Shared/CodePushConstants.cs +0 -35
  184. package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +0 -329
  185. package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +0 -235
  186. package/windows-legacy/CodePush.Shared/CodePushUtils.cs +0 -70
  187. package/windows-legacy/CodePush.Shared/InstallMode.cs +0 -9
  188. package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +0 -44
  189. package/windows-legacy/CodePush.Shared/SettingsManager.cs +0 -148
  190. package/windows-legacy/CodePush.Shared/TelemetryManager.cs +0 -250
  191. package/windows-legacy/CodePush.Shared/UpdateState.cs +0 -9
@@ -1,294 +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
-
21
- #include "aesopt.h"
22
- #include "aestab.h"
23
-
24
- #if defined(__cplusplus)
25
- extern "C"
26
- {
27
- #endif
28
-
29
- #define si(y,x,k,c) (s(y,c) = word_in(x, c) ^ (k)[c])
30
- #define so(y,x,c) word_out(y, c, s(x,c))
31
-
32
- #if defined(ARRAYS)
33
- #define locals(y,x) x[4],y[4]
34
- #else
35
- #define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3
36
- #endif
37
-
38
- #define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
39
- s(y,2) = s(x,2); s(y,3) = s(x,3);
40
- #define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3)
41
- #define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3)
42
- #define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3)
43
-
44
- #if ( FUNCS_IN_C & ENCRYPTION_IN_C )
45
-
46
- /* Visual C++ .Net v7.1 provides the fastest encryption code when using
47
- Pentium optimiation with small code but this is poor for decryption
48
- so we need to control this with the following VC++ pragmas
49
- */
50
-
51
- #if defined( _MSC_VER ) && !defined( _WIN64 )
52
- #pragma optimize( "s", on )
53
- #endif
54
-
55
- /* Given the column (c) of the output state variable, the following
56
- macros give the input state variables which are needed in its
57
- computation for each row (r) of the state. All the alternative
58
- macros give the same end values but expand into different ways
59
- of calculating these values. In particular the complex macro
60
- used for dynamically variable block sizes is designed to expand
61
- to a compile time constant whenever possible but will expand to
62
- conditional clauses on some branches (I am grateful to Frank
63
- Yellin for this construction)
64
- */
65
-
66
- #define fwd_var(x,r,c)\
67
- ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
68
- : r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\
69
- : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
70
- : ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2)))
71
-
72
- #if defined(FT4_SET)
73
- #undef dec_fmvars
74
- #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c))
75
- #elif defined(FT1_SET)
76
- #undef dec_fmvars
77
- #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(f,n),fwd_var,rf1,c))
78
- #else
79
- #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ fwd_mcol(no_table(x,t_use(s,box),fwd_var,rf1,c)))
80
- #endif
81
-
82
- #if defined(FL4_SET)
83
- #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,l),fwd_var,rf1,c))
84
- #elif defined(FL1_SET)
85
- #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(f,l),fwd_var,rf1,c))
86
- #else
87
- #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c))
88
- #endif
89
-
90
- AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1])
91
- { uint_32t locals(b0, b1);
92
- const uint_32t *kp;
93
- #if defined( dec_fmvars )
94
- dec_fmvars; /* declare variables for fwd_mcol() if needed */
95
- #endif
96
-
97
- if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 )
98
- return EXIT_FAILURE;
99
-
100
- kp = cx->ks;
101
- state_in(b0, in, kp);
102
-
103
- #if (ENC_UNROLL == FULL)
104
-
105
- switch(cx->inf.b[0])
106
- {
107
- case 14 * 16:
108
- round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
109
- round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
110
- kp += 2 * N_COLS;
111
- case 12 * 16:
112
- round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
113
- round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
114
- kp += 2 * N_COLS;
115
- case 10 * 16:
116
- round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
117
- round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
118
- round(fwd_rnd, b1, b0, kp + 3 * N_COLS);
119
- round(fwd_rnd, b0, b1, kp + 4 * N_COLS);
120
- round(fwd_rnd, b1, b0, kp + 5 * N_COLS);
121
- round(fwd_rnd, b0, b1, kp + 6 * N_COLS);
122
- round(fwd_rnd, b1, b0, kp + 7 * N_COLS);
123
- round(fwd_rnd, b0, b1, kp + 8 * N_COLS);
124
- round(fwd_rnd, b1, b0, kp + 9 * N_COLS);
125
- round(fwd_lrnd, b0, b1, kp +10 * N_COLS);
126
- }
127
-
128
- #else
129
-
130
- #if (ENC_UNROLL == PARTIAL)
131
- { uint_32t rnd;
132
- for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
133
- {
134
- kp += N_COLS;
135
- round(fwd_rnd, b1, b0, kp);
136
- kp += N_COLS;
137
- round(fwd_rnd, b0, b1, kp);
138
- }
139
- kp += N_COLS;
140
- round(fwd_rnd, b1, b0, kp);
141
- #else
142
- { uint_32t rnd;
143
- for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
144
- {
145
- kp += N_COLS;
146
- round(fwd_rnd, b1, b0, kp);
147
- l_copy(b0, b1);
148
- }
149
- #endif
150
- kp += N_COLS;
151
- round(fwd_lrnd, b0, b1, kp);
152
- }
153
- #endif
154
-
155
- state_out(out, b0);
156
- return EXIT_SUCCESS;
157
- }
158
-
159
- #endif
160
-
161
- #if ( FUNCS_IN_C & DECRYPTION_IN_C)
162
-
163
- /* Visual C++ .Net v7.1 provides the fastest encryption code when using
164
- Pentium optimiation with small code but this is poor for decryption
165
- so we need to control this with the following VC++ pragmas
166
- */
167
-
168
- #if defined( _MSC_VER ) && !defined( _WIN64 )
169
- #pragma optimize( "t", on )
170
- #endif
171
-
172
- /* Given the column (c) of the output state variable, the following
173
- macros give the input state variables which are needed in its
174
- computation for each row (r) of the state. All the alternative
175
- macros give the same end values but expand into different ways
176
- of calculating these values. In particular the complex macro
177
- used for dynamically variable block sizes is designed to expand
178
- to a compile time constant whenever possible but will expand to
179
- conditional clauses on some branches (I am grateful to Frank
180
- Yellin for this construction)
181
- */
182
-
183
- #define inv_var(x,r,c)\
184
- ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
185
- : r == 1 ? ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))\
186
- : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
187
- : ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0)))
188
-
189
- #if defined(IT4_SET)
190
- #undef dec_imvars
191
- #define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,n),inv_var,rf1,c))
192
- #elif defined(IT1_SET)
193
- #undef dec_imvars
194
- #define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(i,n),inv_var,rf1,c))
195
- #else
196
- #define inv_rnd(y,x,k,c) (s(y,c) = inv_mcol((k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c)))
197
- #endif
198
-
199
- #if defined(IL4_SET)
200
- #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,l),inv_var,rf1,c))
201
- #elif defined(IL1_SET)
202
- #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(i,l),inv_var,rf1,c))
203
- #else
204
- #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c))
205
- #endif
206
-
207
- /* This code can work with the decryption key schedule in the */
208
- /* order that is used for encrytpion (where the 1st decryption */
209
- /* round key is at the high end ot the schedule) or with a key */
210
- /* schedule that has been reversed to put the 1st decryption */
211
- /* round key at the low end of the schedule in memory (when */
212
- /* AES_REV_DKS is defined) */
213
-
214
- #ifdef AES_REV_DKS
215
- #define key_ofs 0
216
- #define rnd_key(n) (kp + n * N_COLS)
217
- #else
218
- #define key_ofs 1
219
- #define rnd_key(n) (kp - n * N_COLS)
220
- #endif
221
-
222
- AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1])
223
- { uint_32t locals(b0, b1);
224
- #if defined( dec_imvars )
225
- dec_imvars; /* declare variables for inv_mcol() if needed */
226
- #endif
227
- const uint_32t *kp;
228
-
229
- if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 )
230
- return EXIT_FAILURE;
231
-
232
- kp = cx->ks + (key_ofs ? (cx->inf.b[0] >> 2) : 0);
233
- state_in(b0, in, kp);
234
-
235
- #if (DEC_UNROLL == FULL)
236
-
237
- kp = cx->ks + (key_ofs ? 0 : (cx->inf.b[0] >> 2));
238
- switch(cx->inf.b[0])
239
- {
240
- case 14 * 16:
241
- round(inv_rnd, b1, b0, rnd_key(-13));
242
- round(inv_rnd, b0, b1, rnd_key(-12));
243
- case 12 * 16:
244
- round(inv_rnd, b1, b0, rnd_key(-11));
245
- round(inv_rnd, b0, b1, rnd_key(-10));
246
- case 10 * 16:
247
- round(inv_rnd, b1, b0, rnd_key(-9));
248
- round(inv_rnd, b0, b1, rnd_key(-8));
249
- round(inv_rnd, b1, b0, rnd_key(-7));
250
- round(inv_rnd, b0, b1, rnd_key(-6));
251
- round(inv_rnd, b1, b0, rnd_key(-5));
252
- round(inv_rnd, b0, b1, rnd_key(-4));
253
- round(inv_rnd, b1, b0, rnd_key(-3));
254
- round(inv_rnd, b0, b1, rnd_key(-2));
255
- round(inv_rnd, b1, b0, rnd_key(-1));
256
- round(inv_lrnd, b0, b1, rnd_key( 0));
257
- }
258
-
259
- #else
260
-
261
- #if (DEC_UNROLL == PARTIAL)
262
- { uint_32t rnd;
263
- for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
264
- {
265
- kp = rnd_key(1);
266
- round(inv_rnd, b1, b0, kp);
267
- kp = rnd_key(1);
268
- round(inv_rnd, b0, b1, kp);
269
- }
270
- kp = rnd_key(1);
271
- round(inv_rnd, b1, b0, kp);
272
- #else
273
- { uint_32t rnd;
274
- for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
275
- {
276
- kp = rnd_key(1);
277
- round(inv_rnd, b1, b0, kp);
278
- l_copy(b0, b1);
279
- }
280
- #endif
281
- kp = rnd_key(1);
282
- round(inv_lrnd, b0, b1, kp);
283
- }
284
- #endif
285
-
286
- state_out(out, b0);
287
- return EXIT_SUCCESS;
288
- }
289
-
290
- #endif
291
-
292
- #if defined(__cplusplus)
293
- }
294
- #endif