Wow, after working for days, I post it on this group, but immediately
after I found a solution:  I replaced strings with SecByteBlock.
Thanks for the time :-D

#include <crypto++/dll.h>

using namespace CryptoPP;
using namespace std;

int main(void)
{
   AutoSeededRandomPool rng;
   InvertibleRSAFunction parameters;
   parameters.GenerateRandomWithKeySize(rng, 1536);
   RSA::PrivateKey privateKey(parameters);
   RSA::PublicKey publicKey(parameters);
   RSAES_OAEP_SHA_Encryptor encryptor(publicKey);
   RSAES_OAEP_SHA_Decryptor decryptor(privateKey);

   static const int SIZE = 16;
   SecByteBlock plaintext(SIZE);
   byte block[SIZE];
   rng.GenerateBlock(block, SIZE);
   memcpy(plaintext, block, SIZE);
   for(int x = 0; x < SIZE; x++) {
      printf("%X%X", (block[x] & 240) >> 4, (block[x] & 15));
   }
   cout << endl;
   size_t ecl = encryptor.CiphertextLength(plaintext.size());
   SecByteBlock ciphertext(ecl);
   encryptor.Encrypt(rng, plaintext, plaintext.size(), ciphertext);
   size_t dpl = decryptor.MaxPlaintextLength(ciphertext.size());
   SecByteBlock
recovered(decryptor.MaxPlaintextLength(ciphertext.size()));
   DecodingResult result = decryptor.Decrypt(rng, ciphertext,
ciphertext.size(), recovered);
   recovered.resize(result.messageLength);
   assert(plaintext == recovered);
   for(int x = 0; x < SIZE; x++) {
      printf("%X%X", (plaintext[x] & 240) >> 4, (plaintext[x] & 15));
   }
   cout << endl;
   return 0;
}

-- 
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