Make sure gcrypt is initalized when SymmetricCipherGcrypt objects are created.

This commit is contained in:
Felix Geyer 2011-11-20 10:24:12 +01:00
parent baace14918
commit bc63d18f68
4 changed files with 14 additions and 0 deletions

View File

@ -76,6 +76,11 @@ void Crypto::init()
m_initalized = true; m_initalized = true;
} }
bool Crypto::initalized()
{
return m_initalized;
}
bool Crypto::selfTest() bool Crypto::selfTest()
{ {
return (gcry_control(GCRYCTL_SELFTEST) == 0); return (gcry_control(GCRYCTL_SELFTEST) == 0);

View File

@ -22,6 +22,7 @@ class Crypto
{ {
public: public:
static void init(); static void init();
static bool initalized();
static bool selfTest(); static bool selfTest();
private: private:

View File

@ -17,6 +17,13 @@
#include "SymmetricCipherGcrypt.h" #include "SymmetricCipherGcrypt.h"
#include "crypto/Crypto.h"
SymmetricCipherGcrypt::SymmetricCipherGcrypt()
{
Q_ASSERT(Crypto::initalized());
}
SymmetricCipherGcrypt::~SymmetricCipherGcrypt() SymmetricCipherGcrypt::~SymmetricCipherGcrypt()
{ {
gcry_cipher_close(m_ctx); gcry_cipher_close(m_ctx);

View File

@ -25,6 +25,7 @@
class SymmetricCipherGcrypt : public SymmetricCipherBackend class SymmetricCipherGcrypt : public SymmetricCipherBackend
{ {
public: public:
SymmetricCipherGcrypt();
~SymmetricCipherGcrypt(); ~SymmetricCipherGcrypt();
void setAlgorithm(SymmetricCipher::Algorithm algo); void setAlgorithm(SymmetricCipher::Algorithm algo);
void setMode(SymmetricCipher::Mode mode); void setMode(SymmetricCipher::Mode mode);