Commit 6a02d5d
authored
Enable AES encryption on Browser WASM (#70915)
* Copy RijndaelManagedTransform from reference source
Copied from https://github.com/microsoft/referencesource/blob/5697c29004a34d80acdaf5742d7e699022c64ecd/mscorlib/system/security/cryptography/rijndaelmanagedtransform.cs
* Format document
* Clean up RijndaelManagedTransform
1. Add copyright
2. Remove unnecessary attributes
3. Mark class as internal
4. Remove FEATURE_CRYPTO define. Only support CipherMode.CBC and PaddingMode.PKCS7.
5. Remove Contracts and replace with Debug.Assert.
* Get RijndaelManagedTransform to compile successfully.
* Make RijndaelManagedTransform implement ILiteSymmetricCipher
And hook it up to AesImplementation for Browser.
* Enable all the Aes tests on Browser.
Mark Aes APIs as supported on Browser.
* Mark all CipherModes and PaddingModes other than CBC and PKCS7 as unsupported on Browser
* Make fields readonly and rename according to code style.
* Replace RijndaelManagedTransformMode with bool encrypting.
* Throw PNSE for unsupported CipherMode and PaddingMode.
Remove unnecessary parameters and fields that aren't supported.
* Fix DecryptorReuse_LeadsToSameResults test so it works on Browser and passes for all CipherModes on other platforms
* Spanify the input buffer in RijndaelManagedTransform Transform and TransformFinal.
* First round of PR feedback
* Make _Nb constant BlockSizeInts
* Get rid of unnecessary allocations
* Remove unsafe pointers from RijndaelManagedTransform.
* PR feedback
Encrypt and Decrypt index arrays are constant values.
Use CopyTo in more places.
* Rename RijndaelManagedTransform => AesManagedTransform
* Change AesManagedTransform to no longer do padding.
Instead, reuse the UniversalCrypto infrastructure to do padding.
* Remove UnsupportedPlatform for PaddingMode
* PR feedback
- clean up unnecessary changes
* PR feedback
Remove UnsupportedOSPlatform("browser") from CipherMode and the SymmetricAlgorithm base class. These create too many false positives and aren't technically accurate since other implementations may support these on browser.1 parent c389356 commit 6a02d5d
File tree
29 files changed
+1818
-645
lines changed- src/libraries
- Common/tests/System/Security/Cryptography/AlgorithmImplementations
- AES
- Symmetric
- System.Security.Cryptography
- ref
- src
- Resources
- System/Security/Cryptography
- tests
- apicompat
29 files changed
+1818
-645
lines changedLines changed: 529 additions & 527 deletions
Large diffs are not rendered by default.
Lines changed: 68 additions & 16 deletions
Large diffs are not rendered by default.
Lines changed: 20 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| |||
302 | 303 | | |
303 | 304 | | |
304 | 305 | | |
305 | | - | |
| 306 | + | |
306 | 307 | | |
307 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
308 | 311 | | |
309 | | - | |
310 | | - | |
| 312 | + | |
| 313 | + | |
311 | 314 | | |
312 | | - | |
313 | | - | |
| 315 | + | |
| 316 | + | |
314 | 317 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
320 | 323 | | |
321 | | - | |
322 | | - | |
323 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
324 | 328 | | |
325 | 329 | | |
326 | 330 | | |
| |||
382 | 386 | | |
383 | 387 | | |
384 | 388 | | |
| 389 | + | |
385 | 390 | | |
386 | 391 | | |
387 | 392 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| 413 | + | |
413 | 414 | | |
414 | 415 | | |
415 | 416 | | |
| |||
469 | 470 | | |
470 | 471 | | |
471 | 472 | | |
| 473 | + | |
472 | 474 | | |
473 | 475 | | |
474 | 476 | | |
| |||
495 | 497 | | |
496 | 498 | | |
497 | 499 | | |
| 500 | + | |
498 | 501 | | |
499 | 502 | | |
500 | 503 | | |
| |||
547 | 550 | | |
548 | 551 | | |
549 | 552 | | |
| 553 | + | |
550 | 554 | | |
551 | 555 | | |
552 | 556 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
| |||
98 | 97 | | |
99 | 98 | | |
100 | 99 | | |
101 | | - | |
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
| |||
135 | 133 | | |
136 | 134 | | |
137 | 135 | | |
138 | | - | |
139 | 136 | | |
140 | 137 | | |
141 | 138 | | |
| |||
1747 | 1744 | | |
1748 | 1745 | | |
1749 | 1746 | | |
1750 | | - | |
1751 | 1747 | | |
1752 | 1748 | | |
1753 | 1749 | | |
1754 | 1750 | | |
1755 | 1751 | | |
1756 | 1752 | | |
1757 | | - | |
1758 | 1753 | | |
1759 | 1754 | | |
1760 | 1755 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
753 | 753 | | |
754 | 754 | | |
755 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
756 | 759 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
| 550 | + | |
| 551 | + | |
551 | 552 | | |
552 | 553 | | |
553 | 554 | | |
| |||
0 commit comments