Updated this program, but now it's worse. All decryptions fail with the first
error mentioned, I have not yet implemented the PBKDF due to the fact that I
have no idea where to start on it, but I have tried to switch the hexDecode
into a byte loading process, yet encryption is failing again. I think It's
probably a stupid mistake of mine, but I can't seem to find it. Encryption
function has not changed.


int xxz568::AESDecrypt(std::string key, std::string input, std::string
&output) {
   std::string store2, init, hexDec;
   CryptoPP::SecByteBlock test;
   test.Grow(16);
   try{
      byte keyB[32];
      std::string hashKey = sha1(key).substr(0, 32);
      memcpy(keyB, hashKey.c_str(), 32); 
          //obtain IV
          init.assign(input.substr(0, 16));
          HexDecodeintoByte(init, test, 16);
          cout << "Byte Decoded: " << test << endl;
          //obtain the remaining piece
          store2.assign(input.substr(16, input.length()));
      HexDecode(store2, hexDec);
          cout << "Finishing Decode: " << store2 << " -> DECD: " << hexDec << 
endl;
          //
      StringSink* sink = new StringSink(output);
      CBC_Mode<AES>::Decryption aes(keyB, sizeof(keyB), test);
      StreamTransformationFilter* aes_enc = new
StreamTransformationFilter(aes, sink);
      StringSource cipher(hexDec, true, aes_enc);
   }
   catch(CryptoPP::Exception e) {
      cout << e.GetWhat() << endl;
          output = "Decrypt Error:";
          output.append(e.GetWhat());
   }
   return 1;
}

int xxz568::HexDecodeintoByte(std::string input, CryptoPP::SecByteBlock
&output, int size) {
   CryptoPP::StringSource foo(input, true,
      new CryptoPP::HexDecoder(
             new CryptoPP::ArraySink(output, size)));
   return 1;
}
-- 
View this message in context: 
http://old.nabble.com/AES-Problem-tp31186698p31224154.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to