turiya / keyczar

Automatically exported from code.google.com/p/keyczar
0 stars 0 forks source link

EncryptingStreamWriter.close() does not call .flush() #148

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an EncryptingStreamWriter
2. Write data to it
3. Call close() on the EncryptingStreamWriter
4. Attempt to read the data back with a DecryptingStreamReader

What is the expected output? What do you see instead?
Decoded stream should be read back correctly and in full. Instead, a partial 
block is returned, causing the following exception when reading the stream back:

    File "/lib/python2.7/site-packages/keyczar/keys.py", line 1202, in read
       decrypted_data = self.__cipher.decrypt(data_to_decrypt)
    ValueError: Input strings must be a multiple of 16 in length

This is caused because close() on EncryptingStreamWriter does not first call 
flush(), causing the final (partial) block to never be written to disk.

What version of the product are you using? On what operating system?
KeyCzar head

Original issue reported on code.google.com by arach...@notdot.net on 20 Nov 2013 at 4:20