summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-02 20:55:18 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-02 20:55:18 +0000
commit78c0815c4118fe24ab78cce2dc48a6232dcd824a (patch)
tree8512c50df70b8dd80c919e88ade3419207c95956 /plugins/CryptoPP
parentce816d83a8c75808e0eb06832592bffefe4a8dc4 (diff)
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP')
-rw-r--r--plugins/CryptoPP/GPGw/gpg.c26
-rw-r--r--plugins/CryptoPP/GPGw/main.c40
-rw-r--r--plugins/CryptoPP/GPGw/pipeexec.c12
-rw-r--r--plugins/CryptoPP/GPGw/tools.c2
-rw-r--r--plugins/CryptoPP/PGPw/main.cpp6
-rw-r--r--plugins/CryptoPP/base16.cpp4
-rw-r--r--plugins/CryptoPP/base64.cpp2
-rw-r--r--plugins/CryptoPP/commonheaders.cpp14
-rw-r--r--plugins/CryptoPP/cpp_cntx.cpp38
-rw-r--r--plugins/CryptoPP/cpp_gpgw.cpp30
-rw-r--r--plugins/CryptoPP/cpp_keys.cpp18
-rw-r--r--plugins/CryptoPP/cpp_misc.cpp24
-rw-r--r--plugins/CryptoPP/cpp_pgpw.cpp34
-rw-r--r--plugins/CryptoPP/cpp_rsam.cpp152
-rw-r--r--plugins/CryptoPP/cpp_rsau.cpp22
-rw-r--r--plugins/CryptoPP/cpp_rsau.h10
-rw-r--r--plugins/CryptoPP/cpp_svcs.cpp28
-rw-r--r--plugins/CryptoPP/crypto/crc.cpp2
-rw-r--r--plugins/CryptoPP/crypto/des.cpp4
-rw-r--r--plugins/CryptoPP/crypto/gzip.cpp4
-rw-r--r--plugins/CryptoPP/crypto/mars.cpp2
-rw-r--r--plugins/CryptoPP/crypto/osrng.cpp2
-rw-r--r--plugins/CryptoPP/main.cpp2
23 files changed, 239 insertions, 239 deletions
diff --git a/plugins/CryptoPP/GPGw/gpg.c b/plugins/CryptoPP/GPGw/gpg.c
index 354e455a94..8ec3a57b11 100644
--- a/plugins/CryptoPP/GPGw/gpg.c
+++ b/plugins/CryptoPP/GPGw/gpg.c
@@ -126,7 +126,7 @@ gpgResult gpgListPublicKeys(char *aresult)
replace(commandline, txthome, gpgHomeDirectory);
pxresult=pxExecute(commandline, "", &output, &exitcode);
- if((pxresult!=pxSuccess)||(exitcode!=0))
+ if ((pxresult!=pxSuccess)||(exitcode!=0))
{
free(output);
return gpgExecuteFailed;
@@ -153,7 +153,7 @@ gpgResult gpgListSecretKeys(char *aresult)
replace(commandline, txthome, gpgHomeDirectory);
pxresult=pxExecute(commandline, "", &output, &exitcode);
- if((pxresult!=pxSuccess)||(exitcode!=0))
+ if ((pxresult!=pxSuccess)||(exitcode!=0))
{
free(output);
return gpgExecuteFailed;
@@ -175,7 +175,7 @@ gpgResult gpgImportPublicKey(const char *akey)
char *output;
LogMessage(">>> ", "import public key", "\n");
- if(! writeToFile(filename, akey)) return gpgWriteToFileFailed;
+ if (! writeToFile(filename, akey)) return gpgWriteToFileFailed;
output=(char *)malloc(1);
strcpy(output, "");
@@ -186,7 +186,7 @@ gpgResult gpgImportPublicKey(const char *akey)
remove(filename);
free(output);
- if((pxresult!=pxSuccess)||(exitcode!=0))
+ if ((pxresult!=pxSuccess)||(exitcode!=0))
return gpgExecuteFailed;
return gpgSuccess;
@@ -208,7 +208,7 @@ gpgResult gpgExportPublicKey(char *aresult, const char *auserid)
replace(commandline, txthome, gpgHomeDirectory);
pxresult=pxExecute(commandline, "", &output, &exitcode);
- if((pxresult!=pxSuccess)||(exitcode!=0))
+ if ((pxresult!=pxSuccess)||(exitcode!=0))
{
strcpy(aresult, "");
free(output);
@@ -237,7 +237,7 @@ gpgResult gpgDetectUserID(char *aresult, const char *aciphertext)
LogMessage(">>> ", "detect user id", "\n");
strcpy(aresult, "");
- if(! writeToFile(filename, aciphertext))
+ if (! writeToFile(filename, aciphertext))
return gpgWriteToFileFailed;
output=(char *)malloc(1);
@@ -248,7 +248,7 @@ gpgResult gpgDetectUserID(char *aresult, const char *aciphertext)
pxresult=pxExecute(commandline, "", &output, &exitcode);
remove(filename);
- if((pxresult!=pxSuccess)&&(pxresult!=pxSuccessExitCodeInvalid))
+ if ((pxresult!=pxSuccess)&&(pxresult!=pxSuccessExitCodeInvalid))
{
free(output);
return gpgExecuteFailed;
@@ -287,7 +287,7 @@ gpgResult gpgEncrypt(char *aresult, const char *auserid, const char *aplaintext)
LogMessage(">>> ", "encrypt", "\n");
strcpy(aresult, "");
- if(! writeToFile(plainfile, aplaintext))
+ if (! writeToFile(plainfile, aplaintext))
return gpgWriteToFileFailed;
output=(char *)malloc(1);
@@ -302,13 +302,13 @@ gpgResult gpgEncrypt(char *aresult, const char *auserid, const char *aplaintext)
remove(plainfile);
free(output);
- if((pxresult!=pxSuccess)||(exitcode!=0))
+ if ((pxresult!=pxSuccess)||(exitcode!=0))
{
remove(cipherfile);
return gpgExecuteFailed;
}
- if(! readFromFile(aresult, cipherfile))
+ if (! readFromFile(aresult, cipherfile))
{
remove(cipherfile);
return gpgReadFromFileFailed;
@@ -332,7 +332,7 @@ gpgResult gpgDecrypt(char *aresult, const char *aciphertext, const char *apassph
LogMessage(">>> ", "decrypt", "\n");
strcpy(aresult, "");
- if(! writeToFile(cipherfile, aciphertext))
+ if (! writeToFile(cipherfile, aciphertext))
return gpgWriteToFileFailed;
output=(char *)malloc(1);
@@ -348,13 +348,13 @@ gpgResult gpgDecrypt(char *aresult, const char *aciphertext, const char *apassph
remove(cipherfile);
free(output);
- if((pxresult!=pxSuccess)||(exitcode!=0))
+ if ((pxresult!=pxSuccess)||(exitcode!=0))
{
remove(plainfile);
return gpgExecuteFailed;
}
- if(! readFromFile(aresult, plainfile))
+ if (! readFromFile(aresult, plainfile))
{
remove(plainfile);
return gpgReadFromFileFailed;
diff --git a/plugins/CryptoPP/GPGw/main.c b/plugins/CryptoPP/GPGw/main.c
index 766d491704..fc23b24262 100644
--- a/plugins/CryptoPP/GPGw/main.c
+++ b/plugins/CryptoPP/GPGw/main.c
@@ -27,13 +27,13 @@ int __cdecl _gpg_done()
int __cdecl _gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath)
{
- if( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) {
+ if ( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) {
return 0;
}
- if( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) {
+ if ( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) {
return 0;
}
- if( !existsFile(ExecPath) ) {
+ if ( !existsFile(ExecPath) ) {
// ErrorMessage(txtwarning, txtinvalidexecutable, txtverifyoptions);
return 0;
}
@@ -84,9 +84,9 @@ LPSTR __cdecl _gpg_get_passphrases()
// encrypt
for(i=0; i<strlen(b); i++)
- if( b[i]>2 ) {
+ if ( b[i]>2 ) {
x = b[i] ^ ( (i&0x7f) ^ 13);
- if( x>2 ) b[i]=x;
+ if ( x>2 ) b[i]=x;
}
return b;
@@ -97,16 +97,16 @@ void __cdecl _gpg_set_passphrases(LPCSTR buffer)
{
size_t i, l = strlen(buffer); char *t, *p, *b, x;
- if( !l ) return;
+ if ( !l ) return;
b = (char *) LocalAlloc(LPTR,l+1);
strcpy(b, buffer);
// decrypt
for(i=0; i<strlen(b); i++)
- if( b[i]>2 ) {
+ if ( b[i]>2 ) {
x = b[i] ^ ( (i&0x7f) ^ 13);
- if( x>2 ) b[i]=x;
+ if ( x>2 ) b[i]=x;
}
while(*b) {
@@ -167,7 +167,7 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR message)
begin=strstr(message, txtbeginpgpmessage);
end=strstr(message, txtendpgpmessage);
- if((begin!=NULL)&&(end!=NULL))
+ if ((begin!=NULL)&&(end!=NULL))
{
strcpy(buffer, "");
strncat(buffer, begin, end-begin+strlen(txtendpgpmessage));
@@ -218,7 +218,7 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR message)
strcpy(buffer, plaintext);
}
- if( gpgresult==gpgSuccess && useridvalid==TRUE)
+ if ( gpgresult==gpgSuccess && useridvalid==TRUE)
addPassphrase(keyuserid, passphrase);
ZeroMemory(passphrase, sizeof(passphrase));
@@ -255,7 +255,7 @@ int __cdecl _gpg_select_keyid(HWND hdlg, LPSTR keyid)
void noBackslash(LPSTR path) {
LPSTR ptr;
ptr = path + strlen(path) - 1;
- if( *ptr=='\\' ) *ptr = '\0';
+ if ( *ptr=='\\' ) *ptr = '\0';
}
@@ -267,7 +267,7 @@ LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName){
LPSTR ret=0;
RegOpenKey(hKey,szPath,&hKey);
- if( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ){
+ if ( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ) {
noBackslash((LPSTR)&buf);
ret = (LPSTR)&buf;
}
@@ -280,7 +280,7 @@ LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName){
LPSTR GetEnvValue(LPCSTR szName){
LPSTR ret=0;
- if( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) {
+ if ( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) {
noBackslash((LPSTR)&buf);
ret = (LPSTR)&buf;
}
@@ -295,14 +295,14 @@ BOOL ShowSelectExecDlg(LPSTR path)
ZeroMemory(&ofn,sizeof(ofn));
ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","gpgProgram");
- if( ofn.lpstrFile && existsFile(ofn.lpstrFile) ) {
+ if ( ofn.lpstrFile && existsFile(ofn.lpstrFile) ) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
ofn.lpstrFile = GetRegValue(HKEY_LOCAL_MACHINE,"Software\\GNU\\GnuPG","Install Directory");
- if( ofn.lpstrFile ) {
+ if ( ofn.lpstrFile ) {
strcat(ofn.lpstrFile,"\\gpg.exe");
- if( existsFile(ofn.lpstrFile) ) {
+ if ( existsFile(ofn.lpstrFile) ) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
@@ -327,19 +327,19 @@ BOOL ShowSelectHomeDlg(LPSTR path)
OPENFILENAME ofn;
ofn.lpstrFile = GetEnvValue("GNUPGHOME");
- if( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
+ if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","HomeDir");
- if( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
+ if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
ofn.lpstrFile = GetEnvValue("APPDATA");
- if( ofn.lpstrFile ) {
+ if ( ofn.lpstrFile ) {
strcat(ofn.lpstrFile,"\\gnupg");
- if( existsPath(ofn.lpstrFile) ) {
+ if ( existsPath(ofn.lpstrFile) ) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
diff --git a/plugins/CryptoPP/GPGw/pipeexec.c b/plugins/CryptoPP/GPGw/pipeexec.c
index 871dfbe3b4..ea54f85d1a 100644
--- a/plugins/CryptoPP/GPGw/pipeexec.c
+++ b/plugins/CryptoPP/GPGw/pipeexec.c
@@ -32,7 +32,7 @@ void storeOutput(HANDLE ahandle, char **aoutput)
success=ReadFile(ahandle, readbuffer, sizeof(readbuffer), &transfered, NULL);
- if((success)&&(transfered!=0))
+ if ((success)&&(transfered!=0))
appendText(aoutput, readbuffer, transfered);
}
while(available>0);
@@ -66,14 +66,14 @@ pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aex
else securityattributes.lpSecurityDescriptor=NULL;
success=CreatePipe(&newstdin, &writestdin ,&securityattributes ,0);
- if(! success)
+ if (! success)
{
LogMessage("--- ", "create pipe failed", "\n");
return pxCreatePipeFailed;
}
success=CreatePipe(&readstdout, &newstdout, &securityattributes, 0);
- if(! success)
+ if (! success)
{
LogMessage("--- ", "create pipe failed", "\n");
CloseHandle(newstdin);
@@ -90,7 +90,7 @@ pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aex
success=CreateProcess(NULL, acommandline, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startupinfo, &processinformation);
- if(! success)
+ if (! success)
{
LogMessage("--- ", "create process failed", "\n");
CloseHandle(newstdin);
@@ -105,11 +105,11 @@ pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aex
while(TRUE)
{
success=GetExitCodeProcess(processinformation.hProcess, aexitcode);
- if((success)&&(*aexitcode!=STILL_ACTIVE)) break;
+ if ((success)&&(*aexitcode!=STILL_ACTIVE)) break;
storeOutput(readstdout, aoutput);
- if(*inputpos!='\0') size=1;
+ if (*inputpos!='\0') size=1;
else size=0;
success=WriteFile(writestdin, inputpos, size, &transfered, NULL);
diff --git a/plugins/CryptoPP/GPGw/tools.c b/plugins/CryptoPP/GPGw/tools.c
index ee7adde761..002f18824d 100644
--- a/plugins/CryptoPP/GPGw/tools.c
+++ b/plugins/CryptoPP/GPGw/tools.c
@@ -78,7 +78,7 @@ void appendText(char **abuffer, const char *atext, int atextsize)
{
int size;
- if(*abuffer==NULL) size=0;
+ if (*abuffer==NULL) size=0;
else size=strlen(*abuffer);
size++; // abschliessende 0
if(atextsize==0) atextsize=strlen(atext);
diff --git a/plugins/CryptoPP/PGPw/main.cpp b/plugins/CryptoPP/PGPw/main.cpp
index 116615b839..8427046a16 100644
--- a/plugins/CryptoPP/PGPw/main.cpp
+++ b/plugins/CryptoPP/PGPw/main.cpp
@@ -45,7 +45,7 @@ void _pgp_memcpy(LPSTR dst, LPSTR src, UINT size)
int __cdecl _pgp_init()
{
- if(!pgpErrMsg)
+ if (!pgpErrMsg)
pgpErrMsg = (LPSTR) LocalAlloc(LPTR,pgpErrMsgLen);
pgpVer = 0;
@@ -172,7 +172,7 @@ LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR szPlainMsg, PVOID pgpKeyID)
DWORD dwEncMsgLen;
ClearPGPError();
- if(!pgpKeyDB)
+ if (!pgpKeyDB)
return 0;
#if (PGP_WIN32 < 0x700)
@@ -221,7 +221,7 @@ LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR szEncMsg)
DWORD dwPlainMsgLen;
ClearPGPError();
- if(!pgpKeyDB)
+ if (!pgpKeyDB)
return 0;
int iTry = 0;
diff --git a/plugins/CryptoPP/base16.cpp b/plugins/CryptoPP/base16.cpp
index b8c813eff9..db838e498d 100644
--- a/plugins/CryptoPP/base16.cpp
+++ b/plugins/CryptoPP/base16.cpp
@@ -24,7 +24,7 @@ char *base16decode(const char *inBuffer, int *count) {
BYTE *outBufferPtr = (BYTE *) outBuffer;
bool big_endian = false;
- if(*inBuffer == '0' && *(inBuffer+1) == 'x') {
+ if (*inBuffer == '0' && *(inBuffer+1) == 'x') {
inBuffer += *count;
big_endian = true;
*count -= 2;
@@ -39,7 +39,7 @@ char *base16decode(const char *inBuffer, int *count) {
c0 = decode16(*inBuffer++);
c1 = decode16(*inBuffer++);
}
- if((c0 | c1) == BERR) {
+ if ((c0 | c1) == BERR) {
free(outBuffer);
*count = 0;
return(NULL);
diff --git a/plugins/CryptoPP/base64.cpp b/plugins/CryptoPP/base64.cpp
index f639799b92..70c3d672c7 100644
--- a/plugins/CryptoPP/base64.cpp
+++ b/plugins/CryptoPP/base64.cpp
@@ -75,7 +75,7 @@ char *base64decode(const char *inBuffer, int *count) {
if(delta > 3)
c3 = decode64(inBuffer[srcIndex++]);
}
- if((c0 | c1 | c2 | c3) == BERR) {
+ if ((c0 | c1 | c2 | c3) == BERR) {
free(outBuffer);
return(NULL);
}
diff --git a/plugins/CryptoPP/commonheaders.cpp b/plugins/CryptoPP/commonheaders.cpp
index 4ba0c995fa..e518aecb11 100644
--- a/plugins/CryptoPP/commonheaders.cpp
+++ b/plugins/CryptoPP/commonheaders.cpp
@@ -51,13 +51,13 @@ BOOL ExtractFileFromResource( HANDLE FH, int ResType, int ResId, DWORD* Size )
RH = FindResource( g_hInst, MAKEINTRESOURCE( ResId ), MAKEINTRESOURCE( ResType ) );
- if( RH == NULL ) return FALSE;
+ if ( RH == NULL ) return FALSE;
RP = (PBYTE) LoadResource( g_hInst, RH );
- if( RP == NULL ) return FALSE;
+ if ( RP == NULL ) return FALSE;
s = SizeofResource( g_hInst, RH );
- if( !WriteFile( FH, RP, s, &x, NULL ) ) return FALSE;
- if( x != s ) return FALSE;
- if( Size ) *Size = s;
+ if ( !WriteFile( FH, RP, s, &x, NULL ) ) return FALSE;
+ if ( x != s ) return FALSE;
+ if ( Size ) *Size = s;
return TRUE;
}
@@ -66,7 +66,7 @@ void ExtractFile( char *FileName, int ResType, int ResId )
{
HANDLE FH;
FH = CreateFile( FileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL );
- if( FH == INVALID_HANDLE_VALUE ) return;
+ if ( FH == INVALID_HANDLE_VALUE ) return;
if (!ExtractFileFromResource( FH, ResType, ResId, NULL )) MessageBoxA(0,"Can't extract","!!!",MB_OK);
CloseHandle( FH );
}
@@ -78,7 +78,7 @@ int rtrim(LPCSTR str) {
while( len ) {
char c = *ptr;
- if( c != '\x20' && c != '\x09' && c != '\x0A' && c != '\x0D' ) {
+ if ( c != '\x20' && c != '\x09' && c != '\x0A' && c != '\x0D' ) {
*(ptr+1) = '\0';
break;
}
diff --git a/plugins/CryptoPP/cpp_cntx.cpp b/plugins/CryptoPP/cpp_cntx.cpp
index eba883755d..fe3d5c616f 100644
--- a/plugins/CryptoPP/cpp_cntx.cpp
+++ b/plugins/CryptoPP/cpp_cntx.cpp
@@ -11,14 +11,14 @@ unsigned __stdcall sttTimeoutThread(LPVOID);
// get context data on context id
pCNTX get_context_on_id(HANDLE context) {
- if( !thread_timeout ) {
+ if ( !thread_timeout ) {
unsigned int tID;
thread_timeout = (HANDLE) _beginthreadex(NULL, 0, sttTimeoutThread, NULL, 0, &tID);
}
- if( context ) {
+ if ( context ) {
pCNTX cntx = (pCNTX) context;
- if( cntx->header == HEADER && cntx->footer == FOOTER )
+ if ( cntx->header == HEADER && cntx->footer == FOOTER )
return cntx;
#if defined(_DEBUG) || defined(NETLIB_LOG)
else
@@ -42,16 +42,16 @@ HANDLE __cdecl cpp_create_context(int mode) {
EnterCriticalSection(&localContextMutex);
- if( !CL.empty() ) {
+ if ( !CL.empty() ) {
for(i=CL.begin(); i!=CL.end(); ++i) { // ищем пустой
- if( (*i)->header==EMPTYH && (*i)->footer==EMPTYH ) {
+ if ( (*i)->header==EMPTYH && (*i)->footer==EMPTYH ) {
cntx = (pCNTX) *i;
break;
}
}
}
- if( !cntx ) { // не нашли - создаем новый
+ if ( !cntx ) { // не нашли - создаем новый
cntx = (pCNTX) malloc(sizeof(CNTX));
CL.push_back(cntx); // добавили в конец списка
}
@@ -87,18 +87,18 @@ void __cdecl cpp_reset_context(HANDLE context) {
// allocate pdata
PBYTE cpp_alloc_pdata(pCNTX ptr) {
- if( !ptr->pdata ) {
- if( ptr->mode & MODE_PGP ) {
+ if ( !ptr->pdata ) {
+ if ( ptr->mode & MODE_PGP ) {
ptr->pdata = (PBYTE) malloc(sizeof(PGPDATA));
memset(ptr->pdata,0,sizeof(PGPDATA));
}
else
- if( ptr->mode & MODE_GPG ) {
+ if ( ptr->mode & MODE_GPG ) {
ptr->pdata = (PBYTE) malloc(sizeof(GPGDATA));
memset(ptr->pdata,0,sizeof(GPGDATA));
}
else
- if( ptr->mode & MODE_RSA ) {
+ if ( ptr->mode & MODE_RSA ) {
rsa_alloc(ptr);
}
else {
@@ -115,20 +115,20 @@ void cpp_free_keys(pCNTX ptr) {
SAFE_FREE(ptr->tmp);
cpp_alloc_pdata(ptr);
- if( ptr->mode & MODE_PGP ) {
+ if ( ptr->mode & MODE_PGP ) {
pPGPDATA p = (pPGPDATA) ptr->pdata;
SAFE_FREE(p->pgpKeyID);
SAFE_FREE(p->pgpKey);
SAFE_FREE(ptr->pdata);
}
else
- if( ptr->mode & MODE_GPG ) {
+ if ( ptr->mode & MODE_GPG ) {
pGPGDATA p = (pGPGDATA) ptr->pdata;
SAFE_FREE(p->gpgKeyID);
SAFE_FREE(ptr->pdata);
}
else
- if( ptr->mode & MODE_RSA ) {
+ if ( ptr->mode & MODE_RSA ) {
rsa_free(ptr);
SAFE_DELETE(ptr->pdata);
}
@@ -151,27 +151,27 @@ unsigned __stdcall sttTimeoutThread( LPVOID ) {
list<pCNTX>::iterator i;
while(1) {
Sleep( 1000 ); // раз в секунду
- if( CL.empty() ) continue;
+ if ( CL.empty() ) continue;
u_int time = gettime();
// пробегаем все контексты
EnterCriticalSection(&localContextMutex);
for(i=CL.begin(); i!=CL.end(); ++i) {
pCNTX tmp = *i;
- if( tmp->header!=HEADER || tmp->footer!=FOOTER ) continue;
+ if ( tmp->header!=HEADER || tmp->footer!=FOOTER ) continue;
// пропускаем приватные ключи
- if( tmp->mode&MODE_PRIV_KEY ) continue;
+ if ( tmp->mode&MODE_PRIV_KEY ) continue;
else
- if( tmp->deleted && tmp->deleted < time ) {
+ if ( tmp->deleted && tmp->deleted < time ) {
// удалить помеченный для удаления контекст
cpp_free_keys(tmp);
tmp->deleted = 0;
tmp->header = tmp->footer = EMPTYH;
}
else
- if( tmp->mode&MODE_RSA && tmp->pdata ) {
+ if ( tmp->mode&MODE_RSA && tmp->pdata ) {
// проверяем не протухло ли соединение
pRSADATA p = (pRSADATA) tmp->pdata;
- if( p->time && p->time < time ) {
+ if ( p->time && p->time < time ) {
rsa_timeout((HANDLE)tmp,p);
}
}
diff --git a/plugins/CryptoPP/cpp_gpgw.cpp b/plugins/CryptoPP/cpp_gpgw.cpp
index f053ef8085..90fe8b3062 100644
--- a/plugins/CryptoPP/cpp_gpgw.cpp
+++ b/plugins/CryptoPP/cpp_gpgw.cpp
@@ -111,7 +111,7 @@ int load_gpg_mem(HMODULE mod) {
int __cdecl gpg_init()
{
int r; char t[MAX_PATH];
- if( isVista ){
+ if ( isVista ) {
sprintf(t,"%s\\gnupgw.dll",TEMP);
ExtractFile(t,666,1);
hgpg = LoadLibraryA(t);
@@ -122,13 +122,13 @@ int __cdecl gpg_init()
hgpg = MemLoadLibrary( pRS_gpg );
}
if (hgpg) {
- if( isVista ) load_gpg_dll(hgpg);
+ if ( isVista ) load_gpg_dll(hgpg);
else load_gpg_mem(hgpg);
r = p_gpg_init();
if(r) {
return r;
}
- if( isVista ){
+ if ( isVista ) {
FreeLibrary(hgpg);
}
else {
@@ -149,7 +149,7 @@ int __cdecl gpg_done()
int r = 0;
if(hgpg) {
r = p_gpg_done();
- if( isVista ){
+ if ( isVista ) {
FreeLibrary(hgpg);
}
else {
@@ -201,7 +201,7 @@ LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
LPSTR szEncMsg;
szEncMsg = p_gpg_encrypt(szPlainMsg,(LPCSTR)p->gpgKeyID);
- if(!szEncMsg) return 0;
+ if (!szEncMsg) return 0;
ptr->tmp = (LPSTR) strdup(szEncMsg);
LocalFree((LPVOID)szEncMsg);
@@ -216,11 +216,11 @@ LPSTR __cdecl gpg_decrypt(pCNTX ptr, LPCSTR szEncMsg)
SAFE_FREE(ptr->tmp);
LPSTR szPlainMsg = p_gpg_decrypt(szEncMsg);
-/* if(!szPlainMsg) {
+/* if (!szPlainMsg) {
ptr = get_context_on_id(hPGPPRIV); // find private pgp keys
if(ptr && ptr->pgpKey)
szPlainMsg = p_gpg_decrypt_key(szEncMsg,(LPCSTR)ptr->pgpKey);
- if(!szPlainMsg) return NULL;
+ if (!szPlainMsg) return NULL;
}*/
ptr->tmp = (LPSTR) strdup(szPlainMsg);
@@ -232,13 +232,13 @@ LPSTR __cdecl gpg_decrypt(pCNTX ptr, LPCSTR szEncMsg)
LPSTR __cdecl gpg_encode(HANDLE context, LPCSTR szPlainMsg)
{
- pCNTX ptr = get_context_on_id(context); if(!ptr) return NULL;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return NULL;
pGPGDATA p = (pGPGDATA) cpp_alloc_pdata(ptr);
- if(!p->gpgKeyID) { ptr->error = ERROR_NO_GPG_KEY; return NULL; }
+ if (!p->gpgKeyID) { ptr->error = ERROR_NO_GPG_KEY; return NULL; }
// utf8 message: encrypt.
LPSTR szUtfMsg;
- if( ptr->mode & MODE_GPG_ANSI ) {
+ if ( ptr->mode & MODE_GPG_ANSI ) {
LPWSTR wszMsg = utf8decode(szPlainMsg);
int wlen = wcslen(wszMsg)+1;
szUtfMsg = (LPSTR) alloca(wlen);
@@ -254,13 +254,13 @@ LPSTR __cdecl gpg_encode(HANDLE context, LPCSTR szPlainMsg)
LPSTR __cdecl gpg_decode(HANDLE context, LPCSTR szEncMsg)
{
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return NULL;
+ if (!ptr) return NULL;
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = gpg_decrypt(ptr, szEncMsg);
if(szOldMsg) {
- if( !is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg) ) {
+ if ( !is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg) ) {
int slen = strlen(szOldMsg)+1;
LPWSTR wszMsg = (LPWSTR) alloca(slen*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, szOldMsg, -1, wszMsg, slen*sizeof(WCHAR));
@@ -279,10 +279,10 @@ LPSTR __cdecl gpg_decode(HANDLE context, LPCSTR szEncMsg)
int __cdecl gpg_set_key(HANDLE context, LPCSTR RemoteKey)
{
/* pCNTX ptr = get_context_on_id(context);
- if(!ptr) return 0;
+ if (!ptr) return 0;
ptr->error = ERROR_NONE;
-// if(!p_gpg_check_key(RemoteKey)) return 0;
+// if (!p_gpg_check_key(RemoteKey)) return 0;
SAFE_FREE(ptr->pgpKey);
ptr->pgpKey = (BYTE *) malloc(strlen(RemoteKey)+1);
@@ -296,7 +296,7 @@ int __cdecl gpg_set_key(HANDLE context, LPCSTR RemoteKey)
int __cdecl gpg_set_keyid(HANDLE context, LPCSTR RemoteKeyID)
{
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pGPGDATA p = (pGPGDATA) cpp_alloc_pdata(ptr);
ptr->error = ERROR_NONE;
diff --git a/plugins/CryptoPP/cpp_keys.cpp b/plugins/CryptoPP/cpp_keys.cpp
index 51ac7247b4..16e4e0d281 100644
--- a/plugins/CryptoPP/cpp_keys.cpp
+++ b/plugins/CryptoPP/cpp_keys.cpp
@@ -6,7 +6,7 @@ const unsigned char IV[] = "PSKhell@MIRANDA!";
// generate KeyA pair, return public key as ASCII
LPSTR __cdecl cpp_init_keya(HANDLE context, int features) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return NULL;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return NULL;
pSIMDATA p = (pSIMDATA) cpp_alloc_pdata(ptr);
int send_features = FEATURES;
@@ -70,19 +70,19 @@ LPSTR __cdecl cpp_init_keya(HANDLE context, int features) {
// store KeyB
int __cdecl cpp_init_keyb(HANDLE context, LPCSTR key) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pSIMDATA p = (pSIMDATA) cpp_alloc_pdata(ptr);
int clen = rtrim(key);
ptr->features = 0;
LPSTR pub_binary;
- if((clen==KEYSIZE*2) || (clen==(KEYSIZE+2)*2))
+ if ((clen==KEYSIZE*2) || (clen==(KEYSIZE+2)*2))
pub_binary = base16decode(key,&clen);
else
pub_binary = base64decode(key,&clen);
- if( !pub_binary || (clen!=KEYSIZE && clen!=KEYSIZE+2) ) {
+ if ( !pub_binary || (clen!=KEYSIZE && clen!=KEYSIZE+2) ) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("cpp_init_keyb: error bad_keyb");
#endif
@@ -95,7 +95,7 @@ int __cdecl cpp_init_keyb(HANDLE context, LPCSTR key) {
memcpy((PVOID)&ptr->features,(PVOID)(pub_binary+KEYSIZE),2);
if(p->KeyP) {
- if(!(ptr->features & FEATURES_PSK)) { // if NO PSK on other side
+ if (!(ptr->features & FEATURES_PSK)) { // if NO PSK on other side
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("cpp_init_keyb: error no_psk");
#endif
@@ -141,11 +141,11 @@ int __cdecl cpp_init_keyb(HANDLE context, LPCSTR key) {
// calculate secret key, return true or false
int __cdecl cpp_calc_keyx(HANDLE context) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pSIMDATA p = (pSIMDATA) cpp_alloc_pdata(ptr);
- if(!p->KeyA) { ptr->error = ERROR_NO_KEYA; return 0; }
- if(!p->KeyB) { ptr->error = ERROR_NO_KEYB; return 0; }
+ if (!p->KeyA) { ptr->error = ERROR_NO_KEYA; return 0; }
+ if (!p->KeyB) { ptr->error = ERROR_NO_KEYB; return 0; }
ptr->error = ERROR_NONE;
BYTE agreeVal[KEYSIZE];
@@ -178,7 +178,7 @@ int __cdecl cpp_calc_keyx(HANDLE context) {
// create pre-shared key from password
int __cdecl cpp_init_keyp(HANDLE context, LPCSTR password) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pSIMDATA p = (pSIMDATA) cpp_alloc_pdata(ptr);
BYTE buffer[Tiger::DIGESTSIZE]; // buffer for hash
diff --git a/plugins/CryptoPP/cpp_misc.cpp b/plugins/CryptoPP/cpp_misc.cpp
index 526cebf6bc..5e5720df18 100644
--- a/plugins/CryptoPP/cpp_misc.cpp
+++ b/plugins/CryptoPP/cpp_misc.cpp
@@ -2,13 +2,13 @@
int __cdecl cpp_get_features(HANDLE context) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
return ptr->features;
}
int __cdecl cpp_get_error(HANDLE context) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
return ptr->error;
}
@@ -20,8 +20,8 @@ int __cdecl cpp_get_version(void) {
BOOL cpp_get_simdata(HANDLE context, pCNTX *ptr, pSIMDATA *p) {
*ptr = get_context_on_id(context);
-// if(!*ptr || !(*ptr)->pdata || (*ptr)->mode&(MODE_PGP|MODE_GPG|MODE_RSA)) return FALSE;
- if(!*ptr || (*ptr)->mode&(MODE_PGP|MODE_GPG|MODE_RSA)) return FALSE;
+// if (!*ptr || !(*ptr)->pdata || (*ptr)->mode&(MODE_PGP|MODE_GPG|MODE_RSA)) return FALSE;
+ if (!*ptr || (*ptr)->mode&(MODE_PGP|MODE_GPG|MODE_RSA)) return FALSE;
*p = (pSIMDATA) cpp_alloc_pdata(*ptr);
return TRUE;
}
@@ -33,14 +33,14 @@ int __cdecl cpp_size_keyx(void) {
void __cdecl cpp_get_keyx(HANDLE context, BYTE *key) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return;
memcpy(key,p->KeyX,Tiger::DIGESTSIZE);
memcpy(key+Tiger::DIGESTSIZE,&ptr->features,2);
}
void __cdecl cpp_set_keyx(HANDLE context, BYTE *key) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return;
SAFE_FREE(p->PubA);
SAFE_FREE(p->KeyA);
SAFE_FREE(p->KeyB);
@@ -52,7 +52,7 @@ void __cdecl cpp_set_keyx(HANDLE context, BYTE *key) {
void __cdecl cpp_get_keyp(HANDLE context, BYTE *key) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return;
memcpy(key,p->KeyP,Tiger::DIGESTSIZE);
}
@@ -63,7 +63,7 @@ int __cdecl cpp_size_keyp(void) {
void __cdecl cpp_set_keyp(HANDLE context, BYTE *key) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return;
SAFE_FREE(p->KeyP);
p->KeyP = (PBYTE) malloc(Tiger::DIGESTSIZE);
memcpy(p->KeyP,key,Tiger::DIGESTSIZE);
@@ -71,25 +71,25 @@ void __cdecl cpp_set_keyp(HANDLE context, BYTE *key) {
int __cdecl cpp_keya(HANDLE context) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return 0;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return 0;
return p->KeyA!=NULL;
}
int __cdecl cpp_keyb(HANDLE context) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return 0;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return 0;
return p->KeyB!=NULL;
}
int __cdecl cpp_keyx(HANDLE context) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return 0;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return 0;
return p->KeyX!=NULL;
}
int __cdecl cpp_keyp(HANDLE context) {
- pCNTX ptr; pSIMDATA p; if(!cpp_get_simdata(context,&ptr,&p)) return 0;
+ pCNTX ptr; pSIMDATA p; if (!cpp_get_simdata(context,&ptr,&p)) return 0;
return p->KeyP!=NULL;
}
diff --git a/plugins/CryptoPP/cpp_pgpw.cpp b/plugins/CryptoPP/cpp_pgpw.cpp
index 6d06ac0d7f..e8f9f98ab4 100644
--- a/plugins/CryptoPP/cpp_pgpw.cpp
+++ b/plugins/CryptoPP/cpp_pgpw.cpp
@@ -101,7 +101,7 @@ BOOL load_pgp_sdk(int type, int id)
int r; char t[MAX_PATH];
pgpVer = 0;
- if( isVista ){
+ if ( isVista ) {
sprintf(t,"%s\\pgpsdkw.dll",TEMP);
ExtractFile(t,type,id);
hpgpsdk = LoadLibraryA(t);
@@ -112,14 +112,14 @@ BOOL load_pgp_sdk(int type, int id)
hpgpsdk = MemLoadLibrary( pRS_pgp );
}
if (hpgpsdk) {
- if( isVista ) load_pgpsdk_dll(hpgpsdk);
+ if ( isVista ) load_pgpsdk_dll(hpgpsdk);
else load_pgpsdk_mem(hpgpsdk);
r = p_pgp_init();
if(r) {
pgpVer = p_pgp_get_version();
return r;
}
- if( isVista ){
+ if ( isVista ) {
FreeLibrary(hpgpsdk);
}
else {
@@ -136,7 +136,7 @@ int __cdecl pgp_init()
{
int r;
- if( !hPGPPRIV ) {
+ if ( !hPGPPRIV ) {
// create context for private pgp keys
hPGPPRIV = (HANDLE) cpp_create_context(MODE_PGP|MODE_PRIV_KEY);
pCNTX tmp = (pCNTX) hPGPPRIV;
@@ -144,8 +144,8 @@ int __cdecl pgp_init()
memset(tmp->pdata,0,sizeof(PGPDATA));
}
- if( r = load_pgp_sdk(666,6) ) return r;
- if( r = load_pgp_sdk(666,8) ) return r;
+ if ( r = load_pgp_sdk(666,6) ) return r;
+ if ( r = load_pgp_sdk(666,8) ) return r;
hpgpsdk = 0;
@@ -159,7 +159,7 @@ int __cdecl pgp_done()
pgpVer = 0;
if(hpgpsdk) {
r = p_pgp_done();
- if( isVista ){
+ if ( isVista ) {
FreeLibrary(hpgpsdk);
}
else {
@@ -208,7 +208,7 @@ LPSTR __cdecl pgp_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
szEncMsg = p_pgp_encrypt_key(szPlainMsg,(LPCSTR)p->pgpKey);
else
szEncMsg = p_pgp_encrypt_keydb(szPlainMsg,p->pgpKeyID);
- if(!szEncMsg) return 0;
+ if (!szEncMsg) return 0;
ptr->tmp = (LPSTR) strdup(szEncMsg);
LocalFree((LPVOID)szEncMsg);
@@ -223,14 +223,14 @@ LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg)
SAFE_FREE(ptr->tmp);
LPSTR szPlainMsg = p_pgp_decrypt_keydb(szEncMsg);
- if(!szPlainMsg) {
+ if (!szPlainMsg) {
ptr = get_context_on_id(hPGPPRIV); // find private pgp keys
if(ptr) {
pPGPDATA p = (pPGPDATA) ptr->pdata;
if(p->pgpKey)
szPlainMsg = p_pgp_decrypt_key(szEncMsg,(LPCSTR)p->pgpKey);
}
- if(!szPlainMsg) return NULL;
+ if (!szPlainMsg) return NULL;
}
ptr->tmp = (LPSTR) strdup(szPlainMsg);
@@ -242,9 +242,9 @@ LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg)
LPSTR __cdecl pgp_encode(HANDLE context, LPCSTR szPlainMsg)
{
- pCNTX ptr = get_context_on_id(context); if(!ptr) return NULL;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return NULL;
pPGPDATA p = (pPGPDATA) cpp_alloc_pdata(ptr);
- if( !p->pgpKeyID && !p->pgpKey ) { ptr->error = ERROR_NO_PGP_KEY; return NULL; }
+ if ( !p->pgpKeyID && !p->pgpKey ) { ptr->error = ERROR_NO_PGP_KEY; return NULL; }
// utf8 message: encrypt.
return pgp_encrypt(ptr, szPlainMsg);
@@ -254,13 +254,13 @@ LPSTR __cdecl pgp_encode(HANDLE context, LPCSTR szPlainMsg)
LPSTR __cdecl pgp_decode(HANDLE context, LPCSTR szEncMsg)
{
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return NULL;
+ if (!ptr) return NULL;
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = pgp_decrypt(ptr, szEncMsg);
if(szOldMsg) {
- if( !is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg) ) {
+ if ( !is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg) ) {
int slen = strlen(szOldMsg)+1;
LPWSTR wszMsg = (LPWSTR) alloca(slen*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, szOldMsg, -1, wszMsg, slen*sizeof(WCHAR));
@@ -284,11 +284,11 @@ int __cdecl pgp_set_priv_key(LPCSTR LocalKey)
int __cdecl pgp_set_key(HANDLE context, LPCSTR RemoteKey)
{
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pPGPDATA p = (pPGPDATA) cpp_alloc_pdata(ptr);
ptr->error = ERROR_NONE;
-// if(!p_pgp_check_key(RemoteKey)) return 0;
+// if (!p_pgp_check_key(RemoteKey)) return 0;
SAFE_FREE(p->pgpKey);
p->pgpKey = (PBYTE) strdup(RemoteKey);
@@ -299,7 +299,7 @@ int __cdecl pgp_set_key(HANDLE context, LPCSTR RemoteKey)
int __cdecl pgp_set_keyid(HANDLE context, PVOID RemoteKeyID)
{
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pPGPDATA p = (pPGPDATA) cpp_alloc_pdata(ptr);
ptr->error = ERROR_NONE;
diff --git a/plugins/CryptoPP/cpp_rsam.cpp b/plugins/CryptoPP/cpp_rsam.cpp
index 2cdd77b6e1..a40c11f4b6 100644
--- a/plugins/CryptoPP/cpp_rsam.cpp
+++ b/plugins/CryptoPP/cpp_rsam.cpp
@@ -53,7 +53,7 @@ int __cdecl rsa_init(pRSA_EXPORT* e, pRSA_IMPORT i) {
#endif
*e = &exp;
imp = i;
- if( !hRSA4096 ) {
+ if ( !hRSA4096 ) {
// create context for private rsa keys
hRSA4096 = (HANDLE) cpp_create_context(MODE_RSA_4096|MODE_PRIV_KEY);
pCNTX tmp = (pCNTX) hRSA4096;
@@ -77,7 +77,7 @@ int __cdecl rsa_done(void) {
pRSAPRIV rsa_gen_keys(HANDLE context) {
- if( context!=hRSA4096 ) return 0;
+ if ( context!=hRSA4096 ) return 0;
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_gen_keys: %d", context);
@@ -117,7 +117,7 @@ int __cdecl rsa_gen_keypair(short mode) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_gen_keypair: %d", mode);
#endif
- if( mode&MODE_RSA_4096 ) rsa_gen_keys(hRSA4096); // 4096
+ if ( mode&MODE_RSA_4096 ) rsa_gen_keys(hRSA4096); // 4096
return 1;
}
@@ -130,8 +130,8 @@ int __cdecl rsa_get_keypair(short mode, PBYTE privKey, int* privKeyLen, PBYTE pu
pCNTX ptr = get_context_on_id(hRSA4096);
pRSAPRIV r = (pRSAPRIV) ptr->pdata;
- *privKeyLen = r->priv_k.length(); if( privKey ) r->priv_k.copy((char*)privKey, *privKeyLen);
- *pubKeyLen = r->pub_k.length(); if( pubKey ) r->pub_k.copy((char*)pubKey, *pubKeyLen);
+ *privKeyLen = r->priv_k.length(); if ( privKey ) r->priv_k.copy((char*)privKey, *privKeyLen);
+ *pubKeyLen = r->pub_k.length(); if ( pubKey ) r->pub_k.copy((char*)pubKey, *pubKeyLen);
return 1;
}
@@ -144,8 +144,8 @@ int __cdecl rsa_get_keyhash(short mode, PBYTE privKey, int* privKeyLen, PBYTE pu
pCNTX ptr = get_context_on_id(hRSA4096);
pRSAPRIV r = (pRSAPRIV) ptr->pdata;
- if( privKey ) { *privKeyLen = r->priv_s.length(); r->priv_s.copy((char*)privKey, *privKeyLen); }
- if( pubKey ) { *pubKeyLen = r->pub_s.length(); r->pub_s.copy((char*)pubKey, *pubKeyLen); }
+ if ( privKey ) { *privKeyLen = r->priv_s.length(); r->priv_s.copy((char*)privKey, *privKeyLen); }
+ if ( pubKey ) { *pubKeyLen = r->pub_s.length(); r->pub_s.copy((char*)pubKey, *pubKeyLen); }
return 1;
}
@@ -158,11 +158,11 @@ int __cdecl rsa_set_keypair(short mode, PBYTE privKey, int privKeyLen) {
pCNTX ptr = get_context_on_id(hRSA4096);
pRSAPRIV r = (pRSAPRIV) ptr->pdata;
- if( privKey && privKeyLen ) {
+ if ( privKey && privKeyLen ) {
string priv;
priv.assign((char*)privKey, privKeyLen);
- if( mode & MODE_RSA_BER ) {
+ if ( mode & MODE_RSA_BER ) {
// old BER format
StringStore s(priv);
r->priv.BERDecode(s);
@@ -190,10 +190,10 @@ int __cdecl rsa_get_pubkey(HANDLE context, PBYTE pubKey, int* pubKeyLen) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_get_pubkey: %s", pubKey);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
- *pubKeyLen = p->pub_k.length(); if( pubKey ) p->pub_k.copy((char*)pubKey, *pubKeyLen);
+ *pubKeyLen = p->pub_k.length(); if ( pubKey ) p->pub_k.copy((char*)pubKey, *pubKeyLen);
return 1;
}
@@ -203,10 +203,10 @@ int __cdecl rsa_set_pubkey(HANDLE context, PBYTE pubKey, int pubKeyLen) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_set_pubkey: %s", pubKey);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
- if( pubKey && pubKeyLen ) {
+ if ( pubKey && pubKeyLen ) {
string pub;
pub.assign((char*)pubKey, pubKeyLen);
init_pub(p,pub);
@@ -226,7 +226,7 @@ void __cdecl rsa_set_timeout(int t) {
int __cdecl rsa_get_state(HANDLE context) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
return p->state;
@@ -241,7 +241,7 @@ int __cdecl rsa_get_hash(PBYTE pubKey, int pubKeyLen, PBYTE pubHash, int* pubHas
sig = hash(pubKey, pubKeyLen);
*pubHashLen = sig.length();
- if( pubHash ) sig.copy((char*)pubHash, *pubHashLen);
+ if ( pubHash ) sig.copy((char*)pubHash, *pubHashLen);
return 1;
}
@@ -251,7 +251,7 @@ int __cdecl rsa_connect(HANDLE context) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_connect: %08x", context);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state) return p->state;
pRSAPRIV r = rsa_get_priv(ptr);
@@ -273,11 +273,11 @@ int __cdecl rsa_disconnect(HANDLE context) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_disconnect: %08x", context);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
rsa_free( ptr ); // удалим трэд и очередь сообщений
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
- if( !p->state ) return 1;
+ if ( !p->state ) return 1;
PBYTE buffer=(PBYTE) alloca(RAND_SIZE);
GlobalRNG().GenerateBlock(buffer,RAND_SIZE);
@@ -294,7 +294,7 @@ int __cdecl rsa_disabled(HANDLE context) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_disabled: %08x", context);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
rsa_free( ptr ); // удалим трэд и очередь сообщений
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
@@ -310,24 +310,24 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_recv: %s", msg);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
pRSAPRIV r = rsa_get_priv(ptr);
rtrim(msg);
string buf = base64decode(msg);
- if( !buf.length() ) return 0;
+ if ( !buf.length() ) return 0;
string data; int type;
un_tlv(buf,type,data);
- if( type==-1 ) return 0;
+ if ( type==-1 ) return 0;
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_recv: %02x %d", type, p->state);
#endif
- if( type>0x10 && type<0xE0 ) // проверим тип сообщения (когда соединение еще не установлено)
- if( p->state==0 || p->state!=(type>>4) ) { // неверное состояние
+ if ( type>0x10 && type<0xE0 ) // проверим тип сообщения (когда соединение еще не установлено)
+ if ( p->state==0 || p->state!=(type>>4) ) { // неверное состояние
// шлем перерывание сессии
p->state=0; p->time=0;
rsa_free( ptr ); // удалим трэд и очередь сообщений
@@ -340,7 +340,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
case 0x00: // прерывание сессии по ошибке другой стороной
{
// если соединение установлено - ничего не делаем
- if( p->state == 0 || p->state == 7 ) return 0;
+ if ( p->state == 0 || p->state == 7 ) return 0;
// иначе сбрасываем текущее состояние
p->state=0; p->time=0;
imp->rsa_notify(context,-2); // сессия разорвана по ошибке другой стороной
@@ -359,7 +359,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
case 0x0D: // запрос паблика
case 0xD0: // ответ пабликом
{
- if( !p->event ) {
+ if ( !p->event ) {
p->event = CreateEvent(NULL,FALSE,FALSE,NULL);
unsigned int tID;
p->thread = (HANDLE) _beginthreadex(NULL, 0, sttConnectThread, (PVOID)context, 0, &tID);
@@ -376,7 +376,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
case 0x50: // получили криптотест, отправляем свой криптотест
{
string msg = decode_msg(p,data);
- if( !msg.length() ) {
+ if ( !msg.length() ) {
p->state=0; p->time=0;
null_msg(context,0x00,-type); // сессия разорвана по ошибке
return 0;
@@ -392,7 +392,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
case 0x60: // получили криптотест, сессия установлена
{
string msg = decode_msg(p,data);
- if( !msg.length() ) {
+ if ( !msg.length() ) {
p->state=0; p->time=0;
null_msg(context,0x00,-type); // сессия разорвана по ошибке
return 0;
@@ -406,7 +406,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
{
SAFE_FREE(ptr->tmp);
string msg = decode_msg(p,data);
- if( msg.length() ) {
+ if ( msg.length() ) {
ptr->tmp = (LPSTR) strdup(msg.c_str());
}
else {
@@ -419,7 +419,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
{
SAFE_FREE(ptr->tmp);
string msg = decode_rsa(p,r,data);
- if( msg.length() ) {
+ if ( msg.length() ) {
ptr->tmp = (LPSTR) strdup(msg.c_str());
}
else {
@@ -430,9 +430,9 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
case 0xF0: // разрыв соединения вручную
{
- if( p->state != 7 ) return 0;
+ if ( p->state != 7 ) return 0;
string msg = decode_msg(p,data);
- if( !msg.length() ) return 0;
+ if ( !msg.length() ) return 0;
p->state=0;
rsa_free( ptr ); // удалим трэд и очередь сообщений
imp->rsa_notify(context,-4); // соединение разорвано вручную другой стороной
@@ -447,7 +447,7 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
}
- if( p->state != 0 && p->state != 7 )
+ if ( p->state != 0 && p->state != 7 )
p->time = gettime() + timeout;
return 0;
@@ -455,14 +455,14 @@ LPSTR __cdecl rsa_recv(HANDLE context, LPCSTR msg) {
int __cdecl rsa_send(HANDLE context, LPCSTR msg) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state!=0 && p->state!=7) return 0;
- if( p->state == 7 ) // сессия установлена, шифруем AES и отправляем
+ if ( p->state == 7 ) // сессия установлена, шифруем AES и отправляем
inject_msg(context,0x70,encode_msg(1,p,string(msg)));
else
- if( p->state == 0 ) { // сессия установлена, отправляем RSA сообщение
- if( !p->pub_k.length() ) return 0;
+ if ( p->state == 0 ) { // сессия установлена, отправляем RSA сообщение
+ if ( !p->pub_k.length() ) return 0;
// есть паблик ключ - отправим сообщение
pRSAPRIV r = rsa_get_priv(ptr);
inject_msg(context,0xE0,encode_rsa(1,p,r,string(msg)));
@@ -517,7 +517,7 @@ string decode_msg(pRSADATA p, string& msg) {
cbcDecryptor.Put((PBYTE)ciphered.data(),ciphered.length());
cbcDecryptor.MessageEnd();
- if( sig == hash(zlib) ) {
+ if ( sig == hash(zlib) ) {
unciphered = (t1==1) ? cpp_zlibd(zlib) : zlib;
}
}
@@ -551,7 +551,7 @@ string decode_rsa(pRSADATA p, pRSAPRIV r, string& msg) {
string unciphered,zlib;
zlib = RSADecryptString(r->priv,ciphered);
- if( zlib.length() && RSAVerifyString(p->pub,zlib,sig) ) {
+ if ( zlib.length() && RSAVerifyString(p->pub,zlib,sig) ) {
unciphered = (t1==1) ? cpp_zlibd(zlib) : zlib;
}
return unciphered;
@@ -598,7 +598,7 @@ void init_priv(pRSAPRIV r, string& priv) {
}
}
- // if( !empty );
+ // if ( !empty );
r->pub_k = tlv(1,n)+tlv(2,e);
r->pub_s = hash(r->pub_k);
@@ -625,7 +625,7 @@ void init_pub(pRSADATA p, string& pub) {
}
}
- // if( !empty );
+ // if ( !empty );
p->pub.Initialize(BinaryToInteger(n),BinaryToInteger(e));
}
@@ -652,7 +652,7 @@ void rsa_timeout(HANDLE context, pRSADATA p) {
int __cdecl rsa_encrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state!=7) return 0;
try {
@@ -669,7 +669,7 @@ int __cdecl rsa_encrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) {
int __cdecl rsa_decrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) {
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state!=7) return 0;
try {
@@ -689,13 +689,13 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_recv_thread: %s", msg.c_str());
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
pRSAPRIV r = rsa_get_priv(ptr);
string data; int type;
un_tlv(msg,type,data);
- if( type==-1 ) return 0;
+ if ( type==-1 ) return 0;
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_recv_thread: %02x %d", type, p->state);
@@ -709,7 +709,7 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
int features; string sha1,sha2;
un_tlv(un_tlv(un_tlv(data,t[0],features),t[1],sha1),t[2],sha2);
BOOL lr = (p->pub_s==sha1); BOOL ll = (r->pub_s==sha2);
- switch( (lr<<4)|ll ){
+ switch( (lr<<4)|ll ) {
case 0x11: { // оба паблика совпали
inject_msg(context,0x21,gen_aes_key_iv(ptr->mode,p,r));
p->state=5;
@@ -734,13 +734,13 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
int features; string pub;
un_tlv(un_tlv(data,t[0],features),t[1],pub);
string sig = hash(pub);
- if( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
+ if ( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
p->state=0; p->time=0;
null_msg(context,0x00,-type); // сессия разорвана по ошибке
return 0;
}
init_pub(p,pub);
- if( p->state==0 ) { // timeout
+ if ( p->state==0 ) { // timeout
// rsa_connect(context);
return -1;
}
@@ -761,13 +761,13 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
int features; string pub;
un_tlv(un_tlv(data,t[0],features),t[1],pub);
string sig = hash(pub);
- if( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
+ if ( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
p->state=0; p->time=0;
null_msg(context,0x00,-type); // сессия разорвана по ошибке
return 0;
}
init_pub(p,pub);
- if( p->state==0 ) { // timeout
+ if ( p->state==0 ) { // timeout
// rsa_connect(context);
return -1;
}
@@ -781,13 +781,13 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
string pub;
un_tlv(data,t[0],pub);
string sig = hash(pub);
- if( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
+ if ( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
p->state=0; p->time=0;
null_msg(context,0x00,-type); // сессия разорвана по ошибке
return 0;
}
init_pub(p,pub);
- if( p->state==0 ) { // timeout
+ if ( p->state==0 ) { // timeout
// rsa_connect(context);
return -1;
}
@@ -800,7 +800,7 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
case 0x40:
{
string key = decode_rsa(p,r,data);
- if( !key.length() ) {
+ if ( !key.length() ) {
p->state=0; p->time=0;
null_msg(context,0x00,-type); // сессия разорвана по ошибке
return 0;
@@ -818,16 +818,16 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
{
int features; string pub,sha;
un_tlv(un_tlv(un_tlv(data,t[0],features),t[1],pub),t[2],sha);
- if( p->pub_k!=pub ) { // пришел новый паблик
+ if ( p->pub_k!=pub ) { // пришел новый паблик
string sig = hash(pub);
- if( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
+ if ( !imp->rsa_check_pub(context,(PBYTE)pub.data(),pub.length(),(PBYTE)sig.data(),sig.length()) ) {
p->state=0; p->time=0;
null_msg(context,0x00,-type); // сессия разорвана по ошибке
return 0;
}
init_pub(p,pub);
}
- if( type == 0x0D ) { // нужно отправить мой паблик
+ if ( type == 0x0D ) { // нужно отправить мой паблик
inject_msg(context,0xD0,tlv(0,features)+tlv(1,r->pub_k)+tlv(2,p->pub_s));
}
p->state=0; p->time=0;
@@ -835,7 +835,7 @@ int __cdecl rsa_recv_thread(HANDLE context, string& msg) {
}
- if( p->state != 0 && p->state != 7 )
+ if ( p->state != 0 && p->state != 7 )
p->time = gettime() + timeout;
return 1;
@@ -855,7 +855,7 @@ void rsa_alloc( pCNTX ptr ) {
void rsa_free( pCNTX ptr ) {
pRSADATA p = (pRSADATA) ptr->pdata;
- if( p && p->event ) {
+ if ( p && p->event ) {
p->thread_exit = 2; // отпускаем поток в свободное плавание
SetEvent( p->event );
rsa_alloc(ptr);
@@ -864,7 +864,7 @@ void rsa_free( pCNTX ptr ) {
void rsa_free_thread( pRSADATA p ) {
- if( p->event ) {
+ if ( p->event ) {
p->thread_exit = 1;
SetEvent( p->event );
// ждем завершения потока
@@ -893,7 +893,7 @@ unsigned __stdcall sttConnectThread( LPVOID arg ) {
HANDLE context = (HANDLE) arg;
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
while(1) {
@@ -901,8 +901,8 @@ unsigned __stdcall sttConnectThread( LPVOID arg ) {
Sent_NetLog("sttConnectThread: WaitForSingleObject");
#endif
WaitForSingleObject(p->event, INFINITE); // dwMsec rc==WAIT_TIMEOUT
- if( p->thread_exit == 1 ) return 0;
- if( p->thread_exit == 2 ) {
+ if ( p->thread_exit == 1 ) return 0;
+ if ( p->thread_exit == 2 ) {
// мы в свободном плавании - освободим память и завершим трэд
CloseHandle( p->thread );
CloseHandle( p->event );
@@ -913,7 +913,7 @@ unsigned __stdcall sttConnectThread( LPVOID arg ) {
// дождались сообщения в очереди
while( !p->thread_exit && p->queue && !p->queue->empty() ) {
// обработаем сообщения из очереди
- if( rsa_recv_thread(context, p->queue->front()) == -1 ) {
+ if ( rsa_recv_thread(context, p->queue->front()) == -1 ) {
// очистить очередь
clear_queue(p);
break;
@@ -933,14 +933,14 @@ int __cdecl rsa_export_keypair(short mode, LPSTR privKey, LPSTR pubKey, LPSTR pa
pCNTX ptr = get_context_on_id(hRSA4096);
pRSAPRIV r = (pRSAPRIV) ptr->pdata;
- if( pubKey ) {
+ if ( pubKey ) {
string pub;
pub = tlv(3,r->pub_k) + tlv(4,r->pub_s);
pub = pub_beg + crlf + add_delim(base64encode(pub),crlf,65) + pub_end + crlf;
strcpy(pubKey, pub.c_str());
}
- if( privKey && passPhrase ) {
+ if ( privKey && passPhrase ) {
string key = hash256(passPhrase);
string iv = hash256(key);
string priv = pad256(r->priv_k);
@@ -976,7 +976,7 @@ int __cdecl rsa_import_keypair(short mode, LPSTR privKey, LPSTR passPhrase) {
pCNTX ptr = get_context_on_id(hRSA4096);
pRSAPRIV r = (pRSAPRIV) ptr->pdata;
- if( !passPhrase ) return 0;
+ if ( !passPhrase ) return 0;
string priv;
u_int found;
@@ -985,13 +985,13 @@ int __cdecl rsa_import_keypair(short mode, LPSTR privKey, LPSTR passPhrase) {
del_delim(priv,crlf);
found = priv.find(priv_beg);
- if( found != string::npos ) {
+ if ( found != string::npos ) {
priv = priv.substr(found+priv_beg.length());
found = priv.find(priv_end);
- if( found != string::npos ) {
+ if ( found != string::npos ) {
priv = base64decode(priv.substr(0,found));
TLV k(priv);
- if( k.exist(1) && k.exist(2) && hash(k.get(1)) == k.get(2) ) {
+ if ( k.exist(1) && k.exist(2) && hash(k.get(1)) == k.get(2) ) {
priv = k.get(1);
string key = hash256(passPhrase);
@@ -1025,10 +1025,10 @@ int __cdecl rsa_export_pubkey(HANDLE context, LPSTR pubKey) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_export_pubkey: %08x", context);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
- if( !p->pub_k.length() || !pubKey ) return 0;
+ if ( !p->pub_k.length() || !pubKey ) return 0;
string pub;
pub = tlv(3,p->pub_k) + tlv(4,p->pub_s);
@@ -1043,10 +1043,10 @@ int __cdecl rsa_import_pubkey(HANDLE context, LPSTR pubKey) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("rsa_import_pubkey: %08x", context);
#endif
- pCNTX ptr = get_context_on_id(context); if(!ptr) return 0;
+ pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr);
- if( !pubKey ) return 0;
+ if ( !pubKey ) return 0;
string pub;
u_int found;
@@ -1055,13 +1055,13 @@ int __cdecl rsa_import_pubkey(HANDLE context, LPSTR pubKey) {
del_delim(pub,crlf);
found = pub.find(pub_beg);
- if( found != string::npos ) {
+ if ( found != string::npos ) {
pub = pub.substr(found+pub_beg.length());
found = pub.find(pub_end);
- if( found != string::npos ) {
+ if ( found != string::npos ) {
pub = base64decode(pub.substr(0,found));
TLV k(pub);
- if( k.exist(3) && k.exist(4) && hash(k.get(3)) == k.get(4) ) {
+ if ( k.exist(3) && k.exist(4) && hash(k.get(3)) == k.get(4) ) {
init_pub(p,k.get(3));
return 1;
}
diff --git a/plugins/CryptoPP/cpp_rsau.cpp b/plugins/CryptoPP/cpp_rsau.cpp
index 6644e715fa..be8e499ed1 100644
--- a/plugins/CryptoPP/cpp_rsau.cpp
+++ b/plugins/CryptoPP/cpp_rsau.cpp
@@ -6,14 +6,14 @@ const string padding = "PADDING!PADDING!PADDING!PADDING!"; // 256 bit
string pad256(string& str) {
string out = str;
int pad = out.length() % 32;
- if( pad ) { // ­ ¤® ўла®ў­пвм ­  256 ЎЁв
- if( pad>3 ) {
+ if ( pad ) { // ­ ¤® ўла®ў­пвм ­  256 ЎЁв
+ if ( pad>3 ) {
out += tlv(0,padding.substr(0,32-3-pad));
}
else {
- if( pad==3 ) out += string("\0\0\0");
+ if ( pad==3 ) out += string("\0\0\0");
else
- if( pad==2 ) out += string("\0\0");
+ if ( pad==2 ) out += string("\0\0");
else out += string("\0");
}
}
@@ -23,7 +23,7 @@ string pad256(string& str) {
string& add_delim(string& str, const string& del, int len) {
string val;
- for( u_int i=0; i<str.length(); i+=len ) {
+ for ( u_int i=0; i<str.length(); i+=len ) {
val += str.substr(i,len) + del;
}
str = val;
@@ -33,8 +33,8 @@ string& add_delim(string& str, const string& del, int len) {
string& del_delim(string& str, const string& del) {
string val;
- for( u_int i=0; i<str.length(); i++ ) {
- if( del.find(str[i]) == string::npos )
+ for ( u_int i=0; i<str.length(); i++ ) {
+ if ( del.find(str[i]) == string::npos )
val += str[i];
}
str = val;
@@ -66,17 +66,17 @@ string tlv(int t, int v) {
string& un_tlv(string& b, int& t, string& v) {
string r; v = r;
- if( b.length() > 3 ) {
+ if ( b.length() > 3 ) {
t = 0;
b.copy((char*)&t,3);
u_int l = t>>8;
t &= 0xFF;
- if( b.length() >= 3+l ) {
+ if ( b.length() >= 3+l ) {
v = b.substr(3,l);
r = b.substr(3+l);
}
}
- if( !v.length() ) {
+ if ( !v.length() ) {
t = -1;
}
b = r;
@@ -95,7 +95,7 @@ string& un_tlv(string& b, int& t, int& v) {
int str2int(string& s) {
int v = 0;
- if( s.length()<=sizeof(int) )
+ if ( s.length()<=sizeof(int) )
s.copy((char*)&v,s.length());
return v;
}
diff --git a/plugins/CryptoPP/cpp_rsau.h b/plugins/CryptoPP/cpp_rsau.h
index adb017c18b..ae41e64def 100644
--- a/plugins/CryptoPP/cpp_rsau.h
+++ b/plugins/CryptoPP/cpp_rsau.h
@@ -12,7 +12,7 @@ public:
string encode() {
map<u_char,string>::const_iterator i;
string b;
- for( i=data.begin(); i!=data.end(); ++i ) {
+ for ( i=data.begin(); i!=data.end(); ++i ) {
b += tlv(i->first,i->second);
}
return b;
@@ -23,7 +23,7 @@ public:
string r = b;
while( r.length() ) {
t = un_tlv(r,v);
- if( t==-1 ) {
+ if ( t==-1 ) {
break;
}
data[t] = v;
@@ -46,16 +46,16 @@ private:
u_char un_tlv(string& b, string& v) {
string r; v = r;
u_int t = 0;
- if( b.length() > 3 ) {
+ if ( b.length() > 3 ) {
b.copy((char*)&t,3);
u_int l = t>>8;
t &= 0xFF;
- if( b.length() >= 3+l ) {
+ if ( b.length() >= 3+l ) {
v = b.substr(3,l);
r = b.substr(3+l);
}
}
- if( !v.length() ) {
+ if ( !v.length() ) {
return -1;
}
b = r;
diff --git a/plugins/CryptoPP/cpp_svcs.cpp b/plugins/CryptoPP/cpp_svcs.cpp
index 50a3ee1a54..e03800648d 100644
--- a/plugins/CryptoPP/cpp_svcs.cpp
+++ b/plugins/CryptoPP/cpp_svcs.cpp
@@ -159,9 +159,9 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) {
LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg) {
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return NULL;
+ if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
- if(!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) msg;
@@ -187,9 +187,9 @@ LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg) {
LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg) {
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return NULL;
+ if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
- if(!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) msg;
@@ -215,9 +215,9 @@ LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg) {
LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg) {
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return NULL;
+ if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
- if(!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) msg;
@@ -242,9 +242,9 @@ LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg) {
LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg) {
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return NULL;
+ if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
- if(!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = cpp_decrypt(ptr, szEncMsg);
@@ -278,9 +278,9 @@ LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg) {
LPSTR __cdecl cpp_decodeU(HANDLE context, LPCSTR szEncMsg) {
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return NULL;
+ if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
- if(!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
+ if (!p->KeyX) { ptr->error = ERROR_NO_KEYX; return NULL; }
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = cpp_decrypt(ptr, szEncMsg);
@@ -307,9 +307,9 @@ LPSTR __cdecl cpp_decodeU(HANDLE context, LPCSTR szEncMsg) {
int __cdecl cpp_encrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) {
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return 0;
+ if (!ptr) return 0;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
- if(!p->KeyX) return 0;
+ if (!p->KeyX) return 0;
try{
CBC_Mode<AES>::Encryption enc(p->KeyX,Tiger::DIGESTSIZE,IV);
@@ -326,9 +326,9 @@ int __cdecl cpp_encrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) {
int __cdecl cpp_decrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) {
pCNTX ptr = get_context_on_id(context);
- if(!ptr) return 0;
+ if (!ptr) return 0;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
- if(!p->KeyX) return 0;
+ if (!p->KeyX) return 0;
try{
CBC_Mode<AES>::Decryption dec(p->KeyX,Tiger::DIGESTSIZE,IV);
diff --git a/plugins/CryptoPP/crypto/crc.cpp b/plugins/CryptoPP/crypto/crc.cpp
index 3a2cb4fee3..a27f891ba4 100644
--- a/plugins/CryptoPP/crypto/crc.cpp
+++ b/plugins/CryptoPP/crypto/crc.cpp
@@ -126,7 +126,7 @@ void CRC32::Update(const byte *s, size_t n)
{
word32 crc = m_crc;
- for(; !IsAligned<word32>(s) && n > 0; n--)
+ for (; !IsAligned<word32>(s) && n > 0; n--)
crc = m_tab[CRC32_INDEX(crc) ^ *s++] ^ CRC32_SHIFTED(crc);
while (n >= 4)
diff --git a/plugins/CryptoPP/crypto/des.cpp b/plugins/CryptoPP/crypto/des.cpp
index 5002f26588..69c4ba066d 100644
--- a/plugins/CryptoPP/crypto/des.cpp
+++ b/plugins/CryptoPP/crypto/des.cpp
@@ -292,9 +292,9 @@ void RawDES::RawSetKey(CipherDir dir, const byte *key)
for (j=0; j<56; j++) /* rotate pc1 the right amount */
pcr[j] = pc1m[(l=j+totrot[i])<(j<28? 28 : 56) ? l: l-28];
/* rotate left and right halves independently */
- for (j=0; j<48; j++){ /* select bits individually */
+ for (j=0; j<48; j++) { /* select bits individually */
/* check bit that goes to ks[j] */
- if (pcr[pc2[j]-1]){
+ if (pcr[pc2[j]-1]) {
/* mask it in if it's there */
l= j % 6;
ks[j/6] |= bytebit[l] >> 2;
diff --git a/plugins/CryptoPP/crypto/gzip.cpp b/plugins/CryptoPP/crypto/gzip.cpp
index c9f75584de..3a52529dc6 100644
--- a/plugins/CryptoPP/crypto/gzip.cpp
+++ b/plugins/CryptoPP/crypto/gzip.cpp
@@ -65,12 +65,12 @@ void Gunzip::ProcessPrestreamHeader()
if (flags & FILENAME) // skip filename
do
- if(!m_inQueue.Get(b)) throw HeaderErr();
+ if (!m_inQueue.Get(b)) throw HeaderErr();
while (b);
if (flags & COMMENTS) // skip comments
do
- if(!m_inQueue.Get(b)) throw HeaderErr();
+ if (!m_inQueue.Get(b)) throw HeaderErr();
while (b);
}
diff --git a/plugins/CryptoPP/crypto/mars.cpp b/plugins/CryptoPP/crypto/mars.cpp
index 74aad3a9b9..6e2fe9d94f 100644
--- a/plugins/CryptoPP/crypto/mars.cpp
+++ b/plugins/CryptoPP/crypto/mars.cpp
@@ -28,7 +28,7 @@ static word32 gen_mask(word32 x)
m = (~x ^ (x >> 1)) & 0x7fffffff;
m &= (m >> 1) & (m >> 2); m &= (m >> 3) & (m >> 6);
- if(!m)
+ if (!m)
return 0;
m <<= 1; m |= (m << 1); m |= (m << 2); m |= (m << 4);
diff --git a/plugins/CryptoPP/crypto/osrng.cpp b/plugins/CryptoPP/crypto/osrng.cpp
index 6ad488c56f..ff7f034de7 100644
--- a/plugins/CryptoPP/crypto/osrng.cpp
+++ b/plugins/CryptoPP/crypto/osrng.cpp
@@ -47,7 +47,7 @@ OS_RNG_Err::OS_RNG_Err(const std::string &operation)
MicrosoftCryptoProvider::MicrosoftCryptoProvider()
{
- if(!CryptAcquireContext(&m_hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+ if (!CryptAcquireContext(&m_hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
throw OS_RNG_Err("CryptAcquireContext");
}
diff --git a/plugins/CryptoPP/main.cpp b/plugins/CryptoPP/main.cpp
index 69f30cc1ff..042086d4b3 100644
--- a/plugins/CryptoPP/main.cpp
+++ b/plugins/CryptoPP/main.cpp
@@ -5,7 +5,7 @@ int hLangpack;
// dllmain
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) {
g_hInst = hInst;
- if( dwReason == DLL_PROCESS_ATTACH ) {
+ if ( dwReason == DLL_PROCESS_ATTACH ) {
{
char temp[MAX_PATH];
GetTempPath(sizeof(temp),temp);