diff options
Diffstat (limited to 'plugins/CryptoPP/src/cpp_gpgw.cpp')
-rw-r--r-- | plugins/CryptoPP/src/cpp_gpgw.cpp | 80 |
1 files changed, 32 insertions, 48 deletions
diff --git a/plugins/CryptoPP/src/cpp_gpgw.cpp b/plugins/CryptoPP/src/cpp_gpgw.cpp index 3336b825df..2e62b77deb 100644 --- a/plugins/CryptoPP/src/cpp_gpgw.cpp +++ b/plugins/CryptoPP/src/cpp_gpgw.cpp @@ -27,52 +27,46 @@ int __cdecl gpg_init() int __cdecl gpg_done()
{
- int r = 0;
- if (hgpg) {
- r = _gpg_done();
+ int r = 0;
+ if (hgpg) {
+ r = _gpg_done();
hgpg = 0;
- }
+ }
return r;
}
-
int __cdecl gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath)
{
return _gpg_open_keyrings(ExecPath, HomePath);
}
-
int __cdecl gpg_close_keyrings()
{
return _gpg_close_keyrings();
}
-
void __cdecl gpg_set_log(LPCSTR LogPath)
{
_gpg_set_log(LogPath);
}
-
void __cdecl gpg_set_tmp(LPCSTR TmpPath)
{
_gpg_set_tmp(TmpPath);
}
-
LPSTR __cdecl gpg_get_error()
{
return _gpg_get_error();
}
-
LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
{
ptr->error = ERROR_NONE;
- pGPGDATA p = (pGPGDATA) ptr->pdata;
+ pGPGDATA p = (pGPGDATA)ptr->pdata;
LPSTR szEncMsg;
- szEncMsg = _gpg_encrypt(szPlainMsg,(LPCSTR)p->gpgKeyID);
+ szEncMsg = _gpg_encrypt(szPlainMsg, (LPCSTR)p->gpgKeyID);
if (!szEncMsg) {
replaceStr(ptr->tmp, 0);
return 0;
@@ -83,31 +77,29 @@ LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg) return ptr->tmp;
}
-
LPSTR __cdecl gpg_decrypt(pCNTX ptr, LPCSTR szEncMsg)
{
- ptr->error = ERROR_NONE;
+ ptr->error = ERROR_NONE;
- LPSTR szPlainMsg = _gpg_decrypt(szEncMsg);
- replaceStr(ptr->tmp, mir_strdup(szPlainMsg));
- LocalFree((LPVOID)szPlainMsg);
+ LPSTR szPlainMsg = _gpg_decrypt(szEncMsg);
+ replaceStr(ptr->tmp, mir_strdup(szPlainMsg));
+ LocalFree((LPVOID)szPlainMsg);
- return ptr->tmp;
+ return ptr->tmp;
}
-
LPSTR __cdecl gpg_encode(HANDLE context, LPCSTR szPlainMsg)
{
pCNTX ptr = get_context_on_id(context); if (!ptr) return NULL;
- pGPGDATA p = (pGPGDATA) cpp_alloc_pdata(ptr);
+ pGPGDATA p = (pGPGDATA)cpp_alloc_pdata(ptr);
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 = (int)wcslen(wszMsg)+1;
- szUtfMsg = (LPSTR) alloca(wlen);
+ int wlen = (int)wcslen(wszMsg) + 1;
+ szUtfMsg = (LPSTR)alloca(wlen);
WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szUtfMsg, wlen, 0, 0);
}
else {
@@ -126,9 +118,9 @@ LPSTR __cdecl gpg_decode(HANDLE context, LPCSTR szEncMsg) LPSTR szOldMsg = gpg_decrypt(ptr, szEncMsg);
if (szOldMsg) {
- if ( !is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg) ) {
- int slen = (int)strlen(szOldMsg)+1;
- LPWSTR wszMsg = (LPWSTR) alloca(slen*sizeof(WCHAR));
+ if (!is_7bit_string(szOldMsg) && !is_utf8_string(szOldMsg)) {
+ int slen = (int)strlen(szOldMsg) + 1;
+ LPWSTR wszMsg = (LPWSTR)alloca(slen*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, szOldMsg, -1, wszMsg, slen*sizeof(WCHAR));
szNewMsg = _strdup(utf8encode(wszMsg));
}
@@ -140,60 +132,52 @@ LPSTR __cdecl gpg_decode(HANDLE context, LPCSTR szEncMsg) return szNewMsg;
}
-
int __cdecl gpg_set_key(HANDLE context, LPCSTR RemoteKey)
{
-/* pCNTX ptr = get_context_on_id(context);
- if (!ptr) return 0;
- ptr->error = ERROR_NONE;
+ /*
+ pCNTX ptr = get_context_on_id(context);
+ if (!ptr) return 0;
+ ptr->error = ERROR_NONE;
-// if (!_gpg_check_key(RemoteKey)) return 0;
+ if (!_gpg_check_key(RemoteKey)) return 0;
- SAFE_FREE(ptr->pgpKey);
+ SAFE_FREE(ptr->pgpKey);
ptr->pgpKey = (BYTE *) malloc(strlen(RemoteKey)+1);
strcpy((LPSTR)ptr->pgpKey,RemoteKey);
- return 1;
-*/
+ return 1;
+ */
return 0;
}
-
int __cdecl gpg_set_keyid(HANDLE context, LPCSTR RemoteKeyID)
{
pCNTX ptr = get_context_on_id(context); if (!ptr) return 0;
- pGPGDATA p = (pGPGDATA) cpp_alloc_pdata(ptr);
- ptr->error = ERROR_NONE;
+ pGPGDATA p = (pGPGDATA)cpp_alloc_pdata(ptr);
+ ptr->error = ERROR_NONE;
- SAFE_FREE(p->gpgKeyID);
+ SAFE_FREE(p->gpgKeyID);
p->gpgKeyID = (PBYTE)_strdup(RemoteKeyID);
- return 1;
+ return 1;
}
-
int __cdecl gpg_size_keyid()
{
return _gpg_size_keyid();
}
-
-int __cdecl gpg_select_keyid(HWND hDlg,LPSTR szKeyID)
+int __cdecl gpg_select_keyid(HWND hDlg, LPSTR szKeyID)
{
- return _gpg_select_keyid(hDlg,szKeyID);
+ return _gpg_select_keyid(hDlg, szKeyID);
}
-
LPSTR __cdecl gpg_get_passphrases()
{
return _gpg_get_passphrases();
}
-
void __cdecl gpg_set_passphrases(LPCSTR buffer)
{
_gpg_set_passphrases(buffer);
}
-
-
-// EOF
\ No newline at end of file |