bcgit / pc-dart

Pointy Castle - Dart Derived Bouncy Castle APIs
MIT License
241 stars 125 forks source link

WEB RELEASE Invalid argument(s): Invalid or corrupted pad block #223

Closed MichalNemec closed 9 months ago

MichalNemec commented 9 months ago

Hello, I had exactly the same issue with encrypt library, so i tried to use pointycastle straight away. in debug on web i have no problems. The encryption and decryption works fully on debug. The encryption works on release, but decryption breaks on release. on release i get this:

[2024-02-19 17:00:19.772 | Catcher 2 | INFO] ============================== CATCHER 2 LOG ==============================
js_primitives.dart:42 [2024-02-19 17:00:19.773 | Catcher 2 | INFO] Crash occurred on 2024-02-19 17:00:05.396
js_primitives.dart:42 [2024-02-19 17:00:19.773 | Catcher 2 | INFO] 
js_primitives.dart:42 [2024-02-19 17:00:19.774 | Catcher 2 | INFO] ---------- ERROR ----------
js_primitives.dart:42 [2024-02-19 17:00:19.774 | Catcher 2 | INFO] Invalid argument(s): Invalid or corrupted pad block
js_primitives.dart:42 [2024-02-19 17:00:19.774 | Catcher 2 | INFO] 
js_primitives.dart:42 [2024-02-19 17:00:19.774 | Catcher 2 | INFO] ------- STACK TRACE -------
js_primitives.dart:42 [2024-02-19 17:00:19.775 | Catcher 2 | INFO] Invalid argument(s): Invalid or corrupted pad block
js_primitives.dart:42 [2024-02-19 17:00:19.775 | Catcher 2 | INFO]     at Object.d (http://localhost:53017/main.dart.js:5663:19)
js_primitives.dart:42 [2024-02-19 17:00:19.776 | Catcher 2 | INFO]     at a8g.b3U (http://localhost:53017/main.dart.js:138545:23)
js_primitives.dart:42 [2024-02-19 17:00:19.776 | Catcher 2 | INFO]     at Object.bzg (http://localhost:53017/main.dart.js:47044:63)
js_primitives.dart:42 [2024-02-19 17:00:19.776 | Catcher 2 | INFO]     at WZ.a1a (http://localhost:53017/main.dart.js:149743:5)
js_primitives.dart:42 [2024-02-19 17:00:19.776 | Catcher 2 | INFO]     at WZ.C (http://localhost:53017/main.dart.js:149810:3)
js_primitives.dart:42 [2024-02-19 17:00:19.777 | Catcher 2 | INFO]     at ln.c7 (http://localhost:53017/main.dart.js:115982:21)
js_primitives.dart:42 [2024-02-19 17:00:19.777 | Catcher 2 | INFO]     at ln.n2 (http://localhost:53017/main.dart.js:115955:9)
js_primitives.dart:42 [2024-02-19 17:00:19.777 | Catcher 2 | INFO]     at ln.n2 (http://localhost:53017/main.dart.js:115988:11)
js_primitives.dart:42 [2024-02-19 17:00:19.777 | Catcher 2 | INFO]     at ln.Pc (http://localhost:53017/main.dart.js:115906:10)
js_primitives.dart:42 [2024-02-19 17:00:19.777 | Catcher 2 | INFO]     at ln.ak_ (http://localhost:53017/main.dart.js:115907:19)
js_primitives.dart:42 [2024-02-19 17:00:19.777 | Catcher 2 | INFO] ======================================================================

using CBCBlockCipher and pointycastle: 3.7.4 and pad/unpad functions from here https://github.com/bcgit/pc-dart/blob/ab532655475ff885b65c1860ff57950b066fadc2/tutorials/examples/aes-cbc-direct.dart#L118

Does someone know why it works on debug, but not on release?

MichalNemec commented 9 months ago

Found the problem, its outside of this library. Using encrypted data to dart with incorrect salt -.-