[Botan-devel] Botan: Decoding error: AES/CBC/PKCS7

Jawwad Shamsi jshamsi at cs.wayne.edu
Thu Apr 14 16:21:50 EDT 2005


Hello Jack-
The suggestion you have posted for Q1 did not worked.

I am still getting the same error.

exc caught: Botan: Decoding error: AES/CBC/PKCS7

could you please think of some thing else that might be causing this
problem.

Pipe pipe(get_cipher("AES/CBC/PKCS7", key, iv, ENCRYPTION));

Pipe pipe2(get_cipher("AES/CBC/PKCS7", key, iv, DECRYPTION));

Thanks
Jawwad
-----Original Message-----
From: botan-devel-bounces at randombit.net
[mailto:botan-devel-bounces at randombit.net] On Behalf Of Jack Lloyd
Sent: Thursday, April 14, 2005 9:43 AM
To: Botan development list
Subject: Re: [Botan-devel] Botan: Decoding error: AES/CBC/PKCS7

On Thu, Apr 14, 2005 at 02:35:34AM -0400, Jawwad Shamsi wrote:
> 
> Hello
> I have two questions
> 
> Q1.
> I am trying to write a program which has two parts
> 1) Part 1 reads plain text from file, encrypts it and writes the cipher to
> the output file
> 2) Part 2 reads the cipher text from file , decrypts it and writes the
> plain text to another output file .
> 
> The program uses symmeric key, However I am unable to get the 2nd part
> working and getting Decoding error: AES/CBC/PKCS7

That is because your first Pipe is

 Pipe pipe(get_cipher("AES/CBC/PKCS7", key,iv, ENCRYPTION),
           new Base64_Encoder);

and your second is

 Pipe pipe2(get_cipher("AES/CBC/PKCS7", key, iv, DECRYPTION));

which doesn't match up; the ciphertext is base64 encoded but you never do
the
cooresponding base64 decode prior to decrypting it. So you'd want to either
add
a Base64_Decoder before the cipher in pipe2, or remove the Base64_Encoder in
pipe.

> 
> Q2.
> Also, I was wondering if it is possible to encrypt a C++ object like
> structure ?

It is, but you would have to serialize them to a bytestream somehow. There
are
different levels of complexity in such a setup, for example simply
serializing
to a fixed format, or doing type tagging, or even serializing the code
attached
to the object (which is a pretty crazy thing to do in C/C++, a little more
reasoanble in some other languages).

You can do it by hand, or there are frameworks for it (Googling for "C++
object
serialization" shows some results that may be helpful). If you're going to
be
serializing a lot of different objects and there are no standard layouts for
any of them, you might want to consider learning a bit of ASN.1 and then
using
Botan's DER encoder support. However, that's a lot of work if you're only
planning on doing a small number of objects (or if you're in a hurry).

I just found that Boost has a serialization framework of some sort as
well. That may be one to consider.
http://www.boost.org/libs/serialization/doc/

-Jack
_______________________________________________
botan-devel mailing list
botan-devel at randombit.net
http://www.randombit.net/mailman/listinfo/botan-devel




More information about the botan-devel mailing list