summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-07 21:50:44 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-07 21:50:44 +0000
commit2236e9a252983edcce561223534041629935d750 (patch)
tree8425c78b92568a3a8931f5bab07ed3eea86ae067 /plugins/CryptoPP
parentacfdcaaea2a735e2bf2dcf2c3144f429081078c0 (diff)
various code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@6820 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP')
-rw-r--r--plugins/CryptoPP/src/cpp_cntx.cpp37
-rw-r--r--plugins/CryptoPP/src/cpp_rsam.cpp27
2 files changed, 33 insertions, 31 deletions
diff --git a/plugins/CryptoPP/src/cpp_cntx.cpp b/plugins/CryptoPP/src/cpp_cntx.cpp
index 54a4d88bed..62ee204079 100644
--- a/plugins/CryptoPP/src/cpp_cntx.cpp
+++ b/plugins/CryptoPP/src/cpp_cntx.cpp
@@ -1,7 +1,8 @@
#include "commonheaders.h"
// get context data on context id
-pCNTX get_context_on_id(HANDLE context) {
+pCNTX get_context_on_id(HANDLE context)
+{
if ( context ) {
pCNTX cntx = (pCNTX) context;
if ( cntx->header == HEADER && cntx->footer == FOOTER )
@@ -15,7 +16,8 @@ pCNTX get_context_on_id(HANDLE context) {
}
// create context, return context id
-HANDLE __cdecl cpp_create_context(int mode) {
+HANDLE __cdecl cpp_create_context(int mode)
+{
pCNTX cntx = (pCNTX) malloc(sizeof(CNTX));
memset(cntx,0,sizeof(CNTX)); // очищаем выделенный блок
cntx->header = HEADER;
@@ -26,7 +28,8 @@ HANDLE __cdecl cpp_create_context(int mode) {
// delete context
-void __cdecl cpp_delete_context(HANDLE context) {
+void __cdecl cpp_delete_context(HANDLE context)
+{
pCNTX tmp = get_context_on_id(context);
if (tmp) { // помечаем на удаление
cpp_free_keys(tmp);
@@ -36,40 +39,40 @@ void __cdecl cpp_delete_context(HANDLE context) {
// reset context
-void __cdecl cpp_reset_context(HANDLE context) {
+void __cdecl cpp_reset_context(HANDLE context)
+{
pCNTX tmp = get_context_on_id(context);
if (tmp) cpp_free_keys(tmp);
}
// allocate pdata
-PBYTE cpp_alloc_pdata(pCNTX ptr) {
+PBYTE cpp_alloc_pdata(pCNTX ptr)
+{
if ( !ptr->pdata ) {
- if ( ptr->mode & MODE_PGP ) {
+ if ( ptr->mode & MODE_PGP ) {
ptr->pdata = (PBYTE) malloc(sizeof(PGPDATA));
memset(ptr->pdata,0,sizeof(PGPDATA));
- }
- else
- if ( ptr->mode & MODE_GPG ) {
+ }
+ else if ( ptr->mode & MODE_GPG ) {
ptr->pdata = (PBYTE) malloc(sizeof(GPGDATA));
memset(ptr->pdata,0,sizeof(GPGDATA));
- }
- else
- if ( ptr->mode & MODE_RSA ) {
+ }
+ else if ( ptr->mode & MODE_RSA ) {
rsa_alloc(ptr);
- }
- else {
+ }
+ else {
ptr->pdata = (PBYTE) malloc(sizeof(SIMDATA));
memset(ptr->pdata,0,sizeof(SIMDATA));
- }
+ }
}
return ptr->pdata;
}
// free memory from keys
-void cpp_free_keys(pCNTX ptr) {
-
+void cpp_free_keys(pCNTX ptr)
+{
replaceStr(ptr->tmp, 0);
cpp_alloc_pdata(ptr);
if ( ptr->mode & MODE_PGP ) {
diff --git a/plugins/CryptoPP/src/cpp_rsam.cpp b/plugins/CryptoPP/src/cpp_rsam.cpp
index 2b2afe5154..202dffbc94 100644
--- a/plugins/CryptoPP/src/cpp_rsam.cpp
+++ b/plugins/CryptoPP/src/cpp_rsam.cpp
@@ -717,23 +717,23 @@ 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 ) {
- case 0x11: { // оба паблика совпали
+ switch((lr << 4) | ll) {
+ case 0x11: // оба паблика совпали
inject_msg(context,0x21,gen_aes_key_iv(ptr->mode,p,r));
- p->state=5;
- } break;
- case 0x10: { // совпал удаленный паблик, нужен локальный
+ p->state = 5;
+ break;
+ case 0x10: // совпал удаленный паблик, нужен локальный
inject_msg(context,0x22,tlv(0,features)+tlv(1,r->pub_k)+tlv(2,r->pub_s));
- p->state=3;
- } break;
- case 0x01: { // совпал локальный паблик, нужен удаленный
+ p->state = 3;
+ break;
+ case 0x01: // совпал локальный паблик, нужен удаленный
inject_msg(context,0x23,tlv(0,features));
- p->state=3;
- } break;
- case 0x00: { // не совпали оба паблика
+ p->state = 3;
+ break;
+ case 0x00: // не совпали оба паблика
inject_msg(context,0x24,tlv(0,features)+tlv(1,r->pub_k)+tlv(2,r->pub_s));
- p->state=3;
- } break;
+ p->state = 3;
+ break;
}
} break;
@@ -1079,5 +1079,4 @@ int __cdecl rsa_import_pubkey(HANDLE context, LPSTR pubKey) {
return 0;
}
-
// EOF