LibCrypto: Do not trim leading zeros in export_data by default

This fixes the issue with the exported data having a leading zero,
causing RSA::encrypt to trim the block down, and ruining the encryption.

Fixes #2691 :^)
This commit is contained in:
AnotherTest 2020-07-31 13:33:14 +04:30 committed by Andreas Kling
commit b00ffc860b
Notes: sideshowbarker 2024-07-19 04:26:38 +09:00
6 changed files with 27 additions and 19 deletions

View file

@ -1933,7 +1933,7 @@ void bigint_import_export()
I_TEST((BigInteger | BigEndian Export));
auto number = "448378203247"_bigint;
char exported[8] { 0 };
auto exported_length = number.export_data({ exported, 8 });
auto exported_length = number.export_data({ exported, 8 }, true);
if (exported_length == 5 && memcmp(exported + 3, "hello", 5) == 0) {
PASS;
} else {