summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-03-25 10:15:50 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-03-25 10:33:32 +0100
commita1e3d36dca9c6abf235c7ddf47ab9185c4b748d5 (patch)
tree859befb5df101432b7388e1562f90a01c6d8e238 /src
downloadIT-Sicherheit-a1e3d36dca9c6abf235c7ddf47ab9185c4b748d5.tar.gz
IT-Sicherheit-a1e3d36dca9c6abf235c7ddf47ab9185c4b748d5.zip
First commit of IT-Sicherheit
Diffstat (limited to 'src')
-rw-r--r--src/cipherssingleton.cpp53
-rw-r--r--src/cipherssingleton.h111
-rw-r--r--src/crypt/cryptclassbase.cpp48
-rw-r--r--src/crypt/cryptclassbase.h250
-rw-r--r--src/crypt/cryptclassnullcipher.cpp21
-rw-r--r--src/crypt/cryptclassnullcipher.h49
-rw-r--r--src/crypt/cryptengine.cpp137
-rw-r--r--src/crypt/cryptengine.h261
-rw-r--r--src/dialogload.cpp57
-rw-r--r--src/dialogload.h108
-rw-r--r--src/dialogsave.cpp55
-rw-r--r--src/dialogsave.h110
-rw-r--r--src/forms/dialogload.ui88
-rw-r--r--src/forms/dialogsave.ui132
-rw-r--r--src/forms/mainwindow.ui436
-rw-r--r--src/forms/tabasymmetric.ui68
-rw-r--r--src/forms/tabhybrid.ui124
-rw-r--r--src/forms/tabsymmetric.ui65
-rw-r--r--src/main.cpp21
-rw-r--r--src/mainwindow.cpp475
-rw-r--r--src/mainwindow.h296
-rw-r--r--src/spinboxciphers.cpp17
-rw-r--r--src/spinboxciphers.h70
-rw-r--r--src/tabasymmetric.cpp33
-rw-r--r--src/tabasymmetric.h82
-rw-r--r--src/tabhybrid.cpp34
-rw-r--r--src/tabhybrid.h82
-rw-r--r--src/tabsymmetric.cpp29
-rw-r--r--src/tabsymmetric.h81
-rw-r--r--src/tabwidgetselectalgorithm.cpp80
-rw-r--r--src/tabwidgetselectalgorithm.h151
31 files changed, 3624 insertions, 0 deletions
diff --git a/src/cipherssingleton.cpp b/src/cipherssingleton.cpp
new file mode 100644
index 0000000..89c66e8
--- /dev/null
+++ b/src/cipherssingleton.cpp
@@ -0,0 +1,53 @@
+#include "cipherssingleton.h"
+
+
+//Create Singleton-instance
+CiphersSingleton CiphersSingleton::instance;
+
+
+
+CiphersSingleton::CiphersSingleton()
+{
+ //Enter QStrings as Descriptions for symmetric Ciphers
+ m_symmetricCipherDescriptions.append( QString("NullCipher") );
+ m_symmetricCipherDescriptions.append( QString("Caesar") );
+ m_symmetricCipherDescriptions.append( QString("Cube") );
+ m_symmetricCipherDescriptions.append( QString("AES") );
+
+ //Enter QStrings as Descriptions for asymmetric Ciphers
+ m_asymmetricCipherDescriptions.append( QString("RSA") );
+ m_asymmetricCipherDescriptions.append( QString("ECC") );
+}
+
+QString CiphersSingleton::textFromValue(int value)
+{
+ if( value > m_symmetricCipherDescriptions.size()-1 )
+ {
+ if( (value - m_symmetricCipherDescriptions.size()) > m_asymmetricCipherDescriptions.size()-1 )
+ return QString("ERROR");
+ else
+ return m_asymmetricCipherDescriptions[(value - m_symmetricCipherDescriptions.size())];
+ }
+
+ return m_symmetricCipherDescriptions[value];
+}
+
+int CiphersSingleton::valueFromText(const QString& text)
+{
+ //Search Symmetric Ciphers
+ for (int var = 0; var < m_symmetricCipherDescriptions.size(); var++)
+ {
+ if( m_symmetricCipherDescriptions[var] == text )
+ return var;
+ }
+
+ //Search Asymmetric Ciphers
+ for (int var = 0; var < m_asymmetricCipherDescriptions.size(); var++)
+ {
+ if( m_asymmetricCipherDescriptions[var] == text )
+ return (var + m_symmetricCipherDescriptions.size());
+ }
+
+ //Nothing found
+ return -1;
+}
diff --git a/src/cipherssingleton.h b/src/cipherssingleton.h
new file mode 100644
index 0000000..6286652
--- /dev/null
+++ b/src/cipherssingleton.h
@@ -0,0 +1,111 @@
+#ifndef CIPHERSSINGLETON_H
+#define CIPHERSSINGLETON_H
+
+#include <QVector>
+#include <QString>
+
+
+/**
+* \class CiphersSingleton
+* \brief Singleton-Class to assign a short descriptive string and a number for all Ciphers.
+*
+* This Class, basically, provides an Array containing QStrings, each of which is used as
+* description for an available cipher.
+* The index of each QString is also used to describe the cipher.
+* This is needed since sometimes ciphers need to be referred to by strings, and other times
+* by integers.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.1
+* \date 28.02.2013
+*/
+class CiphersSingleton
+{
+public: //Methods
+ /**
+ * \brief Method to fetch the Singleton-Instance of this class.
+ *
+ * The Assignments of QStrings to Integers (and vice versa) made in this Class is needed
+ * throughout the entire program. This Method, therefore, returns a Singleton-instance of
+ * this Class.
+ * \returns A reference to the Singleton-instance of this Class
+ */
+ static CiphersSingleton & getInstance()
+ { return instance; }
+
+
+
+ /**
+ * \brief Method to fetch a QString corresponding with the given Integer.
+ *
+ * For the given value, looks up what QString corresponds to it and returns that.
+ * \param int value integer representing an algorithm
+ * \returns QString corresponding to the given integer.
+ */
+ QString textFromValue ( int value );
+
+
+ /**
+ * \brief Method to fetch an Integer corresponding with the given QString.
+ *
+ * For the given QString, looks up what Integer corresponds to it and returns that.
+ * \param QString& text QString representing an algorithm
+ * \returns Integer corresponding to the given QString.
+ */
+ int valueFromText ( const QString& text );
+
+
+ /**
+ * \brief Method to fetch the number of supported symmetric Ciphers.
+ *
+ * Returns the number of supported symmetric Ciphers.
+ * \returns The number of supported symmetric Ciphers.
+ */
+ int symmetricCiphersCount()
+ { return m_symmetricCipherDescriptions.size(); }
+
+
+ /**
+ * \brief Method to fetch the number of supported asymmetric Ciphers.
+ *
+ * Returns the number of supported asymmetric Ciphers.
+ * \returns The number of supported asymmetric Ciphers.
+ */
+ int asymmetricCiphersCount()
+ { return m_asymmetricCipherDescriptions.size(); }
+
+
+private: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes the Array containing the Cipher-Strings.
+ */
+ CiphersSingleton();
+
+
+
+private: //Attributes
+ /**
+ * \brief Singleton-instance of this class.
+ */
+ static CiphersSingleton instance;
+
+
+
+ /**
+ * \brief QVector of QStrings assigning an integer to a String for each symmetric Cipher (and vice versa).
+ *
+ * \attention These Strings are used throughout the entire program to reference ciphers!
+ */
+ QVector<QString> m_symmetricCipherDescriptions;
+
+
+ /**
+ * \brief QVector of QStrings assigning an integer to a String for each asymmetric Cipher (and vice versa).
+ *
+ * \attention These Strings are used throughout the entire program to reference ciphers!
+ */
+ QVector<QString> m_asymmetricCipherDescriptions;
+};
+
+#endif // CIPHERSSINGLETON_H
diff --git a/src/crypt/cryptclassbase.cpp b/src/crypt/cryptclassbase.cpp
new file mode 100644
index 0000000..88f99a1
--- /dev/null
+++ b/src/crypt/cryptclassbase.cpp
@@ -0,0 +1,48 @@
+#include "src/crypt/cryptclassbase.h"
+
+CryptClassBase::CryptClassBase()
+{
+}
+
+CryptClassBase::~CryptClassBase()
+{
+ m_key.fill(0);
+ m_cryptText.fill(0);
+ m_clearText.fill(0);
+ m_binaryData = false;
+}
+
+void CryptClassBase::generateRandomKey()
+{
+ qDebug("CryptClassBase::generateRandomKey - This Method does nothing so far!");
+}
+
+void CryptClassBase::setKey(QByteArray value)
+{
+ m_key = value;
+}
+
+void CryptClassBase::setKey(const uchar* value, int keyLength )
+{
+ m_key.setRawData( (const char*)value, keyLength );
+}
+
+void CryptClassBase::setCryptText( QByteArray value )
+{
+ m_cryptText = value;
+}
+
+void CryptClassBase::setCryptText( const uchar* value, int dataLength )
+{
+ m_cryptText.setRawData( (const char*)value, dataLength );
+}
+
+void CryptClassBase::setClearText( QByteArray value )
+{
+ m_clearText = value;
+}
+
+void CryptClassBase::setClearText( const uchar* value, int dataLength )
+{
+ m_clearText.setRawData( (const char*)value, dataLength );
+}
diff --git a/src/crypt/cryptclassbase.h b/src/crypt/cryptclassbase.h
new file mode 100644
index 0000000..064264e
--- /dev/null
+++ b/src/crypt/cryptclassbase.h
@@ -0,0 +1,250 @@
+#ifndef CRYPTCLASSBASE_H
+#define CRYPTCLASSBASE_H
+
+#include <QString>
+#include <QByteArray>
+
+
+
+
+/**
+* \class CryptClassBase
+* \brief Purely virtual Base-Class for all Ciphers.
+*
+* This class serves as Base or Parent Class for all Ciphers, containing Methods to set or get key, encrypted (CryptText) and unencrypted (ClearText) text.
+* The purely virtual Methods encrypt and decrypt have to be overloaded in each subclass.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.1
+* \date 28.02.2013
+*/
+class CryptClassBase
+{
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Does nothing.
+ */
+ CryptClassBase();
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Overwrites Key, Crypt- and ClearText with 0 when called.
+ */
+ ~CryptClassBase();
+
+
+
+ /**
+ * \brief Method to generate a random Key.
+ *
+ * Overload this if your Cipher supports/ needs random Key generation.
+ * \see CryptEngine::generateRandomKey
+ */
+ virtual void generateRandomKey();
+
+
+ /**
+ * \brief Method to set the Key for en/decryption.
+ *
+ * Sets the Attribute m_key to contents of value.
+ * \param QByteArray value Contains the Key to be used for en/decryption
+ * \see CryptEngine::setKey
+ */
+ virtual void setKey( QByteArray value );
+
+
+ /**
+ * \brief Method to set the Key for en/decryption.
+ *
+ * Sets the Attribute m_key to contents of value of length keyLength.
+ * \param const uchar* value Contains the Key to be used for en/decryption
+ * \param int keyLength Length of keyData contained in value
+ * \see CryptEngine::setKey
+ */
+ virtual void setKey( const uchar* value, int keyLength );
+
+
+ /**
+ * \brief Method to get the Key used for en/decryption.
+ *
+ * Returns a reference to the Attribute m_key, containing the current key for en/decryption.
+ * \returns QBteArray& key The Key used for en/decryption.
+ * \see Cryptengine::getKey
+ */
+ virtual QByteArray& getKey() { return m_key; }
+
+
+ /**
+ * \brief Method to set the length of the Key used for en/decryption.
+ *
+ * Sets the length of the Key used for en/decryption to value.
+ * \see Cryptengine::setKeyLength
+ */
+ virtual void setKeyLength( int value ) { m_keyLength = value; }
+
+
+ /**
+ * \brief Method to set the Initialization Vector for Ciphers needing it.
+ *
+ * Sets the Initialization Vector to contents of iv.
+ * \param const QBteArray& iv The Initialization Vector to contents of iv.
+ * \see Cryptengine::setIV
+ */
+ virtual void setIV( const QByteArray& iv ) { m_iv = iv; }
+
+
+ /**
+ * \brief Method to get the Initialization Vector for Ciphers needing it.
+ *
+ * Returns a reference to the the Initialization Vector.
+ * \returns QBteArray& The Initialization Vector for Ciphers needing it.
+ * \see Cryptengine::getIV
+ */
+ virtual QByteArray& getIV() { return m_iv; }
+
+ /**
+ * \brief True if algorithm uses binary data instead of plain text.
+ *
+ * Binar Data cannot be displayed as Plain Text and vice versa.
+ * This property holds information on whether to handle the Crypted
+ * text prodiced by this class.
+ * \returns bool: True if algorithm uses binary data instead of plain text.
+ * \see CryptEngine::oncipherSelected_triggered()
+ */
+ bool getBinaryData() { return m_binaryData; }
+
+
+ /**
+ * \brief Method to set the encrypted text.
+ *
+ * Sets the Attribute m_cryptText to contents of value.
+ * \param QByteArray value Contains the encrypted data
+ * \see CryptEngine::setCryptText
+ */
+ void setCryptText( QByteArray value );
+
+
+ /**
+ * \brief Method to set the encrypted text.
+ *
+ * Sets the Attribute m_cryptText to contents of value of length dataLength.
+ * \param const uchar* value Contains the encrypted data
+ * \param int dataLength Length of encrypted data contained in value
+ * \see CryptEngine::setCryptText
+ */
+ void setCryptText( const uchar* value, int dataLength );
+
+
+ /**
+ * \brief Method to set the unencrypted text.
+ *
+ * Sets the Attribute m_clearText to contents of value.
+ * \param QByteArray value Contains the unencrypted data
+ * \see CryptEngine::setClearText
+ */
+ void setClearText( QByteArray value );
+
+
+ /**
+ * \brief Method to set the unencrypted text.
+ *
+ * Sets the Attribute m_clearText to contents of value of length dataLength.
+ * \param const uchar* value Contains the unencrypted data
+ * \param int dataLength Length of unencrypted data contained in value
+ * \see CryptEngine::setClearText
+ */
+ void setClearText( const uchar* value, int keyLength );
+
+
+ /**
+ * \brief Method to get the encrypted text.
+ *
+ * Returns the encrypted data as a QByteArray
+ * \see CryptEngine::getCryptText
+ * \returns QByteArray with encrypted data
+ */
+ QByteArray getCryptText() { return m_cryptText; }
+
+
+ /**
+ * \brief Method to get the unencrypted text.
+ *
+ * Returns the unencrypted data as a QByteArray
+ * \see CryptEngine::getClearText
+ * \returns QByteArray with unencrypted data
+ */
+ QByteArray getClearText() { return m_clearText; }
+
+
+ /**
+ * \brief Purely virtual Method for encryption.
+ *
+ * SubClasses need to overload this purely virtual method so that it contains or calls all necessary steps to encrypt the data in
+ * m_clearText using the algorithm the specific SubClass is designed for. The encrypted Text will be stored in m_cryptText.
+ */
+ virtual void encrypt() = 0;
+
+
+ /**
+ * \brief Purely virtual Method for decryption.
+ *
+ * SubClasses need to overload this purely virtual method so that it contains or calls all necessary steps to decrypt the data in
+ * m_cryptText using the algorithm the specific SubClass is designed for. The decrypted Text will be stored in m_clearText.
+ */
+ virtual void decrypt() = 0;
+
+
+
+protected: //Attributes
+ /**
+ * \brief ByteArray to hold the Key for en/decryption.
+ *
+ * \attention Sensitive data. Overwrite when no longer needed!
+ */
+ QByteArray m_key;
+
+
+ /**
+ * \brief Length of Key to use for the Cipher.
+ */
+ int m_keyLength;
+
+
+ /**
+ * \brief ByteArray to hold the Initialization Vector for Ciphers needing it.
+ *
+ * \attention Sensitive data. Overwrite when no longer needed!
+ */
+ QByteArray m_iv;
+
+
+ /**
+ * \brief ByteArray to hold the encrypted text.
+ *
+ * \attention Sensitive data. Overwrite when no longer needed!
+ */
+ QByteArray m_cryptText;
+
+
+ /**
+ * \brief ByteArray to hold the unencrypted text.
+ *
+ * \attention Sensitive data. Overwrite when no longer needed!
+ */
+ QByteArray m_clearText;
+
+
+ /**
+ * \brief True if algorithm uses binary data instead of plain text.
+ *
+ * Binar Data cannot be displayed as Plain Text and vice versa.
+ * This property holds information on whether to handle the Crypted
+ * text prodiced by this class.
+ * \see CryptEngine::oncipherSelected_triggered()
+ */
+ bool m_binaryData;
+};
+
+#endif // CRYPTCLASSBASE_H
diff --git a/src/crypt/cryptclassnullcipher.cpp b/src/crypt/cryptclassnullcipher.cpp
new file mode 100644
index 0000000..29e9dd7
--- /dev/null
+++ b/src/crypt/cryptclassnullcipher.cpp
@@ -0,0 +1,21 @@
+#include "cryptclassnullcipher.h"
+
+CryptClassNullCipher::CryptClassNullCipher()
+ : CryptClassBase()
+{
+
+}
+
+void CryptClassNullCipher::encrypt()
+{
+ m_cryptText = m_clearText;
+}
+
+
+
+
+
+void CryptClassNullCipher::decrypt()
+{
+ m_clearText = m_cryptText;
+}
diff --git a/src/crypt/cryptclassnullcipher.h b/src/crypt/cryptclassnullcipher.h
new file mode 100644
index 0000000..6b3c284
--- /dev/null
+++ b/src/crypt/cryptclassnullcipher.h
@@ -0,0 +1,49 @@
+#ifndef CRYPTCLASSNULLCIPHER_H
+#define CRYPTCLASSNULLCIPHER_H
+
+#include "cryptclassbase.h"
+
+#include <openssl/evp.h>
+
+
+/**
+* \class CryptClassNullCipher
+* \brief For testing purposes, NullCipher does nothing to the Text.
+*
+* The NullCipher class is, like all Ciphers/Algorithm-classes, derived from CryptclassBase.
+* It's intended to be used for testing purposes of the overall Programm-Funcionality only and does
+* no encryption whatsoever. Data is merely copied from m_cryptText to m_clearText and vice versa.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.1
+* \date 28.02.2013
+*/
+class CryptClassNullCipher : public CryptClassBase
+{
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Does nothing.
+ */
+ CryptClassNullCipher();
+
+
+ /**
+ * \brief Overloaded Method to encrypt present unencrypted data using the current key.
+ *
+ * NullCipher is used for testing purposes and simulation. No actual encryption is done.
+ * Data is copied from m_clearText to m_cryptText.
+ */
+ virtual void encrypt();
+
+
+ /**
+ * \brief Overloaded Method to decrypt present encrypted data using the current key.
+ *
+ * NullCipher is used for testing purposes and simulation. No actual decryption is done.
+ * Data is copied from m_cryptText to m_clearText.
+ */
+ virtual void decrypt();
+};
+
+#endif // CRYPTCLASSNULLCIPHER_H
diff --git a/src/crypt/cryptengine.cpp b/src/crypt/cryptengine.cpp
new file mode 100644
index 0000000..32e33bb
--- /dev/null
+++ b/src/crypt/cryptengine.cpp
@@ -0,0 +1,137 @@
+#include "cryptengine.h"
+
+CryptEngine::CryptEngine(QObject *parent)
+ : QObject(parent)
+{
+ m_algorithm = 0; //Initialize NullCipher
+ m_cryptClass = new CryptClassNullCipher;
+}
+
+
+CryptEngine::~CryptEngine()
+{
+ delete m_cryptClass;
+}
+
+void CryptEngine::generateRandomKey()
+{
+ m_cryptClass->generateRandomKey();
+}
+
+void CryptEngine::setKey(QString value)
+{
+ m_cryptClass->setKey( value.toLatin1() );
+}
+
+void CryptEngine::setKey(QByteArray value)
+{
+ m_cryptClass->setKey( value );
+}
+
+void CryptEngine::setKey(const uchar *value, int keyLength )
+{
+ m_cryptClass->setKey( value, keyLength );
+}
+
+QByteArray &CryptEngine::getKey()
+{
+ return m_cryptClass->getKey();
+}
+
+void CryptEngine::setCryptText(QByteArray value)
+{
+ m_cryptClass->setCryptText(value);
+}
+
+void CryptEngine::setCryptText(const uchar *value, int dataLength )
+{
+ m_cryptClass->setCryptText(value, dataLength);
+}
+
+void CryptEngine::setClearText(QByteArray value)
+{
+ m_cryptClass->setClearText(value);
+}
+
+void CryptEngine::setClearText(const uchar *value, int dataLength )
+{
+ m_cryptClass->setClearText(value, dataLength);
+}
+
+void CryptEngine::encrypt()
+{
+ //If cleartext present, set in CryptClass, encrypt, and fetch encrypted data
+ if( m_cryptClass->getClearText().length() > 0 )
+ {
+ m_cryptClass->encrypt();
+ }
+}
+
+void CryptEngine::decrypt()
+{
+ //If crypttext present, set in CryptClass, decrypt, and fetch decrypted data
+ if( m_cryptClass->getCryptText().length() > 0 )
+ {
+ m_cryptClass->decrypt();
+ }
+}
+
+void CryptEngine::oncipherSelected_triggered(int cipher)
+{
+ m_algorithm = cipher;
+
+ //Get Instance of Singleton mapping Integers to String for Cipher description
+ CiphersSingleton ciphers = CiphersSingleton::getInstance();
+
+ //Algorithm contains cipher as text.
+ QString algorithm = ciphers.textFromValue(m_algorithm);
+
+
+ //delete old CryptClass and create new one according to selected algorithm
+ if( algorithm == "NullCipher" )
+ {
+ delete m_cryptClass;
+ m_cryptClass = new CryptClassNullCipher;
+ qDebug("CryptEngine::oncipherSelected_triggered - NullCipher");
+ }
+ else if( algorithm == "Caesar" )
+ {
+// delete m_cryptClass;
+// m_cryptClass = new CryptClassCaesar;
+ qDebug("CryptEngine::oncipherSelected_triggered - Caesar");
+ }
+ else if( algorithm == "Cube" )
+ {
+// delete m_cryptClass;
+// m_cryptClass = new CryptClassCube;
+ qDebug("CryptEngine::oncipherSelected_triggered - Cube");
+ }
+ else if( algorithm == "AES" )
+ {
+// delete m_cryptClass;
+// m_cryptClass = new CryptClassAES;
+ qDebug("CryptEngine::oncipherSelected_triggered - AES");
+ }
+ else if( algorithm == "RSA" )
+ {
+// delete m_cryptClass;
+// m_cryptClass = new CryptClassRSA;
+ qDebug("CryptEngine::oncipherSelected_triggered - RSA");
+ }
+ else if( algorithm == "ECC" )
+ {
+// delete m_cryptClass;
+// m_cryptClass = new CryptClassECC;
+ qDebug("CryptEngine::oncipherSelected_triggered - ECC");
+ }
+
+ //Send Signal confirming if data is binary or not
+ emit binaryData( m_cryptClass->getBinaryData() );
+}
+
+void CryptEngine::onkeylengthChanged(int value, bool symmetric)
+{
+ qDebug("CrptEngine::onkeylengthChanged - new Keylength: %d", value);
+
+ m_cryptClass->setKeyLength(value);
+}
diff --git a/src/crypt/cryptengine.h b/src/crypt/cryptengine.h
new file mode 100644
index 0000000..9272183
--- /dev/null
+++ b/src/crypt/cryptengine.h
@@ -0,0 +1,261 @@
+#ifndef CRYPTENGINE_H
+#define CRYPTENGINE_H
+
+#include <QObject>
+
+#include "../cipherssingleton.h"
+#include "cryptclassbase.h"
+#include "cryptclassnullcipher.h"
+//#include "cryptclasscaesar.h"
+//#include "cryptclasscube.h"
+//#include "cryptclassaes.h"
+//#include "cryptclassrsa.h"
+//#include "cryptclassecc.h"
+
+
+/**
+* \class CryptEngine
+* \brief Interface for all algorithms.
+*
+* This class provides an easy to use interface for all Ciphers/algorithms (used as synonyms) and encapsulates all functionality
+* related to de/encryption.
+* Ciphers are referenced by NameSpaceCryptEngine::CryptAlgorithm (see enums.h), the currently active one stored in m_algorithm.
+* The Functionality for every Cipher is encapsulated in a SubClass of CryptClassBase, m_cryptClass points to an instance of the
+* one for the currently active algorithm.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.7
+* \date 13.05.2013
+*/
+class CryptEngine : public QObject
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes NullCipher.
+ * \param QObject* parent The QObject the used instance of this class is subordinated to.
+ */
+ CryptEngine( QObject* parent = 0 );
+
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Overwrites Key, Crypt- and ClearText with 0 when called.
+ */
+ ~CryptEngine();
+
+
+
+ /**
+ * \brief Method to generate a random Key.
+ *
+ * Calls Method generateKey of the CryptClass in use.
+ * \attention This Method may do nothing depending on the Algorithm in use.
+ * \see CryptClassBase::generateRandomKey
+ */
+ void generateRandomKey();
+
+
+ /**
+ * \brief Method to set the Key for en/decryption.
+ *
+ * Sets the Attribute m_key to contents of value.
+ * \param QString value Contains the Key to be used for en/decryption
+ * \see CryptClassBase::setKey
+ */
+ void setKey( QString value );
+
+
+ /**
+ * \brief Method to set the Key for en/decryption.
+ *
+ * Sets the Attribute m_key to contents of value.
+ * \param QByteArray value Contains the Key to be used for en/decryption
+ * \see CryptClassBase::setKey
+ */
+ void setKey( QByteArray value );
+
+
+ /**
+ * \brief Method to set the Key for en/decryption.
+ *
+ * Sets the Attribute m_key to contents of value of length keyLength.
+ * \param const uchar* value Contains the Key to be used for en/decryption
+ * \param int keyLength Length of keyData contained in value
+ * \see CryptClassBase::setKey
+ */
+ void setKey( const uchar* value, int keyLength );
+
+
+ /**
+ * \brief Method to get the Key used for en/decryption.
+ *
+ * Returns a reference to the Attribute m_key, containing the current key for en/decryption.
+ * \returns QBteArray& key The Key used for en/decryption.
+ * \see CryptClassBase::getKey
+ */
+ QByteArray& getKey();
+
+
+ /**
+ * \brief Method to set the length of the Key used for en/decryption.
+ *
+ * Sets the length of the Key used for en/decryption to value.
+ * \see CryptClassBase::setKeyLength
+ */
+ virtual void setKeyLength( int value ) { m_cryptClass->setKeyLength(value); }
+
+
+ /**
+ * \brief Method to set the Initialization Vector for Ciphers needing it.
+ *
+ * Sets the Initialization Vector to contents of iv.
+ * \param const QBteArray& iv The Initialization Vector to contents of iv.
+ * \see CryptClassBase::setIV
+ */
+ virtual void setIV( const QByteArray& iv ) { m_cryptClass->setIV(iv); }
+
+
+ /**
+ * \brief Method to get the Initialization Vector for Ciphers needing it.
+ *
+ * Returns a reference to the the Initialization Vector.
+ * \returns QBteArray& The Initialization Vector for Ciphers needing it.
+ * \see CryptClassBase::getIV
+ */
+ virtual QByteArray& getIV() { return m_cryptClass->getIV(); }
+
+
+ /**
+ * \brief Method to set the encrypted text.
+ *
+ * Sets the Attribute m_cryptText to contents of value.
+ * \param QByteArray value Contains the encrypted data
+ * \see CryptClassBase::setCryptText
+ */
+ void setCryptText( QByteArray value );
+
+
+ /**
+ * \brief Method to set the encrypted text.
+ *
+ * Sets the Attribute m_cryptText to contents of value of length dataLength.
+ * \param const uchar* value Contains the encrypted data
+ * \param int dataLength Length of encrypted data contained in value
+ * \see CryptClassBase::setCryptText
+ */
+ void setCryptText( const uchar* value, int dataLength );
+
+
+ /**
+ * \brief Method to set the unencrypted text.
+ *
+ * Sets the Attribute m_clearText to contents of value.
+ * \param QByteArray value Contains the unencrypted data
+ * \see CryptClassBase::setClearText
+ */
+ void setClearText( QByteArray value );
+
+
+ /**
+ * \brief Method to set the unencrypted text.
+ *
+ * Sets the Attribute m_clearText to contents of value of length dataLength.
+ * \param const uchar* value Contains the unencrypted data
+ * \param int dataLength Length of unencrypted data contained in value
+ * \see CryptClassBase::setClearText
+ */
+ void setClearText( const uchar* value, int keyLength );
+
+
+ /**
+ * \brief Method to get the encrypted text.
+ *
+ * Returns the encrypted data as a QByteArray
+ * \see CryptClassBase::getCryptText
+ * \returns QByteArray with encrypted data
+ */
+ QByteArray getCryptText() { return m_cryptClass->getCryptText(); }
+
+
+ /**
+ * \brief Method to get the unencrypted text.
+ *
+ * Returns the unencrypted data as a QByteArray
+ * \see CryptClassBase::getClearText
+ * \returns QByteArray with unencrypted data
+ */
+ QByteArray getClearText() { return m_cryptClass->getClearText(); }
+
+
+ /**
+ * \brief Method to encrypt present unencrypted data using the currently selected algorithm and key.
+ *
+ * Calls the encrypt method of the currently selected algorithm
+ */
+ void encrypt();
+
+
+ /**
+ * \brief Method to decrypt present encrypted data using the currently selected algorithm and key.
+ *
+ * Calls the decrypt method of the currently selected algorithm
+ */
+ void decrypt();
+
+
+
+public slots:
+ /**
+ * \brief Slot called when an active algorithm gets selected.
+ *
+ * Deletes intance of former Cipher and creates a new object for the selected one.
+ * \param int cipher Integer referencing the selected Cipher according to assignment in Class CiphersSingleton.
+ * \see Class CiphersSingleton
+ */
+ void oncipherSelected_triggered( int cipher );
+
+
+ /**
+ * \brief SLOT to set the new Keylength.
+ *
+ * Called when a new Keylength is selected. Passes the value on in connection with the bool
+ * signifying that it is for a symmetric Cipher (true) or an asymmetric one (false).
+ * \param int value The new Keylength.
+ * \param bool symmetric true for symmetric Cipher, false for asymmetric.
+ */
+ void onkeylengthChanged(int value, bool symmetric);
+
+
+signals:
+ /**
+ * \brief SIGNAL to inform other Classes that the selected Cipher uses binary data.
+ *
+ * This Signal is used to inform other Classes that the selected Cipher uses binary data.
+ * \param bool dataIsbinary is true when data should be displayes as Hex.
+ */
+ void binaryData( bool dataIsBinary );
+
+
+private: //Attributes
+ /**
+ * \brief Enum for currently used algorithm (NullCipher/ Caesar).
+ *
+ * \see File enums.h for list of available algorithms
+ */
+ int m_algorithm;
+
+
+ /**
+ * \brief Pointer to an instance of a SubClass of CryptclassBase for the currently used algorithm.
+ *
+ * Should either be NULL or point to an instance of the SubClass for the algorithm specified in m_algorithm
+ * \see CryptClassBase
+ */
+ CryptClassBase* m_cryptClass;
+};
+
+#endif // CRYPTENGINE_H
diff --git a/src/dialogload.cpp b/src/dialogload.cpp
new file mode 100644
index 0000000..7b93b93
--- /dev/null
+++ b/src/dialogload.cpp
@@ -0,0 +1,57 @@
+#include "dialogload.h"
+#include "ui_dialogload.h"
+
+DialogLoad::DialogLoad(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::DialogLoad)
+{
+ ui->setupUi(this);
+ setWindowTitle("Load from File");
+}
+
+DialogLoad::~DialogLoad()
+{
+ delete ui;
+}
+
+bool DialogLoad::getEncrypted()
+{
+ return ui->radioButtonEncrypted->isChecked();
+}
+
+bool DialogLoad::getBinary()
+{
+ return ui->checkBoxBinaryData->isChecked();
+}
+
+QString DialogLoad::getFileName()
+{
+ return ui->lineEditFileName->text();
+}
+
+
+
+
+//private slots:
+void DialogLoad::on_pushButtonSelectFile_clicked()
+{
+ QString fileName;
+
+ fileName = QFileDialog::getOpenFileName(this, "Choose File to open", QDir::currentPath());
+
+ if(fileName.length() == 0) return;
+
+ ui->lineEditFileName->setText( fileName );
+}
+
+void DialogLoad::on_pushButtonLoad_clicked()
+{
+ //TODO check data
+
+ QDialog::accept();
+}
+
+void DialogLoad::on_pushButtonCancel_clicked()
+{
+ QDialog::reject();
+}
diff --git a/src/dialogload.h b/src/dialogload.h
new file mode 100644
index 0000000..f9e6af3
--- /dev/null
+++ b/src/dialogload.h
@@ -0,0 +1,108 @@
+#ifndef DIALOGLOAD_H
+#define DIALOGLOAD_H
+
+#include <QDialog>
+#include <QFileDialog>
+#include <QDir>
+#include <QString>
+
+namespace Ui {
+class DialogLoad;
+}
+
+
+
+/**
+* \class DialogLoad
+* \brief Dialog-Widget for opening Files, providing some extra Options.
+*
+* This Class provides a Dialog-Widget used for loading a file.
+* Options are loading of encrypted or unencrypted data, and marking either as binary.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.1
+* \date 28.02.2013
+*/
+class DialogLoad : public QDialog
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes Graphical Elements of the Widget and sets the Window's Title.
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to.
+ */
+ DialogLoad(QWidget* parent = 0);
+
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Deletes the ui-Object containing the graphical Elements.
+ */
+ ~DialogLoad();
+
+
+ /**
+ * \brief Method to decide whether encrypted or unencrypted data shall be loaded.
+ *
+ * Returns true if encrypted data should be loaded, false if unencrypted data should be loaded.
+ * \returns true for encrypted, false for unencrypted data
+ */
+ bool getEncrypted();
+
+
+ /**
+ * \brief Method to decide if the file should be opened in binary mode.
+ *
+ * Returns true if the file should be opened in binary mode.
+ * \returns true if the file should be opened in binary mode.
+ */
+ bool getBinary();
+
+
+ /**
+ * \brief Method to get the name of the file to open.
+ *
+ * Returns the name of the file to be opened.
+ * \returns QString containing the name of the file to be opened.
+ */
+ QString getFileName();
+
+
+
+private: //Attributes
+ /**
+ * \brief Pointer to GUI-Object.
+ */
+ Ui::DialogLoad *ui;
+
+
+
+private slots:
+ /**
+ * \brief Slot for the Select File Button.
+ *
+ * Opens a Dialog for selection of the file to open.
+ */
+ void on_pushButtonSelectFile_clicked();
+
+
+ /**
+ * \brief Slot for the Load Button.
+ *
+ * Loads data from the currently selected file, with the currently selected Parameters (clear- or cryptData, binary data or Text)
+ */
+ void on_pushButtonLoad_clicked();
+
+
+ /**
+ * \brief Slot for the Cancel Button.
+ *
+ * Closes the Dialog (calls QDialog::reject()).
+ */
+ void on_pushButtonCancel_clicked();
+};
+
+#endif // DIALOGLOAD_H
diff --git a/src/dialogsave.cpp b/src/dialogsave.cpp
new file mode 100644
index 0000000..1da8d26
--- /dev/null
+++ b/src/dialogsave.cpp
@@ -0,0 +1,55 @@
+#include "dialogsave.h"
+#include "ui_dialogsave.h"
+
+DialogSave::DialogSave(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::DialogSave)
+{
+ ui->setupUi(this);
+ setWindowTitle("Save to File");
+}
+
+DialogSave::~DialogSave()
+{
+ delete ui;
+}
+
+bool DialogSave::getEncrypted()
+{
+ return ui->radioButtonEncrypted->isChecked();
+}
+
+bool DialogSave::getBinary()
+{
+ return ui->checkBoxBinaryData->isChecked();
+}
+
+QString DialogSave::getFileName()
+{
+ return ui->lineEditFileName->text();
+}
+
+
+//private slots:
+void DialogSave::on_pushButtonSelectFile_clicked()
+{
+ QString fileName;
+
+ fileName = QFileDialog::getSaveFileName(this, "Choose Filename to save as", QDir::currentPath());
+
+ if(fileName.length() == 0) return;
+
+ ui->lineEditFileName->setText( fileName );
+}
+
+void DialogSave::on_pushButtonSave_clicked()
+{
+ //TODO check data
+
+ QDialog::accept();
+}
+
+void DialogSave::on_pushButtonCancel_clicked()
+{
+ QDialog::reject();
+}
diff --git a/src/dialogsave.h b/src/dialogsave.h
new file mode 100644
index 0000000..edd977b
--- /dev/null
+++ b/src/dialogsave.h
@@ -0,0 +1,110 @@
+#ifndef DIALOGSAVE_H
+#define DIALOGSAVE_H
+
+#include <QDialog>
+#include <QFileDialog>
+#include <QDir>
+
+
+namespace Ui {
+class DialogSave;
+}
+
+
+
+/**
+* \class DialogSave
+* \brief Dialog-Widget for saving Files, providing some extra Options.
+*
+* This Class provides a Dialog-Widget used for saving a file.
+* Options are saving of encrypted or unencrypted data, and marking either as binary.
+* [The "marking-as-binary"-option should be automatized in future versions]
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.1
+* \date 28.02.2013
+*/
+class DialogSave : public QDialog
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes Graphical Elements of the Widget and sets the Window's Title.
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to.
+ */
+ DialogSave(QWidget *parent = 0);
+
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Deletes the ui-Object containing the graphical Elements.
+ */
+ ~DialogSave();
+
+
+
+ /**
+ * \brief Method to decide whether encrypted or unencrypted data shall be saved.
+ *
+ * Returns true if encrypted data should be saved, false if unencrypted data should be saved.
+ * \returns true for encrypted, false for unencrypted data
+ */
+ bool getEncrypted();
+
+
+ /**
+ * \brief Method to decide if the file should be opened in binary mode.
+ *
+ * Returns true if the file should be opened in binary mode.
+ * \returns true if the file should be opened in binary mode.
+ */
+ bool getBinary();
+
+
+ /**
+ * \brief Method to get the name of the file to save.
+ *
+ * Returns the name of the file to be saved.
+ * \returns QString containing the name of the file to be saved.
+ */
+ QString getFileName();
+
+
+
+private: //Attributes
+ /**
+ * \brief Pointer to GUI-Object.
+ */
+ Ui::DialogSave *ui;
+
+
+
+private slots:
+ /**
+ * \brief Slot for the Select File Button.
+ *
+ * Opens a Dialog for selection of the file to save.
+ */
+ void on_pushButtonSelectFile_clicked();
+
+
+ /**
+ * \brief Slot for the Save Button.
+ *
+ * Saves data from the currently selected file, with the currently selected Parameters (clear- or cryptData, binary data or Text)
+ */
+ void on_pushButtonSave_clicked();
+
+
+ /**
+ * \brief Slot for the Cancel Button.
+ *
+ * Closes the Dialog (calls QDialog::reject()).
+ */
+ void on_pushButtonCancel_clicked();
+};
+
+#endif // DIALOGSAVE_H
diff --git a/src/forms/dialogload.ui b/src/forms/dialogload.ui
new file mode 100644
index 0000000..e05c959
--- /dev/null
+++ b/src/forms/dialogload.ui
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogLoad</class>
+ <widget class="QDialog" name="DialogLoad">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>379</width>
+ <height>232</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0" colspan="2">
+ <widget class="QFrame" name="frame">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="pushButtonSelectFile">
+ <property name="text">
+ <string>Select File</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QLineEdit" name="lineEditFileName">
+ <property name="text">
+ <string>[filename]</string>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QRadioButton" name="radioButtonEncrypted">
+ <property name="text">
+ <string>Load Encrypted Data</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QRadioButton" name="radioButtonUnencrypted">
+ <property name="text">
+ <string>Load Unencrypted Text</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QCheckBox" name="checkBoxBinaryData">
+ <property name="text">
+ <string>Binary Data</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="pushButtonCancel">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="pushButtonLoad">
+ <property name="text">
+ <string>Load</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/forms/dialogsave.ui b/src/forms/dialogsave.ui
new file mode 100644
index 0000000..90daca4
--- /dev/null
+++ b/src/forms/dialogsave.ui
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogSave</class>
+ <widget class="QDialog" name="DialogSave">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QPushButton" name="pushButtonSave">
+ <property name="geometry">
+ <rect>
+ <x>290</x>
+ <y>250</y>
+ <width>93</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButtonCancel">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>250</y>
+ <width>93</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ <widget class="QFrame" name="frame">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>30</y>
+ <width>361</width>
+ <height>181</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QPushButton" name="pushButtonSelectFile">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>29</y>
+ <width>86</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Select File</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="lineEditFileName">
+ <property name="geometry">
+ <rect>
+ <x>102</x>
+ <y>29</y>
+ <width>146</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>[filename]</string>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton" name="radioButtonEncrypted">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>81</y>
+ <width>164</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Save Encrypted Data</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QRadioButton" name="radioButtonUnencrypted">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>128</y>
+ <width>179</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Save Unencrypted Text</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="checkBoxBinaryData">
+ <property name="geometry">
+ <rect>
+ <x>230</x>
+ <y>130</y>
+ <width>111</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Binary Data</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/forms/mainwindow.ui b/src/forms/mainwindow.ui
new file mode 100644
index 0000000..c475ce5
--- /dev/null
+++ b/src/forms/mainwindow.ui
@@ -0,0 +1,436 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>988</width>
+ <height>742</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QGridLayout" name="gridLayout_5">
+ <item row="0" column="0" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="labelPassword">
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEditPassword"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonGeneratePassword">
+ <property name="text">
+ <string>Generate Password</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="3" rowspan="2">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="labelAlgorithm">
+ <property name="text">
+ <string>Current Algorithm:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelAlgorithmCurrent">
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string>NullCipher</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="TabWidgetSelectAlgorithm" name="tabWidgetSelectAlgorithm">
+ <property name="minimumSize">
+ <size>
+ <width>350</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QFrame" name="frameUnencrypted">
+ <property name="minimumSize">
+ <size>
+ <width>175</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>175</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelUnencrypted">
+ <property name="text">
+ <string>Unencrypted</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="pushButtonClearUnencrypted">
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QPlainTextEdit" name="PlainTextEditUnencrypted"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>224</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QFrame" name="frameframeCryptButtons">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="pushButtonEncrypt">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&gt;&gt; Encrypt &gt;&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="pushButtonDecrypt">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;&lt; Decrypt &lt;&lt;</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>223</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QFrame" name="frameFileButtons">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="pushButtonLoad">
+ <property name="text">
+ <string>Load from File</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="pushButtonSave">
+ <property name="text">
+ <string>Save to File</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="2">
+ <widget class="QFrame" name="frameEncrypted">
+ <property name="minimumSize">
+ <size>
+ <width>175</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>175</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelEncrypted">
+ <property name="text">
+ <string>Encrypted</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="pushButtonClearEncrypted">
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QPlainTextEdit" name="PlainTextEditEncrypted">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>988</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>&amp;File</string>
+ </property>
+ <addaction name="actionLoad"/>
+ <addaction name="actionSave"/>
+ <addaction name="separator"/>
+ <addaction name="actionExit"/>
+ </widget>
+ <widget class="QMenu" name="menuHelp">
+ <property name="title">
+ <string>&amp;Help</string>
+ </property>
+ <addaction name="actionAbout"/>
+ </widget>
+ <widget class="QMenu" name="menuCrypt">
+ <property name="title">
+ <string>&amp;Crypt</string>
+ </property>
+ <addaction name="actionNullCipher"/>
+ <addaction name="actionSymmetric"/>
+ <addaction name="actionAsymmetric"/>
+ <addaction name="actionHybrid"/>
+ </widget>
+ <widget class="QMenu" name="menuView">
+ <property name="title">
+ <string>&amp;View</string>
+ </property>
+ <addaction name="actionUnencrypted_as_Text"/>
+ <addaction name="actionUnencrypted_as_Binary"/>
+ <addaction name="separator"/>
+ <addaction name="actionEncrypted_as_Text"/>
+ <addaction name="actionEncrypted_as_Binary"/>
+ </widget>
+ <addaction name="menuFile"/>
+ <addaction name="menuCrypt"/>
+ <addaction name="menuView"/>
+ <addaction name="menuHelp"/>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ <action name="actionExit">
+ <property name="text">
+ <string>Exit</string>
+ </property>
+ </action>
+ <action name="actionLoad">
+ <property name="text">
+ <string>Load</string>
+ </property>
+ </action>
+ <action name="actionSave">
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </action>
+ <action name="actionAbout">
+ <property name="text">
+ <string>About</string>
+ </property>
+ </action>
+ <action name="actionNullCipher">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>NullCipher</string>
+ </property>
+ </action>
+ <action name="actionSymmetric">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Symmetric</string>
+ </property>
+ </action>
+ <action name="actionAsymmetric">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Asymmetric</string>
+ </property>
+ </action>
+ <action name="actionHybrid">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Hybrid</string>
+ </property>
+ </action>
+ <action name="actionUnencrypted_as_Text">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Unencrypted as Text</string>
+ </property>
+ </action>
+ <action name="actionUnencrypted_as_Binary">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Unencrypted as Binary</string>
+ </property>
+ </action>
+ <action name="actionEncrypted_as_Text">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Encrypted as Text</string>
+ </property>
+ </action>
+ <action name="actionEncrypted_as_Binary">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Encrypted as Binary</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>TabWidgetSelectAlgorithm</class>
+ <extends>QTabWidget</extends>
+ <header>src/tabwidgetselectalgorithm.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/forms/tabasymmetric.ui b/src/forms/tabasymmetric.ui
new file mode 100644
index 0000000..6d90434
--- /dev/null
+++ b/src/forms/tabasymmetric.ui
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TabAsymmetric</class>
+ <widget class="QWidget" name="TabAsymmetric">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelSelectedAlgorithm">
+ <property name="text">
+ <string>Selected Algorithm:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="SpinBoxCiphers" name="spinBoxCipher">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelSelectedKelength">
+ <property name="text">
+ <string>Keylength:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="spinBoxKeylength">
+ <property name="minimum">
+ <number>1024</number>
+ </property>
+ <property name="maximum">
+ <number>4096</number>
+ </property>
+ <property name="singleStep">
+ <number>1024</number>
+ </property>
+ <property name="value">
+ <number>1024</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>SpinBoxCiphers</class>
+ <extends>QSpinBox</extends>
+ <header>src/spinboxciphers.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/forms/tabhybrid.ui b/src/forms/tabhybrid.ui
new file mode 100644
index 0000000..ae47b3d
--- /dev/null
+++ b/src/forms/tabhybrid.ui
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TabHybrid</class>
+ <widget class="QWidget" name="TabHybrid">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>404</width>
+ <height>464</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelHybrid">
+ <property name="font">
+ <font>
+ <family>Century Schoolbook L</family>
+ <pointsize>20</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Hybrid Cipher</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelSelectedAlgorithmSymmetric">
+ <property name="text">
+ <string>Symmetric Algorithm:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="SpinBoxCiphers" name="spinBoxCipherSymmetric">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="labelSelectedKelength">
+ <property name="text">
+ <string>Symmetric Keylength:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="spinBoxKeylengthSymmetric">
+ <property name="minimum">
+ <number>128</number>
+ </property>
+ <property name="maximum">
+ <number>256</number>
+ </property>
+ <property name="singleStep">
+ <number>64</number>
+ </property>
+ <property name="value">
+ <number>256</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="labelSelectedAlgorithmAsymmetric">
+ <property name="text">
+ <string>Asymmetric Algorithm:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="SpinBoxCiphers" name="spinBoxCipherAsymmetric">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="labelSelectedKelength_2">
+ <property name="text">
+ <string>Asymmetric Keylength:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSpinBox" name="spinBoxKeylengthAsymmetric">
+ <property name="minimum">
+ <number>1024</number>
+ </property>
+ <property name="maximum">
+ <number>4096</number>
+ </property>
+ <property name="singleStep">
+ <number>1024</number>
+ </property>
+ <property name="value">
+ <number>1024</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>SpinBoxCiphers</class>
+ <extends>QSpinBox</extends>
+ <header>src/spinboxciphers.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/forms/tabsymmetric.ui b/src/forms/tabsymmetric.ui
new file mode 100644
index 0000000..ddc12ed
--- /dev/null
+++ b/src/forms/tabsymmetric.ui
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TabSymmetric</class>
+ <widget class="QWidget" name="TabSymmetric">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelSelectedAlgorithm">
+ <property name="text">
+ <string>Selected Algorithm:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="SpinBoxCiphers" name="spinBoxCipher">
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelSelectedKelength">
+ <property name="text">
+ <string>Keylength:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="spinBoxKeylength">
+ <property name="minimum">
+ <number>128</number>
+ </property>
+ <property name="maximum">
+ <number>256</number>
+ </property>
+ <property name="singleStep">
+ <number>64</number>
+ </property>
+ <property name="value">
+ <number>256</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>SpinBoxCiphers</class>
+ <extends>QSpinBox</extends>
+ <header>src/spinboxciphers.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..3cb3667
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,21 @@
+/**
+ * @mainpage This project serves as a starter for the cryptographic exercises for the IT-Security lecture
+ */
+
+#include <QApplication>
+#include "mainwindow.h"
+
+/**
+ * @brief main Default main function as created by QtCreator
+ * @param argc Argument count
+ * @param argv Array with commandline arguments
+ * @return Return 0 on success.
+ */
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
new file mode 100644
index 0000000..2c6088e
--- /dev/null
+++ b/src/mainwindow.cpp
@@ -0,0 +1,475 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+ setWindowTitle(tr("IT-Security SS2015"));
+
+
+ m_cryptEngine = new CryptEngine(this);
+
+ //Create ActionGroup to group the four Crypt-Actions
+ //(only one can be active at a time, ActionGroup takes care of that)
+ m_actionGroupAlgorithm = new QActionGroup(this);
+
+
+ //Add the four Crypt-Actions
+ m_actionGroupAlgorithm->addAction(ui->actionNullCipher);
+ m_actionGroupAlgorithm->addAction(ui->actionSymmetric);
+ m_actionGroupAlgorithm->addAction(ui->actionAsymmetric);
+ m_actionGroupAlgorithm->addAction(ui->actionHybrid);
+
+
+ //ActionGroup for the format of PlainTextEditEncrypted
+ QActionGroup* actionGroup = new QActionGroup(this);
+ actionGroup->addAction(ui->actionEncrypted_as_Text);
+ actionGroup->addAction(ui->actionEncrypted_as_Binary);
+
+ //ActionGroup for the format of PlainTextEditUnencrypted
+ actionGroup = new QActionGroup(this);
+ actionGroup->addAction(ui->actionUnencrypted_as_Text);
+ actionGroup->addAction(ui->actionUnencrypted_as_Binary);
+
+
+ //NullCipher/Symmetric/Asymmetric/Hybrid can also be selected via TabWidget:
+ connect( ui->tabWidgetSelectAlgorithm, SIGNAL(currentTabChanged(QString)),
+ this, SLOT(oncurrentTabChanged_triggered(QString)));
+
+ //When another Cipher is selected, tell that directly to the CryptEngine
+ connect( ui->tabWidgetSelectAlgorithm, SIGNAL(cipherChanged(int)),
+ m_cryptEngine, SLOT(oncipherSelected_triggered(int)));
+
+ //When another Cipher is selected, change PlainTextEdits for Hex or PlainText Data
+ connect( m_cryptEngine, SIGNAL(binaryData(bool)),
+ this, SLOT(ondataIsBinary_triggered(bool)));
+
+ //When a new Keylength is selected, pass it on
+ connect( ui->tabWidgetSelectAlgorithm, SIGNAL(keyLengthChanged(int,bool)),
+ m_cryptEngine, SLOT(onkeylengthChanged(int,bool)));
+}
+
+MainWindow::~MainWindow()
+{
+ delete m_cryptEngine;
+ delete ui;
+}
+
+
+void MainWindow::setDataToPlainTextEditUnencrypted(QString text)
+{
+// //Set ClearText in CryptEngine, as binary or not
+// if( ui->actionUnencrypted_as_Text->isChecked() )
+// {
+// m_cryptEngine->setClearText( ui->PlainTextEditUnencrypted->toPlainText().toAscii() );
+// }
+// else if( ui->actionUnencrypted_as_Binary->isChecked() )
+// {
+// QString hexString = ui->PlainTextEditUnencrypted->toPlainText().toAscii();
+// QStringList hexStrings = hexString.split(' ');
+// hexString = hexStrings.join("");
+// m_cryptEngine->setClearText( QByteArray::fromHex(QByteArray(hexString.toLatin1())) );
+// }
+// else
+// {
+// QMessageBox::critical(this, "Error", "Unencrypted Text as neither ClearText nor Binary data!");
+// return;
+// }
+}
+
+void MainWindow::setDataToPlainTextEditEncrypted(QString text)
+{
+}
+
+
+
+
+
+//private Methods
+void MainWindow::setPlainTextFromFile( QPlainTextEdit* destination, QFile* source )
+{
+ destination->clear();
+ destination->appendPlainText(QString(source->readAll()));
+}
+
+
+void MainWindow::setBinaryDataFromFile( QPlainTextEdit* destination, QFile* source )
+{
+ QMessageBox::warning(this, "WARNING", "The Method MainWindow::setBinaryDataFromFile is not implemented yet.\nEven the Prototype might change soon!");
+}
+
+
+void MainWindow::writePlainTextToFile( QPlainTextEdit* source, QFile* destination )
+{
+ destination->write( source->toPlainText().toLatin1() );
+}
+
+
+void MainWindow::writeBinaryDataToFile( QPlainTextEdit* source, QFile* destination )
+{
+ QMessageBox::warning(this, "WARNING", "The Method MainWindow::setBinaryDataFromFile is not implemented yet.\nEven the Prototype will change soon!");
+}
+
+
+
+//private slots, actions:
+void MainWindow::on_actionLoad_triggered()
+{
+ DialogLoad loadDialog(this);
+ if (loadDialog.exec())
+ {
+ QFile file( loadDialog.getFileName() );
+ if( file.open(QIODevice::ReadOnly) )
+ {
+ if( loadDialog.getEncrypted() )
+ {
+ if( loadDialog.getBinary() )
+ {
+ setBinaryDataFromFile( ui->PlainTextEditEncrypted, &file );
+ }
+ else
+ {
+ setPlainTextFromFile( ui->PlainTextEditEncrypted, &file );
+ }
+ }
+ else
+ {
+ if( loadDialog.getBinary() )
+ {
+ setBinaryDataFromFile( ui->PlainTextEditUnencrypted, &file );
+ }
+ else
+ {
+ setPlainTextFromFile( ui->PlainTextEditUnencrypted, &file );
+ }
+ }
+ file.close();
+ }
+ else
+ {
+ QMessageBox::warning(this,"Warning: Loading of File", "File " + loadDialog.getFileName() + " could not be loaded!");
+ return;
+ }
+ }
+}
+
+void MainWindow::on_actionSave_triggered()
+{
+ DialogSave saveDialog(this);
+ if (saveDialog.exec())
+ {
+ QFile file( saveDialog.getFileName() );
+ if( file.open(QIODevice::WriteOnly) )
+ {
+ if( saveDialog.getEncrypted() )
+ {
+ if( saveDialog.getBinary() )
+ {
+ writeBinaryDataToFile( ui->PlainTextEditEncrypted, &file );
+ }
+ else
+ {
+ writePlainTextToFile( ui->PlainTextEditEncrypted, &file );
+ }
+ }
+ else
+ {
+ if( saveDialog.getBinary() )
+ {
+ writeBinaryDataToFile( ui->PlainTextEditUnencrypted, &file );
+ }
+ else
+ {
+ writePlainTextToFile( ui->PlainTextEditUnencrypted, &file );
+ }
+ }
+ file.close();
+ }
+ else
+ {
+ QMessageBox::warning(this,"Warning: Saving of File", "File " + saveDialog.getFileName() + " could not be saved!");
+ return;
+ }
+ }
+}
+
+void MainWindow::on_actionExit_triggered()
+{
+ QApplication::quit();
+}
+
+void MainWindow::on_actionAbout_triggered()
+{
+ QMessageBox::information(this, "Project IT-Sicherheit", "Projectbase for the course\nIT-Sicherheit, SS2013\n@FH-SWF, Iserlohn");
+}
+
+
+
+void MainWindow::on_actionNullCipher_triggered()
+{
+ ui->tabWidgetSelectAlgorithm->onNullCipher_selected();
+
+}
+
+void MainWindow::on_actionSymmetric_triggered()
+{
+ ui->tabWidgetSelectAlgorithm->onSymmetric_selected();
+}
+
+void MainWindow::on_actionAsymmetric_triggered()
+{
+ ui->tabWidgetSelectAlgorithm->onAsymmetric_selected();
+}
+
+void MainWindow::on_actionHybrid_triggered()
+{
+ ui->tabWidgetSelectAlgorithm->onHybrid_selected();
+}
+
+
+//private slots, buttons:
+void MainWindow::on_pushButtonClearUnencrypted_clicked()
+{
+ ui->PlainTextEditUnencrypted->clear();
+}
+
+
+
+void MainWindow::on_pushButtonClearEncrypted_clicked()
+{
+ ui->PlainTextEditEncrypted->clear();
+}
+
+
+void MainWindow::on_pushButtonEncrypt_clicked()
+{
+ //If neither Symmetric, Asymmetric nor Hybrid is selected: Error
+ if( m_actionGroupAlgorithm->checkedAction() == 0 )
+ {
+ QMessageBox::critical(this, "Error", "No Algorithm selected");
+ return;
+ }
+ else if( ui->PlainTextEditUnencrypted->toPlainText().length() == 0 )
+ {
+ QMessageBox::critical(this, "Error", "No Data to encrypt");
+ return;
+ }
+
+ //Set Key
+ m_cryptEngine->setKey( ui->lineEditPassword->text() );
+
+ //Set ClearText in CryptEngine, as binary or not
+ if( ui->actionUnencrypted_as_Text->isChecked() )
+ {
+ m_cryptEngine->setClearText( ui->PlainTextEditUnencrypted->toPlainText().toLatin1() );
+ }
+ else if( ui->actionUnencrypted_as_Binary->isChecked() )
+ {
+ QString hexString = ui->PlainTextEditUnencrypted->toPlainText().toLatin1();
+ QStringList hexStrings = hexString.split(" ");
+ hexString = hexStrings.join("");
+ m_cryptEngine->setClearText( QByteArray::fromHex(QByteArray(hexString.toLatin1())) );
+ }
+ else
+ {
+ QMessageBox::critical(this, "Error", "Unencrypted Text as neither ClearText nor Binary data!");
+ return;
+ }
+
+ //encrypt
+ m_cryptEngine->encrypt();
+
+ //Fetch CryptText to display
+ ui->PlainTextEditEncrypted->clear();
+
+ if( ui->actionEncrypted_as_Text->isChecked() )
+ {
+ ui->PlainTextEditEncrypted->appendPlainText( QString(m_cryptEngine->getCryptText()) );
+ }
+ else if( ui->actionEncrypted_as_Binary->isChecked() )
+ {
+
+ QString tempString = QString(m_cryptEngine->getCryptText().toHex());
+ QString hexString;
+
+ for (int var = 0; var < tempString.length(); var+=2)
+ {
+ hexString.append( tempString.at(var) );
+ hexString.append( tempString.at(var+1) );
+ hexString.append( ' ' );
+ }
+
+ ui->PlainTextEditEncrypted->appendPlainText( hexString );
+ }
+ else
+ {
+ QMessageBox::critical(this, "Error", "Encrypted Text as neither ClearText nor Binary data!");
+ return;
+ }
+}
+
+
+void MainWindow::on_pushButtonDecrypt_clicked()
+{
+ //If neither Symmetric, Asymmetric nor Hybrid is selected: Error
+ if( m_actionGroupAlgorithm->checkedAction() == 0 )
+ {
+ QMessageBox::critical(this, "Error", "No Algorithm selected");
+ return;
+ }
+ else if( ui->PlainTextEditEncrypted->toPlainText().length() == 0 )
+ {
+ QMessageBox::critical(this, "Error", "No Data to decrypt");
+ return;
+ }
+
+ //Set Key
+ m_cryptEngine->setKey( ui->lineEditPassword->text() );
+
+ //Set CryptText in CryptEngine
+ if( ui->actionEncrypted_as_Text->isChecked() )
+ {
+ m_cryptEngine->setCryptText( ui->PlainTextEditEncrypted->toPlainText().toLatin1() );
+ }
+ else if( ui->actionEncrypted_as_Binary->isChecked() )
+ {
+ QString hexString = ui->PlainTextEditEncrypted->toPlainText().toLatin1();
+ QStringList hexStrings = hexString.split(" ");
+ hexString = hexStrings.join("");
+ m_cryptEngine->setCryptText( QByteArray::fromHex(QByteArray(hexString.toLatin1())) );
+ }
+ else
+ {
+ QMessageBox::critical(this, "Error", "Encrypted Text as neither ClearText nor Binary data!");
+ return;
+ }
+
+
+
+ //decrypt
+ m_cryptEngine->decrypt();
+
+
+ //fetch ClearText to display
+ ui->PlainTextEditUnencrypted->clear();
+
+ if( ui->actionUnencrypted_as_Text->isChecked() )
+ {
+ ui->PlainTextEditUnencrypted->appendPlainText( QString(m_cryptEngine->getClearText()) );
+ }
+ else if( ui->actionUnencrypted_as_Binary->isChecked() )
+ {
+
+ QString tempString = QString(m_cryptEngine->getClearText().toHex());
+ QString hexString;
+
+ for (int var = 0; var < tempString.length(); var+=2)
+ {
+ hexString.append( tempString.at(var) );
+ hexString.append( tempString.at(var+1) );
+ hexString.append( ' ' );
+ }
+ hexString.chop(1); //Last ' '
+
+ ui->PlainTextEditUnencrypted->appendPlainText( hexString );
+ }
+ else
+ {
+ QMessageBox::critical(this, "Error", "Unencrypted Text as neither ClearText nor Binary data!");
+ return;
+ }
+}
+
+void MainWindow::on_pushButtonLoad_clicked()
+{
+ on_actionLoad_triggered();
+}
+
+void MainWindow::on_pushButtonSave_clicked()
+{
+ on_actionSave_triggered();
+}
+
+
+void MainWindow::oncurrentTabChanged_triggered(QString currentTabName)
+{
+ //Selection on TabWidget changes (NullCipher)/Symmetric/Asymmetric/Hybrid as well
+ if( currentTabName == "NullCipher" )
+ ui->actionNullCipher->setChecked(true);
+ else if( currentTabName == "Symmetric" )
+ ui->actionSymmetric->setChecked(true);
+ else if( currentTabName == "Asymmetric" )
+ ui->actionAsymmetric->setChecked(true);
+ else if( currentTabName == "Hybrid" )
+ ui->actionHybrid->setChecked(true);
+
+
+ //set Algorithm Indicator Label to current kind of Algorithm
+ ui->labelAlgorithmCurrent->setText(currentTabName);
+}
+
+void MainWindow::ondataIsBinary_triggered(bool dataIsBinary)
+{
+
+ if(dataIsBinary)
+ {
+ ui->actionEncrypted_as_Binary->setChecked(true);
+ ui->actionUnencrypted_as_Binary->setChecked(true);
+ ui->actionEncrypted_as_Text->setChecked( false);
+ ui->actionUnencrypted_as_Text->setChecked(false);
+ on_actionUnencrypted_as_Binary_triggered( true );
+ on_actionEncrypted_as_Binary_triggered( true );
+ qDebug("databinary true");
+ }
+ else
+ {
+ ui->actionEncrypted_as_Binary->setChecked(false);
+ ui->actionUnencrypted_as_Binary->setChecked(false);
+ ui->actionEncrypted_as_Text->setChecked( true);
+ ui->actionUnencrypted_as_Text->setChecked(true);
+ on_actionUnencrypted_as_Binary_triggered( false );
+ on_actionEncrypted_as_Binary_triggered( false );
+ qDebug("databinary false");
+ }
+}
+
+void MainWindow::on_pushButtonGeneratePassword_clicked()
+{
+ m_cryptEngine->generateRandomKey();
+ ui->lineEditPassword->setText( m_cryptEngine->getKey().toHex() );
+}
+
+
+void MainWindow::on_actionUnencrypted_as_Text_triggered(bool checked)
+{
+ if( checked )
+ ui->PlainTextEditUnencrypted->setEnabled(true);
+ else
+ ui->PlainTextEditUnencrypted->setEnabled(false);
+}
+
+void MainWindow::on_actionUnencrypted_as_Binary_triggered(bool checked)
+{
+ if( checked )
+ ui->PlainTextEditUnencrypted->setEnabled(false);
+ else
+ ui->PlainTextEditUnencrypted->setEnabled(true);
+}
+
+void MainWindow::on_actionEncrypted_as_Text_triggered(bool checked)
+{
+ if( checked )
+ ui->PlainTextEditEncrypted->setEnabled(true);
+ else
+ ui->PlainTextEditEncrypted->setEnabled(false);
+}
+
+void MainWindow::on_actionEncrypted_as_Binary_triggered(bool checked)
+{
+ if( checked )
+ ui->PlainTextEditEncrypted->setEnabled(false);
+ else
+ ui->PlainTextEditEncrypted->setEnabled(true);
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
new file mode 100644
index 0000000..9352e0f
--- /dev/null
+++ b/src/mainwindow.h
@@ -0,0 +1,296 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QPlainTextEdit>
+#include <QMenu>
+#include <QActionGroup>
+#include <QMessageBox>
+#include <QFile>
+
+#include "tabwidgetselectalgorithm.h"
+#include "crypt/cryptengine.h"
+#include "dialogload.h"
+#include "dialogsave.h"
+
+namespace Ui {
+class MainWindow;
+}
+
+
+
+
+/**
+* \class MainWindow
+* \brief Class for the Application's MainWindow.
+*
+* This Class encapsulates the GUI-functionality (Menu, Buttons, Edits and their connections).
+* The Attribute m_cryptEngine provides an interface to all crypt-related functionality.
+* [m_cryptEngine is a QObject and thus can be connected via Signals and Slots]
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 1.0.1
+* \date 13.05.2013
+*/
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes Graphical Elements of the Widget and sets the Window's Title.
+ * A new cryptEngine is created (m_cryptEngine).
+ * Menu actions for the four kinds of Ciphers are grouped in the actionGroup m_actionGroupAlgorithm to enable
+ * exclusive selection.
+ * The TabWidgetSelectAlgorithm's Signal "currentTabChanged(QString)" is connected to the Slot "oncurrentTabChanged_triggered(QString)",
+ * so that the currently active Tab corresponds to what action is selected in the menu.
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to (0, since this is the MainWindow).
+ */
+ MainWindow(QWidget *parent = 0);
+
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Deletes CryptEngine and the ui-Object containing the graphical Elements.
+ */
+ ~MainWindow();
+
+
+
+private: //Attributes
+ /**
+ * \brief Pointer to GUI-Object.
+ */
+ Ui::MainWindow* ui;
+
+
+ /**
+ * \brief Pointer to the instance of the Crypt-Interface-Class.
+ */
+ CryptEngine* m_cryptEngine;
+
+
+ /**
+ * \brief Actiongroup used to group the menu-actions for the four kinds of Ciphers.
+ */
+ QActionGroup* m_actionGroupAlgorithm;
+
+
+
+private: //Methods
+ /**
+ * \brief Method to put Text from a File into a QPlainTextEdit.
+ *
+ * \param QPlainTextEdit* destination Text will be inserted here.
+ */
+ void setDataToPlainTextEditUnencrypted( QString text );
+
+ /**
+ * \brief Method to put Text from a File into a QPlainTextEdit.
+ *
+ * \param QPlainTextEdit* destination Text will be inserted here.
+ */
+ void setDataToPlainTextEditEncrypted( QString text );
+
+
+
+ /**
+ * \brief Method to put Text from a File into a QPlainTextEdit.
+ *
+ * Reads all Text from File and puts it into the given QPlainTextEdit.
+ * \param QPlainTextEdit* destination Text will be inserted here.
+ * \param QFile* source Text will be read from here.
+ */
+ void setPlainTextFromFile( QPlainTextEdit* destination, QFile* source );
+
+
+ /**
+ * \brief Method to put Binary Data from a File into a Subclass of QPlainTextEdit.
+ *
+ * Reads all data from File and puts it into the given QPlainTextEdit.
+ * \param QPlainTextEdit* destination Data will be inserted here.
+ * \param QFile* source Data will be read from here.
+ * \attention THIS METHOD IS NOT IMPLEMENTED YET
+ */
+ void setBinaryDataFromFile( QPlainTextEdit* destination, QFile* source );
+
+
+ /**
+ * \brief Method to write Text from a QPlainTextEdit into a File.
+ *
+ * Writes all Text from QPlainTextEdit and puts it into the given File.
+ * \param QPlainTextEdit* source Text will be read from here.
+ * \param QFile* destination Text will be read from here.
+ */
+ void writePlainTextToFile( QPlainTextEdit* source, QFile* destination );
+
+
+ /**
+ * \brief Method to write Binary Data into a File.
+ *
+ * Writes all data into File.
+ * \param QPlainTextEdit* source Text will be inserted here.
+ * \param QFile* destination Text will be read from here.
+ * \attention THIS METHOD IS NOT IMPLEMENTED YET
+ */
+ void writeBinaryDataToFile( QPlainTextEdit* source, QFile* destination );
+
+
+
+private slots:
+ //actions
+ /**
+ * \brief Slot for the Load Action.
+ *
+ * Opens a Dialog for selection of the file to open.
+ */
+ void on_actionLoad_triggered();
+
+
+ /**
+ * \brief Slot for the Save Action.
+ *
+ * Opens a Dialog for selection of the file to save.
+ */
+ void on_actionSave_triggered();
+
+
+ /**
+ * \brief Slot for the Exit Action.
+ *
+ * Closes the application.
+ */
+ void on_actionExit_triggered();
+
+
+ /**
+ * \brief Slot for the About Action.
+ *
+ * Opens a Message Box displaying basic Information about the application.
+ */
+ void on_actionAbout_triggered();
+
+
+
+ //crypt actions
+ /**
+ * \brief Slot for the NullCipher Action.
+ *
+ * Sets the active kind of algorithm to NullCipher. The instance of the TabWidgetSelectAlgorithm's Tab for NullCipher
+ * will be set active as well.
+ */
+ void on_actionNullCipher_triggered();
+
+
+ /**
+ * \brief Slot for the Symmetric Action.
+ *
+ * Sets the active kind of algorithm to Symmetric Ciphers. The instance of the TabWidgetSelectAlgorithm's Tab for Symmetric Ciphers
+ * will be set active as well.
+ */
+ void on_actionSymmetric_triggered();
+
+
+ /**
+ * \brief Slot for the Asymmetric Action.
+ *
+ * Sets the active kind of algorithm to Asymmetric Ciphers. The instance of the TabWidgetSelectAlgorithm's Tab for Asymmetric Ciphers
+ * will be set active as well.
+ */
+ void on_actionAsymmetric_triggered();
+
+
+ /**
+ * \brief Slot for the Hybrid Action.
+ *
+ * Sets the active kind of algorithm to Hybrid Ciphers. The instance of the TabWidgetSelectAlgorithm's Tab for Hybrid Ciphers
+ * will be set active as well.
+ */
+ void on_actionHybrid_triggered();
+
+
+ void on_actionUnencrypted_as_Text_triggered(bool checked);
+ void on_actionUnencrypted_as_Binary_triggered(bool checked);
+ void on_actionEncrypted_as_Text_triggered(bool checked);
+ void on_actionEncrypted_as_Binary_triggered(bool checked);
+
+ //rest gui
+ /**
+ * \brief Slot for the Button which tells the CryptEngine to generate a new Password.
+ *
+ * Calls the generatePassword Method of class CryptEngine.
+ * \attention This Method may do nothing depending on the Algorithm in use.
+ * \see CryptEngine::generatePassword
+ */
+ void on_pushButtonGeneratePassword_clicked();
+
+
+ /**
+ * \brief Slot for the Clear Button for QPlainTextEdit for Unencrpted Data.
+ *
+ * Calls the clear-method of the QPlainTextEdit for Unencrypted Data.
+ */
+ void on_pushButtonClearUnencrypted_clicked();
+
+
+ /**
+ * \brief Slot for the Clear Button for QPlainTextEdit for Encrpted Data.
+ *
+ * Calls the clear-method of the QPlainTextEdit for Encrypted Data.
+ */
+ void on_pushButtonClearEncrypted_clicked();
+
+
+ /**
+ * \brief Slot for the Encrypt Button.
+ *
+ * Calls the encrypt-method of m_CryptEngine, encrypting CryptText using the currently selected algorithm and key.
+ */
+ void on_pushButtonEncrypt_clicked();
+
+
+ /**
+ * \brief Slot for the Decrypt Button.
+ *
+ * Calls the decrypt-method of m_CryptEngine, decrypting CryptText using the currently selected algorithm and key.
+ */
+ void on_pushButtonDecrypt_clicked();
+
+
+ /**
+ * \brief Slot for the Load Button.
+ *
+ * Opens a Dialog for selection of the file to open by calling on_actionLoad_triggered().
+ */
+ void on_pushButtonLoad_clicked();
+
+
+ /**
+ * \brief Slot for the Save Button.
+ *
+ * Opens a Dialog for selection of the file to save by calling on_actionSave_triggered().
+ */
+ void on_pushButtonSave_clicked();
+
+
+
+ //rest/ other
+ /**
+ * \brief Slot called when the instance of TabWidgetSelectAlgorithm changes the active Tab.
+ *
+ * Changes the currently selected Menu-Action (what kind of encryption) according to the newly active Tab.
+ */
+ void oncurrentTabChanged_triggered( QString currentTabName );
+
+
+ /**
+ * \brief Slot called to change PlainTextEdits from Binary to PlainText when a new algorithm is selected.
+ *
+ * Sets both PlainttextEdits to whatever the newly selected algorithm needs.
+ */
+ void ondataIsBinary_triggered( bool dataIsBinary );
+};
+
+#endif // MAINWINDOW_H
diff --git a/src/spinboxciphers.cpp b/src/spinboxciphers.cpp
new file mode 100644
index 0000000..8b2193c
--- /dev/null
+++ b/src/spinboxciphers.cpp
@@ -0,0 +1,17 @@
+#include "spinboxciphers.h"
+
+SpinBoxCiphers::SpinBoxCiphers(QWidget* parent) :
+ QSpinBox(parent)
+{
+ m_cipherStrings = &(CiphersSingleton::getInstance());
+}
+
+QString SpinBoxCiphers::textFromValue(int value) const
+{
+ return m_cipherStrings->textFromValue(value);
+}
+
+int SpinBoxCiphers::valueFromText(const QString &text) const
+{
+ return m_cipherStrings->valueFromText(text);
+}
diff --git a/src/spinboxciphers.h b/src/spinboxciphers.h
new file mode 100644
index 0000000..f073292
--- /dev/null
+++ b/src/spinboxciphers.h
@@ -0,0 +1,70 @@
+#ifndef SPINBOXCIPHERS_H
+#define SPINBOXCIPHERS_H
+
+#include <QSpinBox>
+
+#include "cipherssingleton.h"
+
+
+/**
+* \class SpinBoxCiphers
+* \brief SpinBox-Widget to enable Selection of Ciphers.
+*
+* This Class provides specialized SpinBox able to display strings to make for an
+* easier Selection of Algorithms
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.1
+* \date 28.02.2013
+*/
+class SpinBoxCiphers : public QSpinBox
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Gets the instance of the CiphersSingleton-Class.
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to.
+ */
+ SpinBoxCiphers( QWidget* parent = 0 );
+
+
+
+protected: //Methods
+ /**
+ * \brief Method to fetch a QString corresponding with the given Integer.
+ *
+ * For the given value, looks up what QString corresponds to it according to the definition
+ * in the Class CipherSingleton and returns it.
+ * \param int value integer representing an algorithm
+ * \see QSpinBox-Documentation
+ * \see Class CipherSingleton for assignments of Strings to Integers (and vice versa).
+ * \returns QString corresponding to the given integer.
+ */
+ QString textFromValue ( int value ) const;
+
+
+ /**
+ * \brief Method to fetch an Integer corresponding with the given QString.
+ *
+ * For the given QString, looks up what Integer corresponds to it according to the definition
+ * in the Class CipherSingleton and returns it.
+ * \param QString& text QString representing an algorithm
+ * \see QSpinBox-Documentation
+ * \see Class CipherSingleton for assignments of Strings to Integers (and vice versa).
+ * \returns Integer corresponding to the given QString.
+ */
+ int valueFromText ( const QString & text ) const;
+
+
+private: //Attributes
+ /**
+ * \brief Instance of the Class used to assign an integer to a String for each Cipher (and vice versa).
+ *
+ * \attention These Strings are used throughout the entire program to reference ciphers!
+ */
+ CiphersSingleton* m_cipherStrings;
+};
+
+#endif // SPINBOXCIPHERS_H
diff --git a/src/tabasymmetric.cpp b/src/tabasymmetric.cpp
new file mode 100644
index 0000000..e29d646
--- /dev/null
+++ b/src/tabasymmetric.cpp
@@ -0,0 +1,33 @@
+#include "tabasymmetric.h"
+#include "ui_tabasymmetric.h"
+
+TabAsymmetric::TabAsymmetric(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::TabAsymmetric)
+{
+ ui->setupUi(this);
+
+ //Set SpinBoxCiphers to number of Asymmetric Ciphers
+ ui->spinBoxCipher->setMinimum( (CiphersSingleton::getInstance()).symmetricCiphersCount() );
+ ui->spinBoxCipher->setMaximum( (CiphersSingleton::getInstance()).symmetricCiphersCount() +
+ (CiphersSingleton::getInstance()).asymmetricCiphersCount()-1 );
+
+ //Send Selection from SpinBox on to TabWidgetSelectAlgorithm
+ connect( ui->spinBoxCipher, SIGNAL(valueChanged(int)),
+ this, SIGNAL(cipherChanged(int)) );
+
+
+ connect( ui->spinBoxKeylength, SIGNAL(valueChanged(int)),
+ this, SLOT(on_spinBoxKeylength_valueChanged(int)));
+}
+
+TabAsymmetric::~TabAsymmetric()
+{
+ delete ui;
+}
+
+
+void TabAsymmetric::on_spinBoxKeylength_valueChanged(int value)
+{
+ emit keyLengthChanged(value, true);
+}
diff --git a/src/tabasymmetric.h b/src/tabasymmetric.h
new file mode 100644
index 0000000..29632c7
--- /dev/null
+++ b/src/tabasymmetric.h
@@ -0,0 +1,82 @@
+#ifndef TABASYMMETRIC_H
+#define TABASYMMETRIC_H
+
+#include <QWidget>
+
+#include "cipherssingleton.h"
+
+namespace Ui {
+class TabAsymmetric;
+}
+
+
+/**
+* \class TabAsymmetric
+* \brief TabWidget for the TabWidgetSelectAlgorithm, Asymmetric Ciphers.
+*
+* This Widget contains all Settings necessary for Asymmetric Ciphers and is used as a Tab in the TabWidgetSelectAlgorithm-Class.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.2
+* \date 13.05s.2013
+*/
+class TabAsymmetric : public QWidget
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes Graphical Elements of the Widget.
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to.
+ */
+ TabAsymmetric(QWidget *parent = 0);
+
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Deletes the ui-Object containing the graphical Elements.
+ */
+ ~TabAsymmetric();
+
+
+signals:
+ /**
+ * \brief SIGNAL to inform other Classes when a Cipher gets selected.
+ *
+ * This Signal is used to inform other Classes when a Cipher gets selected.
+ * \param int cipher The Integer referencing the selected Cipher according to the Class CiphersSingleton.
+ */
+ void cipherChanged(int cipher);
+
+
+ /**
+ * \brief SIGNAL to inform other Classes when the Keylength is changed.
+ *
+ * This Signal is used to inform other Classes when the Keylength is changed.
+ * \param int keyLength The new Keylength.
+ * \param bool symmetric True if Length for Symmetric Cipher, false if for asymmetric Cipher.
+ */
+ void keyLengthChanged(int keyLength, bool symmetric);
+
+
+private slots:
+ /**
+ * \brief SLOT to pass on the new Keylength.
+ *
+ * Called when a new Keylength is selected. Passes the value on in connection with a bool
+ * set to true, signifying that it is for a symmetric Cipher.
+ * \param int value The new Keylength.
+ */
+ void on_spinBoxKeylength_valueChanged(int value);
+
+
+private: //Attributes
+ /**
+ * \brief Pointer to GUI-Object.
+ */
+ Ui::TabAsymmetric *ui;
+};
+
+#endif // TABASYMMETRIC_H
diff --git a/src/tabhybrid.cpp b/src/tabhybrid.cpp
new file mode 100644
index 0000000..b985c32
--- /dev/null
+++ b/src/tabhybrid.cpp
@@ -0,0 +1,34 @@
+#include "tabhybrid.h"
+#include "ui_tabhybrid.h"
+
+TabHybrid::TabHybrid(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::TabHybrid)
+{
+ ui->setupUi(this);
+
+ //Set SpinBoxCiphers to number of Symmetric Ciphers
+ ui->spinBoxCipherSymmetric->setMaximum( (CiphersSingleton::getInstance()).symmetricCiphersCount()-1 );
+ //Set SpinBoxCiphers to number of Asymmetric Ciphers
+ ui->spinBoxCipherAsymmetric->setMinimum( (CiphersSingleton::getInstance()).symmetricCiphersCount() );
+ ui->spinBoxCipherAsymmetric->setMaximum( (CiphersSingleton::getInstance()).symmetricCiphersCount() +
+ (CiphersSingleton::getInstance()).asymmetricCiphersCount()-1 );
+
+ //Send Selection from SpinBox on to TabWidgetSelectAlgorithm
+ connect( ui->spinBoxCipherSymmetric, SIGNAL(valueChanged(int)),
+ this, SIGNAL(cipherChanged(int)) );
+
+ //TODO enable Hybrid - Asymmetric
+ connect( ui->spinBoxKeylengthSymmetric, SIGNAL(valueChanged(int)),
+ this, SLOT(on_spinBoxKeylengthSymmetric_valueChanged(int)));
+}
+
+TabHybrid::~TabHybrid()
+{
+ delete ui;
+}
+
+void TabHybrid::on_spinBoxKeylengthSymmetric_valueChanged(int value)
+{
+ emit keyLengthChanged(value, true);
+}
diff --git a/src/tabhybrid.h b/src/tabhybrid.h
new file mode 100644
index 0000000..f2293b0
--- /dev/null
+++ b/src/tabhybrid.h
@@ -0,0 +1,82 @@
+#ifndef TABHYBRID_H
+#define TABHYBRID_H
+
+#include <QWidget>
+
+#include "cipherssingleton.h"
+
+namespace Ui {
+class TabHybrid;
+}
+
+
+/**
+* \class TabHybrid
+* \brief TabWidget for the TabWidgetSelectAlgorithm, Hybrid Ciphers.
+*
+* This Widget contains all Settings necessary for Hybrid Ciphers and is used as a Tab in the TabWidgetSelectAlgorithm-Class.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.2
+* \date 13.05.2013
+*/
+class TabHybrid : public QWidget
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes Graphical Elements of the Widget.
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to.
+ */
+ TabHybrid(QWidget *parent = 0);
+
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Deletes the ui-Object containing the graphical Elements.
+ */
+ ~TabHybrid();
+
+
+signals:
+ /**
+ * \brief SIGNAL to inform other Classes when a Cipher gets selected.
+ *
+ * This Signal is used to inform other Classes when a Cipher gets selected.
+ * \param int cipher The Integer referencing the selected Cipher according to the Class CiphersSingleton.
+ */
+ void cipherChanged(int cipher);
+
+
+ /**
+ * \brief SIGNAL to inform other Classes when the Keylength is changed.
+ *
+ * This Signal is used to inform other Classes when the Keylength is changed.
+ * \param int keyLength The new Keylength.
+ * \param bool symmetric True if Length for Symmetric Cipher, false if for asymmetric Cipher.
+ */
+ void keyLengthChanged(int keyLength, bool symmetric);
+
+
+private slots:
+ /**
+ * \brief SLOT to pass on the new Keylength.
+ *
+ * Called when a new Keylength is selected. Passes the value on in connection with a bool
+ * set to true, signifying that it is for a symmetric Cipher.
+ * \param int value The new Keylength.
+ */
+ void on_spinBoxKeylengthSymmetric_valueChanged(int value);
+
+
+private: //Attributes
+ /**
+ * \brief Pointer to GUI-Object.
+ */
+ Ui::TabHybrid *ui;
+};
+
+#endif // TABHYBRID_H
diff --git a/src/tabsymmetric.cpp b/src/tabsymmetric.cpp
new file mode 100644
index 0000000..85f742d
--- /dev/null
+++ b/src/tabsymmetric.cpp
@@ -0,0 +1,29 @@
+#include "tabsymmetric.h"
+#include "ui_tabsymmetric.h"
+
+TabSymmetric::TabSymmetric(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::TabSymmetric)
+{
+ ui->setupUi(this);
+
+ //Set SpinBoxCiphers to number of Symmetric Ciphers
+ ui->spinBoxCipher->setMaximum( (CiphersSingleton::getInstance()).symmetricCiphersCount()-1 );
+
+ //Send Selection from SpinBox on to TabWidgetSelectAlgorithm
+ connect( ui->spinBoxCipher, SIGNAL(valueChanged(int)),
+ this, SIGNAL(cipherChanged(int)) );
+
+ connect( ui->spinBoxKeylength, SIGNAL(valueChanged(int)),
+ this, SLOT(on_spinBoxKeylength_valueChanged(int)));
+}
+
+TabSymmetric::~TabSymmetric()
+{
+ delete ui;
+}
+
+void TabSymmetric::on_spinBoxKeylength_valueChanged(int value)
+{
+ emit keyLengthChanged(value, true);
+}
diff --git a/src/tabsymmetric.h b/src/tabsymmetric.h
new file mode 100644
index 0000000..ae65466
--- /dev/null
+++ b/src/tabsymmetric.h
@@ -0,0 +1,81 @@
+#ifndef TABSYMMETRIC_H
+#define TABSYMMETRIC_H
+
+#include <QWidget>
+
+#include "cipherssingleton.h"
+
+namespace Ui {
+class TabSymmetric;
+}
+
+
+/**
+* \class TabSymmetric
+* \brief TabWidget for the TabWidgetSelectAlgorithm, Symmetric Ciphers.
+*
+* This Widget contains all Settings necessary for Symmetric Ciphers and is used as a Tab in the TabWidgetSelectAlgorithm-Class.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.2
+* \date 13.05.2013
+*/
+class TabSymmetric : public QWidget
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes Graphical Elements of the Widget.
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to.
+ */
+ TabSymmetric(QWidget *parent = 0);
+
+
+ /**
+ * \brief Class Destructor.
+ *
+ * Class Destructor. Deletes the ui-Object containing the graphical Elements.
+ */
+ ~TabSymmetric();
+
+
+signals:
+ /**
+ * \brief SIGNAL to inform other Classes when a Cipher gets selected.
+ *
+ * This Signal is used to inform other Classes when a Cipher gets selected.
+ * \param int cipher The Integer referencing the selected Cipher according to the Class CiphersSingleton.
+ */
+ void cipherChanged(int cipher);
+
+
+ /**
+ * \brief SIGNAL to inform other Classes when the Keylength is changed.
+ *
+ * This Signal is used to inform other Classes when the Keylength is changed.
+ * \param int keyLength The new Keylength.
+ * \param bool symmetric True if Length for Symmetric Cipher, false if for asymmetric Cipher.
+ */
+ void keyLengthChanged(int keyLength, bool symmetric);
+
+private slots:
+ /**
+ * \brief SLOT to pass on the new Keylength.
+ *
+ * Called when a new Keylength is selected. Passes the value on in connection with a bool
+ * set to true, signifying that it is for a symmetric Cipher.
+ * \param int value The new Keylength.
+ */
+ void on_spinBoxKeylength_valueChanged(int value);
+
+
+private: //Attributes
+ /**
+ * \brief Pointer to GUI-Object.
+ */
+ Ui::TabSymmetric *ui;
+};
+
+#endif // TABSYMMETRIC_H
diff --git a/src/tabwidgetselectalgorithm.cpp b/src/tabwidgetselectalgorithm.cpp
new file mode 100644
index 0000000..a3d85af
--- /dev/null
+++ b/src/tabwidgetselectalgorithm.cpp
@@ -0,0 +1,80 @@
+#include "tabwidgetselectalgorithm.h"
+
+TabWidgetSelectAlgorithm::TabWidgetSelectAlgorithm(QWidget *parent) :
+ QTabWidget(parent)
+{
+ //Create the Widgets for Algorithm-Selection
+ m_nullCipher = new QWidget(this);
+ m_symmetric = new TabSymmetric(this);
+ m_asymmetric = new TabAsymmetric(this);
+ m_hybrid = new TabHybrid(this);
+
+ //Add those Widgets as Tabs
+ addTab(m_nullCipher, "NullCipher");
+ addTab(m_symmetric, "Symmetric");
+ addTab(m_asymmetric, "Asymmetric");
+ addTab(m_hybrid, "Hybrid");
+
+
+ connect( this, SIGNAL(currentChanged(int)),
+ this, SLOT(oncurrentChanged_triggered(int)));
+
+ //Send Selection from SubTabs on: Ciphers
+ connect( m_symmetric, SIGNAL(cipherChanged(int)),
+ this, SIGNAL(cipherChanged(int)) );
+ connect( m_asymmetric, SIGNAL(cipherChanged(int)),
+ this, SIGNAL(cipherChanged(int)) );
+ connect( m_hybrid, SIGNAL(cipherChanged(int)),
+ this, SIGNAL(cipherChanged(int)) );
+
+ //Send Selection from SubTabs on: KeyLength
+ connect( m_symmetric, SIGNAL(keyLengthChanged(int, bool)),
+ this, SIGNAL(keyLengthChanged(int,bool)));
+ connect( m_asymmetric, SIGNAL(keyLengthChanged(int, bool)),
+ this, SIGNAL(keyLengthChanged(int,bool)));
+ connect( m_hybrid, SIGNAL(keyLengthChanged(int, bool)),
+ this, SIGNAL(keyLengthChanged(int,bool)));
+}
+
+
+
+//public slots:
+void TabWidgetSelectAlgorithm::onNullCipher_selected()
+{
+ setCurrentWidget(m_nullCipher);
+}
+
+void TabWidgetSelectAlgorithm::onSymmetric_selected()
+{
+ setCurrentWidget(m_symmetric);
+}
+
+void TabWidgetSelectAlgorithm::onAsymmetric_selected()
+{
+ setCurrentWidget(m_asymmetric);
+}
+
+void TabWidgetSelectAlgorithm::onHybrid_selected()
+{
+ setCurrentWidget(m_hybrid);
+}
+
+
+
+
+// private slots:
+void TabWidgetSelectAlgorithm::oncurrentChanged_triggered(int index)
+{
+ QString tabName;
+
+ if( currentWidget() == m_nullCipher )
+ tabName = "NullCipher";
+ else if( currentWidget() == m_symmetric )
+ tabName = "Symmetric";
+ else if( currentWidget() == m_asymmetric )
+ tabName = "Asymmetric";
+ else if( currentWidget() == m_hybrid )
+ tabName = "Hybrid";
+
+ emit (currentTabChanged( tabName ));
+}
diff --git a/src/tabwidgetselectalgorithm.h b/src/tabwidgetselectalgorithm.h
new file mode 100644
index 0000000..01265f3
--- /dev/null
+++ b/src/tabwidgetselectalgorithm.h
@@ -0,0 +1,151 @@
+#ifndef TABWIDGETSELECTALGORITHM_H
+#define TABWIDGETSELECTALGORITHM_H
+
+#include <QTabWidget>
+
+#include "cipherssingleton.h"
+#include "tabsymmetric.h"
+#include "tabasymmetric.h"
+#include "tabhybrid.h"
+
+
+
+
+
+/**
+* \class TabWidgetSelectAlgorithm
+* \brief Subclassed TabWidget for Algorithm-Selection.
+*
+* SubClass of QTabWidget with added functionality for exclusive selection of an algorithm for de/encryption,
+* sorted by the kind of algorithm (NullCipher, Symmetric, Asymmetric, Hybrid)
+* For each kind of algorithm, a special TabWidget has been implemented.
+* \author Uwe Gogolin [Gogolin.Uwe@FH-SWF.de]
+* \version 0.1
+* \date 28.02.2013
+*/
+class TabWidgetSelectAlgorithm : public QTabWidget
+{
+ Q_OBJECT
+
+public: //Methods
+ /**
+ * \brief Class Constructor.
+ *
+ * Class Constructor. Initializes the four different TabWidgets and adds them as Tabs to itself.
+ * Connects the Signal "currentChanged(int)" with the Slot "oncurrentChanged_triggered(int)", which
+ * after checking which is the new current Widget, sends that info via the Signal "currentTabChanged(QString)"
+ * [This is needed to keep the corresponding option in the Menu up to date]
+ * \param QWidget* parent The QWidget the used instance of this class is subordinated to.
+ */
+ TabWidgetSelectAlgorithm(QWidget *parent = 0);
+
+
+
+public slots:
+ /**
+ * \brief Slot called to set Tab for NullCipher active.
+ *
+ * Changes the current Tab to the NullCipher-Tab.
+ */
+ void onNullCipher_selected();
+
+
+ /**
+ * \brief Slot called to set Tab for Symmetric Ciphers active.
+ *
+ * Changes the current Tab to the Symmetric Ciphers-Tab.
+ */
+ void onSymmetric_selected();
+
+
+ /**
+ * \brief Slot called to set Tab for Asymmetric Ciphers active.
+ *
+ * Changes the current Tab to the Asymmetric Ciphers-Tab.
+ */
+ void onAsymmetric_selected();
+
+
+ /**
+ * \brief Slot called to set Tab for Hybrid Ciphers active.
+ *
+ * Changes the current Tab to the Hybrid Ciphers-Tab.
+ */
+ void onHybrid_selected();
+
+
+
+signals:
+ /**
+ * \brief SIGNAL to inform other Classes when another Tab becomes active.
+ *
+ * This Signal is used to inform other Classes when a new Tab becomes active.
+ * [NOTE: Will be modified to use NameSpaceCryptEngine::CryptAlgorithm in the future]
+ * \param QString currentTabName string containing the Name of the newly active Tab.
+ */
+ void currentTabChanged(QString currentTabName);
+
+
+
+ /**
+ * \brief SIGNAL to inform other Classes when a Cipher gets selected.
+ *
+ * This Signal is used to inform other Classes when a Cipher gets selected.
+ * \param int cipher The Integer referencing the selected Cipher according to the Class CiphersSingleton.
+ */
+ void cipherChanged(int cipher);
+
+
+
+ /**
+ * \brief SIGNAL to inform other Classes when the Keylength is changed.
+ *
+ * This Signal is used to inform other Classes when the Keylength is changed.
+ * \param int keyLength The new Keylength.
+ * \param bool symmetric True if Length for Symmetric Cipher, false if for asymmetric Cipher.
+ */
+ void keyLengthChanged(int keyLength, bool symmetric);
+
+
+private slots:
+ /**
+ * \brief Slot needed to get the pointer to the newly active Tab from its index.
+ *
+ * This slot is called when the currently active Tab changes. This Tab, however, is only referenced by index
+ * by the Signal "currentChanged", which is fine for reference inside this Class.
+ * For Classes outside, a better description is needed. Currently, a QString is used.
+ * [NOTE: Will be modified to use NameSpaceCryptEngine::CryptAlgorithm in the future]
+ * \param int index Index of the newly active Tab
+ */
+ void oncurrentChanged_triggered(int index);
+
+
+
+private: //Attributes
+ /**
+ * \brief Pointer to the TabWidget for NullCipher.
+ *
+ * \attention This Tab is supposed to be empty, since there no settings for the NullCipher.
+ */
+ QWidget* m_nullCipher;
+
+
+ /**
+ * \brief Pointer to the TabWidget for Symmetric Ciphers.
+ */
+ QWidget* m_symmetric;
+
+
+ /**
+ * \brief Pointer to the TabWidget for Asymmetric Ciphers.
+ */
+ QWidget* m_asymmetric;
+
+
+ /**
+ * \brief Pointer to the TabWidget for Hybrid Ciphers.
+ */
+ QWidget* m_hybrid;
+};
+
+#endif // TABWIDGETSELECTALGORITHM_H