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

Ivan Romanov drizt at land.ru
Tue Jan 7 07:21:04 EST 2014

> > 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.

I want to fix update function from qca-botan plugin. 

    bool update(const QCA::SecureArray &in, QCA::SecureArray *out)
        QCA::SecureArray result( in.size() + blockSize() );
        m_crypter->write((Botan::byte*)in.data(), in.size());
        int bytes_read = m_crypter->read((Botan::byte*)result.data(), 
        *out = result;
        return true;

In this function I must have ouptut.
So I should to do end_msg() with some algorythms if I want to get output?
For which algorythms I can safely do end_msg()?

More information about the botan-devel mailing list