diff options
| author | 2010-08-14 02:46:11 +0000 | |
|---|---|---|
| committer | 2010-08-14 02:46:11 +0000 | |
| commit | 6c5cef203bfeef3c26043e13ddd23c01da589fe1 (patch) | |
| tree | ab80fc8e47e86d2957cc30ade3742953ed4f26b8 | |
| parent | finally fixed translation extraction (diff) | |
| download | KVIrc-6c5cef203bfeef3c26043e13ddd23c01da589fe1.tar.gz KVIrc-6c5cef203bfeef3c26043e13ddd23c01da589fe1.tar.bz2 KVIrc-6c5cef203bfeef3c26043e13ddd23c01da589fe1.zip | |
improved hungarian notation;
cleaned code;
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4869 17fca916-40b9-46aa-a4ea-0a15b648b75c
| -rw-r--r-- | src/kvilib/ext/kvi_crypt.cpp | 43 | ||||
| -rw-r--r-- | src/kvilib/ext/kvi_crypt.h | 14 | ||||
| -rw-r--r-- | src/kvirc/module/kvi_module.cpp | 2 | ||||
| -rw-r--r-- | src/kvirc/sparser/kvi_sp_literal.cpp | 6 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_channel.cpp | 8 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_cryptcontroller.cpp | 166 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_cryptcontroller.h | 10 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_query.cpp | 8 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_window.cpp | 6 | ||||
| -rw-r--r-- | src/modules/dcc/chat.cpp | 14 | ||||
| -rw-r--r-- | src/modules/lamerizer/libkvilamerizer.cpp | 24 | ||||
| -rw-r--r-- | src/modules/rijndael/libkvirijndael.cpp | 84 | ||||
| -rw-r--r-- | src/modules/rijndael/libkvirijndael_cryptopp.cpp | 144 | ||||
| -rw-r--r-- | src/modules/rijndael/libkvirijndael_cryptopp.h | 12 | ||||
| -rw-r--r-- | src/modules/rot13/libkvirot13.cpp | 15 | ||||
| -rw-r--r-- | src/modules/window/libkviwindow.cpp | 8 |
16 files changed, 285 insertions, 279 deletions
diff --git a/src/kvilib/ext/kvi_crypt.cpp b/src/kvilib/ext/kvi_crypt.cpp index f2fe1a33d..c5a78a284 100644 --- a/src/kvilib/ext/kvi_crypt.cpp +++ b/src/kvilib/ext/kvi_crypt.cpp @@ -168,18 +168,18 @@ #ifdef COMPILE_CRYPT_SUPPORT - bool KviCryptEngine::init(const char *,int,const char *,int) + bool KviCryptEngine::init(const char *, int, const char *, int) { return false; } - KviCryptEngine::EncryptResult KviCryptEngine::encrypt(const char *,KviStr &) + KviCryptEngine::EncryptResult KviCryptEngine::encrypt(const char *, KviStr &) { // qDebug("Pure virtual KviCryptEngine::encrypt() called"); return EncryptError; } - KviCryptEngine::DecryptResult KviCryptEngine::decrypt(const char *,KviStr &) + KviCryptEngine::DecryptResult KviCryptEngine::decrypt(const char *, KviStr &) { // qDebug("Pure virtual KviCryptEngine::decrypt() called"); return DecryptError; @@ -197,12 +197,12 @@ delete m_pEngineDict; } - void KviCryptEngineManager::registerEngine(KviCryptEngineDescription * d) + void KviCryptEngineManager::registerEngine(KviCryptEngineDescription * pDesc) { - m_pEngineDict->replace(d->szName,d); + m_pEngineDict->replace(pDesc->m_szName,pDesc); } - void KviCryptEngineManager::unregisterEngine(const QString &szName) + void KviCryptEngineManager::unregisterEngine(const QString & szName) { m_pEngineDict->remove(szName); } @@ -212,31 +212,34 @@ KviPointerList<QString> lEnginesToRemove; lEnginesToRemove.setAutoDelete(true); - for(KviPointerHashTableEntry<QString,KviCryptEngineDescription> * e = m_pEngineDict->firstEntry();e;e = m_pEngineDict->nextEntry()) + for(KviPointerHashTableEntry<QString,KviCryptEngineDescription> * pDesc = m_pEngineDict->firstEntry();pDesc;pDesc = m_pEngineDict->nextEntry()) { - if(e->data()->providerHandle == providerHandle) - lEnginesToRemove.append(new QString(e->key())); + if(pDesc->data()->m_providerHandle == providerHandle) + lEnginesToRemove.append(new QString(pDesc->key())); } for(QString * pszEngineName = lEnginesToRemove.first();pszEngineName;pszEngineName = lEnginesToRemove.next()) m_pEngineDict->remove(*pszEngineName); } - KviCryptEngine * KviCryptEngineManager::allocateEngine(const QString &szName) + KviCryptEngine * KviCryptEngineManager::allocateEngine(const QString & szName) { - KviCryptEngineDescription * d = m_pEngineDict->find(szName); - if(!d)return 0; - KviCryptEngine * e = d->allocFunc(); - if(!e)return 0; - e->m_deallocFunc = d->deallocFunc; // remember the dealloc func from now on - return e; + KviCryptEngineDescription * pDesc = m_pEngineDict->find(szName); + if(!pDesc) + return 0; + KviCryptEngine * pEngine = pDesc->m_allocFunc(); + if(!pEngine) + return 0; + pEngine->m_deallocFunc = pDesc->m_deallocFunc; // remember the dealloc func from now on + return pEngine; } - void KviCryptEngineManager::deallocateEngine(KviCryptEngine * e) + void KviCryptEngineManager::deallocateEngine(KviCryptEngine * pEngine) { - if(!e)return; - crypt_engine_deallocator_func deallocFunc = e->m_deallocFunc; - deallocFunc(e); + if(!pEngine) + return; + crypt_engine_deallocator_func deallocFunc = pEngine->m_deallocFunc; + deallocFunc(pEngine); } #endif //COMPILE_CRYPT_SUPPORT diff --git a/src/kvilib/ext/kvi_crypt.h b/src/kvilib/ext/kvi_crypt.h index 300e6665e..f3ebfb047 100644 --- a/src/kvilib/ext/kvi_crypt.h +++ b/src/kvilib/ext/kvi_crypt.h @@ -123,13 +123,13 @@ KviCryptEngineDescription(){}; virtual ~KviCryptEngineDescription(){}; public: - QString szName; // engine name - QString szDescription; // details - QString szAuthor; // algorithm author - int iFlags; // properties - crypt_engine_allocator_func allocFunc; // engine allocator - crypt_engine_deallocator_func deallocFunc; // deallocation function (if called from outside the origin module) - void * providerHandle; // used to identify the provider module + QString m_szName; // engine name + QString m_szDescription; // details + QString m_szAuthor; // algorithm author + int m_iFlags; // properties + crypt_engine_allocator_func m_allocFunc; // engine allocator + crypt_engine_deallocator_func m_deallocFunc; // deallocation function (if called from outside the origin module) + void * m_providerHandle; // used to identify the provider module }; diff --git a/src/kvirc/module/kvi_module.cpp b/src/kvirc/module/kvi_module.cpp index 987b2fd7f..ce177e253 100644 --- a/src/kvirc/module/kvi_module.cpp +++ b/src/kvirc/module/kvi_module.cpp @@ -186,7 +186,7 @@ unsigned int KviModule::secondsSinceLastAccess() void KviModule::registerCryptEngine(KviCryptEngineDescription * d) { - d->providerHandle = (void *)this; + d->m_providerHandle = (void *)this; g_pCryptEngineManager->registerEngine(d); } diff --git a/src/kvirc/sparser/kvi_sp_literal.cpp b/src/kvirc/sparser/kvi_sp_literal.cpp index 0487db98a..2191b3905 100644 --- a/src/kvirc/sparser/kvi_sp_literal.cpp +++ b/src/kvirc/sparser/kvi_sp_literal.cpp @@ -666,8 +666,8 @@ void KviServerParser::parseLiteralKick(KviIrcMessage *msg) #ifdef COMPILE_CRYPT_SUPPORT #define DECRYPT_IF_NEEDED(_target,_txt,_type,_type2,_buffer,_retptr,_retmsgtype) \ if(KviCryptSessionInfo * cinf = _target->cryptSessionInfo()){ \ - if(cinf->bDoDecrypt){ \ - switch(cinf->pEngine->decrypt(_txt,_buffer)) \ + if(cinf->m_bDoDecrypt){ \ + switch(cinf->m_pEngine->decrypt(_txt,_buffer)) \ { \ case KviCryptEngine::DecryptOkWasEncrypted: \ _retptr = _buffer.ptr(); \ @@ -680,7 +680,7 @@ void KviServerParser::parseLiteralKick(KviIrcMessage *msg) break; \ default: /* also case KviCryptEngine::DecryptError: */ \ { \ - QString szEngineError = cinf->pEngine->lastError(); \ + QString szEngineError = cinf->m_pEngine->lastError(); \ _target->output(KVI_OUT_SYSTEMERROR, \ __tr2qs("The following message appears to be encrypted, but the crypto engine failed to decode it: %Q"), \ &szEngineError); \ diff --git a/src/kvirc/ui/kvi_channel.cpp b/src/kvirc/ui/kvi_channel.cpp index b6b4f60bc..f9d429fd7 100644 --- a/src/kvirc/ui/kvi_channel.cpp +++ b/src/kvirc/ui/kvi_channel.cpp @@ -1122,13 +1122,13 @@ void KviChannel::ownMessage(const QString & szBuffer, bool bUserFeedback) #ifdef COMPILE_CRYPT_SUPPORT if(cryptSessionInfo()) { - if(cryptSessionInfo()->bDoEncrypt) + if(cryptSessionInfo()->m_bDoEncrypt) { if(*d != KVI_TEXT_CRYPTESCAPE) { KviStr encrypted; - cryptSessionInfo()->pEngine->setMaxEncryptLen(maxMsgLen); - switch(cryptSessionInfo()->pEngine->encrypt(d,encrypted)) + cryptSessionInfo()->m_pEngine->setMaxEncryptLen(maxMsgLen); + switch(cryptSessionInfo()->m_pEngine->encrypt(d,encrypted)) { case KviCryptEngine::Encrypted: if(!connection()->sendFmtData("PRIVMSG %s :%s",szName.data(),encrypted.ptr())) @@ -1152,7 +1152,7 @@ void KviChannel::ownMessage(const QString & szBuffer, bool bUserFeedback) break; default: // also case KviCryptEngine::EncryptError { - QString szEngineError = cryptSessionInfo()->pEngine->lastError(); + QString szEngineError = cryptSessionInfo()->m_pEngine->lastError(); output(KVI_OUT_SYSTEMERROR, __tr2qs("The crypto engine was unable to encrypt the current message (%Q): %Q, no data sent to the server"), &szBuffer,&szEngineError); diff --git a/src/kvirc/ui/kvi_cryptcontroller.cpp b/src/kvirc/ui/kvi_cryptcontroller.cpp index e19a2aac2..a3d69b622 100644 --- a/src/kvirc/ui/kvi_cryptcontroller.cpp +++ b/src/kvirc/ui/kvi_cryptcontroller.cpp @@ -45,22 +45,22 @@ extern KVIRC_API KviCryptEngineManager * g_pCryptEngineManager; extern KVIRC_API KviModuleManager * g_pModuleManager; - KviEngineListBoxItem::KviEngineListBoxItem(KviTalListWidget * lb,KviCryptEngineDescription * d,const char * modName) - : KviTalListWidgetText(lb,d->szName) + KviEngineListBoxItem::KviEngineListBoxItem(KviTalListWidget * pList, KviCryptEngineDescription * pDesc, const char * pcModName) + : KviTalListWidgetText(pList,pDesc->m_szName) { - m_szName = d->szName; - m_szAuthor = d->szAuthor; - m_szDescription = d->szDescription; - m_iFlags = d->iFlags; - m_szModuleName = modName; - setText(d->szName); + m_szName = pDesc->m_szName; + m_szAuthor = pDesc->m_szAuthor; + m_szDescription = pDesc->m_szDescription; + m_iFlags = pDesc->m_iFlags; + m_szModuleName = pcModName; + setText(pDesc->m_szName); } KviEngineListBoxItem::~KviEngineListBoxItem() { } - KviCryptController::KviCryptController(QWidget * pParent, KviWindowToolPageButton * pButton, const char *,KviWindow * pWnd, KviCryptSessionInfo * pInfo) + KviCryptController::KviCryptController(QWidget * pParent, KviWindowToolPageButton * pButton, KviWindow * pWnd, KviCryptSessionInfo * pInfo) : KviWindowToolWidget(pParent,pButton) { // Load the known encryption modules @@ -70,66 +70,66 @@ setFocusPolicy(Qt::ClickFocus); - QGridLayout *g = new QGridLayout(this); + QGridLayout * pLayout = new QGridLayout(this); - QLabel *l = new QLabel(this); - l->setPixmap(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_LOCKED))); - g->addWidget(l,0,0); - l = new QLabel(__tr2qs("Cryptography/text transformation"),this); - g->addWidget(l,0,1,1,3); + QLabel * pLabel = new QLabel(this); + pLabel->setPixmap(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_LOCKED))); + pLayout->addWidget(pLabel,0,0); + pLabel = new QLabel(__tr2qs("Cryptography/text transformation"),this); + pLayout->addWidget(pLabel,0,1,1,3); - QFrame * frm = new QFrame(this); - frm->setFrameStyle(QFrame::HLine | QFrame::Sunken); - g->addWidget(frm,1,0,1,4); + QFrame * pFrame = new QFrame(this); + pFrame->setFrameStyle(QFrame::HLine | QFrame::Sunken); + pLayout->addWidget(pFrame,1,0,1,4); m_pEnableCheck = new QCheckBox(__tr2qs("Use the crypt engine"),this); - g->addWidget(m_pEnableCheck,2,0,1,4); + pLayout->addWidget(m_pEnableCheck,2,0,1,4); connect(m_pEnableCheck,SIGNAL(toggled(bool)),this,SLOT(enableCheckToggled(bool))); m_pListBox = new KviTalListWidget(this); connect(m_pListBox,SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),this,SLOT(engineHighlighted(QListWidgetItem *, QListWidgetItem *))); - g->addWidget(m_pListBox,3,0,6,1); + pLayout->addWidget(m_pListBox,3,0,6,1); m_pDescriptionLabel = new QLabel(this); m_pDescriptionLabel->setWordWrap(true); m_pDescriptionLabel->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); m_pDescriptionLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); - g->addWidget(m_pDescriptionLabel,3,1,1,3); + pLayout->addWidget(m_pDescriptionLabel,3,1,1,3); m_pAuthorLabel = new QLabel(this); m_pAuthorLabel->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); - g->addWidget(m_pAuthorLabel,4,1,1,3); + pLayout->addWidget(m_pAuthorLabel,4,1,1,3); m_pEnableEncrypt = new QCheckBox(__tr2qs("Enable encryption"),this); - g->addWidget(m_pEnableEncrypt,5,1,1,3); + pLayout->addWidget(m_pEnableEncrypt,5,1,1,3); m_pEncryptKeyLabel = new QLabel(__tr2qs("Encrypt key:"),this); - g->addWidget(m_pEncryptKeyLabel,6,1); + pLayout->addWidget(m_pEncryptKeyLabel,6,1); m_pEncryptKeyEdit = new QLineEdit(this); - g->addWidget(m_pEncryptKeyEdit,6,2); + pLayout->addWidget(m_pEncryptKeyEdit,6,2); m_pEncryptHexKeyCheck = new QCheckBox(__tr2qs("Hex"),this); - g->addWidget(m_pEncryptHexKeyCheck,6,3); + pLayout->addWidget(m_pEncryptHexKeyCheck,6,3); m_pEnableDecrypt = new QCheckBox(__tr2qs("Enable decryption"),this); - g->addWidget(m_pEnableDecrypt,7,1,1,3); + pLayout->addWidget(m_pEnableDecrypt,7,1,1,3); m_pDecryptKeyLabel = new QLabel(__tr2qs("Decrypt key:"),this); - g->addWidget(m_pDecryptKeyLabel,8,1); + pLayout->addWidget(m_pDecryptKeyLabel,8,1); m_pDecryptKeyEdit = new QLineEdit(this); - g->addWidget(m_pDecryptKeyEdit,8,2); + pLayout->addWidget(m_pDecryptKeyEdit,8,2); m_pDecryptHexKeyCheck = new QCheckBox(__tr2qs("Hex"),this); - g->addWidget(m_pDecryptHexKeyCheck,8,3); + pLayout->addWidget(m_pDecryptHexKeyCheck,8,3); m_pOkButton = new QPushButton(__tr2qs("OK"),this); - g->addWidget(m_pOkButton,9,0,1,4); + pLayout->addWidget(m_pOkButton,9,0,1,4); connect(m_pOkButton,SIGNAL(clicked()),this,SLOT(okClicked())); - g->setRowStretch(3,1); - g->setColumnStretch(2,1); + pLayout->setRowStretch(3,1); + pLayout->setColumnStretch(2,1); m_pLastItem = 0; m_pSessionInfo = 0; @@ -138,13 +138,13 @@ if(pInfo) { - QListWidgetItem * pItem = m_pListBox->findItems(QString(pInfo->szEngineName),Qt::MatchFixedString).first(); + QListWidgetItem * pItem = m_pListBox->findItems(QString(pInfo->m_szEngineName),Qt::MatchFixedString).first(); if(pItem) { m_pEnableCheck->setChecked(true); m_pListBox->setCurrentItem(pItem); - m_pEnableEncrypt->setChecked(pInfo->bDoEncrypt); - m_pEnableDecrypt->setChecked(pInfo->bDoDecrypt); + m_pEnableEncrypt->setChecked(pInfo->m_bDoEncrypt); + m_pEnableDecrypt->setChecked(pInfo->m_bDoDecrypt); } else enableWidgets(false); } else { enableWidgets(false); @@ -156,7 +156,7 @@ if(m_pSessionInfo) { // huh ? - g_pCryptEngineManager->deallocateEngine(m_pSessionInfo->pEngine); + g_pCryptEngineManager->deallocateEngine(m_pSessionInfo->m_pEngine); delete m_pSessionInfo; } // Unload the unused ones... @@ -165,49 +165,50 @@ void KviCryptController::fillEngineList() { - const KviPointerHashTable<QString,KviCryptEngineDescription> * a = g_pCryptEngineManager->engineDict(); - if(a) + const KviPointerHashTable<QString,KviCryptEngineDescription> * pHash = g_pCryptEngineManager->engineDict(); + if(pHash) { - KviPointerHashTableIterator<QString,KviCryptEngineDescription> it(*a); + KviPointerHashTableIterator<QString,KviCryptEngineDescription> it(*pHash); while(it.current()) { - QString szModName = it.current()->providerHandle ? ((KviModule *)(it.current()->providerHandle))->name() : ""; + QString szModName = it.current()->m_providerHandle ? ((KviModule *)(it.current()->m_providerHandle))->name() : ""; (void)(new KviEngineListBoxItem(m_pListBox,it.current(),szModName.toUtf8().data())); ++it; } - if(m_pListBox->count() != 0)return; + if(m_pListBox->count() != 0) + return; } noEnginesAvailable(); } - void KviCryptController::engineHighlighted(QListWidgetItem *it, QListWidgetItem *) + void KviCryptController::engineHighlighted(QListWidgetItem * pItem, QListWidgetItem *) { - if(it) + if(pItem) { - KviEngineListBoxItem * eit = (KviEngineListBoxItem *)it; - m_pAuthorLabel->setText(eit->m_szAuthor.toUtf8().data()); + KviEngineListBoxItem * pEngine = (KviEngineListBoxItem *)pItem; + m_pAuthorLabel->setText(pEngine->m_szAuthor.toUtf8().data()); QString szDesc = "<p>"; - szDesc += eit->m_szDescription.toUtf8().data(); + szDesc += pEngine->m_szDescription.toUtf8().data(); szDesc += "<br><br>"; szDesc += __tr2qs("If you don't want to encrypt a particular text line then just start it with the CTRL+P prefix"); m_pDescriptionLabel->setText(szDesc); - m_pEnableEncrypt->setEnabled(eit->m_iFlags & KVI_CRYPTENGINE_CAN_ENCRYPT); - m_pEncryptKeyLabel->setEnabled((eit->m_iFlags & KVI_CRYPTENGINE_CAN_ENCRYPT) && - (eit->m_iFlags & KVI_CRYPTENGINE_WANT_ENCRYPT_KEY)); - m_pEncryptKeyEdit->setEnabled((eit->m_iFlags & KVI_CRYPTENGINE_CAN_ENCRYPT) && - (eit->m_iFlags & KVI_CRYPTENGINE_WANT_ENCRYPT_KEY)); + m_pEnableEncrypt->setEnabled(pEngine->m_iFlags & KVI_CRYPTENGINE_CAN_ENCRYPT); + m_pEncryptKeyLabel->setEnabled((pEngine->m_iFlags & KVI_CRYPTENGINE_CAN_ENCRYPT) && + (pEngine->m_iFlags & KVI_CRYPTENGINE_WANT_ENCRYPT_KEY)); + m_pEncryptKeyEdit->setEnabled((pEngine->m_iFlags & KVI_CRYPTENGINE_CAN_ENCRYPT) && + (pEngine->m_iFlags & KVI_CRYPTENGINE_WANT_ENCRYPT_KEY)); m_pEnableEncrypt->setChecked(m_pEncryptKeyEdit->isEnabled()); - m_pEnableDecrypt->setEnabled(eit->m_iFlags & KVI_CRYPTENGINE_CAN_DECRYPT); + m_pEnableDecrypt->setEnabled(pEngine->m_iFlags & KVI_CRYPTENGINE_CAN_DECRYPT); m_pEncryptHexKeyCheck->setEnabled(m_pEncryptKeyEdit->isEnabled()); m_pEncryptHexKeyCheck->setChecked(false); - m_pDecryptKeyLabel->setEnabled((eit->m_iFlags & KVI_CRYPTENGINE_CAN_DECRYPT) && - (eit->m_iFlags & KVI_CRYPTENGINE_WANT_DECRYPT_KEY)); - m_pDecryptKeyEdit->setEnabled((eit->m_iFlags & KVI_CRYPTENGINE_CAN_DECRYPT) && - (eit->m_iFlags & KVI_CRYPTENGINE_WANT_DECRYPT_KEY)); + m_pDecryptKeyLabel->setEnabled((pEngine->m_iFlags & KVI_CRYPTENGINE_CAN_DECRYPT) && + (pEngine->m_iFlags & KVI_CRYPTENGINE_WANT_DECRYPT_KEY)); + m_pDecryptKeyEdit->setEnabled((pEngine->m_iFlags & KVI_CRYPTENGINE_CAN_DECRYPT) && + (pEngine->m_iFlags & KVI_CRYPTENGINE_WANT_DECRYPT_KEY)); m_pEnableDecrypt->setChecked(m_pDecryptKeyEdit->isEnabled()); m_pDecryptHexKeyCheck->setEnabled(m_pDecryptKeyEdit->isEnabled()); m_pDecryptHexKeyCheck->setChecked(false); - m_pLastItem = eit; + m_pLastItem = pEngine; enableWidgets(true); } else m_pLastItem = 0; } @@ -258,26 +259,26 @@ // Reregister the module in case that it has been unloaded // while this dialog was open if(!m_pLastItem->m_szModuleName.isEmpty())(void)g_pModuleManager->getModule(m_pLastItem->m_szModuleName.toUtf8().data()); - m_pSessionInfo->pEngine = g_pCryptEngineManager->allocateEngine(m_pLastItem->m_szName.toUtf8().data()); - if(!m_pSessionInfo->pEngine) + m_pSessionInfo->m_pEngine = g_pCryptEngineManager->allocateEngine(m_pLastItem->m_szName.toUtf8().data()); + if(!m_pSessionInfo->m_pEngine) { m_pWindow->output(KVI_OUT_SYSTEMERROR,__tr2qs("Crypt: Can't create an engine instance: crypting disabled")); delete m_pSessionInfo; m_pSessionInfo = 0; } else { // initialize the engine - if(!initializeEngine(m_pSessionInfo->pEngine)) + if(!initializeEngine(m_pSessionInfo->m_pEngine)) { - QString szErrStr = m_pSessionInfo->pEngine->lastError(); - g_pCryptEngineManager->deallocateEngine(m_pSessionInfo->pEngine); + QString szErrStr = m_pSessionInfo->m_pEngine->lastError(); + g_pCryptEngineManager->deallocateEngine(m_pSessionInfo->m_pEngine); delete m_pSessionInfo; m_pSessionInfo = 0; m_pWindow->output(KVI_OUT_SYSTEMERROR,__tr2qs("Crypt: Can't initialize the engine :%s"),szErrStr.toUtf8().data()); } else { // ok, engine ready and waiting... - m_pSessionInfo->szEngineName = m_pLastItem->m_szName; - m_pSessionInfo->bDoEncrypt = m_pEnableEncrypt->isChecked(); - m_pSessionInfo->bDoDecrypt = m_pEnableDecrypt->isChecked(); + m_pSessionInfo->m_szEngineName = m_pLastItem->m_szName; + m_pSessionInfo->m_bDoEncrypt = m_pEnableEncrypt->isChecked(); + m_pSessionInfo->m_bDoDecrypt = m_pEnableDecrypt->isChecked(); } } } else m_pWindow->output(KVI_OUT_SYSTEMERROR,__tr2qs("Crypt: You have to enable encryption and/or decryption for the engine to work")); @@ -301,13 +302,13 @@ szEncryptKey = m_pEncryptKeyEdit->text(); if(m_pEncryptHexKeyCheck->isChecked()) { - char * tmpKey; - iEncKeyLen = szEncryptKey.hexToBuffer(&tmpKey,false); + char * pcTmpKey; + iEncKeyLen = szEncryptKey.hexToBuffer(&pcTmpKey,false); if(iEncKeyLen > 0) { pcEncKey = (char *)kvi_malloc(iEncKeyLen); - kvi_memmove(pcEncKey,tmpKey,iEncKeyLen); - KviStr::freeBuffer(tmpKey); + kvi_memmove(pcEncKey,pcTmpKey,iEncKeyLen); + KviStr::freeBuffer(pcTmpKey); } } else { pcEncKey = (char *)kvi_malloc(szEncryptKey.len()); @@ -321,13 +322,13 @@ szDecryptKey = m_pDecryptKeyEdit->text(); if(m_pDecryptHexKeyCheck->isChecked()) { - char * tmpKey; - iDecKeyLen = szDecryptKey.hexToBuffer(&tmpKey,false); + char * pcTmpKey; + iDecKeyLen = szDecryptKey.hexToBuffer(&pcTmpKey,false); if(iDecKeyLen > 0) { pcDecKey = (char *)kvi_malloc(iDecKeyLen); - kvi_memmove(pcDecKey,tmpKey,iDecKeyLen); - KviStr::freeBuffer(tmpKey); + kvi_memmove(pcDecKey,pcTmpKey,iDecKeyLen); + KviStr::freeBuffer(pcTmpKey); } } else { pcDecKey = (char *)kvi_malloc(szDecryptKey.len()); @@ -347,9 +348,9 @@ KviCryptSessionInfo * KviCryptController::getNewSessionInfo() { - KviCryptSessionInfo * inf = m_pSessionInfo; + KviCryptSessionInfo * pInfo = m_pSessionInfo; m_pSessionInfo = 0; - return inf; + return pInfo; } KviCryptSessionInfo * KviCryptController::allocateCryptSessionInfo() @@ -358,13 +359,14 @@ return new KviCryptSessionInfo(); } - void KviCryptController::destroyCryptSessionInfo(KviCryptSessionInfo ** inf) + void KviCryptController::destroyCryptSessionInfo(KviCryptSessionInfo ** ppInfo) { - if(!(*inf))return; - (*inf)->pEngine->disconnect(); // disconnect every signal (this is mainly for destroyed()) - g_pCryptEngineManager->deallocateEngine((*inf)->pEngine); // kill the engine - delete *inf; - *inf = 0; + if(!(*ppInfo)) + return; + (*ppInfo)->m_pEngine->disconnect(); // disconnect every signal (this is mainly for destroyed()) + g_pCryptEngineManager->deallocateEngine((*ppInfo)->m_pEngine); // kill the engine + delete *ppInfo; + *ppInfo = 0; } #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "kvi_cryptcontroller.moc" diff --git a/src/kvirc/ui/kvi_cryptcontroller.h b/src/kvirc/ui/kvi_cryptcontroller.h index 5a517b200..6acde8b94 100644 --- a/src/kvirc/ui/kvi_cryptcontroller.h +++ b/src/kvirc/ui/kvi_cryptcontroller.h @@ -44,10 +44,10 @@ class KVIRC_API KviCryptSessionInfo : public KviHeapObject { public: - KviCryptEngine * pEngine; - QString szEngineName; - bool bDoEncrypt; - bool bDoDecrypt; + KviCryptEngine * m_pEngine; + QString m_szEngineName; + bool m_bDoEncrypt; + bool m_bDoDecrypt; }; class KVIRC_API KviEngineListBoxItem : public KviTalListWidgetText @@ -68,7 +68,7 @@ { Q_OBJECT public: - KviCryptController(QWidget * pParent, KviWindowToolPageButton * pButton, const char * name,KviWindow * pWnd, KviCryptSessionInfo * pInfo); + KviCryptController(QWidget * pParent, KviWindowToolPageButton * pButton, KviWindow * pWnd, KviCryptSessionInfo * pInfo); ~KviCryptController(); protected: KviWindow * m_pWindow; diff --git a/src/kvirc/ui/kvi_query.cpp b/src/kvirc/ui/kvi_query.cpp index 259efb93f..4ea230c10 100644 --- a/src/kvirc/ui/kvi_query.cpp +++ b/src/kvirc/ui/kvi_query.cpp @@ -582,13 +582,13 @@ void KviQuery::ownMessage(const QString & szBuffer, bool bUserFeedback) #ifdef COMPILE_CRYPT_SUPPORT if(cryptSessionInfo()) { - if(cryptSessionInfo()->bDoEncrypt) + if(cryptSessionInfo()->m_bDoEncrypt) { if(*d != KVI_TEXT_CRYPTESCAPE) { KviStr encrypted; - cryptSessionInfo()->pEngine->setMaxEncryptLen(500 - szName.length()); - switch(cryptSessionInfo()->pEngine->encrypt(d,encrypted)) + cryptSessionInfo()->m_pEngine->setMaxEncryptLen(500 - szName.length()); + switch(cryptSessionInfo()->m_pEngine->encrypt(d,encrypted)) { case KviCryptEngine::Encrypted: if(!connection()->sendFmtData("PRIVMSG %s :%s",szName.data(),encrypted.ptr())) @@ -612,7 +612,7 @@ void KviQuery::ownMessage(const QString & szBuffer, bool bUserFeedback) break; default: // also case KviCryptEngine::EncryptError { - QString szEngineError = cryptSessionInfo()->pEngine->lastError(); + QString szEngineError = cryptSessionInfo()->m_pEngine->lastError(); output(KVI_OUT_SYSTEMERROR, __tr2qs("The crypto engine was unable to encrypt the current message (%Q): %s, no data sent to the server"), &szBuffer,&szEngineError); diff --git a/src/kvirc/ui/kvi_window.cpp b/src/kvirc/ui/kvi_window.cpp index b56641beb..a87442aa5 100644 --- a/src/kvirc/ui/kvi_window.cpp +++ b/src/kvirc/ui/kvi_window.cpp @@ -455,7 +455,7 @@ void KviWindow::toggleCryptController() } else { if(m_pSplitter && m_pInput) { - m_pCryptController = new KviCryptController(m_pSplitter,m_pCryptControllerButton,"crypt_controller",this,m_pCryptSessionInfo); + m_pCryptController = new KviCryptController(m_pSplitter,m_pCryptControllerButton,this,m_pCryptSessionInfo); connect(m_pCryptController,SIGNAL(done()),this,SLOT(cryptControllerFinished())); //setFocusHandlerNoClass(m_pInput,m_pCryptController,"QLineEdit"); //link it! m_pCryptController->show(); @@ -476,7 +476,7 @@ void KviWindow::setCryptSessionInfo(KviCryptSessionInfo * inf) m_pCryptSessionInfo = inf; if(m_pCryptSessionInfo) { - connect(m_pCryptSessionInfo->pEngine,SIGNAL(destroyed()),this,SLOT(cryptSessionInfoDestroyed())); + connect(m_pCryptSessionInfo->m_pEngine,SIGNAL(destroyed()),this,SLOT(cryptSessionInfoDestroyed())); } if(m_pCryptControllerButton) { @@ -505,7 +505,7 @@ void KviWindow::cryptSessionInfoDestroyed() { #ifdef COMPILE_CRYPT_SUPPORT output(KVI_OUT_SYSTEMERROR,__tr2qs("Ops...I've accidentally lost the crypting engine...")); - m_pCryptSessionInfo->pEngine = 0; + m_pCryptSessionInfo->m_pEngine = 0; delete m_pCryptSessionInfo; m_pCryptSessionInfo = 0; #endif diff --git a/src/modules/dcc/chat.cpp b/src/modules/dcc/chat.cpp index e08f6bfa4..c1fdc03de 100644 --- a/src/modules/dcc/chat.cpp +++ b/src/modules/dcc/chat.cpp @@ -305,13 +305,13 @@ void KviDccChat::ownMessage(const QString &text, bool bUserFeedback) #ifdef COMPILE_CRYPT_SUPPORT if(cryptSessionInfo()) { - if(cryptSessionInfo()->bDoEncrypt) + if(cryptSessionInfo()->m_bDoEncrypt) { if(*d != KVI_TEXT_CRYPTESCAPE) { KviStr encrypted; - cryptSessionInfo()->pEngine->setMaxEncryptLen(-1); - switch(cryptSessionInfo()->pEngine->encrypt(d,encrypted)) + cryptSessionInfo()->m_pEngine->setMaxEncryptLen(-1); + switch(cryptSessionInfo()->m_pEngine->encrypt(d,encrypted)) { case KviCryptEngine::Encrypted: { @@ -338,7 +338,7 @@ void KviDccChat::ownMessage(const QString &text, bool bUserFeedback) break; default: // also case KviCryptEngine::EncryptError { - QString szErr = cryptSessionInfo()->pEngine->lastError(); + QString szErr = cryptSessionInfo()->m_pEngine->lastError(); output(KVI_OUT_SYSTEMERROR, __tr2qs_ctx("The crypto engine was not able to encrypt the current message (%Q): %Q, no data was sent to the remote end","dcc"), &text,&szErr); @@ -450,10 +450,10 @@ bool KviDccChat::event(QEvent *e) #ifdef COMPILE_CRYPT_SUPPORT if(KviCryptSessionInfo * cinf = cryptSessionInfo()) { - if(cinf->bDoDecrypt) + if(cinf->m_bDoDecrypt) { KviStr decryptedStuff; - switch(cinf->pEngine->decrypt(d.ptr(),decryptedStuff)) + switch(cinf->m_pEngine->decrypt(d.ptr(),decryptedStuff)) { case KviCryptEngine::DecryptOkWasEncrypted: case KviCryptEngine::DecryptOkWasEncoded: @@ -470,7 +470,7 @@ bool KviDccChat::event(QEvent *e) default: // also case KviCryptEngine::DecryptError { - QString szErr = cinf->pEngine->lastError(); + QString szErr = cinf->m_pEngine->lastError(); output(KVI_OUT_SYSTEMERROR, __tr2qs_ctx("The following message appears to be encrypted, but the crypto engine failed to decode it: %Q","dcc"), &szErr); diff --git a/src/modules/lamerizer/libkvilamerizer.cpp b/src/modules/lamerizer/libkvilamerizer.cpp index c5cdd609b..4ebd0aa5b 100644 --- a/src/modules/lamerizer/libkvilamerizer.cpp +++ b/src/modules/lamerizer/libkvilamerizer.cpp @@ -214,22 +214,22 @@ static bool lamerizer_module_init(KviModule * m) // FIXME: Maybe convert this repeated code to a function eh ? KviCryptEngineDescription * d = new KviCryptEngineDescription; - d->szName = "Lamerizer"; - d->szAuthor = "Szymon Stefanek and Jan Wagner"; - d->szDescription = __tr2qs("A really lame text transformation engine :D"); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT; - d->allocFunc = allocLamerizerEngine; - d->deallocFunc = deallocLamerizerEngine; + d->m_szName = "Lamerizer"; + d->m_szAuthor = "Szymon Stefanek and Jan Wagner"; + d->m_szDescription = __tr2qs("A really lame text transformation engine :D"); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT; + d->m_allocFunc = allocLamerizerEngine; + d->m_deallocFunc = deallocLamerizerEngine; m->registerCryptEngine(d); d = new KviCryptEngineDescription; - d->szName = "LamerizerLight"; - d->szAuthor = "Szymon Stefanek and Jan Wagner"; - d->szDescription = __tr2qs("A really lame text transformation engine: Light Version."); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT; - d->allocFunc = allocLightLamerizerEngine; - d->deallocFunc = deallocLamerizerEngine; + d->m_szName = "LamerizerLight"; + d->m_szAuthor = "Szymon Stefanek and Jan Wagner"; + d->m_szDescription = __tr2qs("A really lame text transformation engine: Light Version."); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT; + d->m_allocFunc = allocLightLamerizerEngine; + d->m_deallocFunc = deallocLamerizerEngine; m->registerCryptEngine(d); return true; diff --git a/src/modules/rijndael/libkvirijndael.cpp b/src/modules/rijndael/libkvirijndael.cpp index f399df8ef..d5ebd0997 100644 --- a/src/modules/rijndael/libkvirijndael.cpp +++ b/src/modules/rijndael/libkvirijndael.cpp @@ -718,70 +718,70 @@ static bool rijndael_module_init(KviModule * m) // FIXME: Maybe convert this repeated code to a function eh ? KviCryptEngineDescription * d = new KviCryptEngineDescription; - d->szName = "Rijndael128Hex"; - d->szAuthor = "Szymon Stefanek"; - d->szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(128); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | + d->m_szName = "Rijndael128Hex"; + d->m_szAuthor = "Szymon Stefanek"; + d->m_szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(128); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | KVI_CRYPTENGINE_WANT_ENCRYPT_KEY | KVI_CRYPTENGINE_WANT_DECRYPT_KEY; - d->allocFunc = allocRijndael128HexEngine; - d->deallocFunc = deallocRijndaelCryptEngine; + d->m_allocFunc = allocRijndael128HexEngine; + d->m_deallocFunc = deallocRijndaelCryptEngine; m->registerCryptEngine(d); d = new KviCryptEngineDescription; - d->szName = "Rijndael192Hex"; - d->szAuthor = "Szymon Stefanek"; - d->szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(192); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | + d->m_szName = "Rijndael192Hex"; + d->m_szAuthor = "Szymon Stefanek"; + d->m_szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(192); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | KVI_CRYPTENGINE_WANT_ENCRYPT_KEY | KVI_CRYPTENGINE_WANT_DECRYPT_KEY; - d->allocFunc = allocRijndael192HexEngine; - d->deallocFunc = deallocRijndaelCryptEngine; + d->m_allocFunc = allocRijndael192HexEngine; + d->m_deallocFunc = deallocRijndaelCryptEngine; m->registerCryptEngine(d); d = new KviCryptEngineDescription; - d->szName = "Rijndael256Hex"; - d->szAuthor = "Szymon Stefanek"; - d->szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(256); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | + d->m_szName = "Rijndael256Hex"; + d->m_szAuthor = "Szymon Stefanek"; + d->m_szDescription = QString(szFormat).arg(__tr2qs("hexadecimal")).arg(256); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | KVI_CRYPTENGINE_WANT_ENCRYPT_KEY | KVI_CRYPTENGINE_WANT_DECRYPT_KEY; - d->allocFunc = allocRijndael256HexEngine; - d->deallocFunc = deallocRijndaelCryptEngine; + d->m_allocFunc = allocRijndael256HexEngine; + d->m_deallocFunc = deallocRijndaelCryptEngine; m->registerCryptEngine(d); d = new KviCryptEngineDescription; - d->szName = "Rijndael128Base64"; - d->szAuthor = "Szymon Stefanek"; - d->szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(128); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | + d->m_szName = "Rijndael128Base64"; + d->m_szAuthor = "Szymon Stefanek"; + d->m_szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(128); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | KVI_CRYPTENGINE_WANT_ENCRYPT_KEY | KVI_CRYPTENGINE_WANT_DECRYPT_KEY; - d->allocFunc = allocRijndael128Base64Engine; - d->deallocFunc = deallocRijndaelCryptEngine; + d->m_allocFunc = allocRijndael128Base64Engine; + d->m_deallocFunc = deallocRijndaelCryptEngine; m->registerCryptEngine(d); d = new KviCryptEngineDescription; - d->szName = "Rijndael192Base64"; - d->szAuthor = "Szymon Stefanek"; - d->szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(192); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | + d->m_szName = "Rijndael192Base64"; + d->m_szAuthor = "Szymon Stefanek"; + d->m_szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(192); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | KVI_CRYPTENGINE_WANT_ENCRYPT_KEY | KVI_CRYPTENGINE_WANT_DECRYPT_KEY; - d->allocFunc = allocRijndael192Base64Engine; - d->deallocFunc = deallocRijndaelCryptEngine; + d->m_allocFunc = allocRijndael192Base64Engine; + d->m_deallocFunc = deallocRijndaelCryptEngine; m->registerCryptEngine(d); d = new KviCryptEngineDescription; - d->szName = "Rijndael256Base64"; - d->szAuthor = "Szymon Stefanek"; - d->szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(256); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | + d->m_szName = "Rijndael256Base64"; + d->m_szAuthor = "Szymon Stefanek"; + d->m_szDescription = QString(szFormat).arg(__tr2qs("base64")).arg(256); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | KVI_CRYPTENGINE_WANT_ENCRYPT_KEY | KVI_CRYPTENGINE_WANT_DECRYPT_KEY; - d->allocFunc = allocRijndael256Base64Engine; - d->deallocFunc = deallocRijndaelCryptEngine; + d->m_allocFunc = allocRijndael256Base64Engine; + d->m_deallocFunc = deallocRijndaelCryptEngine; m->registerCryptEngine(d); d = new KviCryptEngineDescription; - d->szName = "Mircryption"; - d->szAuthor = "Szymon Stefanek"; - d->szDescription = __tr2qs("Popular cryptographic engine based on the\n" \ + d->m_szName = "Mircryption"; + d->m_szAuthor = "Szymon Stefanek"; + d->m_szDescription = __tr2qs("Popular cryptographic engine based on the\n" \ "old Blowfish encryption algorithm.\n" \ "The text is first encrypted with Blowfish \n" \ "and then converted to base64 notation.\n" \ @@ -793,10 +793,10 @@ static bool rijndael_module_init(KviModule * m) "This engine works in ECB mode by default:\n" \ "if you want to use CBC mode you must prefix\n" \ "your key(s) with \"cbc:\".\n"); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT | KVI_CRYPTENGINE_CAN_DECRYPT | KVI_CRYPTENGINE_WANT_ENCRYPT_KEY | KVI_CRYPTENGINE_WANT_DECRYPT_KEY; - d->allocFunc = allocMircryptionEngine; - d->deallocFunc = deallocRijndaelCryptEngine; + d->m_allocFunc = allocMircryptionEngine; + d->m_deallocFunc = deallocRijndaelCryptEngine; m->registerCryptEngine(d); diff --git a/src/modules/rijndael/libkvirijndael_cryptopp.cpp b/src/modules/rijndael/libkvirijndael_cryptopp.cpp index 4502da23a..96375cc71 100644 --- a/src/modules/rijndael/libkvirijndael_cryptopp.cpp +++ b/src/modules/rijndael/libkvirijndael_cryptopp.cpp @@ -86,21 +86,21 @@ KviRijndaelEngine::~KviRijndaelEngine() m_szDecKey.clear(); } -bool KviRijndaelEngine::init(const char *encKey, int encKeyLen, const char *decKey, int decKeyLen) +bool KviRijndaelEngine::init(const char * pcEncKey, int iEncKeyLen, const char * pcDecKey, int iDecKeyLen) { - if(encKey && (encKeyLen > 0)) + if(pcEncKey && (iEncKeyLen > 0)) { - if(!(decKey && (decKeyLen > 0))) + if(!(pcDecKey && (iDecKeyLen > 0))) { - decKey = encKey; - decKeyLen = encKeyLen; + pcDecKey = pcEncKey; + iDecKeyLen = iEncKeyLen; } // else all } else { // no encrypt key specified... - if(decKey && decKeyLen) + if(pcDecKey && iDecKeyLen) { - encKey = decKey; - encKeyLen = decKeyLen; + pcEncKey = pcDecKey; + iEncKeyLen = iDecKeyLen; } else { // both keys missing setLastError(__tr2qs("Missing encryption and decryption key: at least one is needed")); @@ -108,19 +108,19 @@ bool KviRijndaelEngine::init(const char *encKey, int encKeyLen, const char *decK } } - m_szEncKey = encKey; - m_szDecKey = decKey; + m_szEncKey = pcEncKey; + m_szDecKey = pcDecKey; - if(encKeyLen > getKeyLen()) + if(iEncKeyLen > getKeyLen()) m_szEncKey = m_szEncKey.substr(0,getKeyLen()); - if(encKeyLen < getKeyLen()) + if(iEncKeyLen < getKeyLen()) m_szEncKey.resize(getKeyLen()); - if(decKeyLen > getKeyLen()) + if(iDecKeyLen > getKeyLen()) m_szDecKey = m_szDecKey.substr(0,getKeyLen()); - if(decKeyLen < getKeyLen()) + if(iDecKeyLen < getKeyLen()) m_szDecKey.resize(getKeyLen()); if(m_szEncKey.empty() || m_szDecKey.empty()) @@ -129,19 +129,19 @@ bool KviRijndaelEngine::init(const char *encKey, int encKeyLen, const char *decK return true; } -KviCryptEngine::EncryptResult KviRijndaelEngine::encrypt(const char * plainText,KviStr &outBuffer) +KviCryptEngine::EncryptResult KviRijndaelEngine::encrypt(const char * pcPlainText, KviStr & szOutBuffer) { - std::string cipher; + std::string szCipher; // byte is a typedef by Crypto++ for unsigned char. byte key[m_szEncKey.size()],iv[CryptoPP::AES::BLOCKSIZE]; - for(unsigned int i=0;i<m_szEncKey.size();i++) - key[i] = m_szEncKey[i]; + for(unsigned int u=0;u<m_szEncKey.size();u++) + key[u] = m_szEncKey[u]; // The following is absolute shit, but the module we replace does it like // that, so we hardcode the IV to 0 in the required length... - for(unsigned int i=0;i<sizeof(iv);i++) - iv[i] = 0x00; + for(unsigned int u=0;u<sizeof(iv);u++) + iv[u] = 0x00; // We hardcode CBC mode here, as the embedded code is always called in // CBC mode too (see above, line 148), no need to use the external @@ -154,19 +154,19 @@ KviCryptEngine::EncryptResult KviRijndaelEngine::encrypt(const char * plainText, if(getEncoding() == KVI_RIJNDAEL_HEX) { - CryptoPP::StringSource(static_cast<std::string>(plainText), true, + CryptoPP::StringSource(static_cast<std::string>(pcPlainText), true, new CryptoPP::StreamTransformationFilter( encryptor, new CryptoPP::HexEncoder( - new CryptoPP::StringSink( cipher ) + new CryptoPP::StringSink( szCipher ) ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ); } else if(getEncoding() == KVI_RIJNDAEL_B64) { - CryptoPP::StringSource(static_cast<std::string>(plainText), true, + CryptoPP::StringSource(static_cast<std::string>(pcPlainText), true, new CryptoPP::StreamTransformationFilter( encryptor, new CryptoPP::Base64Encoder( - new CryptoPP::StringSink( cipher ) + new CryptoPP::StringSink( szCipher ) ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ); @@ -181,28 +181,28 @@ KviCryptEngine::EncryptResult KviRijndaelEngine::encrypt(const char * plainText, return KviCryptEngine::EncryptError; } - outBuffer = cipher.c_str(); - outBuffer.prepend(KVI_TEXT_CRYPTESCAPE); + szOutBuffer = szCipher.c_str(); + szOutBuffer.prepend(KVI_TEXT_CRYPTESCAPE); return KviCryptEngine::Encrypted; } -KviCryptEngine::DecryptResult KviRijndaelEngine::decrypt(const char * inBuffer,KviStr &plainText) +KviCryptEngine::DecryptResult KviRijndaelEngine::decrypt(const char * pcInBuffer, KviStr & szPlainText) { - std::string plain; + std::string szPlain; byte key[m_szDecKey.size()],iv[CryptoPP::AES::BLOCKSIZE]; - std::string szIn = inBuffer; + std::string szIn = pcInBuffer; - for(unsigned int i=0;i<m_szDecKey.size();i++) - key[i] = m_szDecKey[i]; + for(unsigned int u=0;u<m_szDecKey.size();u++) + key[u] = m_szDecKey[u]; // The following is absolute shit, but the module we replace does it like // that, so we hardcode the IV to 0 in the required length... - for(unsigned int i=0;i<sizeof(iv);i++) - iv[i] = 0x00; + for(unsigned int u=0;u<sizeof(iv);u++) + iv[u] = 0x00; if(static_cast<int>(szIn[0]) != KVI_TEXT_CRYPTESCAPE) { - plainText = inBuffer; + szPlainText = pcInBuffer; return KviCryptEngine::DecryptOkWasPlainText; } @@ -210,7 +210,7 @@ KviCryptEngine::DecryptResult KviRijndaelEngine::decrypt(const char * inBuffer,K if(szIn.empty()) { - plainText = inBuffer; + szPlainText = pcInBuffer; return KviCryptEngine::DecryptOkWasPlainText; // empty buffer } @@ -222,7 +222,7 @@ KviCryptEngine::DecryptResult KviRijndaelEngine::decrypt(const char * inBuffer,K CryptoPP::StringSource(szIn, true, new CryptoPP::HexDecoder( new CryptoPP::StreamTransformationFilter( - decryptor, new CryptoPP::StringSink( plain ), + decryptor, new CryptoPP::StringSink( szPlain ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ) ); @@ -231,7 +231,7 @@ KviCryptEngine::DecryptResult KviRijndaelEngine::decrypt(const char * inBuffer,K CryptoPP::StringSource(szIn, true, new CryptoPP::Base64Decoder( new CryptoPP::StreamTransformationFilter( - decryptor, new CryptoPP::StringSink( plain ), + decryptor, new CryptoPP::StringSink( szPlain ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ) ); @@ -246,7 +246,7 @@ KviCryptEngine::DecryptResult KviRijndaelEngine::decrypt(const char * inBuffer,K return KviCryptEngine::DecryptError; } - plainText = plain.c_str(); + szPlainText = szPlain.c_str(); return KviCryptEngine::DecryptOkWasEncrypted; } @@ -303,21 +303,21 @@ KviMircryptionEngine::~KviMircryptionEngine() m_szDecKey.clear(); } -bool KviMircryptionEngine::init(const char * encKey,int encKeyLen,const char * decKey,int decKeyLen) +bool KviMircryptionEngine::init(const char * pcEncKey, int iEncKeyLen, const char * pcDecKey, int iDecKeyLen) { - if(encKey && (encKeyLen > 0)) + if(pcEncKey && (iEncKeyLen > 0)) { - if(!(decKey && (decKeyLen > 0))) + if(!(pcDecKey && (iDecKeyLen > 0))) { - decKey = encKey; - decKeyLen = encKeyLen; + pcDecKey = pcEncKey; + iDecKeyLen = iEncKeyLen; } // else all } else { // no encrypt key specified... - if(decKey && decKeyLen) + if(pcDecKey && iDecKeyLen) { - encKey = decKey; - encKeyLen = decKeyLen; + pcEncKey = pcDecKey; + iEncKeyLen = iDecKeyLen; } else { // both keys missing setLastError(__tr2qs("Missing encryption and decryption key: at least one is needed")); @@ -325,8 +325,8 @@ bool KviMircryptionEngine::init(const char * encKey,int encKeyLen,const char * d } } - m_szEncKey = std::string(encKey,encKeyLen); - m_szDecKey = std::string(decKey,decKeyLen); + m_szEncKey = std::string(pcEncKey,iEncKeyLen); + m_szDecKey = std::string(pcDecKey,iDecKeyLen); if((m_szEncKey.find("cbc:",0,4) != std::string::npos) && (m_szEncKey.size() > 4)) { @@ -347,25 +347,25 @@ bool KviMircryptionEngine::init(const char * encKey,int encKeyLen,const char * d return true; } -KviCryptEngine::EncryptResult KviMircryptionEngine::encrypt(const char * plainText,KviStr &outBuffer) +KviCryptEngine::EncryptResult KviMircryptionEngine::encrypt(const char * pcPlainText, KviStr & szOutBuffer) { - std::string cipher; + std::string szCipher; byte key[m_szEncKey.size()], iv[CryptoPP::Blowfish::BLOCKSIZE]; - for(unsigned int i=0;i<m_szEncKey.size();i++) - key[i] = m_szEncKey.at(i); + for(unsigned int u=0;u<m_szEncKey.size();u++) + key[u] = m_szEncKey.at(u); if(m_bEncryptCBC) { try { - for(unsigned int i=0;i<sizeof(iv);i++) - iv[i] = 0x00; + for(unsigned int u=0;u<sizeof(iv);u++) + iv[u] = 0x00; CryptoPP::CBC_Mode< CryptoPP::Blowfish >::Encryption encryptor( key, sizeof(key), iv ); - CryptoPP::StringSource(static_cast<std::string>(plainText), true, + CryptoPP::StringSource(static_cast<std::string>(pcPlainText), true, new CryptoPP::StreamTransformationFilter( encryptor, new CryptoPP::Base64Encoder( - new CryptoPP::StringSink( cipher ) + new CryptoPP::StringSink( szCipher ) ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ); @@ -378,10 +378,10 @@ KviCryptEngine::EncryptResult KviMircryptionEngine::encrypt(const char * plainTe } else { try { CryptoPP::ECB_Mode< CryptoPP::Blowfish >::Encryption encryptor( key, sizeof(key) ); - CryptoPP::StringSource(static_cast<std::string>(plainText), true, + CryptoPP::StringSource(static_cast<std::string>(pcPlainText), true, new CryptoPP::StreamTransformationFilter( encryptor, new CryptoPP::Base64Encoder( - new CryptoPP::StringSink( cipher ) + new CryptoPP::StringSink( szCipher ) ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ); @@ -393,16 +393,16 @@ KviCryptEngine::EncryptResult KviMircryptionEngine::encrypt(const char * plainTe } } - outBuffer = "+OK "; - outBuffer.append(cipher.c_str()); + szOutBuffer = "+OK "; + szOutBuffer.append(szCipher.c_str()); return KviCryptEngine::Encrypted; } -KviCryptEngine::DecryptResult KviMircryptionEngine::decrypt(const char * inBuffer,KviStr &plainText) +KviCryptEngine::DecryptResult KviMircryptionEngine::decrypt(const char * pcInBuffer, KviStr & szPlainText) { - std::string plain; - std::string szIn = inBuffer; + std::string szPlain; + std::string szIn = pcInBuffer; byte key[m_szDecKey.size()], iv[CryptoPP::Blowfish::BLOCKSIZE]; // various old versions @@ -414,25 +414,25 @@ KviCryptEngine::DecryptResult KviMircryptionEngine::decrypt(const char * inBuffe // some servers seem to strip the + at the beginning... szIn = szIn.substr(3); } else { - plainText = szIn.c_str(); + szPlainText = szIn.c_str(); return KviCryptEngine::DecryptOkWasPlainText; } - for(unsigned int i=0;i<m_szDecKey.size();i++) - key[i] = m_szDecKey.at(i); + for(unsigned int u=0;u<m_szDecKey.size();u++) + key[u] = m_szDecKey.at(u); if(m_bDecryptCBC) { try { - for(unsigned int i=0;i<sizeof(iv);i++) - iv[i] = 0x00; + for(unsigned int u=0;u<sizeof(iv);u++) + iv[u] = 0x00; CryptoPP::CBC_Mode< CryptoPP::Blowfish >::Decryption decryptor( key, sizeof(key), iv ); CryptoPP::StringSource(szIn, true, new CryptoPP::Base64Decoder( new CryptoPP::StreamTransformationFilter( decryptor, - new CryptoPP::StringSink( plain ), + new CryptoPP::StringSink( szPlain ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ) @@ -449,7 +449,7 @@ KviCryptEngine::DecryptResult KviMircryptionEngine::decrypt(const char * inBuffe CryptoPP::StringSource(szIn, true, new CryptoPP::Base64Decoder( new CryptoPP::StreamTransformationFilter( - decryptor, new CryptoPP::StringSink( plain ), + decryptor, new CryptoPP::StringSink( szPlain ), CryptoPP::BlockPaddingSchemeDef::ZEROS_PADDING ) ) ); @@ -461,7 +461,7 @@ KviCryptEngine::DecryptResult KviMircryptionEngine::decrypt(const char * inBuffe } } - plainText = plain.c_str(); + szPlainText = szPlain.c_str(); return KviCryptEngine::DecryptOkWasEncrypted; } @@ -581,7 +581,7 @@ static bool rijndael_module_init(KviModule * m) return true; } -static bool rijndael_module_cleanup(KviModule *m) +static bool rijndael_module_cleanup(KviModule * m) { while(g_pEngineList->first()) delete g_pEngineList->first(); diff --git a/src/modules/rijndael/libkvirijndael_cryptopp.h b/src/modules/rijndael/libkvirijndael_cryptopp.h index 8b27921fa..a6f301523 100644 --- a/src/modules/rijndael/libkvirijndael_cryptopp.h +++ b/src/modules/rijndael/libkvirijndael_cryptopp.h @@ -54,9 +54,9 @@ private: std::string m_szEncKey; std::string m_szDecKey; public: - virtual bool init(const char *encKey,int encKeyLen,const char *decKey,int decKeyLen); - virtual KviCryptEngine::EncryptResult encrypt(const char * plainText,KviStr &outBuffer); - virtual KviCryptEngine::DecryptResult decrypt(const char * inBuffer,KviStr &plainText); + virtual bool init(const char * pcEncKey, int iEncKeyLen, const char * pcDecKey, int iDecKeyLen); + virtual KviCryptEngine::EncryptResult encrypt(const char * pcPlainText, KviStr & szOutBuffer); + virtual KviCryptEngine::DecryptResult decrypt(const char * pcInBuffer, KviStr & szPlainText); }; class KviRijndael128HexEngine : public KviRijndaelEngine @@ -133,9 +133,9 @@ public: KviMircryptionEngine(); ~KviMircryptionEngine(); - virtual bool init(const char *encKey,int encKeyLen,const char *decKey,int decKeyLen); - virtual KviCryptEngine::EncryptResult encrypt(const char * plainText,KviStr &outBuffer); - virtual KviCryptEngine::DecryptResult decrypt(const char * inBuffer,KviStr &plainText); + virtual bool init(const char * pcEncKey, int iEncKeyLen, const char * pcDecKey, int iDecKeyLen); + virtual KviCryptEngine::EncryptResult encrypt(const char * pcPlainText, KviStr & szOutBuffer); + virtual KviCryptEngine::DecryptResult decrypt(const char * pcInBuffer, KviStr & szPlainText); private: std::string m_szEncKey; std::string m_szDecKey; diff --git a/src/modules/rot13/libkvirot13.cpp b/src/modules/rot13/libkvirot13.cpp index 937d6082e..8fc0a6fd3 100644 --- a/src/modules/rot13/libkvirot13.cpp +++ b/src/modules/rot13/libkvirot13.cpp @@ -119,12 +119,12 @@ static bool rot13_module_init(KviModule * m) g_pEngineList->setAutoDelete(false); KviCryptEngineDescription * d = new KviCryptEngineDescription; - d->szName = "ROT13"; - d->szAuthor = "Aeriana"; - d->szDescription = __tr2qs("The simple Caesar-cypher encryption that replaces each letter with the one 13 places forward or back along the alphabet; it is used to enclose the text in a sealed wrapper that the reader must choose to open - e.g. for posting things that might offend some readers, or spoilers."); - d->iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT; - d->allocFunc = allocRot13Engine; - d->deallocFunc = deallocRot13Engine; + d->m_szName = "ROT13"; + d->m_szAuthor = "Aeriana"; + d->m_szDescription = __tr2qs("The simple Caesar-cypher encryption that replaces each letter with the one 13 places forward or back along the alphabet; it is used to enclose the text in a sealed wrapper that the reader must choose to open - e.g. for posting things that might offend some readers, or spoilers."); + d->m_iFlags = KVI_CRYPTENGINE_CAN_ENCRYPT; + d->m_allocFunc = allocRot13Engine; + d->m_deallocFunc = deallocRot13Engine; m->registerCryptEngine(d); return true; @@ -136,7 +136,8 @@ static bool rot13_module_init(KviModule * m) static bool rot13_module_cleanup(KviModule *m) { #ifdef COMPILE_CRYPT_SUPPORT - while(g_pEngineList->first())delete g_pEngineList->first(); + while(g_pEngineList->first()) + delete g_pEngineList->first(); delete g_pEngineList; g_pEngineList = 0; m->unregisterCryptEngines(); diff --git a/src/modules/window/libkviwindow.cpp b/src/modules/window/libkviwindow.cpp index dd44c389c..753a9ca01 100644 --- a/src/modules/window/libkviwindow.cpp +++ b/src/modules/window/libkviwindow.cpp @@ -1518,11 +1518,11 @@ static bool window_kvs_cmd_setCryptEngine(KviKvsModuleCommandCall * c) if(initializeCryptEngine(e,enc,dec,szError)) { KviCryptSessionInfo * inf = KviCryptController::allocateCryptSessionInfo(); - inf->pEngine = e; - inf->szEngineName = szEngine; + inf->m_pEngine = e; + inf->m_szEngineName = szEngine; - inf->bDoEncrypt = (!c->hasSwitch('n',"onlydecrypt")); - inf->bDoDecrypt = (!c->hasSwitch('m',"onlyencrypt")) || c->hasSwitch('n',"onlydecrypt"); + inf->m_bDoEncrypt = (!c->hasSwitch('n',"onlydecrypt")); + inf->m_bDoDecrypt = (!c->hasSwitch('m',"onlyencrypt")) || c->hasSwitch('n',"onlydecrypt"); pWnd->setCryptSessionInfo(inf); } else { if(szError.isEmpty())szError = __tr2qs("Unknown engine error"); |
