diff --git a/src/crypto/Crypto.cpp b/src/crypto/Crypto.cpp index f518ace17..bedd49fc4 100644 --- a/src/crypto/Crypto.cpp +++ b/src/crypto/Crypto.cpp @@ -76,6 +76,11 @@ void Crypto::init() m_initalized = true; } +bool Crypto::initalized() +{ + return m_initalized; +} + bool Crypto::selfTest() { return (gcry_control(GCRYCTL_SELFTEST) == 0); diff --git a/src/crypto/Crypto.h b/src/crypto/Crypto.h index 439c23230..d1b2004b9 100644 --- a/src/crypto/Crypto.h +++ b/src/crypto/Crypto.h @@ -22,6 +22,7 @@ class Crypto { public: static void init(); + static bool initalized(); static bool selfTest(); private: diff --git a/src/crypto/SymmetricCipherGcrypt.cpp b/src/crypto/SymmetricCipherGcrypt.cpp index 2b32bff17..cee66e313 100644 --- a/src/crypto/SymmetricCipherGcrypt.cpp +++ b/src/crypto/SymmetricCipherGcrypt.cpp @@ -17,6 +17,13 @@ #include "SymmetricCipherGcrypt.h" +#include "crypto/Crypto.h" + +SymmetricCipherGcrypt::SymmetricCipherGcrypt() +{ + Q_ASSERT(Crypto::initalized()); +} + SymmetricCipherGcrypt::~SymmetricCipherGcrypt() { gcry_cipher_close(m_ctx); diff --git a/src/crypto/SymmetricCipherGcrypt.h b/src/crypto/SymmetricCipherGcrypt.h index aeaca6e57..d50a31db9 100644 --- a/src/crypto/SymmetricCipherGcrypt.h +++ b/src/crypto/SymmetricCipherGcrypt.h @@ -25,6 +25,7 @@ class SymmetricCipherGcrypt : public SymmetricCipherBackend { public: + SymmetricCipherGcrypt(); ~SymmetricCipherGcrypt(); void setAlgorithm(SymmetricCipher::Algorithm algo); void setMode(SymmetricCipher::Mode mode);