summaryrefslogtreecommitdiffstats
path: root/libcommuni/src/3rdparty/qblowfish/qblowfish.h
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2014-10-06 15:03:54 +0200
committerMarkus Mittendrein <git@maxmitti.tk>2014-10-06 15:03:54 +0200
commit529f38bd8878b6b1bea2b5457031ce936aab8d80 (patch)
tree1193caefcad12f6a36f818048e4547e60add4398 /libcommuni/src/3rdparty/qblowfish/qblowfish.h
parent3b58b5536935adff242928ed9f30e1c0262fbd7c (diff)
downloadmanager-529f38bd8878b6b1bea2b5457031ce936aab8d80.tar.gz
manager-529f38bd8878b6b1bea2b5457031ce936aab8d80.zip
addedd communi
Diffstat (limited to 'libcommuni/src/3rdparty/qblowfish/qblowfish.h')
-rw-r--r--libcommuni/src/3rdparty/qblowfish/qblowfish.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/libcommuni/src/3rdparty/qblowfish/qblowfish.h b/libcommuni/src/3rdparty/qblowfish/qblowfish.h
new file mode 100644
index 0000000..100a2e6
--- /dev/null
+++ b/libcommuni/src/3rdparty/qblowfish/qblowfish.h
@@ -0,0 +1,46 @@
+#ifndef QBLOWFISH_H
+#define QBLOWFISH_H
+
+#include <QByteArray>
+
+class QBlowfish
+{
+public:
+ QBlowfish(const QByteArray &key);
+ bool init();
+
+ // Padding:
+ //
+ // Blowfish works on 8-byte blocks. Padding makes it usable even
+ // in case where the input size is not in exact 8-byte blocks.
+ //
+ // If padding is disabled (the default), encrypted() will work only if the
+ // input size (in bytes) is a multiple of 8. (If it's not a multiple of 8,
+ // encrypted() will return a null bytearray.)
+ //
+ // If padding is enabled, we increase the input length to a multiple of 8
+ // by padding bytes as per PKCS5
+ //
+ // If padding was enabled during encryption, it should be enabled during
+ // decryption for correct decryption (and vice versa).
+
+ void setPaddingEnabled(bool enabled);
+ bool isPaddingEnabled() const;
+
+ // Encrypt / decrypt
+ QByteArray encrypted(const QByteArray &clearText);
+ QByteArray decrypted(const QByteArray &cipherText);
+
+private:
+ // core encrypt/decrypt methods, encrypts/decrypts in-place
+ void coreEncrypt(char *x);
+ void coreDecrypt(char *x);
+
+ QByteArray m_key;
+ bool m_initialized;
+ bool m_paddingEnabled;
+ QByteArray m_parray;
+ QByteArray m_sbox1, m_sbox2, m_sbox3, m_sbox4;
+};
+
+#endif // QBLOWFISH_H