Hi,

i've recently played with AES encryption and found that it is not
working (did not successfully decrypt) in CFB-mode, but is working in
e.g. ECB-mode.

Is there something wrong with my testcode (posted below)?
I've tested with crypto++ 5.4, VS 2003, WindowsXP

Thanks for your help!

#include <iostream>
#include <string>

#include <aes.h>
#include <sha.h>
#include <secblock.h>
#include <modes.h>

using namespace std;
using namespace CryptoPP;

int main (int argc, char* argv[])
{
        cout << "testing AES" << endl;

        string pw = "password";

        string origText =
"In der klassischen UNIX-Welt ist es üblich, eine gemeinsame
Hauptgruppe für alle Benutzer \
einzurichten (zum Beispiel users). Ich finde das modernere Konzept
geschickter, nachdem \
jeder Benutzer einziges Mitglied einer nach ihm benannte Gruppe wird;
das wird auch bei \
Debian und OpenBSD praktiziert. Geschmackssache.
";

        string encText, decText;
        char buffer[1024];

        SecByteBlock sbbKey(SHA256::DIGESTSIZE);
        SHA256().CalculateDigest(sbbKey, reinterpret_cast<const
byte*>(pw.c_str()), pw.size()/*+1*/);

        // create initialisation vector
        const string IVVector("rTgbfw§) !??_  ^");
        SecByteBlock sbbIv(AESEncryption::BLOCKSIZE);

        assert(IVVector.size() == AESEncryption::BLOCKSIZE);
        sbbIv.Assign(reinterpret_cast<const byte*>(IVVector.c_str()),
IVVector.size());

        AESEncryption aesEnc(sbbKey, SHA256::DIGESTSIZE);

        //CFB_Mode_ExternalCipher::Encryption encCipher(aesEnc, sbbIv);
        ECB_Mode_ExternalCipher::Encryption encCipher(aesEnc, sbbIv);

        cout << "original text: " << origText.size() << endl << origText <<
endl << endl;

        encCipher.ProcessString((byte*)buffer, (const byte*)origText.c_str(),
origText.size());
        encText.assign(buffer, origText.size());
        cout << "encrypted text: " << encText.size() << endl << encText <<
endl << endl;

        AESDecryption aesDec(sbbKey, SHA256::DIGESTSIZE);

        //CFB_Mode_ExternalCipher::Decryption decCipher(aesDec, sbbIv);
        ECB_Mode_ExternalCipher::Decryption decCipher(aesDec, sbbIv);

        decCipher.ProcessString((byte*)buffer, (const byte*)encText.c_str(),
encText.size());
        decText.assign(buffer, encText.size());
        cout << "decrypted text: " << decText.size() << endl << decText <<
endl;

        return 0;
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Crypto++ 
Users" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cryptopp-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to