summaryrefslogtreecommitdiff
path: root/plugins/SecureIM
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-19 18:01:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-19 18:01:14 +0000
commitd6e05cc3bca53565d9ca65377ab8b0b6190774b3 (patch)
tree76040facd4d0b82162069a19cae8f7f024bf1f65 /plugins/SecureIM
parent2ef414538760079fa2955fca1a2c03d610459fa8 (diff)
preparing to the transparent cyphering: end of MS_DB_CRYPT_ENCODESTRING/MS_DB_CRYPT_DECODESTRING
git-svn-id: http://svn.miranda-ng.org/main/trunk@6938 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM')
-rw-r--r--plugins/SecureIM/src/commonheaders.cpp2
-rw-r--r--plugins/SecureIM/src/commonheaders.h3
-rw-r--r--plugins/SecureIM/src/crypt_dll.cpp52
-rw-r--r--plugins/SecureIM/src/main.cpp8
-rw-r--r--plugins/SecureIM/src/options.cpp2
-rw-r--r--plugins/SecureIM/src/svcs_menu.cpp2
6 files changed, 29 insertions, 40 deletions
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp
index 4f92e5a34c..97f2f5f13f 100644
--- a/plugins/SecureIM/src/commonheaders.cpp
+++ b/plugins/SecureIM/src/commonheaders.cpp
@@ -45,7 +45,6 @@ LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSet
size_t len = strlen(val)+64;
char *buf = (LPSTR)mir_alloc(len);
strncpy(buf,val,len); mir_free(val);
- CallService(MS_DB_CRYPT_DECODESTRING,(WPARAM)len,(LPARAM)buf);
return buf;
}
@@ -54,7 +53,6 @@ int myDBWriteStringEncode(HANDLE hContact,const char *szModule,const char *szSet
int len = (int)strlen(val)+64;
char *buf = (LPSTR)alloca(len);
strncpy(buf,val,len);
- CallService(MS_DB_CRYPT_ENCODESTRING,(WPARAM)len,(LPARAM)buf);
int ret = db_set_s(hContact,szModule,szSetting,buf);
return ret;
}
diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h
index dc4797b7ce..1485484f3d 100644
--- a/plugins/SecureIM/src/commonheaders.h
+++ b/plugins/SecureIM/src/commonheaders.h
@@ -108,9 +108,6 @@ __forceinline int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hP
return ProtoBroadcastAck( GetContactProto(hContact), hContact, type, result, hProcess, lParam);
}
-LPSTR myDBGetStringDecode(HANDLE,const char *,const char *);
-int myDBWriteStringEncode(HANDLE,const char *,const char *,const char *);
-
extern HANDLE hNetlibUser;
void InitNetlib();
void DeinitNetlib();
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp
index 05220acf99..f9b5325e2f 100644
--- a/plugins/SecureIM/src/crypt_dll.cpp
+++ b/plugins/SecureIM/src/crypt_dll.cpp
@@ -1,6 +1,5 @@
#include "commonheaders.h"
-
// generate KeyA pair and return public key
LPSTR InitKeyA(pUinKey ptr,int features)
{
@@ -11,8 +10,8 @@ LPSTR InitKeyA(pUinKey ptr,int features)
char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK");
if (tmp) {
- cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password
- mir_free(tmp);
+ cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password
+ mir_free(tmp);
}
LPSTR pub_text = cpp_init_keya(ptr->cntx,features); // calculate public and private key & fill KeyA
@@ -24,8 +23,7 @@ LPSTR InitKeyA(pUinKey ptr,int features)
else
keysig = (LPSTR)SIG_KEYA;
}
- else
- if (isProtoSmallPackets(ptr->hContact))
+ else if (isProtoSmallPackets(ptr->hContact))
keysig = (LPSTR)SIG_KEY4;
else
keysig = (LPSTR)SIG_KEY3;
@@ -65,8 +63,8 @@ int InitKeyB(pUinKey ptr,LPCSTR key)
// store KeyX into context
-void InitKeyX(pUinKey ptr,BYTE *key) {
-
+void InitKeyX(pUinKey ptr,BYTE *key)
+{
if (!ptr->cntx)
ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0);
@@ -75,8 +73,8 @@ void InitKeyX(pUinKey ptr,BYTE *key) {
// calculate secret key
-BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {
-
+BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact)
+{
int agr = cpp_calc_keyx(ptr->cntx);
if (agr) {
// do this only if key exchanged is ok
@@ -105,8 +103,8 @@ BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {
// encrypt message
-LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) {
-
+LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg)
+{
LPSTR szSig = (LPSTR) (ptr->offlineKey?SIG_ENOF:SIG_ENON);
int slen = (int)strlen(szSig);
@@ -121,30 +119,27 @@ LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) {
// encode message
-LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) {
-
+LPSTR encodeMsg(pUinKey ptr, LPARAM lParam)
+{
CCSDATA *pccsd = (CCSDATA *)lParam;
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) pccsd->lParam;
if (pccsd->wParam & PREF_UTF )
szNewMsg = encrypt(ptr,cpp_encodeU(ptr->cntx,szOldMsg));
- else
- if (pccsd->wParam & PREF_UNICODE )
+ else if (pccsd->wParam & PREF_UNICODE )
szNewMsg = encrypt(ptr,cpp_encodeW(ptr->cntx,(LPWSTR)(szOldMsg+strlen(szOldMsg)+1)));
else
szNewMsg = encrypt(ptr,cpp_encodeA(ptr->cntx,szOldMsg));
-// pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF);
pccsd->wParam &= ~PREF_UNICODE;
-
return szNewMsg;
}
// decode message
-LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
-
+LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg)
+{
CCSDATA *pccsd = (CCSDATA *)lParam;
PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam;
@@ -152,7 +147,7 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
LPSTR szOldMsg = (ppre->flags&PREF_UTF)?cpp_decodeU(ptr->cntx,szEncMsg):cpp_decode(ptr->cntx,szEncMsg);
if (szOldMsg == NULL) {
- ptr->decoded=false;
+ ptr->decoded = false;
switch(cpp_get_error(ptr->cntx)) {
case CPP_ERROR_BAD_LEN:
szNewMsg = mir_strdup(Translate(sim102));
@@ -160,10 +155,9 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
case CPP_ERROR_BAD_CRC:
szNewMsg = mir_strdup(Translate(sim103));
break;
- default: {
+ default:
ptr->decoded=true;
- szNewMsg = mir_strdup(Translate(sim101));
- }
+ szNewMsg = mir_strdup(Translate(sim101));
break;
}
ppre->flags &= ~(PREF_UNICODE|PREF_UTF);
@@ -200,8 +194,8 @@ BOOL LoadKeyPGP(pUinKey ptr)
db_free(&dbv);
return r;
}
- else if (mode == 1) {
- LPSTR key = myDBGetStringDecode(ptr->hContact,MODULENAME,"pgp");
+ if (mode == 1) {
+ LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"pgp");
if (key) {
pgp_set_key(ptr->cntx,key);
mir_free(key);
@@ -211,15 +205,15 @@ BOOL LoadKeyPGP(pUinKey ptr)
return 0;
}
-BOOL LoadKeyGPG(pUinKey ptr) {
-
+BOOL LoadKeyGPG(pUinKey ptr)
+{
LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"gpg");
if (key) {
gpg_set_keyid(ptr->cntx,key);
mir_free(key);
- return 2;
+ return 2;
}
- return 0;
+ return 0;
}
// EOF
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp
index a08f3c3035..63f191d663 100644
--- a/plugins/SecureIM/src/main.cpp
+++ b/plugins/SecureIM/src/main.cpp
@@ -180,13 +180,13 @@ int onModulesLoaded(WPARAM, LPARAM)
if (bPGP) { //PGP
bPGPloaded = pgp_init();
bUseKeyrings = db_get_b(0,MODULENAME,"ukr",1);
- LPSTR priv = myDBGetStringDecode(0,MODULENAME,"pgpPrivKey");
+ LPSTR priv = db_get_sa(0,MODULENAME,"pgpPrivKey");
if (priv) {
bPGPprivkey = true;
if (bPGPloaded)
pgp_set_priv_key(priv);
mir_free(priv);
- }// if (priv)
+ }
if (bPGPloaded && bUseKeyrings) {
char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH];
PubRingPath[0]='\0'; SecRingPath[0]='\0';
@@ -215,8 +215,8 @@ int onModulesLoaded(WPARAM, LPARAM)
}
}
}
- }// if (bPGPloaded && bUseKeyrings)
- }// if (bPGP)
+ }
+ }
Sent_NetLog("gpg_init");
diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp
index 7e7d7aece5..432d0ccb4d 100644
--- a/plugins/SecureIM/src/options.cpp
+++ b/plugins/SecureIM/src/options.cpp
@@ -1319,7 +1319,7 @@ void ApplyPGPSettings(HWND hDlg)
if (priv) {
bPGPprivkey = true;
pgp_set_priv_key(priv);
- myDBWriteStringEncode(0,MODULENAME,"pgpPrivKey",priv);
+ db_set_s(0,MODULENAME,"pgpPrivKey",priv);
mir_free(priv);
db_unset(0,MODULENAME,"tpgpPrivKey");
}
diff --git a/plugins/SecureIM/src/svcs_menu.cpp b/plugins/SecureIM/src/svcs_menu.cpp
index f9a22638c3..b8fba61f48 100644
--- a/plugins/SecureIM/src/svcs_menu.cpp
+++ b/plugins/SecureIM/src/svcs_menu.cpp
@@ -88,7 +88,7 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam)
char *publ = LoadKeys(KeyPath,false);
if (publ) {
db_unset((HANDLE)wParam,MODULENAME,"pgp");
- myDBWriteStringEncode((HANDLE)wParam,MODULENAME,"pgp",publ);
+ db_set_s((HANDLE)wParam,MODULENAME,"pgp",publ);
db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",1);
db_set_s((HANDLE)wParam,MODULENAME,"pgp_abbr","(binary)");
mir_free(publ);