Sprenger120

Decrypt shared secret

Jul 31st, 2012
1,123
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* *Decrypt shared secred */
  2. /* *Using Crypto++ */
  3. #include <iostream>
  4. #include <osrng.h>
  5. #include <rsa.h>
  6. #include <files.h>
  7. #include <sstream>
  8. #include <modes.h>
  9. #include <aes.h>
  10. using namespace CryptoPP;
  11. using std::stringstream;
  12.  
  13. /* AutoSeedGen,RSA_PrivKey are taken from http://pastebin.com/8eYyKZn6  */
  14.  
  15. RSAES<PKCS1v15>::Decryptor _rsaDecryptor(RSA_PrivKey);
  16. string sEncryptedSharedSecret("FILL ME WITH DATA");
  17. string sDecryptedSharedSecret ("");
  18.  
  19. try {
  20. StringSource StrSrc(sEncryptedSharedSecret,
  21.                     true,
  22.                     new CryptoPP::PK_DecryptorFilter(AutoSeedGen,
  23.                     _rsaDecryptor,
  24.                     new StringSink(sDecryptedSharedSecret)
  25.                     )
  26.                     );
  27.  
  28. } catch(CryptoPP::Exception) {
  29.     std::cout<<"Houston we have a problem\n";
  30. }
  31.  
  32. sDecryptedSharedSecret // Contains your decrypted shared secret
RAW Paste Data