[Botan-devel] Decoding error with TripleDES/CBC -- help please!
Brought to you by:
randombit
|
From: Patrick J S. <swe...@ho...> - 2004-10-19 21:00:09
|
Hi this is my first post so hopefully it works... =20
I'm developing a simple application which encrypts, then decrypts a =
buffer using DES/CBC and TripleDES/CBC.
Using the encryptor Pipe, it appears to be encrypting correctly, though =
at the moment I have no way of knowing because I get the following error =
when the decryptor Pipe is used:
Exception caught: Botan: Decoding error: PKCS7
I get the same error even if I leave the PKCS7 off of the =
"TripleDES/CBC" statement. Not sure what is going on here, any ideas? =
I'm operating FreeBSD 4.10 with Botan version 1.2.8.
Thanks for any help.
<-- Begin code -->
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <memory>
#include <botan/filters.h>
#include <botan/look_pk.h>
#include <botan/lookup.h>
#include <botan/dsa.h>
using namespace Botan;
int main() {
=20
byte buf[] =3D =
"abcdefghijklmnopqrstuvwxyz123456abcdefghijklmnopqrstuvwxyz123456";
try {
=20
LibraryInitializer init;
=20
/* this is the encryption/decryption key */
const char * ph =3D =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte my_iv[] =3D "aaaaaaaaaaaaaaaa";
std::string passphrase(ph);
SymmetricKey key =3D OctetString(passphrase);
InitializationVector iv(my_iv, 8);
Pipe encryptor(get_cipher("TripleDES/CBC/PKCS7", iv, key, =
ENCRYPTION));
Pipe decryptor(get_cipher("TripleDES/CBC/PKCS7", iv, key, =
DECRYPTION));
std::cout << "Clear: " << buf << "\n";
=20
encryptor.start_msg();
encryptor.write(buf,64);
encryptor.end_msg();
encryptor.read(buf,64);
std::cout << "Encrypted: " << buf << "\n";
=20
decryptor.start_msg();
decryptor.write(buf,64);
decryptor.end_msg();
decryptor.read(buf,64);
std::cout << "Decrypted: " << buf << "\n";
=20
}
catch(std::exception& e) {
std::cout << "Exception caught: " << e.what() << std::endl;
}
return 1;
}
<-- end code --> |