Hello,

i am running a Programm with QT and Crypto++ included.

I try to run following Code and get 0xc0000005 when trying to run it:

Qt Code:
  1. // g++ -g3 -ggdb -O0 -DDEBUG -I/usr/include/cryptopp Driver.cpp -o Driver.exe -lcryptopp -lpthread
  2. // g++ -g -O2 -DNDEBUG -I/usr/include/cryptopp Driver.cpp -o Driver.exe -lcryptopp -lpthread
  3.  
  4.  
  5. #define CRYPTOPP_DEFAULT_NO_DLL
  6. #include "cryptopp/dll.h"
  7. #ifdef CRYPTOPP_WIN32_AVAILABLE
  8. #include <windows.h>
  9. #endif
  10.  
  11. #include "cryptopp/osrng.h"
  12. using CryptoPP::AutoSeededRandomPool;
  13.  
  14. #include <iostream>
  15. using std::cout;
  16. using std::cerr;
  17. using std::endl;
  18.  
  19. #include <string>
  20. using std::string;
  21.  
  22. #include <cstdlib>
  23. using std::exit;
  24.  
  25. #include "cryptopp/cryptlib.h"
  26. using CryptoPP::Exception;
  27.  
  28. #include "cryptopp/hex.h"
  29. using CryptoPP::HexEncoder;
  30. using CryptoPP::HexDecoder;
  31.  
  32. #include "cryptopp/filters.h"
  33. using CryptoPP::StringSink;
  34. using CryptoPP::StringSource;
  35. using CryptoPP::StreamTransformationFilter;
  36.  
  37. #include "cryptopp/aes.h"
  38. using CryptoPP::AES;
  39.  
  40. #include "cryptopp/modes.h"
  41. using CryptoPP::CFB_Mode;
  42.  
  43. int main(int argc, char *argv[])
  44. {
  45. AutoSeededRandomPool prng;
  46.  
  47. byte key[AES::DEFAULT_KEYLENGTH];
  48. prng.GenerateBlock(key, sizeof(key));
  49.  
  50. byte iv[AES::BLOCKSIZE];
  51. prng.GenerateBlock(iv, sizeof(iv));
  52.  
  53. string plain = "CFB Mode Test";
  54. string cipher, encoded, recovered;
  55.  
  56. /*********************************\
  57. \*********************************/
  58.  
  59. // Pretty print key
  60. encoded.clear();
  61. StringSource(key, sizeof(key), true,
  62. new HexEncoder(
  63. new StringSink(encoded)
  64. ) // HexEncoder
  65. ); // StringSource
  66. cout << "key: " << encoded << endl;
  67.  
  68. // Pretty print iv
  69. encoded.clear();
  70. StringSource(iv, sizeof(iv), true,
  71. new HexEncoder(
  72. new StringSink(encoded)
  73. ) // HexEncoder
  74. ); // StringSource
  75. cout << "iv: " << encoded << endl;
  76.  
  77. /*********************************\
  78. \*********************************/
  79.  
  80. try
  81. {
  82. cout << "plain text: " << plain << endl;
  83.  
  84. CFB_Mode< AES >::Encryption e;
  85. e.SetKeyWithIV(key, sizeof(key), iv);
  86.  
  87. // CFB mode must not use padding. Specifying
  88. // a scheme will result in an exception
  89. StringSource(plain, true,
  90. new StreamTransformationFilter(e,
  91. new StringSink(cipher)
  92. ) // StreamTransformationFilter
  93. ); // StringSource
  94. }
  95. catch(const CryptoPP::Exception& e)
  96. {
  97. cerr << e.what() << endl;
  98. exit(1);
  99. }
  100.  
  101. /*********************************\
  102. \*********************************/
  103.  
  104. // Pretty print
  105. encoded.clear();
  106. StringSource(cipher, true,
  107. new HexEncoder(
  108. new StringSink(encoded)
  109. ) // HexEncoder
  110. ); // StringSource
  111. cout << "cipher text: " << encoded << endl;
  112.  
  113. /*********************************\
  114. \*********************************/
  115.  
  116. try
  117. {
  118. CFB_Mode< AES >::Decryption d;
  119. d.SetKeyWithIV(key, sizeof(key), iv);
  120.  
  121. // The StreamTransformationFilter removes
  122. // padding as required.
  123. StringSource s(cipher, true,
  124. new StreamTransformationFilter(d,
  125. new StringSink(recovered)
  126. ) // StreamTransformationFilter
  127. ); // StringSource
  128.  
  129. cout << "recovered text: " << recovered << endl;
  130. }
  131. catch(const CryptoPP::Exception& e)
  132. {
  133. cerr << e.what() << endl;
  134. exit(1);
  135. }
  136.  
  137. /*********************************\
  138. \*********************************/
  139.  
  140. return 0;
  141. }
To copy to clipboard, switch view to plain text mode 

I read that its a dll Problem but i cant get along.

I Compiled Crypto++ with this.

Hope you can help me.

Thx!