[Botan-devel] Using Botan for encryption/decryption

Jack Lloyd lloyd at randombit.net
Thu Mar 26 19:00:36 EDT 2009


On Thu, Mar 26, 2009 at 03:44:36PM -0700, Bala Narasimhan wrote:
> Hello,
> I am new to Botan and this mailing list. My goal is enable an application I
> have to encrypt/decrypt buffers of memory using Botan.
> 
> The buffers may be of arbitrary size.
> 
> Based on reading the documentation, I assume I need to use a streaming
> cipher (as opposed to a block cipher.)
> 
> Is this correct?

Somewhat, but not quite.

Block ciphers at their most basic can only encrypt fixed size blocks,
so for example one can encrypt 128 bits (16 bytes) at a time using
AES. However there are methods of using block ciphers (called modes)
which allow encrypting arbitrary lengths of data. Some of these, like
CBC mode, require that the data be padded to a multiple of the block
size, and others, such as counter mode, do not and can encrypt any
arbirary length plaintext to a ciphertext of identical size.

> Can someone give me an example of how to enable a streaming cipher on a
> buffer of memory?

One example that demonstrates this is
  http://botan.randombit.net/examples/row_encryptor.cpp

Hope this helps,

Jack



More information about the botan-devel mailing list