diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp')
-rw-r--r-- | kopete/protocols/jabber/libiris/cutestuff/util/cipher.cpp | 68 |
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) |