ph4r05 / Whitebox-crypto-AES

Whitebox AES implementation in C++. Chow, Karroumi.
https://is.muni.cz/th/325219/fi_m/
337 stars 112 forks source link

When encrypting / decrypting a .txt file is added trash at the end #23

Closed igorcoroli closed 6 years ago

igorcoroli commented 6 years ago

The problem is at line 379 on return of the function: long int iter2comp = min(iters, (long int) ceil((float)bRead / N_BYTES));

The entire iter2comp is coming with one more element. Workaround: long int iter2comp = (min (iters, (long int) ceil ((float) bRead / N_BYTES)) - 1);

ph4r05 commented 6 years ago

Thanks for info, I will take a look at that and see what I can do. I have to verify the it really is a problem.

Pls use pull request next time. Thanks!

ph4r05 commented 6 years ago

You probably used input data which were not correctly padded. In the version you reported the input data has to be aligned on the block size.

The original ./main worked only in plain ECB mode which is highly discouraged to use in practice.

For demonstration purposes, I implemented also PKCS5 padding and CBC mode - ready in master.

There are some unittests run by Travis.