diff options
Diffstat (limited to 'plugins/CryptoPP')
-rw-r--r-- | plugins/CryptoPP/base16.cpp | 2 | ||||
-rw-r--r-- | plugins/CryptoPP/base64.cpp | 12 | ||||
-rw-r--r-- | plugins/CryptoPP/commonheaders.cpp | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/cpp_cntx.cpp | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/cpp_gpgw.cpp | 8 | ||||
-rw-r--r-- | plugins/CryptoPP/cpp_keys.cpp | 14 | ||||
-rw-r--r-- | plugins/CryptoPP/cpp_pgpw.cpp | 12 | ||||
-rw-r--r-- | plugins/CryptoPP/cpp_rsam.cpp | 10 | ||||
-rw-r--r-- | plugins/CryptoPP/cpp_svcs.cpp | 107 | ||||
-rw-r--r-- | plugins/CryptoPP/dllloader.cpp | 4 | ||||
-rw-r--r-- | plugins/CryptoPP/main.cpp | 2 | ||||
-rw-r--r-- | plugins/CryptoPP/mmi.cpp | 6 |
12 files changed, 85 insertions, 100 deletions
diff --git a/plugins/CryptoPP/base16.cpp b/plugins/CryptoPP/base16.cpp index db838e498d..110eea0a9c 100644 --- a/plugins/CryptoPP/base16.cpp +++ b/plugins/CryptoPP/base16.cpp @@ -31,7 +31,7 @@ char *base16decode(const char *inBuffer, int *count) { }
while(*count>1){
BYTE c0,c1;
- if(big_endian) {
+ if (big_endian) {
c1 = decode16(*--inBuffer);
c0 = decode16(*--inBuffer);
}
diff --git a/plugins/CryptoPP/base64.cpp b/plugins/CryptoPP/base64.cpp index 70c3d672c7..1a752bc507 100644 --- a/plugins/CryptoPP/base64.cpp +++ b/plugins/CryptoPP/base64.cpp @@ -25,11 +25,11 @@ char *base64encode(const char *inBuffer, const int count) { outBuffer[destIndex++] = encode64(inBufferPtr[srcIndex++] & 0x3F);
}
- if(remainder == 2) {
+ if (remainder == 2) {
outBuffer[destIndex - 1] = BPAD;
outBuffer[destIndex - 2] = encode64((inBufferPtr[srcIndex - 2] << 2) & 0x3C);
}
- else if(remainder == 1) {
+ else if (remainder == 1) {
outBuffer[destIndex - 2] = outBuffer[destIndex - 1] = BPAD;
outBuffer[destIndex - 3] = encode64((inBufferPtr[srcIndex - 3] << 4) & 0x30);
}
@@ -70,9 +70,9 @@ char *base64decode(const char *inBuffer, int *count) { const int delta = *count - srcIndex;
c0 = decode64(inBuffer[srcIndex++]);
c1 = decode64(inBuffer[srcIndex++]);
- if(delta > 2) {
+ if (delta > 2) {
c2 = decode64(inBuffer[srcIndex++]);
- if(delta > 3)
+ if (delta > 3)
c3 = decode64(inBuffer[srcIndex++]);
}
if ((c0 | c1 | c2 | c3) == BERR) {
@@ -80,9 +80,9 @@ char *base64decode(const char *inBuffer, int *count) { return(NULL);
}
outBuffer[destIndex++] = (c0 << 2) | (c1 >> 4);
- if(delta > 2) {
+ if (delta > 2) {
outBuffer[destIndex++] = (c1 << 4) | (c2 >> 2);
- if(delta > 3 )
+ if (delta > 3 )
outBuffer[destIndex++] = (c2 << 6) | (c3);
}
}
diff --git a/plugins/CryptoPP/commonheaders.cpp b/plugins/CryptoPP/commonheaders.cpp index b1d055eb59..426b7ada54 100644 --- a/plugins/CryptoPP/commonheaders.cpp +++ b/plugins/CryptoPP/commonheaders.cpp @@ -89,7 +89,7 @@ void InitNetlib() { }
void DeinitNetlib() {
- if(hNetlibUser)
+ if (hNetlibUser)
CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0);
}
@@ -101,7 +101,7 @@ int Sent_NetLog(const char *fmt,...) va_start(va,fmt);
mir_vsnprintf(szText,sizeof(szText),fmt,va);
va_end(va);
- if(hNetlibUser)
+ if (hNetlibUser)
return CallService(MS_NETLIB_LOG,(WPARAM)hNetlibUser,(LPARAM)szText);
return 0;
}
diff --git a/plugins/CryptoPP/cpp_cntx.cpp b/plugins/CryptoPP/cpp_cntx.cpp index fe3d5c616f..72c35dcc96 100644 --- a/plugins/CryptoPP/cpp_cntx.cpp +++ b/plugins/CryptoPP/cpp_cntx.cpp @@ -71,7 +71,7 @@ HANDLE __cdecl cpp_create_context(int mode) { void __cdecl cpp_delete_context(HANDLE context) {
pCNTX tmp = get_context_on_id(context);
- if(tmp) { // помечаем на удаление
+ if (tmp) { // помечаем на удаление
tmp->deleted = gettime()+10; // будет удален через 10 секунд
}
}
@@ -81,7 +81,7 @@ void __cdecl cpp_delete_context(HANDLE context) { void __cdecl cpp_reset_context(HANDLE context) {
pCNTX tmp = get_context_on_id(context);
- if(tmp) cpp_free_keys(tmp);
+ if (tmp) cpp_free_keys(tmp);
}
diff --git a/plugins/CryptoPP/cpp_gpgw.cpp b/plugins/CryptoPP/cpp_gpgw.cpp index 223280590f..5107b27ac7 100644 --- a/plugins/CryptoPP/cpp_gpgw.cpp +++ b/plugins/CryptoPP/cpp_gpgw.cpp @@ -125,7 +125,7 @@ int __cdecl gpg_init() if ( isVista ) load_gpg_dll(hgpg);
else load_gpg_mem(hgpg);
r = p_gpg_init();
- if(r) {
+ if (r) {
return r;
}
if ( isVista ) {
@@ -147,7 +147,7 @@ int __cdecl gpg_init() int __cdecl gpg_done()
{
int r = 0;
- if(hgpg) {
+ if (hgpg) {
r = p_gpg_done();
if ( isVista ) {
FreeLibrary(hgpg);
@@ -218,7 +218,7 @@ LPSTR __cdecl gpg_decrypt(pCNTX ptr, LPCSTR szEncMsg) LPSTR szPlainMsg = p_gpg_decrypt(szEncMsg);
/* if (!szPlainMsg) {
ptr = get_context_on_id(hPGPPRIV); // find private pgp keys
- if(ptr && ptr->pgpKey)
+ if (ptr && ptr->pgpKey)
szPlainMsg = p_gpg_decrypt_key(szEncMsg,(LPCSTR)ptr->pgpKey);
if (!szPlainMsg) return NULL;
}*/
@@ -259,7 +259,7 @@ LPSTR __cdecl gpg_decode(HANDLE context, LPCSTR szEncMsg) LPSTR szNewMsg = NULL;
LPSTR szOldMsg = gpg_decrypt(ptr, szEncMsg);
- if(szOldMsg) {
+ if (szOldMsg) {
if ( !is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg) ) {
int slen = strlen(szOldMsg)+1;
LPWSTR wszMsg = (LPWSTR) alloca(slen*sizeof(WCHAR));
diff --git a/plugins/CryptoPP/cpp_keys.cpp b/plugins/CryptoPP/cpp_keys.cpp index 16e4e0d281..b21da13ada 100644 --- a/plugins/CryptoPP/cpp_keys.cpp +++ b/plugins/CryptoPP/cpp_keys.cpp @@ -10,10 +10,10 @@ LPSTR __cdecl cpp_init_keya(HANDLE context, int features) { pSIMDATA p = (pSIMDATA) cpp_alloc_pdata(ptr);
int send_features = FEATURES;
- if(p->KeyP) send_features |= FEATURES_PSK;
+ if (p->KeyP) send_features |= FEATURES_PSK;
SAFE_DELETE(p->dh);
- if(features & FEATURES_NEWPG) {
+ if (features & FEATURES_NEWPG) {
Integer p0("0x865734026113B4DF0082CED84C197718516088FBDA406CFDFD7F033694E11E46F01C8F01E0E5AE6B09F6284691C7DD30A5BA8A74BA4B780198624B84BC8DAF6E0DFF874C0440ABB5C043C82E9E9C9E6F1A470B6A2A6BCEAC9460C43B1BB1331DF0FFD898DB74D22E8A71DB2659F1B0F52F337718D233DED611DA25AEAA90F3BE0C42FA9E541D0487DF58A77E2F44D295AD0C54C369CE260C969CA12F690EAAFAEEF8676C631AF29A3DE3389D3000B94EFA775E31FCA879AEB00A4D05EEF50D4C084A049EB12EF4CDFBD48E36B29CEAF8978D535D6C70BB274D1FEA02ABD521D2EF482A76326C17AF597FCB9B8BF37D9110E22AB0746D6A9779DF5133822E3F15");
Integer q0("0xF1515160E1BFC7636338C13AD5BA775318E287147A1F96B73CF0FB4D97EFFB9D1FCDCF31AB9D92C4F49C9F8D50F06E697D2313E2EBAC7781312A51F458D66FFC687960CAA86BDF150A36ED53D79FBDB4F501FD25E37C181B45F9555D7F1C6124CAB29A822AD1E7BF5DA93C2FDB12A61919B5E5359793CBB16E71516919040A7F");
Integer g0("0x434158F2FF2CF667E3CC1A707770DDE7B56048F6C5005473C6DC4A5E3FC490667F2908C44F9ADC2071EB8A8A1EC6AD6901CDAAAFE806626E3F4C5E69D4FCBF9DF1B67D574DC61C687C4BEF3ACF77A7256752F4D3A7EAEEE5874ED4912AB10C5B122A24E698B14CAC3E0FD006E0DB02714E028AECCA25BAB9DDCA2CF6405E862B403C61BC381D64B46BD96D3FEFBE22B7497FCBDA2B49C840C1B2853502A5216B036F83D2EAD8F835B603FC5BA1EFB816C7634915B1D43963FDD1B1ED626F48CCF8F152392E4693D38C566016708FA9E9598AECF95A8B067212669247552418E538A706564F855D3D5D50717D356259A20D8FD0C6B2A9FCC045D3F7AED1E857C5");
@@ -42,7 +42,7 @@ LPSTR __cdecl cpp_init_keya(HANDLE context, int features) { p->KeyA = (PBYTE) malloc(KEYSIZE);
memcpy(p->KeyA,priv1,KEYSIZE);
- if(p->KeyP) {
+ if (p->KeyP) {
// encrypt PUBLIC use PSK
string ciphered;
CFB_Mode<AES>::Encryption enc(p->KeyP,Tiger::DIGESTSIZE,IV);
@@ -58,7 +58,7 @@ LPSTR __cdecl cpp_init_keya(HANDLE context, int features) { memcpy((PVOID)&publ1[KEYSIZE],(PVOID)&send_features,2);
SAFE_FREE(ptr->tmp);
- if(ptr->mode & MODE_BASE64 || features & FEATURES_NEWPG)
+ if (ptr->mode & MODE_BASE64 || features & FEATURES_NEWPG)
ptr->tmp = base64encode((LPSTR)&publ1,KEYSIZE+2);
else
ptr->tmp = base16encode((LPSTR)&publ1,KEYSIZE+2);
@@ -91,10 +91,10 @@ int __cdecl cpp_init_keyb(HANDLE context, LPCSTR key) { return 0;
}
- if(clen==KEYSIZE+2)
+ if (clen==KEYSIZE+2)
memcpy((PVOID)&ptr->features,(PVOID)(pub_binary+KEYSIZE),2);
- if(p->KeyP) {
+ if (p->KeyP) {
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");
@@ -124,7 +124,7 @@ int __cdecl cpp_init_keyb(HANDLE context, LPCSTR key) { SAFE_FREE(p->KeyB);
p->KeyB = (PBYTE) pub_binary;
- if(p->PubA && memcmp(p->PubA,p->KeyB,KEYSIZE)==0) {
+ if (p->PubA && memcmp(p->PubA,p->KeyB,KEYSIZE)==0) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("cpp_init_keyb: error bad_keyb keya==keyb");
#endif
diff --git a/plugins/CryptoPP/cpp_pgpw.cpp b/plugins/CryptoPP/cpp_pgpw.cpp index e8f9f98ab4..fa20560f94 100644 --- a/plugins/CryptoPP/cpp_pgpw.cpp +++ b/plugins/CryptoPP/cpp_pgpw.cpp @@ -115,7 +115,7 @@ BOOL load_pgp_sdk(int type, int id) if ( isVista ) load_pgpsdk_dll(hpgpsdk);
else load_pgpsdk_mem(hpgpsdk);
r = p_pgp_init();
- if(r) {
+ if (r) {
pgpVer = p_pgp_get_version();
return r;
}
@@ -157,7 +157,7 @@ int __cdecl pgp_done() {
int r = 0;
pgpVer = 0;
- if(hpgpsdk) {
+ if (hpgpsdk) {
r = p_pgp_done();
if ( isVista ) {
FreeLibrary(hpgpsdk);
@@ -204,7 +204,7 @@ LPSTR __cdecl pgp_encrypt(pCNTX ptr, LPCSTR szPlainMsg) SAFE_FREE(ptr->tmp);
LPSTR szEncMsg;
- if(p->pgpKey)
+ if (p->pgpKey)
szEncMsg = p_pgp_encrypt_key(szPlainMsg,(LPCSTR)p->pgpKey);
else
szEncMsg = p_pgp_encrypt_keydb(szPlainMsg,p->pgpKeyID);
@@ -225,9 +225,9 @@ LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg) LPSTR szPlainMsg = p_pgp_decrypt_keydb(szEncMsg);
if (!szPlainMsg) {
ptr = get_context_on_id(hPGPPRIV); // find private pgp keys
- if(ptr) {
+ if (ptr) {
pPGPDATA p = (pPGPDATA) ptr->pdata;
- if(p->pgpKey)
+ if (p->pgpKey)
szPlainMsg = p_pgp_decrypt_key(szEncMsg,(LPCSTR)p->pgpKey);
}
if (!szPlainMsg) return NULL;
@@ -259,7 +259,7 @@ LPSTR __cdecl pgp_decode(HANDLE context, LPCSTR szEncMsg) LPSTR szNewMsg = NULL;
LPSTR szOldMsg = pgp_decrypt(ptr, szEncMsg);
- if(szOldMsg) {
+ if (szOldMsg) {
if ( !is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg) ) {
int slen = strlen(szOldMsg)+1;
LPWSTR wszMsg = (LPWSTR) alloca(slen*sizeof(WCHAR));
diff --git a/plugins/CryptoPP/cpp_rsam.cpp b/plugins/CryptoPP/cpp_rsam.cpp index f4fce6c807..5cfdd824ed 100644 --- a/plugins/CryptoPP/cpp_rsam.cpp +++ b/plugins/CryptoPP/cpp_rsam.cpp @@ -252,10 +252,10 @@ int __cdecl rsa_connect(HANDLE context) { Sent_NetLog("rsa_connect: %08x", context);
#endif
pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
- pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state) return p->state;
+ pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if (p->state) return p->state;
pRSAPRIV r = rsa_get_priv(ptr);
- if(ptr->mode&MODE_RSA_ONLY) {
+ if (ptr->mode&MODE_RSA_ONLY) {
inject_msg(context,0x0D,tlv(0,0)+tlv(1,r->pub_k)+tlv(2,p->pub_s));
p->state = 0x0D;
}
@@ -456,7 +456,7 @@ 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;
- pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state!=0 && p->state!=7) return 0;
+ pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if (p->state!=0 && p->state!=7) return 0;
if ( p->state == 7 ) // сессия установлена, шифруем AES и отправляем
inject_msg(context,0x70,encode_msg(1,p,string(msg)));
@@ -653,7 +653,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;
- pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state!=7) return 0;
+ pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if (p->state!=7) return 0;
try {
CBC_Mode<AES>::Encryption enc((PBYTE)p->aes_k.data(),p->aes_k.length(),(PBYTE)p->aes_v.data());
@@ -670,7 +670,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;
- pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if(p->state!=7) return 0;
+ pRSADATA p = (pRSADATA) cpp_alloc_pdata(ptr); if (p->state!=7) return 0;
try {
CBC_Mode<AES>::Decryption dec((PBYTE)p->aes_k.data(),p->aes_k.length(),(PBYTE)p->aes_v.data());
diff --git a/plugins/CryptoPP/cpp_svcs.cpp b/plugins/CryptoPP/cpp_svcs.cpp index e03800648d..7e97735540 100644 --- a/plugins/CryptoPP/cpp_svcs.cpp +++ b/plugins/CryptoPP/cpp_svcs.cpp @@ -4,9 +4,9 @@ const unsigned char IV[] = "SIMhell@MIRANDA!"; // encrypt string using KeyX, return encoded string as ASCII or NULL
-LPSTR __cdecl cpp_encrypt(pCNTX ptr, LPCSTR szPlainMsg) {
-
- ptr->error = ERROR_NONE;
+LPSTR __cdecl cpp_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
+{
+ ptr->error = ERROR_NONE;
pSIMDATA p = (pSIMDATA) ptr->pdata;
BYTE dataflag = 0;
@@ -14,19 +14,18 @@ LPSTR __cdecl cpp_encrypt(pCNTX ptr, LPCSTR szPlainMsg) { slen = strlen(szPlainMsg);
LPSTR szMsg;
- if(ptr->features & FEATURES_GZIP) {
+ if (ptr->features & FEATURES_GZIP) {
szMsg = (LPSTR) cpp_gzip((BYTE*)szPlainMsg,slen,clen);
- if(clen>=slen) {
- free(szMsg);
- szMsg = _strdup(szPlainMsg);
+ if (clen>=slen) {
+ free(szMsg);
+ szMsg = _strdup(szPlainMsg);
}
else {
- slen = clen;
- dataflag |= DATA_GZIP;
+ slen = clen;
+ dataflag |= DATA_GZIP;
}
}
- else
- szMsg = _strdup(szPlainMsg);
+ else szMsg = _strdup(szPlainMsg);
string ciphered;
@@ -39,33 +38,31 @@ LPSTR __cdecl cpp_encrypt(pCNTX ptr, LPCSTR szPlainMsg) { free(szMsg);
clen = (int) ciphered.length();
- if(ptr->features & FEATURES_CRC32) {
+ if (ptr->features & FEATURES_CRC32) {
BYTE crc32[CRC32::DIGESTSIZE];
memset(crc32,0,sizeof(crc32));
CRC32().CalculateDigest(crc32, (BYTE*)ciphered.data(), clen);
ciphered.insert(0,(LPSTR)&crc32,CRC32::DIGESTSIZE);
ciphered.insert(0,(LPSTR)&clen,2);
}
- if(ptr->features & FEATURES_GZIP) {
+ if (ptr->features & FEATURES_GZIP)
ciphered.insert(0,(LPSTR)&dataflag,1);
- }
+
clen = (int) ciphered.length();
SAFE_FREE(ptr->tmp);
- if(ptr->features & FEATURES_BASE64) {
+ if (ptr->features & FEATURES_BASE64)
ptr->tmp = base64encode(ciphered.data(),clen);
- }
- else {
+ else
ptr->tmp = base16encode(ciphered.data(),clen);
- }
return ptr->tmp;
}
// decrypt string using KeyX, return decoded string as ASCII or NULL
-LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) {
-
+LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg)
+{
LPSTR ciphered = NULL;
try {
@@ -74,7 +71,7 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) { int clen = strlen(szEncMsg);
- if(ptr->features & FEATURES_BASE64)
+ if (ptr->features & FEATURES_BASE64)
ciphered = base64decode(szEncMsg,&clen);
else
ciphered = base16decode(szEncMsg,&clen);
@@ -82,21 +79,15 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) { LPSTR bciphered = ciphered;
BYTE dataflag=0;
- if(ptr->features & FEATURES_GZIP) {
+ if (ptr->features & FEATURES_GZIP) {
dataflag = *ciphered;
bciphered++; clen--; // cut GZIP flag
}
- if(ptr->features & FEATURES_CRC32) {
- int len;
- __asm {
- mov esi,[bciphered];
- xor eax,eax;
- mov ax,word ptr [esi];
- mov [len], eax;
- }
+ if (ptr->features & FEATURES_CRC32) {
+ int len = *( WORD* )bciphered;
bciphered+=2; clen-=2; // cut CRC32 length
- if(clen-CRC32::DIGESTSIZE<len) { // mesage not full
+ if (clen-CRC32::DIGESTSIZE<len) { // mesage not full
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("cpp_decrypt: error bad_len");
#endif
@@ -110,7 +101,7 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) { CRC32().CalculateDigest(crc32, (PBYTE)(bciphered+CRC32::DIGESTSIZE), len);
- if(memcmp(crc32,bciphered,CRC32::DIGESTSIZE)) { // message is bad crc
+ if (memcmp(crc32,bciphered,CRC32::DIGESTSIZE)) { // message is bad crc
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("cpp_decrypt: error bad_crc");
#endif
@@ -133,13 +124,11 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) { free(ciphered);
SAFE_FREE(ptr->tmp);
- if(dataflag & DATA_GZIP) {
+ if (dataflag & DATA_GZIP) {
ptr->tmp = (LPSTR) cpp_gunzip((PBYTE)unciphered.data(),unciphered.length(),clen);
ptr->tmp[clen] = 0;
}
- else {
- ptr->tmp = (LPSTR) strdup(unciphered.c_str());
- }
+ else ptr->tmp = (LPSTR) strdup(unciphered.c_str());
ptr->error = ERROR_NONE;
return ptr->tmp;
@@ -156,8 +145,8 @@ LPSTR __cdecl cpp_decrypt(pCNTX ptr, LPCSTR szEncMsg) { // encode message from ANSI into UTF8 if need
-LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg) {
-
+LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg)
+{
pCNTX ptr = get_context_on_id(context);
if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
@@ -166,7 +155,7 @@ LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg) { LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) msg;
- if(ptr->features & FEATURES_UTF8) {
+ if (ptr->features & FEATURES_UTF8) {
// ansi message: convert to unicode->utf-8 and encrypt.
int slen = strlen(szOldMsg)+1;
LPWSTR wstring = (LPWSTR) alloca(slen*sizeof(WCHAR));
@@ -184,8 +173,8 @@ LPSTR __cdecl cpp_encodeA(HANDLE context, LPCSTR msg) { // encode message from UTF8
-LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg) {
-
+LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg)
+{
pCNTX ptr = get_context_on_id(context);
if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
@@ -194,7 +183,7 @@ LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg) { LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) msg;
- if(ptr->features & FEATURES_UTF8) {
+ if (ptr->features & FEATURES_UTF8) {
// utf8 message: encrypt.
szNewMsg = cpp_encrypt(ptr, szOldMsg);
}
@@ -210,10 +199,9 @@ LPSTR __cdecl cpp_encodeU(HANDLE context, LPCSTR msg) { return szNewMsg;
}
-
// encode message from UNICODE into UTF8 if need
-LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg) {
-
+LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg)
+{
pCNTX ptr = get_context_on_id(context);
if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
@@ -222,7 +210,7 @@ LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg) { LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) msg;
- if(ptr->features & FEATURES_UTF8) {
+ if (ptr->features & FEATURES_UTF8) {
// unicode message: convert to utf-8 and encrypt.
szNewMsg = cpp_encrypt(ptr, utf8encode((LPWSTR)szOldMsg));
}
@@ -239,8 +227,8 @@ LPSTR __cdecl cpp_encodeW(HANDLE context, LPWSTR msg) { // decode message from UTF8 if need, return ANSIzUCS2z
-LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg) {
-
+LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg)
+{
pCNTX ptr = get_context_on_id(context);
if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
@@ -249,8 +237,8 @@ LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg) { LPSTR szNewMsg = NULL;
LPSTR szOldMsg = cpp_decrypt(ptr, szEncMsg);
- if(szOldMsg) {
- if(ptr->features & FEATURES_UTF8) {
+ if (szOldMsg) {
+ if (ptr->features & FEATURES_UTF8) {
// utf8 message: convert to unicode -> ansii
LPWSTR wstring = utf8decode(szOldMsg);
int wlen = wcslen(wstring)+1;
@@ -273,10 +261,9 @@ LPSTR __cdecl cpp_decode(HANDLE context, LPCSTR szEncMsg) { return szNewMsg;
}
-
// decode message return UTF8z
-LPSTR __cdecl cpp_decodeU(HANDLE context, LPCSTR szEncMsg) {
-
+LPSTR __cdecl cpp_decodeU(HANDLE context, LPCSTR szEncMsg)
+{
pCNTX ptr = get_context_on_id(context);
if (!ptr) return NULL;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
@@ -285,8 +272,8 @@ LPSTR __cdecl cpp_decodeU(HANDLE context, LPCSTR szEncMsg) { LPSTR szNewMsg = NULL;
LPSTR szOldMsg = cpp_decrypt(ptr, szEncMsg);
- if(szOldMsg) {
- if(ptr->features & FEATURES_UTF8) {
+ if (szOldMsg) {
+ if (ptr->features & FEATURES_UTF8) {
// utf8 message: copy
szNewMsg = _strdup(szOldMsg);
}
@@ -303,9 +290,8 @@ LPSTR __cdecl cpp_decodeU(HANDLE context, LPCSTR szEncMsg) { return szNewMsg;
}
-
-int __cdecl cpp_encrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) {
-
+int __cdecl cpp_encrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out)
+{
pCNTX ptr = get_context_on_id(context);
if (!ptr) return 0;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
@@ -322,9 +308,8 @@ int __cdecl cpp_encrypt_file(HANDLE context,LPCSTR file_in,LPCSTR file_out) { return 1;
}
-
-int __cdecl cpp_decrypt_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;
cpp_alloc_pdata(ptr); pSIMDATA p = (pSIMDATA) ptr->pdata;
diff --git a/plugins/CryptoPP/dllloader.cpp b/plugins/CryptoPP/dllloader.cpp index 7dfea7ed0c..160e5d98c4 100644 --- a/plugins/CryptoPP/dllloader.cpp +++ b/plugins/CryptoPP/dllloader.cpp @@ -98,12 +98,12 @@ HMODULE MemLoadLibrary(PBYTE data) pOptionalHeader->SizeOfImage,
MEM_RESERVE,PAGE_NOACCESS);
- if(ImageBase==NULL)
+ if (ImageBase==NULL)
{
ImageBase=(PCHAR)VirtualAlloc(NULL,
pOptionalHeader->SizeOfImage,
MEM_RESERVE,PAGE_NOACCESS);
- if(ImageBase==NULL)
+ if (ImageBase==NULL)
return NULL;
}
diff --git a/plugins/CryptoPP/main.cpp b/plugins/CryptoPP/main.cpp index 8f3d89aa34..2a2639d74a 100644 --- a/plugins/CryptoPP/main.cpp +++ b/plugins/CryptoPP/main.cpp @@ -12,7 +12,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) GetTempPath(sizeof(temp),temp);
GetLongPathName(temp,TEMP,sizeof(TEMP));
TEMP_SIZE = strlen(TEMP);
- if(TEMP[TEMP_SIZE-1]=='\\') {
+ if (TEMP[TEMP_SIZE-1]=='\\') {
TEMP_SIZE--;
TEMP[TEMP_SIZE]='\0';
}
diff --git a/plugins/CryptoPP/mmi.cpp b/plugins/CryptoPP/mmi.cpp index 03294c6017..68026578bb 100644 --- a/plugins/CryptoPP/mmi.cpp +++ b/plugins/CryptoPP/mmi.cpp @@ -2,7 +2,7 @@ /*
void m_check(void *ptr, const char *module) {
- if(ptr==NULL) {
+ if (ptr==NULL) {
char buffer[128];
strcpy(buffer,module); strcat(buffer,": NULL pointer detected !");
MessageBoxA(0,buffer,szModuleName,MB_OK|MB_ICONSTOP);
@@ -23,7 +23,7 @@ void *m_alloc(size_t size) { void m_free(void *ptr) {
// m_check(ptr,"m_free");
- if(ptr) {
+ if (ptr) {
free(ptr);
}
}
@@ -59,7 +59,7 @@ void operator delete[](void *p) { char *m_strdup(const char *str) {
- if(str==NULL) return NULL;
+ if (str==NULL) return NULL;
int len = (int)strlen(str)+1;
char *dup = (char*) m_alloc(len);
MoveMemory((void*)dup,(void*)str,len);
|