[botan-devel] When to read message from pipe?

Jack Lloyd lloyd at randombit.net
Mon Jan 6 19:03:12 EST 2014

On Sat, Jan 04, 2014 at 07:41:44AM +0600, Ivan Romanov wrote:
> Hello.
> Documentaion doesn't explain this. Anyway when I encrypt message with 
> AES-128/CBC I can read result before pipe.end_msg(). But when I use 
> AES-128/ECB I get empty result. With ECB I must use pipe.end_msg(). It is 
> confused me.

Well, essentially output is ready whenever the last filter in the pipe
outputs a byte. This will vary depending on the implementation of the
filter, some filters (such as an HMAC) will never output anything
until the message is finished. Others (for instance a lzma compressor)
might sometimes output before finish, but not always, depending on the
input. CBC decryption will buffer a number of block (typically 4-16)
so the block cipher can process them in parallel. ECB (in both
directions) also does this, which is likely why you do not get output
immediately, whereas with CBC encryption (which by its nature requires
iterative processing) the output will be procuced a single block at a
time. If you changed your test to use decryption you would see the
same behavior with CBC.

Thanks for letting me know about the new qca links, I have updated users.rst


More information about the botan-devel mailing list