summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp')
-rw-r--r--kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp68
1 files changed, 34 insertions, 34 deletions
diff --git a/kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp b/kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp
index f1581a6f..8f918dde 100644
--- a/kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp
+++ b/kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp
@@ -25,9 +25,9 @@
#include"bytestream.h"
#include"qrandom.h"
-static bool lib_encryptArray(const EVP_CIPHER *type, const QByteArray &buf, const QByteArray &key, const QByteArray &iv, bool pad, QByteArray *out)
+static bool lib_encryptArray(const EVP_CIPHER *type, const TQByteArray &buf, const TQByteArray &key, const TQByteArray &iv, bool pad, TQByteArray *out)
{
- QByteArray result(buf.size()+type->block_size);
+ TQByteArray result(buf.size()+type->block_size);
int len;
EVP_CIPHER_CTX c;
@@ -42,7 +42,7 @@ static bool lib_encryptArray(const EVP_CIPHER *type, const QByteArray &buf, cons
return false;
result.resize(len);
if(pad) {
- QByteArray last(type->block_size);
+ TQByteArray last(type->block_size);
if(!EVP_EncryptFinal_ex(&c, (unsigned char *)last.data(), &len))
return false;
last.resize(len);
@@ -54,9 +54,9 @@ static bool lib_encryptArray(const EVP_CIPHER *type, const QByteArray &buf, cons
return true;
}
-static bool lib_decryptArray(const EVP_CIPHER *type, const QByteArray &buf, const QByteArray &key, const QByteArray &iv, bool pad, QByteArray *out)
+static bool lib_decryptArray(const EVP_CIPHER *type, const TQByteArray &buf, const TQByteArray &key, const TQByteArray &iv, bool pad, TQByteArray *out)
{
- QByteArray result(buf.size()+type->block_size);
+ TQByteArray result(buf.size()+type->block_size);
int len;
EVP_CIPHER_CTX c;
@@ -77,7 +77,7 @@ static bool lib_decryptArray(const EVP_CIPHER *type, const QByteArray &buf, cons
}
result.resize(len);
if(pad) {
- QByteArray last(type->block_size);
+ TQByteArray last(type->block_size);
if(!EVP_DecryptFinal_ex(&c, (unsigned char *)last.data(), &len))
return false;
last.resize(len);
@@ -89,9 +89,9 @@ static bool lib_decryptArray(const EVP_CIPHER *type, const QByteArray &buf, cons
return true;
}
-static bool lib_generateKeyIV(const EVP_CIPHER *type, const QByteArray &data, const QByteArray &salt, QByteArray *key, QByteArray *iv)
+static bool lib_generateKeyIV(const EVP_CIPHER *type, const TQByteArray &data, const TQByteArray &salt, TQByteArray *key, TQByteArray *iv)
{
- QByteArray k, i;
+ TQByteArray k, i;
unsigned char *kp = 0;
unsigned char *ip = 0;
if(key) {
@@ -129,7 +129,7 @@ Cipher::Key Cipher::generateKey(Type t)
const EVP_CIPHER *type = typeToCIPHER(t);
if(!type)
return k;
- QByteArray out;
+ TQByteArray out;
if(!lib_generateKeyIV(type, QRandom::randomArray(128), QRandom::randomArray(2), &out, 0))
return k;
k.setType(t);
@@ -137,14 +137,14 @@ Cipher::Key Cipher::generateKey(Type t)
return k;
}
-QByteArray Cipher::generateIV(Type t)
+TQByteArray Cipher::generateIV(Type t)
{
const EVP_CIPHER *type = typeToCIPHER(t);
if(!type)
- return QByteArray();
- QByteArray out;
- if(!lib_generateKeyIV(type, QCString("Get this man an iv!"), QByteArray(), 0, &out))
- return QByteArray();
+ return TQByteArray();
+ TQByteArray out;
+ if(!lib_generateKeyIV(type, TQCString("Get this man an iv!"), TQByteArray(), 0, &out))
+ return TQByteArray();
return out;
}
@@ -156,32 +156,32 @@ int Cipher::ivSize(Type t)
return type->iv_len;
}
-QByteArray Cipher::encrypt(const QByteArray &buf, const Key &key, const QByteArray &iv, bool pad, bool *ok)
+TQByteArray Cipher::encrypt(const TQByteArray &buf, const Key &key, const TQByteArray &iv, bool pad, bool *ok)
{
if(ok)
*ok = false;
const EVP_CIPHER *type = typeToCIPHER(key.type());
if(!type)
- return QByteArray();
- QByteArray out;
+ return TQByteArray();
+ TQByteArray out;
if(!lib_encryptArray(type, buf, key.data(), iv, pad, &out))
- return QByteArray();
+ return TQByteArray();
if(ok)
*ok = true;
return out;
}
-QByteArray Cipher::decrypt(const QByteArray &buf, const Key &key, const QByteArray &iv, bool pad, bool *ok)
+TQByteArray Cipher::decrypt(const TQByteArray &buf, const Key &key, const TQByteArray &iv, bool pad, bool *ok)
{
if(ok)
*ok = false;
const EVP_CIPHER *type = typeToCIPHER(key.type());
if(!type)
- return QByteArray();
- QByteArray out;
+ return TQByteArray();
+ TQByteArray out;
if(!lib_decryptArray(type, buf, key.data(), iv, pad, &out))
- return QByteArray();
+ return TQByteArray();
if(ok)
*ok = true;
@@ -272,7 +272,7 @@ RSAKey generateRSAKey()
return key;
}
-QByteArray encryptRSA(const QByteArray &buf, const RSAKey &key, bool *ok)
+TQByteArray encryptRSA(const TQByteArray &buf, const RSAKey &key, bool *ok)
{
if(ok)
*ok = false;
@@ -281,12 +281,12 @@ QByteArray encryptRSA(const QByteArray &buf, const RSAKey &key, bool *ok)
int flen = buf.size();
if(flen >= size - 11)
flen = size - 11;
- QByteArray result(size);
+ TQByteArray result(size);
unsigned char *from = (unsigned char *)buf.data();
unsigned char *to = (unsigned char *)result.data();
int r = RSA_public_encrypt(flen, from, to, (RSA *)key.data(), RSA_PKCS1_PADDING);
if(r == -1)
- return QByteArray();
+ return TQByteArray();
result.resize(r);
if(ok)
@@ -294,19 +294,19 @@ QByteArray encryptRSA(const QByteArray &buf, const RSAKey &key, bool *ok)
return result;
}
-QByteArray decryptRSA(const QByteArray &buf, const RSAKey &key, bool *ok)
+TQByteArray decryptRSA(const TQByteArray &buf, const RSAKey &key, bool *ok)
{
if(ok)
*ok = false;
int size = RSA_size((RSA *)key.data());
int flen = buf.size();
- QByteArray result(size);
+ TQByteArray result(size);
unsigned char *from = (unsigned char *)buf.data();
unsigned char *to = (unsigned char *)result.data();
int r = RSA_private_decrypt(flen, from, to, (RSA *)key.data(), RSA_PKCS1_PADDING);
if(r == -1)
- return QByteArray();
+ return TQByteArray();
result.resize(r);
if(ok)
@@ -314,7 +314,7 @@ QByteArray decryptRSA(const QByteArray &buf, const RSAKey &key, bool *ok)
return result;
}
-QByteArray encryptRSA2(const QByteArray &buf, const RSAKey &key, bool *ok)
+TQByteArray encryptRSA2(const TQByteArray &buf, const RSAKey &key, bool *ok)
{
if(ok)
*ok = false;
@@ -323,12 +323,12 @@ QByteArray encryptRSA2(const QByteArray &buf, const RSAKey &key, bool *ok)
int flen = buf.size();
if(flen >= size - 41)
flen = size - 41;
- QByteArray result(size);
+ TQByteArray result(size);
unsigned char *from = (unsigned char *)buf.data();
unsigned char *to = (unsigned char *)result.data();
int r = RSA_public_encrypt(flen, from, to, (RSA *)key.data(), RSA_PKCS1_OAEP_PADDING);
if(r == -1)
- return QByteArray();
+ return TQByteArray();
result.resize(r);
if(ok)
@@ -336,19 +336,19 @@ QByteArray encryptRSA2(const QByteArray &buf, const RSAKey &key, bool *ok)
return result;
}
-QByteArray decryptRSA2(const QByteArray &buf, const RSAKey &key, bool *ok)
+TQByteArray decryptRSA2(const TQByteArray &buf, const RSAKey &key, bool *ok)
{
if(ok)
*ok = false;
int size = RSA_size((RSA *)key.data());
int flen = buf.size();
- QByteArray result(size);
+ TQByteArray result(size);
unsigned char *from = (unsigned char *)buf.data();
unsigned char *to = (unsigned char *)result.data();
int r = RSA_private_decrypt(flen, from, to, (RSA *)key.data(), RSA_PKCS1_OAEP_PADDING);
if(r == -1)
- return QByteArray();
+ return TQByteArray();
result.resize(r);
if(ok)