From 2fbe1d2262383b272ef887d712f308f787cf33f1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Jun 2013 17:48:18 +0000 Subject: 64-bit compatible version of CryptoPP git-svn-id: http://svn.miranda-ng.org/main/trunk@4917 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CryptoPP/cryptopp_10.vcxproj | 64 ++- plugins/CryptoPP/cryptopp_10.vcxproj.filters | 73 ++- plugins/CryptoPP/cryptopp_11.vcxproj | 55 ++- plugins/CryptoPP/cryptopp_11.vcxproj.filters | 73 ++- plugins/CryptoPP/res/resource.rc | 6 - plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll | Bin 13824 -> 0 bytes plugins/CryptoPP/src/GPGw/commonheaders.c | 42 -- plugins/CryptoPP/src/GPGw/commonheaders.h | 79 ---- plugins/CryptoPP/src/GPGw/gpg.c | 366 --------------- plugins/CryptoPP/src/GPGw/gpg.cpp | 365 +++++++++++++++ plugins/CryptoPP/src/GPGw/gpg.rc | 111 +++++ plugins/CryptoPP/src/GPGw/gpg_main.cpp | 395 ++++++++++++++++ plugins/CryptoPP/src/GPGw/gpg_res.h | 21 + plugins/CryptoPP/src/GPGw/gpgw.h | 61 +++ plugins/CryptoPP/src/GPGw/keys.c | 67 --- plugins/CryptoPP/src/GPGw/keys.cpp | 68 +++ plugins/CryptoPP/src/GPGw/language.c | 27 -- plugins/CryptoPP/src/GPGw/language.cpp | 28 ++ plugins/CryptoPP/src/GPGw/main.c | 369 --------------- plugins/CryptoPP/src/GPGw/passdialog.c | 29 -- plugins/CryptoPP/src/GPGw/passdialog.cpp | 29 ++ plugins/CryptoPP/src/GPGw/passphrases.c | 50 -- plugins/CryptoPP/src/GPGw/passphrases.cpp | 51 +++ plugins/CryptoPP/src/GPGw/pipeexec.c | 134 ------ plugins/CryptoPP/src/GPGw/pipeexec.cpp | 134 ++++++ plugins/CryptoPP/src/GPGw/resource.h | 21 - plugins/CryptoPP/src/GPGw/resource.rc | 112 ----- plugins/CryptoPP/src/GPGw/tools.c | 191 -------- plugins/CryptoPP/src/GPGw/tools.cpp | 192 ++++++++ plugins/CryptoPP/src/GPGw/userdialog.c | 81 ---- plugins/CryptoPP/src/GPGw/userdialog.cpp | 80 ++++ plugins/CryptoPP/src/PGPw/Release6/PGPsdkW6.dll | Bin 8192 -> 0 bytes plugins/CryptoPP/src/PGPw/Release8/PGPsdkW8.dll | Bin 8192 -> 0 bytes plugins/CryptoPP/src/PGPw/commonheaders.cpp | 5 - plugins/CryptoPP/src/PGPw/commonheaders.h | 64 --- plugins/CryptoPP/src/PGPw/main.cpp | 584 ------------------------ plugins/CryptoPP/src/PGPw/pgpw.h | 33 ++ plugins/CryptoPP/src/PGPw/sdk6.cpp | 375 +++++++++++++++ plugins/CryptoPP/src/commonheaders.h | 5 +- plugins/CryptoPP/src/cpp_gpgw.cpp | 159 +------ plugins/CryptoPP/src/cpp_pgpw.cpp | 52 +-- plugins/CryptoPP/src/main.cpp | 9 - 42 files changed, 2210 insertions(+), 2450 deletions(-) delete mode 100644 plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll delete mode 100644 plugins/CryptoPP/src/GPGw/commonheaders.c delete mode 100644 plugins/CryptoPP/src/GPGw/commonheaders.h delete mode 100644 plugins/CryptoPP/src/GPGw/gpg.c create mode 100644 plugins/CryptoPP/src/GPGw/gpg.cpp create mode 100644 plugins/CryptoPP/src/GPGw/gpg.rc create mode 100644 plugins/CryptoPP/src/GPGw/gpg_main.cpp create mode 100644 plugins/CryptoPP/src/GPGw/gpg_res.h create mode 100644 plugins/CryptoPP/src/GPGw/gpgw.h delete mode 100644 plugins/CryptoPP/src/GPGw/keys.c create mode 100644 plugins/CryptoPP/src/GPGw/keys.cpp delete mode 100644 plugins/CryptoPP/src/GPGw/language.c create mode 100644 plugins/CryptoPP/src/GPGw/language.cpp delete mode 100644 plugins/CryptoPP/src/GPGw/main.c delete mode 100644 plugins/CryptoPP/src/GPGw/passdialog.c create mode 100644 plugins/CryptoPP/src/GPGw/passdialog.cpp delete mode 100644 plugins/CryptoPP/src/GPGw/passphrases.c create mode 100644 plugins/CryptoPP/src/GPGw/passphrases.cpp delete mode 100644 plugins/CryptoPP/src/GPGw/pipeexec.c create mode 100644 plugins/CryptoPP/src/GPGw/pipeexec.cpp delete mode 100644 plugins/CryptoPP/src/GPGw/resource.h delete mode 100644 plugins/CryptoPP/src/GPGw/resource.rc delete mode 100644 plugins/CryptoPP/src/GPGw/tools.c create mode 100644 plugins/CryptoPP/src/GPGw/tools.cpp delete mode 100644 plugins/CryptoPP/src/GPGw/userdialog.c create mode 100644 plugins/CryptoPP/src/GPGw/userdialog.cpp delete mode 100644 plugins/CryptoPP/src/PGPw/Release6/PGPsdkW6.dll delete mode 100644 plugins/CryptoPP/src/PGPw/Release8/PGPsdkW8.dll delete mode 100644 plugins/CryptoPP/src/PGPw/commonheaders.cpp delete mode 100644 plugins/CryptoPP/src/PGPw/commonheaders.h delete mode 100644 plugins/CryptoPP/src/PGPw/main.cpp create mode 100644 plugins/CryptoPP/src/PGPw/pgpw.h create mode 100644 plugins/CryptoPP/src/PGPw/sdk6.cpp (limited to 'plugins') diff --git a/plugins/CryptoPP/cryptopp_10.vcxproj b/plugins/CryptoPP/cryptopp_10.vcxproj index 2c77369858..7ba50dbf88 100644 --- a/plugins/CryptoPP/cryptopp_10.vcxproj +++ b/plugins/CryptoPP/cryptopp_10.vcxproj @@ -27,19 +27,23 @@ DynamicLibrary MultiByte true + v100 DynamicLibrary MultiByte true + v100 DynamicLibrary MultiByte + v100 DynamicLibrary MultiByte + v100 @@ -89,10 +93,12 @@ true 0x46000000 false - $(ProfileDir)..\..\bin10\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) $(IntDir)$(TargetName).lib Windows + false + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll @@ -113,10 +119,11 @@ true 0x46000000 false - $(ProfileDir)..\..\bin10\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)64\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) $(IntDir)$(TargetName).lib Windows + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll @@ -138,14 +145,14 @@ 0x46000000 false - $(ProfileDir)..\..\bin10\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) true true $(IntDir)$(TargetName).lib true Windows - /PDBALTPATH:%_PDB% + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll @@ -167,19 +174,49 @@ 0x46000000 false - $(ProfileDir)..\..\bin10\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)64\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) true true $(IntDir)$(TargetName).lib true Windows - /PDBALTPATH:%_PDB% + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + Create @@ -207,17 +244,28 @@ + + + + + + + + + + + - + - + {290c5ed4-71a7-4040-ad26-4820cf7a9e60} diff --git a/plugins/CryptoPP/cryptopp_10.vcxproj.filters b/plugins/CryptoPP/cryptopp_10.vcxproj.filters index de49291ef3..e5d4229b45 100644 --- a/plugins/CryptoPP/cryptopp_10.vcxproj.filters +++ b/plugins/CryptoPP/cryptopp_10.vcxproj.filters @@ -13,6 +13,12 @@ {2fbb24e7-698d-4277-9329-3e500a878dbe} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + {c590377d-f943-46bf-a7db-444e4752c633} + + + {fb417c70-fe70-4812-a2b9-0a499348e6e2} + @@ -66,6 +72,36 @@ Source Files + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\PGPw + @@ -104,12 +140,45 @@ Header Files + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\PGPw + - + Resource Files - + Resource Files diff --git a/plugins/CryptoPP/cryptopp_11.vcxproj b/plugins/CryptoPP/cryptopp_11.vcxproj index 079152c9df..8c7a4df0a3 100644 --- a/plugins/CryptoPP/cryptopp_11.vcxproj +++ b/plugins/CryptoPP/cryptopp_11.vcxproj @@ -93,11 +93,12 @@ true 0x46000000 false - $(ProfileDir)..\..\bin11\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) $(IntDir)$(TargetName).lib Windows false + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll @@ -118,10 +119,11 @@ true 0x46000000 false - $(ProfileDir)..\..\bin11\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)64\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) $(IntDir)$(TargetName).lib Windows + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll @@ -143,13 +145,14 @@ 0x46000000 false - $(ProfileDir)..\..\bin11\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) true true $(IntDir)$(TargetName).lib true Windows + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll @@ -171,18 +174,49 @@ 0x46000000 false - $(ProfileDir)..\..\bin11\lib + $(ProfileDir)..\..\bin11\lib;.\src\PGPw\sdk8\lib ws2_32.lib;$(SolutionDir)$(Configuration)64\Obj\cryptlib\cryptlib.lib;%(AdditionalDependencies) true true $(IntDir)$(TargetName).lib true Windows + pgpsdk.dll;pgpsdknl.dll;pgpsdkui.dll + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + + + ../commonheaders.h + Create @@ -210,14 +244,25 @@ + + + + + + + + + + + - + diff --git a/plugins/CryptoPP/cryptopp_11.vcxproj.filters b/plugins/CryptoPP/cryptopp_11.vcxproj.filters index de49291ef3..e5d4229b45 100644 --- a/plugins/CryptoPP/cryptopp_11.vcxproj.filters +++ b/plugins/CryptoPP/cryptopp_11.vcxproj.filters @@ -13,6 +13,12 @@ {2fbb24e7-698d-4277-9329-3e500a878dbe} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + {c590377d-f943-46bf-a7db-444e4752c633} + + + {fb417c70-fe70-4812-a2b9-0a499348e6e2} + @@ -66,6 +72,36 @@ Source Files + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\PGPw + @@ -104,12 +140,45 @@ Header Files + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\GPGw + + + Source Files\PGPw + - + Resource Files - + Resource Files diff --git a/plugins/CryptoPP/res/resource.rc b/plugins/CryptoPP/res/resource.rc index 93360fb460..61ee5b969f 100644 --- a/plugins/CryptoPP/res/resource.rc +++ b/plugins/CryptoPP/res/resource.rc @@ -11,12 +11,6 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT #pragma code_page(1251) -#ifdef DLL_FROM_RESOURCE -1 666 "..\\src\\gpgw\\release\\gnupgw.dll" -6 666 "..\\src\\pgpw\\release6\\pgpsdkw6.dll" -8 666 "..\\src\\pgpw\\release8\\pgpsdkw8.dll" -#endif - #endif //_WIN32 #ifdef APSTUDIO_INVOKED diff --git a/plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll b/plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll deleted file mode 100644 index 7dba65ea45..0000000000 Binary files a/plugins/CryptoPP/src/GPGw/Release/GnuPGw.dll and /dev/null differ diff --git a/plugins/CryptoPP/src/GPGw/commonheaders.c b/plugins/CryptoPP/src/GPGw/commonheaders.c deleted file mode 100644 index 5404e4ed80..0000000000 --- a/plugins/CryptoPP/src/GPGw/commonheaders.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "commonheaders.h" - -LPCSTR szModuleName = MODULENAME; -LPCSTR szVersionStr = MODULENAME" DLL ("__VERSION_STRING")"; -HINSTANCE g_hInst; - -char temporarydirectory[fullfilenamesize]; -char logfile[fullfilenamesize]; -/* -char *txtbeginpgppublickeyblock="-----BEGIN PGP PUBLIC KEY BLOCK-----"; -char *txtendpgppublickeyblock="-----END PGP PUBLIC KEY BLOCK-----"; -*/ -char *txtbeginpgpmessage="-----BEGIN PGP MESSAGE-----"; -char *txtendpgpmessage="-----END PGP MESSAGE-----"; - - -void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint) -{ - char buffer[errormessagesize]; - - strcpy(buffer, atext); - strcat(buffer, " "); - strcat(buffer, ahint); - MessageBox(NULL, buffer, alevel, MB_OK); -} - - -void __cdecl LogMessage(const char *astart, const char *atext, const char *aend) -{ - FILE *log; - - if(logfile[0]=='\0') return; - - log=fopen(logfile, "a"); - if(log!=NULL) - { - fputs(astart, log); - fputs(atext, log); - fputs(aend, log); - fclose(log); - } -} diff --git a/plugins/CryptoPP/src/GPGw/commonheaders.h b/plugins/CryptoPP/src/GPGw/commonheaders.h deleted file mode 100644 index 4ae6e155a7..0000000000 --- a/plugins/CryptoPP/src/GPGw/commonheaders.h +++ /dev/null @@ -1,79 +0,0 @@ -// Windows API - -#pragma once -#define _WIN32_IE 0x0500 -//#define WIN32_LEAN_AND_MEAN -//#pragma warning(disable: 4078) - -#include -//#include -#include -#include -#include -#include "..\version.h" - -// gnupg plugin -#include "resource.h" -#include "size.h" -#include "language.h" -#include "pipeexec.h" -#include "gpg.h" -#include "tools.h" -#include "passphrases.h" -#include "passdialog.h" -#include "userdialog.h" -#include "keys.h" - -// debug makro -#define debugout(mtext) MessageBox(NULL, (mtext), "GnuPG Plugin - Debug", MB_OK) - -// passphrase typ -struct passphrase -{ - char keyuserid[keyuseridsize]; - char passphrase[passphrasesize]; -}; - -extern struct passphrase *passphrases; -extern int passphrasecount; - -extern char temporarydirectory[fullfilenamesize]; -extern char logfile[fullfilenamesize]; - -extern char *txtbeginpgppublickeyblock; -extern char *txtendpgppublickeyblock; -extern char *txtbeginpgpmessage; -extern char *txtendpgpmessage; - -#ifdef _MSC_VER -//#pragma comment(linker,"/merge:.rdata=.text") -#pragma comment(linker,"/entry:dllmain") -#pragma comment(linker,"/nodefaultlib") -#pragma comment(linker,"/subsystem:windows") -#pragma optimize("gsy", on) -#endif - -#define MODULENAME "GnuPG" - -extern LPCSTR szModuleName; -extern LPCSTR szVersionStr; -extern HINSTANCE g_hInst; - -#define DLLEXPORT __declspec(dllexport) - -extern DLLEXPORT int __cdecl _gpg_init(void); -extern DLLEXPORT int __cdecl _gpg_done(void); -extern DLLEXPORT int __cdecl _gpg_open_keyrings(LPSTR,LPSTR); -extern DLLEXPORT int __cdecl _gpg_close_keyrings(void); -extern DLLEXPORT void __cdecl _gpg_set_log(LPCSTR); -extern DLLEXPORT void __cdecl _gpg_set_tmp(LPCSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_get_error(void); -extern DLLEXPORT int __cdecl _gpg_size_keyid(void); -extern DLLEXPORT int __cdecl _gpg_select_keyid(HWND,LPSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_encrypt(LPCSTR,LPCSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_decrypt(LPCSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_get_passphrases(); -extern DLLEXPORT void __cdecl _gpg_set_passphrases(LPCSTR); - -void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint); -void __cdecl LogMessage(const char *astart, const char *atext, const char *aend); diff --git a/plugins/CryptoPP/src/GPGw/gpg.c b/plugins/CryptoPP/src/GPGw/gpg.c deleted file mode 100644 index 8ec3a57b11..0000000000 --- a/plugins/CryptoPP/src/GPGw/gpg.c +++ /dev/null @@ -1,366 +0,0 @@ -#include "commonheaders.h" -#include - -char *txtgpgargslistpublickeys= - "--homedir \"%home%\"" - " --with-colon" // felder durch : voneinander abgetrennt - " --list-public-keys"; // oeffentliche schluessel auflisten -char *txtgpgargslistsecretkeys= - "--homedir \"%home%\"" - " --with-colon" - " --list-secret-keys"; // geheime schluessel auflisten -char *txtgpgargsimportpublickey= - "--homedir \"%home%\"" - " --import \"%keyfile%\""; // schluessel importieren -char *txtgpgargsexportpublickey= - "--homedir \"%home%\"" - " --batch" - " --yes" // abfragen mit ja beantworten - " --armor" // ausgabe als text - " --comment \"\"" // kommentar unterdruecken ("Comment: For info see http://www.gnupg.org") - " --no-version" // ausgabe der version unterdruecken ("Version: GnuPG v1.0.6 (MingW32)") - " --export \"%userid%\""; // export des schluessels %userid% -char *txtgpgargsdetectuserid= - "--homedir \"%home%\"" - " --batch" // interaktion verhindern (daraus folgt fehler) - " --decrypt \"%cipherfile%\""; // datei %cipherfile% entschluesseln -char *txtgpgargsencrypt= - "--homedir \"%home%\"" - " --batch" - " --yes" // abfragen mit ja beantworten - " --armor" // textausgabe - " --comment \"\"" // kein kommentar hinzufuegen - " --no-version" // keine versions informationen hinzufuegen - " --recipient \"%userid%\"" // %userid% des empfaengers - " --output \"%cipherfile%\"" // ausgabe in datei %cipherfile% - " --encrypt \"%plainfile%\""; // eingabe kommt aus %plainfile% -char *txtgpgargsdecrypt= - "--homedir \"%home%\"" - " --yes" // abfragen mit ja beantworten - " --passphrase-fd 0" // passphrase von stdin - " --output \"%plainfile%\"" // ausgabe in datei %plainfile% - " --decrypt \"%cipherfile%\""; // eingabe kommt aus %cipherfile% - -// oeffentliche zeichenketten -char gpgExecutable[argumentsize]; -char gpgHomeDirectory[argumentsize]; - - -// zeichenketten fuer den internen gebrauch -char *txtpub="pub"; -char *txtsec="sec"; -char *txtcrlf="\r\n"; -char *txtcolon=":"; -char *txtquotationmark="\""; -char *txtgpgcolon="gpg:"; -char *txtplainfile="%plainfile%"; -char *txtcipherfile="%cipherfile%"; -char *txtuserid="%userid%"; -char *txtkeyfile="%keyfile%"; -char *txthome="%home%"; -char *txtidseparator=", "; - - -void assembleCommandLine(char *aresult, const char *aexecutable, const char *aargs) -{ - strcpy(aresult, aexecutable); - strcat(aresult, " "); - strcat(aresult, aargs); -} - - -void detectKeys(char *aresult, char *aoutput, const char *alabel) -{ - char line[linesize]; - char part[linesize]; - char *linepos; - char *partpos; - long i; - - strcpy(aresult, ""); - linepos=aoutput; - - do - { - linepos=getNextPart(line, linepos, txtcrlf); - if(linepos==NULL) break; - - partpos=line; - partpos=getNextPart(part, partpos, txtcolon); - - if(strcmp(part, alabel)==0) - for(i=1; i<=10; i++) - { - partpos=getNextPart(part, partpos, txtcolon); - - switch(i) - { - case 4: - strcat(aresult, part); - strcat(aresult, txtidseparator); - break; - case 9: - strcat(aresult, part); - strcat(aresult, txtcrlf); - break; - } - } - } - while(linepos!=NULL); - - replace(aresult, "\\x3a", ":"); -} - - -gpgResult gpgListPublicKeys(char *aresult) -{ - pxResult pxresult; - char commandline[commandlinesize]; - DWORD exitcode; - char *output; - - LogMessage(">>> ", "list public keys", "\n"); - output=(char *)malloc(1); - strcpy(output, ""); - assembleCommandLine(commandline, gpgExecutable, txtgpgargslistpublickeys); - replace(commandline, txthome, gpgHomeDirectory); - pxresult=pxExecute(commandline, "", &output, &exitcode); - - if ((pxresult!=pxSuccess)||(exitcode!=0)) - { - free(output); - return gpgExecuteFailed; - } - - detectKeys(aresult, output, txtpub); - - free(output); - return gpgSuccess; -} - - -gpgResult gpgListSecretKeys(char *aresult) -{ - pxResult pxresult; - char commandline[commandlinesize]; - DWORD exitcode; - char *output; - - LogMessage(">>> ", "list secret keys", "\n"); - output=(char *)malloc(1); - strcpy(output, ""); - assembleCommandLine(commandline, gpgExecutable, txtgpgargslistsecretkeys); - replace(commandline, txthome, gpgHomeDirectory); - pxresult=pxExecute(commandline, "", &output, &exitcode); - - if ((pxresult!=pxSuccess)||(exitcode!=0)) - { - free(output); - return gpgExecuteFailed; - } - - detectKeys(aresult, output, txtsec); - - free(output); - return gpgSuccess; -} - - -gpgResult gpgImportPublicKey(const char *akey) -{ - pxResult pxresult; - char commandline[commandlinesize]; - char filename[fullfilenamesize]; - DWORD exitcode; - char *output; - - LogMessage(">>> ", "import public key", "\n"); - if (! writeToFile(filename, akey)) return gpgWriteToFileFailed; - - output=(char *)malloc(1); - strcpy(output, ""); - assembleCommandLine(commandline, gpgExecutable, txtgpgargsimportpublickey); - replace(commandline, txtkeyfile, filename); - replace(commandline, txthome, gpgHomeDirectory); - pxresult=pxExecute(commandline, "", &output, &exitcode); - remove(filename); - free(output); - - if ((pxresult!=pxSuccess)||(exitcode!=0)) - return gpgExecuteFailed; - - return gpgSuccess; -} - - -gpgResult gpgExportPublicKey(char *aresult, const char *auserid) -{ - pxResult pxresult; - char commandline[commandlinesize]; - DWORD exitcode; - char *output; - - LogMessage(">>> ", "export public key", "\n"); - output=(char *)malloc(1); - strcpy(output, ""); - assembleCommandLine(commandline, gpgExecutable, txtgpgargsexportpublickey); - replace(commandline, txtuserid, auserid); - replace(commandline, txthome, gpgHomeDirectory); - pxresult=pxExecute(commandline, "", &output, &exitcode); - - if ((pxresult!=pxSuccess)||(exitcode!=0)) - { - strcpy(aresult, ""); - free(output); - return gpgExecuteFailed; - } - - strcpy(aresult, output); - - free(output); - return gpgSuccess; -} - - -gpgResult gpgDetectUserID(char *aresult, const char *aciphertext) -{ - pxResult pxresult; - char commandline[commandlinesize]; - char filename[fullfilenamesize]; - char line[linesize]; - char part[linesize]; - char *linepos; - char *partpos; - DWORD exitcode; - char *output; - - LogMessage(">>> ", "detect user id", "\n"); - strcpy(aresult, ""); - - if (! writeToFile(filename, aciphertext)) - return gpgWriteToFileFailed; - - output=(char *)malloc(1); - strcpy(output, ""); - assembleCommandLine(commandline, gpgExecutable, txtgpgargsdetectuserid); - replace(commandline, txtcipherfile, filename); - replace(commandline, txthome, gpgHomeDirectory); - pxresult=pxExecute(commandline, "", &output, &exitcode); - remove(filename); - - if ((pxresult!=pxSuccess)&&(pxresult!=pxSuccessExitCodeInvalid)) - { - free(output); - return gpgExecuteFailed; - } - - linepos=output; - - do - { - linepos=getNextPart(line, linepos, txtcrlf); - if(strncmp(line, txtgpgcolon, strlen(txtgpgcolon))!=0 && strstr(line, txtgpgcolon)==0) - { - partpos=line; - partpos=getNextPart(part, partpos, txtquotationmark); - getNextPart(part, partpos, txtquotationmark); - linepos=NULL; - } - } - while(linepos!=NULL); - strcpy(aresult, part); - - free(output); - return gpgSuccess; -} - - -gpgResult gpgEncrypt(char *aresult, const char *auserid, const char *aplaintext) -{ - pxResult pxresult; - char commandline[commandlinesize]; - char plainfile[fullfilenamesize]; - char cipherfile[fullfilenamesize]; - DWORD exitcode; - char *output; - - LogMessage(">>> ", "encrypt", "\n"); - strcpy(aresult, ""); - - if (! writeToFile(plainfile, aplaintext)) - return gpgWriteToFileFailed; - - output=(char *)malloc(1); - strcpy(output, ""); - getTemporaryFileName(cipherfile); - assembleCommandLine(commandline, gpgExecutable, txtgpgargsencrypt); - replace(commandline, txtcipherfile, cipherfile); - replace(commandline, txtplainfile, plainfile); - replace(commandline, txtuserid, auserid); - replace(commandline, txthome, gpgHomeDirectory); - pxresult=pxExecute(commandline, "", &output, &exitcode); - remove(plainfile); - free(output); - - if ((pxresult!=pxSuccess)||(exitcode!=0)) - { - remove(cipherfile); - return gpgExecuteFailed; - } - - if (! readFromFile(aresult, cipherfile)) - { - remove(cipherfile); - return gpgReadFromFileFailed; - } - - remove(cipherfile); - return gpgSuccess; -} - - -gpgResult gpgDecrypt(char *aresult, const char *aciphertext, const char *apassphrase) -{ - pxResult pxresult; - char commandline[commandlinesize]; - char plainfile[fullfilenamesize]; - char cipherfile[fullfilenamesize]; - char passphrase[linesize]; - DWORD exitcode; - char *output; - - LogMessage(">>> ", "decrypt", "\n"); - strcpy(aresult, ""); - - if (! writeToFile(cipherfile, aciphertext)) - return gpgWriteToFileFailed; - - output=(char *)malloc(1); - strcpy(output, ""); - getTemporaryFileName(plainfile); - assembleCommandLine(commandline, gpgExecutable, txtgpgargsdecrypt); - replace(commandline, txtcipherfile, cipherfile); - replace(commandline, txtplainfile, plainfile); - replace(commandline, txthome, gpgHomeDirectory); - strcpy(passphrase, apassphrase); - strcat(passphrase, txtcrlf); - pxresult=pxExecute(commandline, passphrase, &output, &exitcode); - remove(cipherfile); - free(output); - - if ((pxresult!=pxSuccess)||(exitcode!=0)) - { - remove(plainfile); - return gpgExecuteFailed; - } - - if (! readFromFile(aresult, plainfile)) - { - remove(plainfile); - return gpgReadFromFileFailed; - } - - remove(plainfile); - return gpgSuccess; -} - diff --git a/plugins/CryptoPP/src/GPGw/gpg.cpp b/plugins/CryptoPP/src/GPGw/gpg.cpp new file mode 100644 index 0000000000..47d5d178dc --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/gpg.cpp @@ -0,0 +1,365 @@ +#include "../commonheaders.h" +#include "gpgw.h" + +char *txtgpgargslistpublickeys= + "--homedir \"%home%\"" + " --with-colon" // felder durch : voneinander abgetrennt + " --list-public-keys"; // oeffentliche schluessel auflisten +char *txtgpgargslistsecretkeys= + "--homedir \"%home%\"" + " --with-colon" + " --list-secret-keys"; // geheime schluessel auflisten +char *txtgpgargsimportpublickey= + "--homedir \"%home%\"" + " --import \"%keyfile%\""; // schluessel importieren +char *txtgpgargsexportpublickey= + "--homedir \"%home%\"" + " --batch" + " --yes" // abfragen mit ja beantworten + " --armor" // ausgabe als text + " --comment \"\"" // kommentar unterdruecken ("Comment: For info see http://www.gnupg.org") + " --no-version" // ausgabe der version unterdruecken ("Version: GnuPG v1.0.6 (MingW32)") + " --export \"%userid%\""; // export des schluessels %userid% +char *txtgpgargsdetectuserid= + "--homedir \"%home%\"" + " --batch" // interaktion verhindern (daraus folgt fehler) + " --decrypt \"%cipherfile%\""; // datei %cipherfile% entschluesseln +char *txtgpgargsencrypt= + "--homedir \"%home%\"" + " --batch" + " --yes" // abfragen mit ja beantworten + " --armor" // textausgabe + " --comment \"\"" // kein kommentar hinzufuegen + " --no-version" // keine versions informationen hinzufuegen + " --recipient \"%userid%\"" // %userid% des empfaengers + " --output \"%cipherfile%\"" // ausgabe in datei %cipherfile% + " --encrypt \"%plainfile%\""; // eingabe kommt aus %plainfile% +char *txtgpgargsdecrypt= + "--homedir \"%home%\"" + " --yes" // abfragen mit ja beantworten + " --passphrase-fd 0" // passphrase von stdin + " --output \"%plainfile%\"" // ausgabe in datei %plainfile% + " --decrypt \"%cipherfile%\""; // eingabe kommt aus %cipherfile% + +// oeffentliche zeichenketten +char gpgExecutable[argumentsize]; +char gpgHomeDirectory[argumentsize]; + + +// zeichenketten fuer den internen gebrauch +char *txtpub="pub"; +char *txtsec="sec"; +char *txtcrlf="\r\n"; +char *txtcolon=":"; +char *txtquotationmark="\""; +char *txtgpgcolon="gpg:"; +char *txtplainfile="%plainfile%"; +char *txtcipherfile="%cipherfile%"; +char *txtuserid="%userid%"; +char *txtkeyfile="%keyfile%"; +char *txthome="%home%"; +char *txtidseparator=", "; + + +void assembleCommandLine(char *aresult, const char *aexecutable, const char *aargs) +{ + strcpy(aresult, aexecutable); + strcat(aresult, " "); + strcat(aresult, aargs); +} + + +void detectKeys(char *aresult, char *aoutput, const char *alabel) +{ + char line[linesize]; + char part[linesize]; + char *linepos; + char *partpos; + long i; + + strcpy(aresult, ""); + linepos=aoutput; + + do + { + linepos=getNextPart(line, linepos, txtcrlf); + if(linepos==NULL) break; + + partpos=line; + partpos=getNextPart(part, partpos, txtcolon); + + if(strcmp(part, alabel)==0) + for(i=1; i<=10; i++) + { + partpos=getNextPart(part, partpos, txtcolon); + + switch(i) + { + case 4: + strcat(aresult, part); + strcat(aresult, txtidseparator); + break; + case 9: + strcat(aresult, part); + strcat(aresult, txtcrlf); + break; + } + } + } + while(linepos!=NULL); + + replace(aresult, "\\x3a", ":"); +} + + +gpgResult gpgListPublicKeys(char *aresult) +{ + pxResult pxresult; + char commandline[commandlinesize]; + DWORD exitcode; + char *output; + + LogMessage(">>> ", "list public keys", "\n"); + output=(char *)malloc(1); + strcpy(output, ""); + assembleCommandLine(commandline, gpgExecutable, txtgpgargslistpublickeys); + replace(commandline, txthome, gpgHomeDirectory); + pxresult=pxExecute(commandline, "", &output, &exitcode); + + if ((pxresult!=pxSuccess)||(exitcode!=0)) + { + free(output); + return gpgExecuteFailed; + } + + detectKeys(aresult, output, txtpub); + + free(output); + return gpgSuccess; +} + + +gpgResult gpgListSecretKeys(char *aresult) +{ + pxResult pxresult; + char commandline[commandlinesize]; + DWORD exitcode; + char *output; + + LogMessage(">>> ", "list secret keys", "\n"); + output=(char *)malloc(1); + strcpy(output, ""); + assembleCommandLine(commandline, gpgExecutable, txtgpgargslistsecretkeys); + replace(commandline, txthome, gpgHomeDirectory); + pxresult=pxExecute(commandline, "", &output, &exitcode); + + if ((pxresult!=pxSuccess)||(exitcode!=0)) + { + free(output); + return gpgExecuteFailed; + } + + detectKeys(aresult, output, txtsec); + + free(output); + return gpgSuccess; +} + + +gpgResult gpgImportPublicKey(const char *akey) +{ + pxResult pxresult; + char commandline[commandlinesize]; + char filename[fullfilenamesize]; + DWORD exitcode; + char *output; + + LogMessage(">>> ", "import public key", "\n"); + if (! writeToFile(filename, akey)) return gpgWriteToFileFailed; + + output=(char *)malloc(1); + strcpy(output, ""); + assembleCommandLine(commandline, gpgExecutable, txtgpgargsimportpublickey); + replace(commandline, txtkeyfile, filename); + replace(commandline, txthome, gpgHomeDirectory); + pxresult=pxExecute(commandline, "", &output, &exitcode); + remove(filename); + free(output); + + if ((pxresult!=pxSuccess)||(exitcode!=0)) + return gpgExecuteFailed; + + return gpgSuccess; +} + + +gpgResult gpgExportPublicKey(char *aresult, const char *auserid) +{ + pxResult pxresult; + char commandline[commandlinesize]; + DWORD exitcode; + char *output; + + LogMessage(">>> ", "export public key", "\n"); + output=(char *)malloc(1); + strcpy(output, ""); + assembleCommandLine(commandline, gpgExecutable, txtgpgargsexportpublickey); + replace(commandline, txtuserid, auserid); + replace(commandline, txthome, gpgHomeDirectory); + pxresult=pxExecute(commandline, "", &output, &exitcode); + + if ((pxresult!=pxSuccess)||(exitcode!=0)) + { + strcpy(aresult, ""); + free(output); + return gpgExecuteFailed; + } + + strcpy(aresult, output); + + free(output); + return gpgSuccess; +} + + +gpgResult gpgDetectUserID(char *aresult, const char *aciphertext) +{ + pxResult pxresult; + char commandline[commandlinesize]; + char filename[fullfilenamesize]; + char line[linesize]; + char part[linesize]; + char *linepos; + char *partpos; + DWORD exitcode; + char *output; + + LogMessage(">>> ", "detect user id", "\n"); + strcpy(aresult, ""); + + if (! writeToFile(filename, aciphertext)) + return gpgWriteToFileFailed; + + output=(char *)malloc(1); + strcpy(output, ""); + assembleCommandLine(commandline, gpgExecutable, txtgpgargsdetectuserid); + replace(commandline, txtcipherfile, filename); + replace(commandline, txthome, gpgHomeDirectory); + pxresult=pxExecute(commandline, "", &output, &exitcode); + remove(filename); + + if ((pxresult!=pxSuccess)&&(pxresult!=pxSuccessExitCodeInvalid)) + { + free(output); + return gpgExecuteFailed; + } + + linepos=output; + + do + { + linepos=getNextPart(line, linepos, txtcrlf); + if(strncmp(line, txtgpgcolon, strlen(txtgpgcolon))!=0 && strstr(line, txtgpgcolon)==0) + { + partpos=line; + partpos=getNextPart(part, partpos, txtquotationmark); + getNextPart(part, partpos, txtquotationmark); + linepos=NULL; + } + } + while(linepos!=NULL); + strcpy(aresult, part); + + free(output); + return gpgSuccess; +} + + +gpgResult gpgEncrypt(char *aresult, const char *auserid, const char *aplaintext) +{ + pxResult pxresult; + char commandline[commandlinesize]; + char plainfile[fullfilenamesize]; + char cipherfile[fullfilenamesize]; + DWORD exitcode; + char *output; + + LogMessage(">>> ", "encrypt", "\n"); + strcpy(aresult, ""); + + if (! writeToFile(plainfile, aplaintext)) + return gpgWriteToFileFailed; + + output=(char *)malloc(1); + strcpy(output, ""); + getTemporaryFileName(cipherfile); + assembleCommandLine(commandline, gpgExecutable, txtgpgargsencrypt); + replace(commandline, txtcipherfile, cipherfile); + replace(commandline, txtplainfile, plainfile); + replace(commandline, txtuserid, auserid); + replace(commandline, txthome, gpgHomeDirectory); + pxresult=pxExecute(commandline, "", &output, &exitcode); + remove(plainfile); + free(output); + + if ((pxresult!=pxSuccess)||(exitcode!=0)) + { + remove(cipherfile); + return gpgExecuteFailed; + } + + if (! readFromFile(aresult, cipherfile)) + { + remove(cipherfile); + return gpgReadFromFileFailed; + } + + remove(cipherfile); + return gpgSuccess; +} + + +gpgResult gpgDecrypt(char *aresult, const char *aciphertext, const char *apassphrase) +{ + pxResult pxresult; + char commandline[commandlinesize]; + char plainfile[fullfilenamesize]; + char cipherfile[fullfilenamesize]; + char passphrase[linesize]; + DWORD exitcode; + char *output; + + LogMessage(">>> ", "decrypt", "\n"); + strcpy(aresult, ""); + + if (! writeToFile(cipherfile, aciphertext)) + return gpgWriteToFileFailed; + + output=(char *)malloc(1); + strcpy(output, ""); + getTemporaryFileName(plainfile); + assembleCommandLine(commandline, gpgExecutable, txtgpgargsdecrypt); + replace(commandline, txtcipherfile, cipherfile); + replace(commandline, txtplainfile, plainfile); + replace(commandline, txthome, gpgHomeDirectory); + strcpy(passphrase, apassphrase); + strcat(passphrase, txtcrlf); + pxresult=pxExecute(commandline, passphrase, &output, &exitcode); + remove(cipherfile); + free(output); + + if ((pxresult!=pxSuccess)||(exitcode!=0)) + { + remove(plainfile); + return gpgExecuteFailed; + } + + if (! readFromFile(aresult, plainfile)) + { + remove(plainfile); + return gpgReadFromFileFailed; + } + + remove(plainfile); + return gpgSuccess; +} diff --git a/plugins/CryptoPP/src/GPGw/gpg.rc b/plugins/CryptoPP/src/GPGw/gpg.rc new file mode 100644 index 0000000000..313dad2701 --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/gpg.rc @@ -0,0 +1,111 @@ +// Microsoft Visual C++ generated resource script. +// +#include "gpg_res.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_PASSPHRASE DIALOG 0, 0, 238, 46 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "GnuPG Plugin - Passphrase" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Enter passphrase for the secret key of user:", IDC_STATIC,6,4,168,8 + LTEXT "User ID",IDC_USERID,6,14,168,8 + EDITTEXT IDC_PASSPHRASE,6,24,168,12,ES_PASSWORD | ES_AUTOHSCROLL + DEFPUSHBUTTON "Ok",IDOK,181,7,50,14 + PUSHBUTTON "Cancel",IDCANCEL,181,24,50,14 +END + +IDD_SELECTKEY DIALOGEX 0, 0, 272, 208 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "GnuPG Plugin - Select public key" +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "",IDC_KEYLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,258,174 + PUSHBUTTON "Refresh",IDC_REFRESH,7,187,50,14 + DEFPUSHBUTTON "Ok",IDOK,154,187,50,14 + PUSHBUTTON "Cancel",IDCANCEL,215,187,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_SELECTKEY, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 265 + TOPMARGIN, 7 + BOTTOMMARGIN, 201 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "gpg_res.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/plugins/CryptoPP/src/GPGw/gpg_main.cpp b/plugins/CryptoPP/src/GPGw/gpg_main.cpp new file mode 100644 index 0000000000..700e27b691 --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/gpg_main.cpp @@ -0,0 +1,395 @@ +#include "../commonheaders.h" +#include "gpgw.h" + +BOOL ShowSelectExecDlg(LPSTR); +BOOL ShowSelectHomeDlg(LPSTR); + +char temporarydirectory[fullfilenamesize]; +char logfile[fullfilenamesize]; +/* +char *txtbeginpgppublickeyblock="-----BEGIN PGP PUBLIC KEY BLOCK-----"; +char *txtendpgppublickeyblock="-----END PGP PUBLIC KEY BLOCK-----"; +*/ +char *txtbeginpgpmessage="-----BEGIN PGP MESSAGE-----"; +char *txtendpgpmessage="-----END PGP MESSAGE-----"; + +void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint) +{ + char buffer[errormessagesize]; + + strcpy(buffer, atext); + strcat(buffer, " "); + strcat(buffer, ahint); + MessageBox(NULL, buffer, alevel, MB_OK); +} + + +void __cdecl LogMessage(const char *astart, const char *atext, const char *aend) +{ + FILE *log; + + if(logfile[0]=='\0') return; + + log=fopen(logfile, "a"); + if(log!=NULL) + { + fputs(astart, log); + fputs(atext, log); + fputs(aend, log); + fclose(log); + } +} + +int __cdecl _gpg_init() +{ + GetTempPath(sizeof(temporarydirectory),temporarydirectory); + logfile[0]='\0'; + initPassphrases(); + initKeyUserIDs(publickeyuserid); + initKeyUserIDs(secretkeyuserid); + return 1; +} + + +int __cdecl _gpg_done() +{ + releaseKeyUserIDs(secretkeyuserid); + releaseKeyUserIDs(publickeyuserid); + releasePassphrases(); + return 1; +} + + +int __cdecl _gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath) +{ + if ( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) { + return 0; + } + if ( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) { + return 0; + } + if ( !existsFile(ExecPath) ) { +// ErrorMessage(txtwarning, txtinvalidexecutable, txtverifyoptions); + return 0; + } + strcpy(gpgExecutable, ExecPath); + strcpy(gpgHomeDirectory, HomePath); + updateKeyUserIDs(publickeyuserid); + updateKeyUserIDs(secretkeyuserid); + return 1; +} + + +int __cdecl _gpg_close_keyrings() +{ + return 1; +} + + +LPSTR __cdecl _gpg_get_error() +{ + return 0; +} + + +void __cdecl _gpg_set_log(LPCSTR LogPath) +{ + if(LogPath) strncpy(logfile,LogPath,sizeof(logfile)); + else logfile[0]='\0'; +} + + +void __cdecl _gpg_set_tmp(LPCSTR TmpPath) +{ + if(TmpPath) strncpy(temporarydirectory,TmpPath,sizeof(temporarydirectory)); + else GetTempPath(sizeof(temporarydirectory),temporarydirectory); +} + + +LPSTR __cdecl _gpg_get_passphrases() +{ + size_t i; char *b, x; + + b = (char *) LocalAlloc(LPTR,(keyuseridsize+passphrasesize)*passphrasecount+1); *b = '\0'; + + for(i=0; i<(size_t)passphrasecount; i++) { + strcat(b,passphrases[i].keyuserid); strcat(b,"\x01"); + strcat(b,passphrases[i].passphrase); strcat(b,"\x02"); + } + + // encrypt + for(i=0; i2 ) { + x = b[i] ^ ( (i&0x7f) ^ 13); + if ( x>2 ) b[i]=x; + } + + return b; +} + + +void __cdecl _gpg_set_passphrases(LPCSTR buffer) +{ + size_t i, l = strlen(buffer); char *t, *p, *b, x; + + if ( !l ) return; + + b = (char *) LocalAlloc(LPTR,l+1); + strcpy(b, buffer); + + // decrypt + for(i=0; i2 ) { + x = b[i] ^ ( (i&0x7f) ^ 13); + if ( x>2 ) b[i]=x; + } + + while(*b) { + t = strchr(b, '\x02'); + if(t) { + *t = '\0'; + p = strchr(b, '\x01'); + *p = '\0'; + addPassphrase(b, p+1); + t++; + } + b = t; + } + LocalFree(b); +} + + +LPSTR __cdecl _gpg_encrypt(LPCSTR message, LPCSTR keyid) +{ + char buffer[ciphertextsize]; + char *encmessage = 0; + int encmessagelen; + gpgResult gpgresult; + + if(strlen(keyid)) + { + ZeroMemory(buffer, sizeof(buffer)); + gpgresult=gpgEncrypt(buffer, keyid, message); + + if(gpgresult!=gpgSuccess) + { +// ErrorMessage(txterror, txtencryptfailed, txtverifyoptions); + return 0; + } + encmessagelen = strlen(buffer)+1; + encmessage = (char *) LocalAlloc(LPTR,encmessagelen); + MoveMemory(encmessage, buffer, encmessagelen); + } + + return encmessage; +} + + +LPSTR __cdecl _gpg_decrypt(LPCSTR message) +{ + char buffer[ciphertextsize]; + char plaintext[plaintextsize]; + char keyuserid[keyuseridsize]; + int dlgresult; + BOOL useridvalid; + char *storedpassphrase; + char passphrase[passphrasesize]; + char *decmessage = 0; + int decmessagelen; + gpgResult gpgresult; + + const char *begin = strstr(message, txtbeginpgpmessage); + const char *end = strstr(message, txtendpgpmessage); + + if ((begin!=NULL)&&(end!=NULL)) + { + strcpy(buffer, ""); + strncat(buffer, begin, end-begin+strlen(txtendpgpmessage)); + replace(buffer, "\r", ""); + replace(buffer, "\n", txtcrlf); + + ZeroMemory(keyuserid, sizeof(keyuserid)); + gpgresult=gpgDetectUserID(keyuserid, buffer); + storedpassphrase=NULL; + + if(gpgresult!=gpgSuccess) + { +// ErrorMessage(txtwarning, txtdetectuseridfailed, txtverifyoptions); + strcpy(keyuserid, txtunknownuserid); + useridvalid=FALSE; + } + else + { + storedpassphrase=getPassphrase(keyuserid); + useridvalid=TRUE; + } + + if(storedpassphrase!=NULL) + { + strcpy(passphrase, storedpassphrase); + ZeroMemory(plaintext, sizeof(plaintext)); + gpgresult=gpgDecrypt(plaintext, buffer, passphrase); + } + else gpgresult=gpgUnknownError; + + dlgresult=IDOK; + while((gpgresult!=gpgSuccess)&&(dlgresult!=IDCANCEL)) + { + dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, PassphraseDialogProcedure, (LPARAM)keyuserid); + + if(dlgresult==IDOK) + { + strcpy(passphrase, dlgpassphrase); + ZeroMemory(dlgpassphrase, passphrasesize); + strcat(passphrase, txtcrlf); + ZeroMemory(plaintext, sizeof(plaintext)); + gpgresult=gpgDecrypt(plaintext, buffer, passphrase); + } + } + + if(gpgresult==gpgSuccess) + { + strcpy(buffer, plaintext); + } + + if ( gpgresult==gpgSuccess && useridvalid==TRUE) + addPassphrase(keyuserid, passphrase); + + ZeroMemory(passphrase, sizeof(passphrase)); + + decmessagelen = strlen(buffer)+1; + decmessage = (char *) LocalAlloc(LPTR,decmessagelen); + MoveMemory(decmessage, buffer, decmessagelen); + } + + return decmessage; +} + + +int __cdecl _gpg_size_keyid() +{ + return keyidsize; +} + + +int __cdecl _gpg_select_keyid(HWND hdlg, LPSTR keyid) +{ + int dlgresult; + + ZeroMemory(keyid, keyidsize); + dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_SELECTKEY), hdlg, UserIdDialogProcedure, (LPARAM)keyid); + + if(dlgresult!=IDOK) + ZeroMemory(keyid, keyidsize); + + return (dlgresult==IDOK); +} + + +void noBackslash(LPSTR path) { + LPSTR ptr; + ptr = path + strlen(path) - 1; + if ( *ptr=='\\' ) *ptr = '\0'; +} + + +static char buf[MAX_PATH]; + + +LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName){ + DWORD len=MAX_PATH,type; + LPSTR ret=0; + + RegOpenKey(hKey,szPath,&hKey); + if ( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ) { + noBackslash((LPSTR)&buf); + ret = (LPSTR)&buf; + } + RegCloseKey(hKey); + + return ret; +} + + +LPSTR GetEnvValue(LPCSTR szName){ + LPSTR ret=0; + + if ( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) { + noBackslash((LPSTR)&buf); + ret = (LPSTR)&buf; + } + + return ret; +} + + +BOOL ShowSelectExecDlg(LPSTR path) +{ + OPENFILENAME ofn; + ZeroMemory(&ofn,sizeof(ofn)); + + ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","gpgProgram"); + 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 ) { + strcat(ofn.lpstrFile,"\\gpg.exe"); + if ( existsFile(ofn.lpstrFile) ) { + strcpy(path, ofn.lpstrFile); + return TRUE; + } + } + + ofn.lStructSize = sizeof(ofn); + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; + + ofn.lpstrFile = path; + ofn.lpstrFilter = "GnuPG executable (gpg.exe)\0gpg.exe\0All files (*.*)\0*.*\0"; + ofn.lpstrTitle = "Select GnuPG executable"; + if (!GetOpenFileName(&ofn)) return FALSE; + + return TRUE; +} + + +BOOL ShowSelectHomeDlg(LPSTR path) +{ + int i; + OPENFILENAME ofn; + + ofn.lpstrFile = GetEnvValue("GNUPGHOME"); + 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) ) { + strcpy(path, ofn.lpstrFile); + return TRUE; + } + ofn.lpstrFile = GetEnvValue("APPDATA"); + if ( ofn.lpstrFile ) { + strcat(ofn.lpstrFile,"\\gnupg"); + if ( existsPath(ofn.lpstrFile) ) { + strcpy(path, ofn.lpstrFile); + return TRUE; + } + } + + ofn.lStructSize = sizeof(ofn); + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; + + ofn.lpstrFile = path; + ofn.lpstrFilter = "Public key rings (pubring.gpg)\0pubring.gpg\0All files (*.*)\0*.*\0"; + ofn.lpstrTitle = "Open Public Keyring"; + if (!GetOpenFileName(&ofn)) return FALSE; + + for(i=strlen(path);i && path[i]!='\\';i--); + path[i] = 0; + + return TRUE; +} diff --git a/plugins/CryptoPP/src/GPGw/gpg_res.h b/plugins/CryptoPP/src/GPGw/gpg_res.h new file mode 100644 index 0000000000..af5efe29d7 --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/gpg_res.h @@ -0,0 +1,21 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define IDD_PASSPHRASE 101 +#define IDD_SELECTKEY 102 +#define IDC_PASSPHRASE 1000 +#define IDC_USERID 1001 +#define IDC_KEYLIST 1002 +#define IDC_REFRESH 1003 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_SYMED_VALUE 103 +#endif +#endif diff --git a/plugins/CryptoPP/src/GPGw/gpgw.h b/plugins/CryptoPP/src/GPGw/gpgw.h new file mode 100644 index 0000000000..abaf52430e --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/gpgw.h @@ -0,0 +1,61 @@ +// Windows API + +#pragma once + +#include "..\version.h" + +// gnupg plugin +#include "gpg_res.h" +#include "size.h" +#include "language.h" +#include "pipeexec.h" +#include "gpg.h" +#include "tools.h" +#include "passphrases.h" +#include "passdialog.h" +#include "userdialog.h" +#include "keys.h" + +// passphrase typ +struct passphrase_t +{ + char keyuserid[keyuseridsize]; + char passphrase[passphrasesize]; +}; + +extern struct passphrase_t *passphrases; +extern int passphrasecount; + +extern char temporarydirectory[fullfilenamesize]; +extern char logfile[fullfilenamesize]; + +extern char *txtbeginpgppublickeyblock; +extern char *txtendpgppublickeyblock; +extern char *txtbeginpgpmessage; +extern char *txtendpgpmessage; + +#undef MODULENAME +#define MODULENAME "GnuPG" + +extern LPCSTR szModuleName; +extern LPCSTR szVersionStr; +extern HINSTANCE g_hInst; + +#define DLLEXPORT __declspec(dllexport) + +extern DLLEXPORT int __cdecl _gpg_init(void); +extern DLLEXPORT int __cdecl _gpg_done(void); +extern DLLEXPORT int __cdecl _gpg_open_keyrings(LPSTR,LPSTR); +extern DLLEXPORT int __cdecl _gpg_close_keyrings(void); +extern DLLEXPORT void __cdecl _gpg_set_log(LPCSTR); +extern DLLEXPORT void __cdecl _gpg_set_tmp(LPCSTR); +extern DLLEXPORT LPSTR __cdecl _gpg_get_error(void); +extern DLLEXPORT int __cdecl _gpg_size_keyid(void); +extern DLLEXPORT int __cdecl _gpg_select_keyid(HWND,LPSTR); +extern DLLEXPORT LPSTR __cdecl _gpg_encrypt(LPCSTR,LPCSTR); +extern DLLEXPORT LPSTR __cdecl _gpg_decrypt(LPCSTR); +extern DLLEXPORT LPSTR __cdecl _gpg_get_passphrases(); +extern DLLEXPORT void __cdecl _gpg_set_passphrases(LPCSTR); + +void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint); +void __cdecl LogMessage(const char *astart, const char *atext, const char *aend); diff --git a/plugins/CryptoPP/src/GPGw/keys.c b/plugins/CryptoPP/src/GPGw/keys.c deleted file mode 100644 index 4cfbe4f71d..0000000000 --- a/plugins/CryptoPP/src/GPGw/keys.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "commonheaders.h" - -typedef char tkeyuserid[keyuseridsize]; - -tkeyuserid *keyuserids[2]; -int keyuseridcount[2]; - - -void initKeyUserIDs(const int atype) -{ - keyuseridcount[atype]=0; - keyuserids[atype]=NULL; -} - - -void updateKeyUserIDs(const int atype) -{ - char *pos; - gpgResult gpgresult; - char buffer[largebuffersize]; - char keyuserid[keyuseridsize]; - - releaseKeyUserIDs(atype); - initKeyUserIDs(atype); - - ZeroMemory(buffer, sizeof(buffer)); - if(atype==publickeyuserid) gpgresult=gpgListPublicKeys(buffer); - else gpgresult=gpgListSecretKeys(buffer); - - if(gpgresult!=gpgSuccess) - { -// if(atype==publickeyuserid) ErrorMessage(txterror, txtlistpublickeysfailed, txtverifyoptions); -// else ErrorMessage(txterror, txtlistsecretkeysfailed, txtverifyoptions); - return; - } - - for(pos=buffer; pos!=NULL; ) - { - pos=getNextPart(keyuserid, pos, txtcrlf); - - if(pos!=NULL) - { - keyuseridcount[atype]++; - keyuserids[atype]=realloc(keyuserids[atype], sizeof(tkeyuserid)*keyuseridcount[atype]); - strcpy(keyuserids[atype][keyuseridcount[atype]-1], keyuserid); - } - } -} - - -void releaseKeyUserIDs(const int atype) -{ - free(keyuserids[atype]); -} - - -char *getKeyUserID(const int atype, const int aindex) -{ - return keyuserids[atype][aindex]; -} - - -int getKeyUserIDCount(const int atype) -{ - return keyuseridcount[atype]; -} - diff --git a/plugins/CryptoPP/src/GPGw/keys.cpp b/plugins/CryptoPP/src/GPGw/keys.cpp new file mode 100644 index 0000000000..19606d446a --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/keys.cpp @@ -0,0 +1,68 @@ +#include "../commonheaders.h" +#include "gpgw.h" + +typedef char tkeyuserid[keyuseridsize]; + +tkeyuserid *keyuserids[2]; +int keyuseridcount[2]; + + +void initKeyUserIDs(const int atype) +{ + keyuseridcount[atype]=0; + keyuserids[atype]=NULL; +} + + +void updateKeyUserIDs(const int atype) +{ + char *pos; + gpgResult gpgresult; + char buffer[largebuffersize]; + char keyuserid[keyuseridsize]; + + releaseKeyUserIDs(atype); + initKeyUserIDs(atype); + + ZeroMemory(buffer, sizeof(buffer)); + if(atype==publickeyuserid) gpgresult=gpgListPublicKeys(buffer); + else gpgresult=gpgListSecretKeys(buffer); + + if(gpgresult!=gpgSuccess) + { +// if(atype==publickeyuserid) ErrorMessage(txterror, txtlistpublickeysfailed, txtverifyoptions); +// else ErrorMessage(txterror, txtlistsecretkeysfailed, txtverifyoptions); + return; + } + + for(pos=buffer; pos!=NULL; ) + { + pos=getNextPart(keyuserid, pos, txtcrlf); + + if(pos!=NULL) + { + keyuseridcount[atype]++; + keyuserids[atype] = (tkeyuserid*)realloc(keyuserids[atype], sizeof(tkeyuserid)*keyuseridcount[atype]); + strcpy(keyuserids[atype][keyuseridcount[atype]-1], keyuserid); + } + } +} + + +void releaseKeyUserIDs(const int atype) +{ + free(keyuserids[atype]); +} + + +char *getKeyUserID(const int atype, const int aindex) +{ + return keyuserids[atype][aindex]; +} + + +int getKeyUserIDCount(const int atype) +{ + return keyuseridcount[atype]; +} + diff --git a/plugins/CryptoPP/src/GPGw/language.c b/plugins/CryptoPP/src/GPGw/language.c deleted file mode 100644 index 4997711629..0000000000 --- a/plugins/CryptoPP/src/GPGw/language.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "commonheaders.h" - -//char *txtverifyoptions="Please verify your settings in M->Options->Plugins->GnuPG and GnuPG Advanced."; /*lang*/ -//char *txtinvalidexecutable="The GnuPG Plugin requires the GnuPG executable \"gpg.exe\"."; /*lang*/ -//char *txtinvaliduserid="Could not obtain the GnuPG user id."; /*lang*/ -//char *txtexportpublickeyfailed="The export of your public key failed."; /*lang*/ -//char *txtimportpublickeyfailed="The import of the key failed."; /*lang*/ -char *txtlistpublickeysfailed="Could not generate a list of the public GnuPG keys."; /*lang*/ -char *txtlistsecretkeysfailed="Could not generate a list of the secret GnuPG keys."; /*lang*/ -//char *txtplugins="Plugins"; /*lang*/ -//char *txtgnupgplugin="GnuPG Plugin"; /*lang*/ -//char *txtexecutablefiles="Executable Files"; /*lang*/ -//char *txtselectexecutable="Select GnuPG Executable"; /*lang*/ -char *txtwarning="GnuPG Plugin - Warning"; /*lang*/ -char *txterror="GnuPG Plugin - Error"; /*lang*/ -//char *txtnone=""; /*lang*/ -//char *txtuseencryption="Use GnuPG Encryption"; /*lang*/ -//char *txtsendpublickey="Send GnuPG Key"; /*lang*/ -//char *txtpublickeyreceived="You received a public key."; /*lang*/ -//char *txtpublickeyreceivedstored="You received a public key. It was added to your keyring."; /*lang*/ -char *txtdetectuseridfailed="You received an encrypted message. Could not detect the user id of the public key, used to encrypt it."; /*lang*/ -char *txtunknownuserid="Unknown User ID"; /*lang*/ -char *txtencryptfailed="Could not encrypt the message. It wasn't sent."; /*lang*/ -//char *txtoptions="GnuPG"; /*lang*/ -//char *txtexpertoptions="GnuPG Advanced"; /*lang*/ - - diff --git a/plugins/CryptoPP/src/GPGw/language.cpp b/plugins/CryptoPP/src/GPGw/language.cpp new file mode 100644 index 0000000000..a815f7cff3 --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/language.cpp @@ -0,0 +1,28 @@ +#include "../commonheaders.h" +#include "gpgw.h" + +//char *txtverifyoptions="Please verify your settings in M->Options->Plugins->GnuPG and GnuPG Advanced."; /*lang*/ +//char *txtinvalidexecutable="The GnuPG Plugin requires the GnuPG executable \"gpg.exe\"."; /*lang*/ +//char *txtinvaliduserid="Could not obtain the GnuPG user id."; /*lang*/ +//char *txtexportpublickeyfailed="The export of your public key failed."; /*lang*/ +//char *txtimportpublickeyfailed="The import of the key failed."; /*lang*/ +char *txtlistpublickeysfailed="Could not generate a list of the public GnuPG keys."; /*lang*/ +char *txtlistsecretkeysfailed="Could not generate a list of the secret GnuPG keys."; /*lang*/ +//char *txtplugins="Plugins"; /*lang*/ +//char *txtgnupgplugin="GnuPG Plugin"; /*lang*/ +//char *txtexecutablefiles="Executable Files"; /*lang*/ +//char *txtselectexecutable="Select GnuPG Executable"; /*lang*/ +char *txtwarning="GnuPG Plugin - Warning"; /*lang*/ +char *txterror="GnuPG Plugin - Error"; /*lang*/ +//char *txtnone=""; /*lang*/ +//char *txtuseencryption="Use GnuPG Encryption"; /*lang*/ +//char *txtsendpublickey="Send GnuPG Key"; /*lang*/ +//char *txtpublickeyreceived="You received a public key."; /*lang*/ +//char *txtpublickeyreceivedstored="You received a public key. It was added to your keyring."; /*lang*/ +char *txtdetectuseridfailed="You received an encrypted message. Could not detect the user id of the public key, used to encrypt it."; /*lang*/ +char *txtunknownuserid="Unknown User ID"; /*lang*/ +char *txtencryptfailed="Could not encrypt the message. It wasn't sent."; /*lang*/ +//char *txtoptions="GnuPG"; /*lang*/ +//char *txtexpertoptions="GnuPG Advanced"; /*lang*/ + + diff --git a/plugins/CryptoPP/src/GPGw/main.c b/plugins/CryptoPP/src/GPGw/main.c deleted file mode 100644 index fc23b24262..0000000000 --- a/plugins/CryptoPP/src/GPGw/main.c +++ /dev/null @@ -1,369 +0,0 @@ -#include "commonheaders.h" - - -BOOL ShowSelectExecDlg(LPSTR); -BOOL ShowSelectHomeDlg(LPSTR); - - -int __cdecl _gpg_init() -{ - GetTempPath(sizeof(temporarydirectory),temporarydirectory); - logfile[0]='\0'; - initPassphrases(); - initKeyUserIDs(publickeyuserid); - initKeyUserIDs(secretkeyuserid); - return 1; -} - - -int __cdecl _gpg_done() -{ - releaseKeyUserIDs(secretkeyuserid); - releaseKeyUserIDs(publickeyuserid); - releasePassphrases(); - return 1; -} - - -int __cdecl _gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath) -{ - if ( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) { - return 0; - } - if ( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) { - return 0; - } - if ( !existsFile(ExecPath) ) { -// ErrorMessage(txtwarning, txtinvalidexecutable, txtverifyoptions); - return 0; - } - strcpy(gpgExecutable, ExecPath); - strcpy(gpgHomeDirectory, HomePath); - updateKeyUserIDs(publickeyuserid); - updateKeyUserIDs(secretkeyuserid); - return 1; -} - - -int __cdecl _gpg_close_keyrings() -{ - return 1; -} - - -LPSTR __cdecl _gpg_get_error() -{ - return 0; -} - - -void __cdecl _gpg_set_log(LPCSTR LogPath) -{ - if(LogPath) strncpy(logfile,LogPath,sizeof(logfile)); - else logfile[0]='\0'; -} - - -void __cdecl _gpg_set_tmp(LPCSTR TmpPath) -{ - if(TmpPath) strncpy(temporarydirectory,TmpPath,sizeof(temporarydirectory)); - else GetTempPath(sizeof(temporarydirectory),temporarydirectory); -} - - -LPSTR __cdecl _gpg_get_passphrases() -{ - size_t i; char *b, x; - - b = (char *) LocalAlloc(LPTR,(keyuseridsize+passphrasesize)*passphrasecount+1); *b = '\0'; - - for(i=0; i<(size_t)passphrasecount; i++) { - strcat(b,passphrases[i].keyuserid); strcat(b,"\x01"); - strcat(b,passphrases[i].passphrase); strcat(b,"\x02"); - } - - // encrypt - for(i=0; i2 ) { - x = b[i] ^ ( (i&0x7f) ^ 13); - if ( x>2 ) b[i]=x; - } - - return b; -} - - -void __cdecl _gpg_set_passphrases(LPCSTR buffer) -{ - size_t i, l = strlen(buffer); char *t, *p, *b, x; - - if ( !l ) return; - - b = (char *) LocalAlloc(LPTR,l+1); - strcpy(b, buffer); - - // decrypt - for(i=0; i2 ) { - x = b[i] ^ ( (i&0x7f) ^ 13); - if ( x>2 ) b[i]=x; - } - - while(*b) { - t = strchr(b, '\x02'); - if(t) { - *t = '\0'; - p = strchr(b, '\x01'); - *p = '\0'; - addPassphrase(b, p+1); - t++; - } - b = t; - } - LocalFree(b); -} - - -LPSTR __cdecl _gpg_encrypt(LPCSTR message, LPCSTR keyid) -{ - char buffer[ciphertextsize]; - char *encmessage = 0; - int encmessagelen; - gpgResult gpgresult; - - if(strlen(keyid)) - { - ZeroMemory(buffer, sizeof(buffer)); - gpgresult=gpgEncrypt(buffer, keyid, message); - - if(gpgresult!=gpgSuccess) - { -// ErrorMessage(txterror, txtencryptfailed, txtverifyoptions); - return 0; - } - encmessagelen = strlen(buffer)+1; - encmessage = (char *) LocalAlloc(LPTR,encmessagelen); - MoveMemory(encmessage, buffer, encmessagelen); - } - - return encmessage; -} - - -LPSTR __cdecl _gpg_decrypt(LPCSTR message) -{ - char buffer[ciphertextsize]; - char plaintext[plaintextsize]; - char keyuserid[keyuseridsize]; - char *begin, *end; - int dlgresult; - BOOL useridvalid; - char *storedpassphrase; - char passphrase[passphrasesize]; - char *decmessage = 0; - int decmessagelen; - gpgResult gpgresult; - - begin=strstr(message, txtbeginpgpmessage); - end=strstr(message, txtendpgpmessage); - - if ((begin!=NULL)&&(end!=NULL)) - { - strcpy(buffer, ""); - strncat(buffer, begin, end-begin+strlen(txtendpgpmessage)); - replace(buffer, "\r", ""); - replace(buffer, "\n", txtcrlf); - - ZeroMemory(keyuserid, sizeof(keyuserid)); - gpgresult=gpgDetectUserID(keyuserid, buffer); - storedpassphrase=NULL; - - if(gpgresult!=gpgSuccess) - { -// ErrorMessage(txtwarning, txtdetectuseridfailed, txtverifyoptions); - strcpy(keyuserid, txtunknownuserid); - useridvalid=FALSE; - } - else - { - storedpassphrase=getPassphrase(keyuserid); - useridvalid=TRUE; - } - - if(storedpassphrase!=NULL) - { - strcpy(passphrase, storedpassphrase); - ZeroMemory(plaintext, sizeof(plaintext)); - gpgresult=gpgDecrypt(plaintext, buffer, passphrase); - } - else gpgresult=gpgUnknownError; - - dlgresult=IDOK; - while((gpgresult!=gpgSuccess)&&(dlgresult!=IDCANCEL)) - { - dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, PassphraseDialogProcedure, (LPARAM)keyuserid); - - if(dlgresult==IDOK) - { - strcpy(passphrase, dlgpassphrase); - ZeroMemory(dlgpassphrase, passphrasesize); - strcat(passphrase, txtcrlf); - ZeroMemory(plaintext, sizeof(plaintext)); - gpgresult=gpgDecrypt(plaintext, buffer, passphrase); - } - } - - if(gpgresult==gpgSuccess) - { - strcpy(buffer, plaintext); - } - - if ( gpgresult==gpgSuccess && useridvalid==TRUE) - addPassphrase(keyuserid, passphrase); - - ZeroMemory(passphrase, sizeof(passphrase)); - - decmessagelen = strlen(buffer)+1; - decmessage = (char *) LocalAlloc(LPTR,decmessagelen); - MoveMemory(decmessage, buffer, decmessagelen); - } - - return decmessage; -} - - -int __cdecl _gpg_size_keyid() -{ - return keyidsize; -} - - -int __cdecl _gpg_select_keyid(HWND hdlg, LPSTR keyid) -{ - int dlgresult; - - ZeroMemory(keyid, keyidsize); - dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_SELECTKEY), hdlg, UserIdDialogProcedure, (LPARAM)keyid); - - if(dlgresult!=IDOK) - ZeroMemory(keyid, keyidsize); - - return (dlgresult==IDOK); -} - - -void noBackslash(LPSTR path) { - LPSTR ptr; - ptr = path + strlen(path) - 1; - if ( *ptr=='\\' ) *ptr = '\0'; -} - - -static char buf[MAX_PATH]; - - -LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName){ - DWORD len=MAX_PATH,type; - LPSTR ret=0; - - RegOpenKey(hKey,szPath,&hKey); - if ( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ) { - noBackslash((LPSTR)&buf); - ret = (LPSTR)&buf; - } - RegCloseKey(hKey); - - return ret; -} - - -LPSTR GetEnvValue(LPCSTR szName){ - LPSTR ret=0; - - if ( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) { - noBackslash((LPSTR)&buf); - ret = (LPSTR)&buf; - } - - return ret; -} - - -BOOL ShowSelectExecDlg(LPSTR path) -{ - OPENFILENAME ofn; - ZeroMemory(&ofn,sizeof(ofn)); - - ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","gpgProgram"); - 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 ) { - strcat(ofn.lpstrFile,"\\gpg.exe"); - if ( existsFile(ofn.lpstrFile) ) { - strcpy(path, ofn.lpstrFile); - return TRUE; - } - } - - ofn.lStructSize = sizeof(ofn); - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; - - ofn.lpstrFile = path; - ofn.lpstrFilter = "GnuPG executable (gpg.exe)\0gpg.exe\0All files (*.*)\0*.*\0"; - ofn.lpstrTitle = "Select GnuPG executable"; - if (!GetOpenFileName(&ofn)) return FALSE; - - return TRUE; -} - - -BOOL ShowSelectHomeDlg(LPSTR path) -{ - int i; - OPENFILENAME ofn; - - ofn.lpstrFile = GetEnvValue("GNUPGHOME"); - 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) ) { - strcpy(path, ofn.lpstrFile); - return TRUE; - } - ofn.lpstrFile = GetEnvValue("APPDATA"); - if ( ofn.lpstrFile ) { - strcat(ofn.lpstrFile,"\\gnupg"); - if ( existsPath(ofn.lpstrFile) ) { - strcpy(path, ofn.lpstrFile); - return TRUE; - } - } - - ofn.lStructSize = sizeof(ofn); - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; - - ofn.lpstrFile = path; - ofn.lpstrFilter = "Public key rings (pubring.gpg)\0pubring.gpg\0All files (*.*)\0*.*\0"; - ofn.lpstrTitle = "Open Public Keyring"; - if (!GetOpenFileName(&ofn)) return FALSE; - - for(i=strlen(path);i && path[i]!='\\';i--); - path[i] = 0; - - return TRUE; -} - - -// dllmain -BOOL WINAPI dllmain(HINSTANCE hInst, DWORD dwReason, LPVOID lpVoid) { - g_hInst = hInst; - return TRUE; -} - diff --git a/plugins/CryptoPP/src/GPGw/passdialog.c b/plugins/CryptoPP/src/GPGw/passdialog.c deleted file mode 100644 index cbba1139ab..0000000000 --- a/plugins/CryptoPP/src/GPGw/passdialog.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "commonheaders.h" - -char dlgpassphrase[passphrasesize]; - - -BOOL CALLBACK PassphraseDialogProcedure(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - SetDlgItemText(hdlg, IDC_USERID, (char *)lparam); - break; - case WM_COMMAND: - switch(LOWORD(wparam)) - { - case IDOK: - ZeroMemory(dlgpassphrase, sizeof(dlgpassphrase)); - GetDlgItemText(hdlg, IDC_PASSPHRASE, dlgpassphrase, sizeof(dlgpassphrase)); - case IDCANCEL: - EndDialog(hdlg, wparam); - return TRUE; - break; - } - break; - } - - return FALSE; -} - diff --git a/plugins/CryptoPP/src/GPGw/passdialog.cpp b/plugins/CryptoPP/src/GPGw/passdialog.cpp new file mode 100644 index 0000000000..d00753af9e --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/passdialog.cpp @@ -0,0 +1,29 @@ +#include "../commonheaders.h" +#include "gpgw.h" + +char dlgpassphrase[passphrasesize]; + +BOOL CALLBACK PassphraseDialogProcedure(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + SetDlgItemText(hdlg, IDC_USERID, (char *)lparam); + break; + case WM_COMMAND: + switch(LOWORD(wparam)) + { + case IDOK: + ZeroMemory(dlgpassphrase, sizeof(dlgpassphrase)); + GetDlgItemText(hdlg, IDC_PASSPHRASE, dlgpassphrase, sizeof(dlgpassphrase)); + case IDCANCEL: + EndDialog(hdlg, wparam); + return TRUE; + break; + } + break; + } + + return FALSE; +} + diff --git a/plugins/CryptoPP/src/GPGw/passphrases.c b/plugins/CryptoPP/src/GPGw/passphrases.c deleted file mode 100644 index 5e93936ffc..0000000000 --- a/plugins/CryptoPP/src/GPGw/passphrases.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "commonheaders.h" - -// globale variablen -struct passphrase *passphrases; -int passphrasecount; - - -void initPassphrases(void) -{ - passphrasecount=0; - passphrases=NULL; -} - - -void releasePassphrases(void) -{ - int i; - - for(i=0; i0); -} - - -pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aexitcode) -{ - BOOL success; - STARTUPINFO startupinfo; - SECURITY_ATTRIBUTES securityattributes; - SECURITY_DESCRIPTOR securitydescriptor; - PROCESS_INFORMATION processinformation; - HANDLE newstdin, newstdout, readstdout, writestdin; - char *inputpos; - DWORD transfered; - int size; - - LogMessage("commandline:\n", acommandline, "\n"); - - ZeroMemory(&securityattributes, sizeof(securityattributes)); - securityattributes.nLength=sizeof(SECURITY_ATTRIBUTES); - securityattributes.bInheritHandle=TRUE; - - if(isWindowsNT()) - { - InitializeSecurityDescriptor(&securitydescriptor, SECURITY_DESCRIPTOR_REVISION); - SetSecurityDescriptorDacl(&securitydescriptor, TRUE, NULL, FALSE); - securityattributes.lpSecurityDescriptor=&securitydescriptor; - } - else securityattributes.lpSecurityDescriptor=NULL; - - success=CreatePipe(&newstdin, &writestdin ,&securityattributes ,0); - if (! success) - { - LogMessage("--- ", "create pipe failed", "\n"); - return pxCreatePipeFailed; - } - - success=CreatePipe(&readstdout, &newstdout, &securityattributes, 0); - if (! success) - { - LogMessage("--- ", "create pipe failed", "\n"); - CloseHandle(newstdin); - CloseHandle(writestdin); - return pxCreatePipeFailed; - } - - GetStartupInfo(&startupinfo); - startupinfo.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; - startupinfo.wShowWindow=SW_HIDE; - startupinfo.hStdOutput=newstdout; - startupinfo.hStdError=newstdout; - startupinfo.hStdInput=newstdin; - - success=CreateProcess(NULL, acommandline, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startupinfo, &processinformation); - - if (! success) - { - LogMessage("--- ", "create process failed", "\n"); - CloseHandle(newstdin); - CloseHandle(writestdin); - CloseHandle(newstdout); - CloseHandle(readstdout); - return pxCreateProcessFailed; - } - - inputpos=ainput; - - while(TRUE) - { - success=GetExitCodeProcess(processinformation.hProcess, aexitcode); - if ((success)&&(*aexitcode!=STILL_ACTIVE)) break; - - storeOutput(readstdout, aoutput); - - if (*inputpos!='\0') size=1; - else size=0; - - success=WriteFile(writestdin, inputpos, size, &transfered, NULL); - - inputpos+=transfered; - } - - storeOutput(readstdout, aoutput); - WaitForSingleObject(processinformation.hProcess, INFINITE); - - LogMessage("output:\n", *aoutput, ""); - - CloseHandle(processinformation.hThread); - CloseHandle(processinformation.hProcess); - CloseHandle(newstdin); - CloseHandle(newstdout); - CloseHandle(readstdout); - CloseHandle(writestdin); - - return pxSuccess; -} - diff --git a/plugins/CryptoPP/src/GPGw/pipeexec.cpp b/plugins/CryptoPP/src/GPGw/pipeexec.cpp new file mode 100644 index 0000000000..fdefb147d6 --- /dev/null +++ b/plugins/CryptoPP/src/GPGw/pipeexec.cpp @@ -0,0 +1,134 @@ +#include "../commonheaders.h" +#include "gpgw.h" + +BOOL isWindowsNT(void) +{ + BOOL result; + OSVERSIONINFO ovi; + + ZeroMemory(&ovi, sizeof(ovi)); + ovi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); + GetVersionEx(&ovi); + + if(ovi.dwPlatformId==VER_PLATFORM_WIN32_NT) result=TRUE; + else result=FALSE; + + return result; +} + + +void storeOutput(HANDLE ahandle, char **aoutput) +{ + DWORD success; + char readbuffer[10]; + DWORD transfered; + DWORD available; + + do + { + PeekNamedPipe(ahandle, NULL, 0, NULL, &available, NULL); + + if(available==0) continue; + + success=ReadFile(ahandle, readbuffer, sizeof(readbuffer), &transfered, NULL); + + if ((success)&&(transfered!=0)) + appendText(aoutput, readbuffer, transfered); + } + while(available>0); +} + + +pxResult pxExecute(char *acommandline, char *ainput, char **aoutput, LPDWORD aexitcode) +{ + BOOL success; + STARTUPINFO startupinfo; + SECURITY_ATTRIBUTES securityattributes; + SECURITY_DESCRIPTOR securitydescriptor; + PROCESS_INFORMATION processinformation; + HANDLE newstdin, newstdout, readstdout, writestdin; + char *inputpos; + DWORD transfered; + int size; + + LogMessage("commandline:\n", acommandline, "\n"); + + ZeroMemory(&securityattributes, sizeof(securityattributes)); + securityattributes.nLength=sizeof(SECURITY_ATTRIBUTES); + securityattributes.bInheritHandle=TRUE; + + if(isWindowsNT()) + { + InitializeSecurityDescriptor(&securitydescriptor, SECURITY_DESCRIPTOR_REVISION); + SetSecurityDescriptorDacl(&securitydescriptor, TRUE, NULL, FALSE); + securityattributes.lpSecurityDescriptor=&securitydescriptor; + } + else securityattributes.lpSecurityDescriptor=NULL; + + success=CreatePipe(&newstdin, &writestdin ,&securityattributes ,0); + if (! success) + { + LogMessage("--- ", "create pipe failed", "\n"); + return pxCreatePipeFailed; + } + + success=CreatePipe(&readstdout, &newstdout, &securityattributes, 0); + if (! success) + { + LogMessage("--- ", "create pipe failed", "\n"); + CloseHandle(newstdin); + CloseHandle(writestdin); + return pxCreatePipeFailed; + } + + GetStartupInfo(&startupinfo); + startupinfo.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; + startupinfo.wShowWindow=SW_HIDE; + startupinfo.hStdOutput=newstdout; + startupinfo.hStdError=newstdout; + startupinfo.hStdInput=newstdin; + + success=CreateProcess(NULL, acommandline, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startupinfo, &processinformation); + + if (! success) + { + LogMessage("--- ", "create process failed", "\n"); + CloseHandle(newstdin); + CloseHandle(writestdin); + CloseHandle(newstdout); + CloseHandle(readstdout); + return pxCreateProcessFailed; + } + + inputpos=ainput; + + while(TRUE) + { + success=GetExitCodeProcess(processinformation.hProcess, aexitcode); + if ((success)&&(*aexitcode!=STILL_ACTIVE)) break; + + storeOutput(readstdout, aoutput); + + if (*inputpos!='\0') size=1; + else size=0; + + success=WriteFile(writestdin, inputpos, size, &transfered, NULL); + + inputpos+=transfered; + } + + storeOutput(readstdout, aoutput); + WaitForSingleObject(processinformation.hProcess, INFINITE); + + LogMessage("output:\n", *aoutput, ""); + + CloseHandle(processinformation.hThread); + CloseHandle(processinformation.hProcess); + CloseHandle(newstdin); + CloseHandle(newstdout); + CloseHandle(readstdout); + CloseHandle(writestdin); + + return pxSuccess; +} + diff --git a/plugins/CryptoPP/src/GPGw/resource.h b/plugins/CryptoPP/src/GPGw/resource.h deleted file mode 100644 index af5efe29d7..0000000000 --- a/plugins/CryptoPP/src/GPGw/resource.h +++ /dev/null @@ -1,21 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDD_PASSPHRASE 101 -#define IDD_SELECTKEY 102 -#define IDC_PASSPHRASE 1000 -#define IDC_USERID 1001 -#define IDC_KEYLIST 1002 -#define IDC_REFRESH 1003 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1004 -#define _APS_NEXT_SYMED_VALUE 103 -#endif -#endif diff --git a/plugins/CryptoPP/src/GPGw/resource.rc b/plugins/CryptoPP/src/GPGw/resource.rc deleted file mode 100644 index 53968a5d2e..0000000000 --- a/plugins/CryptoPP/src/GPGw/resource.rc +++ /dev/null @@ -1,112 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1251) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_PASSPHRASE DIALOG 0, 0, 238, 46 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "GnuPG Plugin - Passphrase" -FONT 8, "MS Shell Dlg" -BEGIN - LTEXT "Enter passphrase for the secret key of user:", IDC_STATIC,6,4,168,8 - LTEXT "User ID",IDC_USERID,6,14,168,8 - EDITTEXT IDC_PASSPHRASE,6,24,168,12,ES_PASSWORD | ES_AUTOHSCROLL - DEFPUSHBUTTON "Ok",IDOK,181,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,181,24,50,14 -END - -IDD_SELECTKEY DIALOGEX 0, 0, 272, 208 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "GnuPG Plugin - Select public key" -FONT 8, "MS Shell Dlg" -BEGIN - CONTROL "",IDC_KEYLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | - LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,258,174 - PUSHBUTTON "Refresh",IDC_REFRESH,7,187,50,14 - DEFPUSHBUTTON "Ok",IDOK,154,187,50,14 - PUSHBUTTON "Cancel",IDCANCEL,215,187,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_SELECTKEY, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 265 - TOPMARGIN, 7 - BOTTOMMARGIN, 201 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/CryptoPP/src/GPGw/tools.c b/plugins/CryptoPP/src/GPGw/tools.c deleted file mode 100644 index 002f18824d..0000000000 --- a/plugins/CryptoPP/src/GPGw/tools.c +++ /dev/null @@ -1,191 +0,0 @@ -#include "commonheaders.h" - -// escape sequence type -struct escapesequence -{ - char *sequence; - char *code; -}; - -// supported escape sequences -struct escapesequence escsequence[]= -{ - {"\\n", "\n"}, - {"\\r", "\r"}, - {"\\t", "\t"} -}; - -// number of supported escape sequences -int escsequencecount=sizeof(escsequence)/sizeof(struct escapesequence); - - -void replace(char *atext, const char *apattern, const char *areplacement) -{ - char *pos, *last; - long textsize; - long patternsize; - long replacementsize; - - pos=atext; - patternsize=strlen(apattern); - replacementsize=strlen(areplacement); - - do - { - // textstelle suchen - last=pos; - pos=strstr(pos, apattern); - // etwas gefunden? - if(pos==NULL) break; - - // laenge des textes ermitteln - textsize=strlen(last); - // platz schaffen - memmove(pos+replacementsize, pos+patternsize, textsize-((pos-last)+patternsize)+1); - // ersetzen - strncpy(pos, areplacement, replacementsize); - pos+=replacementsize; - } - while(pos!=NULL); -} - - -char *getNextPart(char *aresult, char *atext, const char *aseparator) -{ - char *pos; - - strcpy(aresult, ""); - pos=strstr(atext, aseparator); - - if(pos!=NULL) - { - strncat(aresult, atext, pos-atext); - pos+=strlen(aseparator); - } - else strcpy(aresult, atext); - - return pos; -} - - -void getLastPart(char *aresult, char *atext) -{ - strcpy(aresult, atext); -} - - -void appendText(char **abuffer, const char *atext, int atextsize) -{ - int size; - - if (*abuffer==NULL) size=0; - else size=strlen(*abuffer); - size++; // abschliessende 0 - if(atextsize==0) atextsize=strlen(atext); - size+=atextsize; - - *abuffer=(char *)realloc(*abuffer, size); - strncat(*abuffer, atext, atextsize); -} - - -BOOL existsFile(const char *afilename) -{ - int attr; - - if(strlen(afilename)==0) return FALSE; - - attr = GetFileAttributes(afilename); - - return ( (attr!=-1) && ((attr&FILE_ATTRIBUTE_DIRECTORY)==0)); -} - - -BOOL existsPath(const char *apathname) -{ - int attr; - - if(strlen(apathname)==0) return FALSE; - - attr = GetFileAttributes(apathname); - - return ( (attr!=-1) && (attr&FILE_ATTRIBUTE_DIRECTORY) ); -} - - -BOOL writeToFile(char *afilename, const char *atext) -{ - FILE *handle; - size_t written; - size_t length; - - getTemporaryFileName(afilename); - - handle=fopen(afilename, "wb"); - - if(handle==NULL) - { - LogMessage("--- ", "write to file", "\n"); - LogMessage("filename:\n", afilename, "\n"); - return FALSE; - } - - length=strlen(atext); - written=fwrite(atext, sizeof(char), length, handle); - - if(written!=length) return FALSE; - - fclose(handle); - return TRUE; -} - - -BOOL readFromFile(char *aresult, const char *afilename) -{ - FILE *handle; - size_t filesize; - size_t read; - - handle=fopen(afilename, "rb"); - if(handle==NULL) - { - LogMessage("--- ", "read from file", "\n"); - LogMessage("filename:\n", afilename, "\n"); - return FALSE; - } - - fseek(handle, 0, SEEK_END); - filesize=ftell(handle); - fseek(handle, 0, SEEK_SET); - - read=fread(aresult, sizeof(char), filesize, handle); - if(read!=filesize) return FALSE; - - fclose(handle); - return TRUE; -} - - -void getTemporaryFileName(char *aresult) -{ - GetTempFileName(temporarydirectory,"gpg",0,aresult); -} - - -void quoteEscapeSequences(char *atext) -{ - int i; - - for(i=0; i -//#include -#include -#include "..\version.h" - -#pragma comment(linker,"/merge:.rdata=.text") -#pragma comment(linker,"/entry:dllmain") -#pragma comment(linker,"/nodefaultlib") -#pragma comment(linker,"/subsystem:windows") -#pragma optimize("gsy", on) - -// PGP API -#ifndef PGP_WIN32 -#error Define PGP_WIN32 to SDK version (e.g. 0x658) -#endif - -#include -#include -#include -#include -#include -#include -#include - - -#define MODULENAME "PGPsdk" -BOOL ShowSelectKeyringsDlg(HWND,LPSTR,LPSTR); - -extern LPCSTR szModuleName; -extern LPCSTR szVersionStr; -extern HINSTANCE g_hInst; - - -#define DLLEXPORT __declspec(dllexport) - -extern "C" DLLEXPORT int __cdecl _pgp_init(void); -extern "C" DLLEXPORT int __cdecl _pgp_done(void); -extern "C" DLLEXPORT int __cdecl _pgp_open_keyrings(LPSTR,LPSTR); -extern "C" DLLEXPORT int __cdecl _pgp_close_keyrings(void); -extern "C" DLLEXPORT int __cdecl _pgp_get_version(void); -extern "C" DLLEXPORT LPSTR __cdecl _pgp_get_error(void); -extern "C" DLLEXPORT int __cdecl _pgp_size_keyid(void); -extern "C" DLLEXPORT PVOID __cdecl _pgp_select_keyid(HWND,LPSTR); -extern "C" DLLEXPORT LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR,PVOID); -extern "C" DLLEXPORT LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR); -//extern "C" DLLEXPORT int __cdecl _pgp_check_key(LPCSTR); -extern "C" DLLEXPORT LPSTR __cdecl _pgp_encrypt_key(LPCSTR,LPCSTR); -extern "C" DLLEXPORT LPSTR __cdecl _pgp_decrypt_key(LPCSTR,LPCSTR); - -/* -#undef RtlMoveMemory -#undef RtlFillMemory -#undef RtlZeroMemory - -NTSYSAPI VOID NTAPI RtlMoveMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, SIZE_T Length); -NTSYSAPI VOID NTAPI RtlFillMemory(VOID UNALIGNED *Destination, SIZE_T Length, BYTE Fill); -NTSYSAPI VOID NTAPI RtlZeroMemory(VOID UNALIGNED *Destination, SIZE_T Length); -*/ diff --git a/plugins/CryptoPP/src/PGPw/main.cpp b/plugins/CryptoPP/src/PGPw/main.cpp deleted file mode 100644 index 8427046a16..0000000000 --- a/plugins/CryptoPP/src/PGPw/main.cpp +++ /dev/null @@ -1,584 +0,0 @@ -#include "commonheaders.h" - -// pgpsdk.lib pgpsdknl.lib pgpsdkui.lib libcmt.lib -// /delayload:pgpsdk.dll,pgpsdknl.dll,pgpsdkui.dll - -PGPContextRef pgpContext; -#if (PGP_WIN32 < 0x700) -PGPKeySetRef pgpKeyDB = 0; -#else -PGPKeyDBRef pgpKeyDB = 0; -#endif -LPSTR pszPassphrase = 0; -LPSTR pgpErrMsg = 0; -#define pgpErrMsgLen 512 -UINT pgpVer; - - -void ClearPGPError() -{ - *pgpErrMsg = '\0'; -} - - -bool CheckPGPError(PGPError err) -{ - if (IsPGPError(err)) { - PGPSize ErrMsgLen = pgpErrMsgLen; - PGPGetErrorString(err, ErrMsgLen, pgpErrMsg); - return 1; - } - else { - *pgpErrMsg = '\0'; - return 0; - } -} - -#define _pgp_memcpy memmove -/* -void _pgp_memcpy(LPSTR dst, LPSTR src, UINT size) -{ - for(UINT i=0;i> 12; - switch(PGPMajorVersion(pgpVer)) { - case 2: - pgpVer = 1<<24 | ((minor+1)<<16) | (PGPRevVersion(pgpVer)<<8); - break; - case 3: - pgpVer = 1<<24 | ((minor+5)<<16) | (PGPRevVersion(pgpVer)<<8); - break; - default: - pgpVer = 1<<24 | (minor<<16) | (PGPRevVersion(pgpVer)<<8); - break; - } -#else - pgpVer = PGPGetPGPsdkVersion(); -#endif - - return 1; -} - - -int __cdecl _pgp_done() -{ - pgpVer = 0; - __try { - if(pgpErrMsg) LocalFree(pgpErrMsg); - if (pszPassphrase) PGPFreeData(pszPassphrase); -#if (PGP_WIN32 < 0x700) - if (pgpKeyDB) PGPFreeKeySet(pgpKeyDB); -#else - if (pgpKeyDB) PGPFreeKeyDB(pgpKeyDB); -#endif - PGPFreeContext(pgpContext); - PGPsdkUILibCleanup(); - PGPsdkCleanup(); - pszPassphrase = pgpErrMsg = 0; - pgpKeyDB = 0; - pgpContext = 0; - } - __except ( EXCEPTION_EXECUTE_HANDLER ) { - return 0; - } - return 1; -} - - -int __cdecl _pgp_open_keyrings(LPSTR PubRingPath, LPSTR SecRingPath) -{ - _pgp_close_keyrings(); - -#if (PGP_WIN32 < 0x700) - PGPError err = PGPOpenDefaultKeyRings(pgpContext, kPGPKeyRingOpenFlags_None, &pgpKeyDB); -#else - if ((!PubRingPath || !*PubRingPath) && !ShowSelectKeyringsDlg(0,PubRingPath,SecRingPath)) { - return 0; - } - - PGPFileSpecRef PubKeyRing, SecKeyRing; - PGPNewFileSpecFromFullPath(pgpContext, PubRingPath, &PubKeyRing); - PGPNewFileSpecFromFullPath(pgpContext, SecRingPath, &SecKeyRing); - - PGPError err = PGPOpenKeyDBFile(pgpContext, kPGPOpenKeyDBFileOptions_None, PubKeyRing, SecKeyRing, &pgpKeyDB); - PGPFreeFileSpec(SecKeyRing); - PGPFreeFileSpec(PubKeyRing); -#endif - if (CheckPGPError(err)) { - return 0; - } - return 1; -} - - -int __cdecl _pgp_close_keyrings() -{ -#if (PGP_WIN32 < 0x700) - if (pgpKeyDB) { - PGPFreeKeySet(pgpKeyDB); - pgpKeyDB = 0; - } -#else - if (pgpKeyDB) { - PGPFreeKeyDB(pgpKeyDB); - pgpKeyDB = 0; - } -#endif - return 1; -} - - -int __cdecl _pgp_get_version() -{ - return pgpVer; -} - - -LPSTR __cdecl _pgp_get_error() -{ - return pgpErrMsg; -} - - -LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR szPlainMsg, PVOID pgpKeyID) -{ - PGPKeyID *RemoteKeyID = (PGPKeyID *) pgpKeyID; - LPSTR szEncMsg = 0; - DWORD dwEncMsgLen; - - ClearPGPError(); - if (!pgpKeyDB) - return 0; - -#if (PGP_WIN32 < 0x700) - PGPFilterRef IDFilter; - PGPNewKeyIDFilter(pgpContext, RemoteKeyID, &IDFilter); - - PGPKeySetRef PublicKey; - PGPFilterKeySet(pgpKeyDB, IDFilter, &PublicKey); -#else - PGPKeyDBObjRef PublicKey; - PGPFindKeyByKeyID(pgpKeyDB, RemoteKeyID, &PublicKey); -#endif - - PGPError err = PGPEncode(pgpContext, - PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)), - PGPOArmorOutput(pgpContext, TRUE), - PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen), -#if (PGP_WIN32 < 0x700) - PGPOEncryptToKeySet(pgpContext, PublicKey), -#else - PGPOEncryptToKeyDBObj(pgpContext, PublicKey), -#endif - PGPOVersionString(pgpContext, szVersionStr), - PGPOLastOption(pgpContext)); - -#if (PGP_WIN32 < 0x700) - PGPFreeKeySet(PublicKey); - PGPFreeFilter(IDFilter); -#endif - - if (CheckPGPError(err)) - return 0; - - LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwEncMsgLen+1); - _pgp_memcpy(szMsg, szEncMsg, dwEncMsgLen); - szMsg[dwEncMsgLen] = 0; - PGPFreeData((LPVOID)szEncMsg); - - return szMsg; -} - - -LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR szEncMsg) -{ - LPSTR szPlainMsg = 0; - DWORD dwPlainMsgLen; - - ClearPGPError(); - if (!pgpKeyDB) - return 0; - - int iTry = 0; - - do { - if (!pszPassphrase && - PGPPassphraseDialog(pgpContext, - PGPOUIOutputPassphrase(pgpContext, &pszPassphrase), - PGPOLastOption(pgpContext)) == kPGPError_UserAbort) { - iTry = 3; - break; - } - - PGPError err = PGPDecode(pgpContext, - PGPOInputBuffer(pgpContext, szEncMsg, lstrlen(szEncMsg)), - PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szPlainMsg, 16384, (PGPUInt32 *)&dwPlainMsgLen), -#if (PGP_WIN32 < 0x700) - PGPOKeySetRef(pgpContext, pgpKeyDB), -#else - PGPOKeyDBRef(pgpContext, pgpKeyDB), -#endif - PGPOPassphrase(pgpContext, pszPassphrase), - PGPOLastOption(pgpContext)); - - if (CheckPGPError(err)) - iTry = 3; - else - if (!dwPlainMsgLen) { - PGPFreeData(pszPassphrase); - pszPassphrase = 0; - iTry++; - } - - } while(!dwPlainMsgLen && iTry<3); - - if(iTry == 3) return 0; - - LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwPlainMsgLen+1); - _pgp_memcpy(szMsg, szPlainMsg, dwPlainMsgLen); - szMsg[dwPlainMsgLen] = 0; - PGPFreeData((LPVOID)szPlainMsg); - - return szMsg; -} - - -#if (PGP_WIN32 < 0x700) -PGPError _pgp_import_key(PGPKeySetRef *keySet, LPCSTR pgpKey) -{ - return PGPImportKeySet( pgpContext, - keySet, - PGPOInputBuffer( pgpContext, - pgpKey, - lstrlen(pgpKey) ), - PGPOLastOption( pgpContext ) ); -} -#else -PGPError _pgp_import_key(PGPKeyDBRef *keyDB, LPCSTR pgpKey) -{ - return PGPImport( pgpContext, - keyDB, - PGPOInputBuffer( pgpContext, - pgpKey, - lstrlen(pgpKey) ), - PGPOLastOption( pgpContext ) ); -} -#endif - -/* -int __cdecl _pgp_check_key(LPCSTR pgpKey) -{ -#if (PGP_WIN32 < 0x700) - PGPKeySetRef PrivateKey; - if (CheckPGPError(_pgp_import_key(&PrivateKey,pgpKey))) - return 0; - PGPFreeKeySet(PrivateKey); -#else - PGPKeyDBRef PrivateKey; - if (CheckPGPError(_pgp_import_key(&PrivateKey,pgpKey))) - return 0; - PGPFreeKeyDB(PrivateKey); -#endif - return 1; -} -*/ - -LPSTR __cdecl _pgp_encrypt_key(LPCSTR szPlainMsg, LPCSTR pgpKey) -{ - LPSTR szEncMsg = 0; - DWORD dwEncMsgLen; - - PGPUInt32 dwKeys; -#if (PGP_WIN32 < 0x700) - PGPKeySetRef PublicKey; - if (CheckPGPError(_pgp_import_key(&PublicKey,pgpKey))) - return 0; - PGPCountKeys(PublicKey, &dwKeys); -#else - PGPKeyDBRef PublicKeyDB; - if (CheckPGPError(_pgp_import_key(&PublicKeyDB,pgpKey))) - return 0; - - PGPKeyIterRef KeyIterRef; - PGPNewKeyIterFromKeyDB(PublicKeyDB, &KeyIterRef); - - PGPKeyDBObjRef PublicKey; - PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &PublicKey); - - PGPCountKeysInKeyDB(PublicKeyDB, &dwKeys); -#endif - if(dwKeys==0) { -#if (PGP_WIN32 < 0x700) - PGPFreeKeySet(PublicKey); -#else - PGPFreeKeyIter(KeyIterRef); - PGPFreeKeyDB(PublicKeyDB); -#endif - return 0; - } - - PGPError err = PGPEncode(pgpContext, - PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)), - PGPOArmorOutput(pgpContext, TRUE), - PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen), -#if (PGP_WIN32 < 0x700) - PGPOEncryptToKeySet(pgpContext, PublicKey), -#else - PGPOEncryptToKeyDBObj(pgpContext, PublicKey), -#endif - PGPOVersionString(pgpContext, szVersionStr), - PGPOLastOption(pgpContext)); - -#if (PGP_WIN32 < 0x700) - PGPFreeKeySet(PublicKey); -#else - PGPFreeKeyIter(KeyIterRef); - PGPFreeKeyDB(PublicKeyDB); -#endif - - if (CheckPGPError(err)) - return 0; - - LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwEncMsgLen+1); - _pgp_memcpy(szMsg, szEncMsg, dwEncMsgLen); - szMsg[dwEncMsgLen] = 0; - PGPFreeData((LPVOID)szEncMsg); - - return szMsg; -} - - -LPSTR __cdecl _pgp_decrypt_key(LPCSTR szEncMsg, LPCSTR pgpKey) -{ - LPSTR szPlainMsg = 0; - DWORD dwPlainMsgLen; - - PGPUInt32 dwKeys; -#if (PGP_WIN32 < 0x700) - PGPKeySetRef PrivateKeyDB; - if (CheckPGPError(_pgp_import_key(&PrivateKeyDB,pgpKey))) - return 0; - PGPCountKeys(PrivateKeyDB, &dwKeys); -#else - PGPKeyDBRef PrivateKeyDB; - if (CheckPGPError(_pgp_import_key(&PrivateKeyDB,pgpKey))) - return 0; - PGPCountKeysInKeyDB(PrivateKeyDB, &dwKeys); -#endif - if(dwKeys==0) { -#if (PGP_WIN32 < 0x700) - PGPFreeKeySet(PrivateKeyDB); -#else - PGPFreeKeyDB(PrivateKeyDB); -#endif - return 0; - } - - int iTry = 0; - - do { - if (!pszPassphrase && - PGPPassphraseDialog(pgpContext, - PGPOUIOutputPassphrase(pgpContext, &pszPassphrase), - PGPOLastOption(pgpContext)) == kPGPError_UserAbort) { - iTry = 3; - break; - } - -/* -#if (PGP_WIN32 < 0x700) - PGPKeyListRef PrivateKeyList; - PGPOrderKeySet(PrivateKeyDB, kPGPKeyIDOrdering, &PrivateKeyList); - - PGPKeyIterRef KeyIterRef; - PGPNewKeyIter(PrivateKeyList, &KeyIterRef); - - PGPKeyRef PrivateKey; - for(int i=0;i 1) - MessageBox(hDlg, "You selected more than one key. Only the first key will be used.", szModuleName, MB_ICONINFORMATION); - - static PGPKeyID KeyID; - -#if (PGP_WIN32 < 0x700) - PGPKeyListRef ContactKeyList; - PGPOrderKeySet(ContactKeyDB, kPGPKeyIDOrdering, &ContactKeyList); - - PGPKeyIterRef KeyIterRef; - PGPNewKeyIter(ContactKeyList, &KeyIterRef); - - PGPKeyRef ContactKey; - PGPKeyIterNext(KeyIterRef, &ContactKey); - - PGPGetKeyIDFromKey(ContactKey, &KeyID); - PGPGetKeyIDString(&KeyID, kPGPKeyIDString_Abbreviated, szKeyID); - - PGPFreeKeyList(ContactKeyList); - PGPFreeKeyIter(KeyIterRef); - PGPFreeKeySet(ContactKeyDB); -#else - PGPKeyIterRef KeyIterRef; - PGPNewKeyIterFromKeyDB(ContactKeyDB, &KeyIterRef); - - PGPKeyDBObjRef KeyDBObjRef; - PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &KeyDBObjRef); - - PGPSize dwFilled; - PGPGetKeyDBObjDataProperty(KeyDBObjRef, kPGPKeyProperty_KeyID, &KeyID, sizeof(PGPKeyID), &dwFilled); - PGPGetKeyIDString(&KeyID, kPGPKeyIDString_Abbreviated, szKeyID); - - PGPFreeKeyIter(KeyIterRef); - PGPFreeKeyDB(ContactKeyDB); -#endif - - return (PVOID)&KeyID; -} - - -#if (PGP_WIN32 >= 0x700) -BOOL ShowSelectKeyringsDlg(HWND hParent, LPSTR PubRingPath, LPSTR SecRingPath) -{ - // set keyring paths - OPENFILENAME ofn={0}; - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hParent; - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON; - - ofn.lpstrFile = PubRingPath; - ofn.lpstrFilter = "Public key rings (pubring.pkr)\0pubring.pkr\0All files (*.*)\0*.*\0"; - ofn.lpstrTitle = "Open Public Keyring"; - if (!GetOpenFileName(&ofn)) return FALSE; - - ofn.lpstrFile = SecRingPath; - ofn.lpstrFilter = "Secret key rings (secring.skr)\0secring.skr\0All files (*.*)\0*.*\0"; - ofn.lpstrTitle = "Open Secret Keyring"; - if (!GetOpenFileName(&ofn)) return FALSE; - - return TRUE; -} -#endif - - -// dllmain -BOOL WINAPI dllmain(HINSTANCE hInst, DWORD dwReason, LPVOID) { - g_hInst = hInst; - return TRUE; -} - diff --git a/plugins/CryptoPP/src/PGPw/pgpw.h b/plugins/CryptoPP/src/PGPw/pgpw.h new file mode 100644 index 0000000000..9e26090e58 --- /dev/null +++ b/plugins/CryptoPP/src/PGPw/pgpw.h @@ -0,0 +1,33 @@ +// Windows API + +#pragma once + +#include "..\version.h" + +// PGP API +#ifndef PGP_WIN32 +#error Define PGP_WIN32 to SDK version (e.g. 0x658) +#endif + +#undef MODULENAME +#define MODULENAME "PGPsdk" + +BOOL ShowSelectKeyringsDlg(HWND,LPSTR,LPSTR); + +extern LPCSTR szModuleName; +extern LPCSTR szVersionStr; +extern HINSTANCE g_hInst; + +extern "C" int __cdecl _pgp_init(void); +extern "C" int __cdecl _pgp_done(void); +extern "C" int __cdecl _pgp_open_keyrings(LPSTR,LPSTR); +extern "C" int __cdecl _pgp_close_keyrings(void); +extern "C" int __cdecl _pgp_get_version(void); +extern "C" LPSTR __cdecl _pgp_get_error(void); +extern "C" int __cdecl _pgp_size_keyid(void); +extern "C" PVOID __cdecl _pgp_select_keyid(HWND,LPSTR); +extern "C" LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR,PVOID); +extern "C" LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR); +extern "C" int __cdecl _pgp_check_key(LPCSTR); +extern "C" LPSTR __cdecl _pgp_encrypt_key(LPCSTR,LPCSTR); +extern "C" LPSTR __cdecl _pgp_decrypt_key(LPCSTR,LPCSTR); diff --git a/plugins/CryptoPP/src/PGPw/sdk6.cpp b/plugins/CryptoPP/src/PGPw/sdk6.cpp new file mode 100644 index 0000000000..3d9bf47f17 --- /dev/null +++ b/plugins/CryptoPP/src/PGPw/sdk6.cpp @@ -0,0 +1,375 @@ +#include "../commonheaders.h" + +#define PGP_WIN32 0x600 + +#include "sdk6/include/pgpEncode.h" +#include "sdk6/include/pgpErrors.h" +#include "sdk6/include/pgpKeys.h" +#include "sdk6/include/pgpOptionList.h" +#include "sdk6/include/pgpUserInterface.h" +#include "sdk6/include/pgpUtilities.h" +#include "sdk6/include/pgpFeatures.h" + +#include "pgpw.h" + +// pgpsdk.lib pgpsdknl.lib pgpsdkui.lib libcmt.lib +// /delayload:pgpsdk.dll,pgpsdknl.dll,pgpsdkui.dll + +PGPContextRef pgpContext; +PGPKeySetRef pgpKeyDB = 0; +LPSTR pszPassphrase = 0; +LPSTR pgpErrMsg = 0; +#define pgpErrMsgLen 512 +UINT pgpVer; + + +void ClearPGPError() +{ + *pgpErrMsg = '\0'; +} + + +bool CheckPGPError(PGPError err) +{ + if (IsPGPError(err)) { + PGPSize ErrMsgLen = pgpErrMsgLen; + PGPGetErrorString(err, ErrMsgLen, pgpErrMsg); + return 1; + } + else { + *pgpErrMsg = '\0'; + return 0; + } +} + +#define _pgp_memcpy memmove +/* +void _pgp_memcpy(LPSTR dst, LPSTR src, UINT size) +{ + for(UINT i=0;i> 12; + switch(PGPMajorVersion(pgpVer)) { + case 2: + pgpVer = 1<<24 | ((minor+1)<<16) | (PGPRevVersion(pgpVer)<<8); + break; + case 3: + pgpVer = 1<<24 | ((minor+5)<<16) | (PGPRevVersion(pgpVer)<<8); + break; + default: + pgpVer = 1<<24 | (minor<<16) | (PGPRevVersion(pgpVer)<<8); + break; + } + + return 1; +} + + +int __cdecl _pgp_done() +{ + pgpVer = 0; + __try { + if(pgpErrMsg) LocalFree(pgpErrMsg); + if (pszPassphrase) PGPFreeData(pszPassphrase); + if (pgpKeyDB) PGPFreeKeySet(pgpKeyDB); + PGPFreeContext(pgpContext); + PGPsdkUILibCleanup(); + PGPsdkCleanup(); + pszPassphrase = pgpErrMsg = 0; + pgpKeyDB = 0; + pgpContext = 0; + } + __except ( EXCEPTION_EXECUTE_HANDLER ) { + return 0; + } + return 1; +} + + +int __cdecl _pgp_open_keyrings(LPSTR PubRingPath, LPSTR SecRingPath) +{ + _pgp_close_keyrings(); + + PGPError err = PGPOpenDefaultKeyRings(pgpContext, kPGPKeyRingOpenFlags_None, &pgpKeyDB); + if (CheckPGPError(err)) { + return 0; + } + return 1; +} + + +int __cdecl _pgp_close_keyrings() +{ + if (pgpKeyDB) { + PGPFreeKeySet(pgpKeyDB); + pgpKeyDB = 0; + } + return 1; +} + + +int __cdecl _pgp_get_version() +{ + return pgpVer; +} + + +LPSTR __cdecl _pgp_get_error() +{ + return pgpErrMsg; +} + + +LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR szPlainMsg, PVOID pgpKeyID) +{ + PGPKeyID *RemoteKeyID = (PGPKeyID *) pgpKeyID; + LPSTR szEncMsg = 0; + DWORD dwEncMsgLen; + + ClearPGPError(); + if (!pgpKeyDB) + return 0; + + PGPFilterRef IDFilter; + PGPNewKeyIDFilter(pgpContext, RemoteKeyID, &IDFilter); + + PGPKeySetRef PublicKey; + PGPFilterKeySet(pgpKeyDB, IDFilter, &PublicKey); + + PGPError err = PGPEncode(pgpContext, + PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)), + PGPOArmorOutput(pgpContext, TRUE), + PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen), + PGPOEncryptToKeySet(pgpContext, PublicKey), + PGPOVersionString(pgpContext, szVersionStr), + PGPOLastOption(pgpContext)); + + PGPFreeKeySet(PublicKey); + PGPFreeFilter(IDFilter); + + if (CheckPGPError(err)) + return 0; + + LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwEncMsgLen+1); + _pgp_memcpy(szMsg, szEncMsg, dwEncMsgLen); + szMsg[dwEncMsgLen] = 0; + PGPFreeData((LPVOID)szEncMsg); + + return szMsg; +} + + +LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR szEncMsg) +{ + LPSTR szPlainMsg = 0; + DWORD dwPlainMsgLen; + + ClearPGPError(); + if (!pgpKeyDB) + return 0; + + int iTry = 0; + + do { + if (!pszPassphrase && + PGPPassphraseDialog(pgpContext, + PGPOUIOutputPassphrase(pgpContext, &pszPassphrase), + PGPOLastOption(pgpContext)) == kPGPError_UserAbort) { + iTry = 3; + break; + } + + PGPError err = PGPDecode(pgpContext, + PGPOInputBuffer(pgpContext, szEncMsg, lstrlen(szEncMsg)), + PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szPlainMsg, 16384, (PGPUInt32 *)&dwPlainMsgLen), + PGPOKeySetRef(pgpContext, pgpKeyDB), + PGPOPassphrase(pgpContext, pszPassphrase), + PGPOLastOption(pgpContext)); + + if (CheckPGPError(err)) + iTry = 3; + else + if (!dwPlainMsgLen) { + PGPFreeData(pszPassphrase); + pszPassphrase = 0; + iTry++; + } + + } while(!dwPlainMsgLen && iTry<3); + + if(iTry == 3) return 0; + + LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwPlainMsgLen+1); + _pgp_memcpy(szMsg, szPlainMsg, dwPlainMsgLen); + szMsg[dwPlainMsgLen] = 0; + PGPFreeData((LPVOID)szPlainMsg); + + return szMsg; +} + + +PGPError _pgp_import_key(PGPKeySetRef *keySet, LPCSTR pgpKey) +{ + return PGPImportKeySet( pgpContext, + keySet, + PGPOInputBuffer( pgpContext, + pgpKey, + lstrlen(pgpKey) ), + PGPOLastOption( pgpContext ) ); +} + +LPSTR __cdecl _pgp_encrypt_key(LPCSTR szPlainMsg, LPCSTR pgpKey) +{ + LPSTR szEncMsg = 0; + DWORD dwEncMsgLen; + + PGPUInt32 dwKeys; + PGPKeySetRef PublicKey; + if (CheckPGPError(_pgp_import_key(&PublicKey,pgpKey))) + return 0; + PGPCountKeys(PublicKey, &dwKeys); + if(dwKeys==0) { + PGPFreeKeySet(PublicKey); + return 0; + } + + PGPError err = PGPEncode(pgpContext, + PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)), + PGPOArmorOutput(pgpContext, TRUE), + PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen), + PGPOEncryptToKeySet(pgpContext, PublicKey), + PGPOVersionString(pgpContext, szVersionStr), + PGPOLastOption(pgpContext)); + + PGPFreeKeySet(PublicKey); + if (CheckPGPError(err)) + return 0; + + LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwEncMsgLen+1); + _pgp_memcpy(szMsg, szEncMsg, dwEncMsgLen); + szMsg[dwEncMsgLen] = 0; + PGPFreeData((LPVOID)szEncMsg); + + return szMsg; +} + + +LPSTR __cdecl _pgp_decrypt_key(LPCSTR szEncMsg, LPCSTR pgpKey) +{ + LPSTR szPlainMsg = 0; + DWORD dwPlainMsgLen; + + PGPUInt32 dwKeys; + PGPKeySetRef PrivateKeyDB; + if (CheckPGPError(_pgp_import_key(&PrivateKeyDB,pgpKey))) + return 0; + PGPCountKeys(PrivateKeyDB, &dwKeys); + if(dwKeys==0) { + PGPFreeKeySet(PrivateKeyDB); + return 0; + } + + int iTry = 0; + + do { + if (!pszPassphrase && + PGPPassphraseDialog(pgpContext, + PGPOUIOutputPassphrase(pgpContext, &pszPassphrase), + PGPOLastOption(pgpContext)) == kPGPError_UserAbort) { + iTry = 3; + break; + } + + PGPError err = PGPDecode(pgpContext, + PGPOInputBuffer(pgpContext, szEncMsg, lstrlen(szEncMsg)), + PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szPlainMsg, 16384, (PGPUInt32 *)&dwPlainMsgLen), + PGPOKeySetRef(pgpContext, PrivateKeyDB), + PGPOPassphrase(pgpContext, pszPassphrase), + PGPOLastOption(pgpContext)); + + if (CheckPGPError(err)) + iTry = 3; + else + if (!dwPlainMsgLen) { + PGPFreeData(pszPassphrase); + pszPassphrase = 0; + iTry++; + } + + } while(!dwPlainMsgLen && iTry<3); + + PGPFreeKeySet(PrivateKeyDB); + + if(iTry == 3) return 0; + + LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwPlainMsgLen+1); + _pgp_memcpy(szMsg, szPlainMsg, dwPlainMsgLen); + szMsg[dwPlainMsgLen] = 0; + PGPFreeData((LPVOID)szPlainMsg); + + return szMsg; +} + + +int __cdecl _pgp_size_keyid() +{ + return sizeof(PGPKeyID); +} + + +PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID) +{ + PGPKeySetRef ContactKeyDB; + PGPError err; + err = PGPRecipientDialog(pgpContext, pgpKeyDB, TRUE, &ContactKeyDB, + PGPOUIParentWindowHandle(pgpContext, hDlg), + PGPOUIWindowTitle(pgpContext, "Select Contact's Key"), + PGPOLastOption(pgpContext)); + if (err == kPGPError_UserAbort) + return 0; + + PGPUInt32 dwKeys; + PGPCountKeys(ContactKeyDB, &dwKeys); + if (!dwKeys) { + return 0; + } else if (dwKeys > 1) + MessageBox(hDlg, "You selected more than one key. Only the first key will be used.", szModuleName, MB_ICONINFORMATION); + + static PGPKeyID KeyID; + + PGPKeyListRef ContactKeyList; + PGPOrderKeySet(ContactKeyDB, kPGPKeyIDOrdering, &ContactKeyList); + + PGPKeyIterRef KeyIterRef; + PGPNewKeyIter(ContactKeyList, &KeyIterRef); + + PGPKeyRef ContactKey; + PGPKeyIterNext(KeyIterRef, &ContactKey); + + PGPGetKeyIDFromKey(ContactKey, &KeyID); + PGPGetKeyIDString(&KeyID, kPGPKeyIDString_Abbreviated, szKeyID); + + PGPFreeKeyList(ContactKeyList); + PGPFreeKeyIter(KeyIterRef); + PGPFreeKeySet(ContactKeyDB); + return (PVOID)&KeyID; +} diff --git a/plugins/CryptoPP/src/commonheaders.h b/plugins/CryptoPP/src/commonheaders.h index aa2b79c773..0d1c068d9e 100644 --- a/plugins/CryptoPP/src/commonheaders.h +++ b/plugins/CryptoPP/src/commonheaders.h @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include @@ -70,9 +72,6 @@ extern LPCSTR szModuleName; extern LPCSTR szVersionStr; -extern TCHAR TEMP[MAX_PATH]; -extern int TEMP_SIZE; -extern BOOL isVista; // shared vars extern HINSTANCE g_hInst; diff --git a/plugins/CryptoPP/src/cpp_gpgw.cpp b/plugins/CryptoPP/src/cpp_gpgw.cpp index e6a5899fc2..ff62e0104d 100644 --- a/plugins/CryptoPP/src/cpp_gpgw.cpp +++ b/plugins/CryptoPP/src/cpp_gpgw.cpp @@ -5,20 +5,6 @@ HMODULE hgpg; HRSRC hRS_gpg; PBYTE pRS_gpg; -extern DLLEXPORT int __cdecl _gpg_init(void); -extern DLLEXPORT int __cdecl _gpg_done(void); -extern DLLEXPORT int __cdecl _gpg_open_keyrings(LPSTR,LPSTR); -extern DLLEXPORT int __cdecl _gpg_close_keyrings(void); -extern DLLEXPORT void __cdecl _gpg_set_log(LPCSTR); -extern DLLEXPORT void __cdecl _gpg_set_tmp(LPCSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_get_error(void); -extern DLLEXPORT int __cdecl _gpg_size_keyid(void); -extern DLLEXPORT int __cdecl _gpg_select_keyid(HWND,LPSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_encrypt(LPCSTR,LPCSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_decrypt(LPCSTR); -extern DLLEXPORT LPSTR __cdecl _gpg_get_passphrases(); -extern DLLEXPORT void __cdecl _gpg_set_passphrases(LPCSTR); - int __cdecl _gpg_init(void); int __cdecl _gpg_done(void); int __cdecl _gpg_open_keyrings(LPSTR,LPSTR); @@ -33,130 +19,17 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR); LPSTR __cdecl _gpg_get_passphrases(); void __cdecl _gpg_set_passphrases(LPCSTR); -int (__cdecl *p_gpg_init)(void); -int (__cdecl *p_gpg_done)(void); -int (__cdecl *p_gpg_open_keyrings)(LPSTR,LPSTR); -int (__cdecl *p_gpg_close_keyrings)(void); -void (__cdecl *p_gpg_set_log)(LPCSTR); -void (__cdecl *p_gpg_set_tmp)(LPCSTR); -LPSTR (__cdecl *p_gpg_get_error)(void); -int (__cdecl *p_gpg_size_keyid)(void); -int (__cdecl *p_gpg_select_keyid)(HWND,LPSTR); -LPSTR (__cdecl *p_gpg_encrypt)(LPCSTR,LPCSTR); -LPSTR (__cdecl *p_gpg_decrypt)(LPCSTR); -LPSTR (__cdecl *p_gpg_get_passphrases)(); -void (__cdecl *p_gpg_set_passphrases)(LPCSTR); - - -#define GPA(x) \ - { \ - *((PVOID*)&p##x) = (PVOID)GetProcAddress(mod, TEXT(#x)); \ - if (!p##x) { \ - return 0; \ - } \ - } - -int load_gpg_dll(HMODULE mod) { - - GPA(_gpg_init); - GPA(_gpg_done); - GPA(_gpg_open_keyrings); - GPA(_gpg_close_keyrings); - GPA(_gpg_set_log); - GPA(_gpg_set_tmp); - GPA(_gpg_get_error); - GPA(_gpg_size_keyid); - GPA(_gpg_select_keyid); - GPA(_gpg_encrypt); - GPA(_gpg_decrypt); - GPA(_gpg_get_passphrases); - GPA(_gpg_set_passphrases); - - return 1; -} - -#undef GPA - - -#define GPA(x) \ - { \ - *((PVOID*)&p##x) = (PVOID)MemGetProcAddress(mod, TEXT(#x)); \ - if (!p##x) { \ - return 0; \ - } \ - } - -int load_gpg_mem(HMODULE mod) { - - GPA(_gpg_init); - GPA(_gpg_done); - GPA(_gpg_open_keyrings); - GPA(_gpg_close_keyrings); - GPA(_gpg_set_log); - GPA(_gpg_set_tmp); - GPA(_gpg_get_error); - GPA(_gpg_size_keyid); - GPA(_gpg_select_keyid); - GPA(_gpg_encrypt); - GPA(_gpg_decrypt); - GPA(_gpg_get_passphrases); - GPA(_gpg_set_passphrases); - - return 1; -} - -#undef GPA - - int __cdecl gpg_init() { - int r; char t[MAX_PATH]; - if ( isVista ) { - sprintf(t,"%s\\gnupgw.dll",TEMP); - ExtractFile(t,666,1); - hgpg = LoadLibraryA(t); - } - else { - hRS_gpg = FindResource( g_hInst, MAKEINTRESOURCE(1), MAKEINTRESOURCE(666) ); - pRS_gpg = (PBYTE) LoadResource( g_hInst, hRS_gpg ); LockResource( pRS_gpg ); - hgpg = MemLoadLibrary( pRS_gpg ); - } - if (hgpg) { - if ( isVista ) load_gpg_dll(hgpg); - else load_gpg_mem(hgpg); - r = p_gpg_init(); - if (r) { - return r; - } - if ( isVista ) { - FreeLibrary(hgpg); - } - else { - MemFreeLibrary(hgpg); - UnlockResource( pRS_gpg ); - FreeResource( pRS_gpg ); - } - } - - hgpg = 0; - - return 0; + hgpg = g_hInst; + return _gpg_init(); } - int __cdecl gpg_done() { int r = 0; if (hgpg) { - r = p_gpg_done(); - if ( isVista ) { - FreeLibrary(hgpg); - } - else { - MemFreeLibrary(hgpg); - UnlockResource( pRS_gpg ); - FreeResource( pRS_gpg ); - } + r = _gpg_done(); hgpg = 0; } return r; @@ -165,31 +38,31 @@ int __cdecl gpg_done() int __cdecl gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath) { - return p_gpg_open_keyrings(ExecPath, HomePath); + return _gpg_open_keyrings(ExecPath, HomePath); } int __cdecl gpg_close_keyrings() { - return p_gpg_close_keyrings(); + return _gpg_close_keyrings(); } void __cdecl gpg_set_log(LPCSTR LogPath) { - p_gpg_set_log(LogPath); + _gpg_set_log(LogPath); } void __cdecl gpg_set_tmp(LPCSTR TmpPath) { - p_gpg_set_tmp(TmpPath); + _gpg_set_tmp(TmpPath); } LPSTR __cdecl gpg_get_error() { - return p_gpg_get_error(); + return _gpg_get_error(); } @@ -200,7 +73,7 @@ LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg) SAFE_FREE(ptr->tmp); LPSTR szEncMsg; - szEncMsg = p_gpg_encrypt(szPlainMsg,(LPCSTR)p->gpgKeyID); + szEncMsg = _gpg_encrypt(szPlainMsg,(LPCSTR)p->gpgKeyID); if (!szEncMsg) return 0; ptr->tmp = (LPSTR)_strdup(szEncMsg); @@ -215,11 +88,11 @@ LPSTR __cdecl gpg_decrypt(pCNTX ptr, LPCSTR szEncMsg) ptr->error = ERROR_NONE; SAFE_FREE(ptr->tmp); - LPSTR szPlainMsg = p_gpg_decrypt(szEncMsg); + LPSTR szPlainMsg = _gpg_decrypt(szEncMsg); /* 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); + szPlainMsg = _gpg_decrypt_key(szEncMsg,(LPCSTR)ptr->pgpKey); if (!szPlainMsg) return NULL; }*/ @@ -282,7 +155,7 @@ int __cdecl gpg_set_key(HANDLE context, LPCSTR RemoteKey) if (!ptr) return 0; ptr->error = ERROR_NONE; -// if (!p_gpg_check_key(RemoteKey)) return 0; +// if (!_gpg_check_key(RemoteKey)) return 0; SAFE_FREE(ptr->pgpKey); ptr->pgpKey = (BYTE *) malloc(strlen(RemoteKey)+1); @@ -309,25 +182,25 @@ int __cdecl gpg_set_keyid(HANDLE context, LPCSTR RemoteKeyID) int __cdecl gpg_size_keyid() { - return p_gpg_size_keyid(); + return _gpg_size_keyid(); } int __cdecl gpg_select_keyid(HWND hDlg,LPSTR szKeyID) { - return p_gpg_select_keyid(hDlg,szKeyID); + return _gpg_select_keyid(hDlg,szKeyID); } LPSTR __cdecl gpg_get_passphrases() { - return p_gpg_get_passphrases(); + return _gpg_get_passphrases(); } void __cdecl gpg_set_passphrases(LPCSTR buffer) { - p_gpg_set_passphrases(buffer); + _gpg_set_passphrases(buffer); } diff --git a/plugins/CryptoPP/src/cpp_pgpw.cpp b/plugins/CryptoPP/src/cpp_pgpw.cpp index 7a70a99607..84349583c7 100644 --- a/plugins/CryptoPP/src/cpp_pgpw.cpp +++ b/plugins/CryptoPP/src/cpp_pgpw.cpp @@ -92,46 +92,8 @@ int load_pgpsdk_mem(HMODULE mod) { #undef GPA -BOOL load_pgp_sdk(int type, int id) -{ - int r; char t[MAX_PATH]; - pgpVer = 0; - - if ( isVista ) { - sprintf(t,"%s\\pgpsdkw.dll",TEMP); - ExtractFile(t,type,id); - hpgpsdk = LoadLibraryA(t); - } - else { - hRS_pgp = FindResource( g_hInst, MAKEINTRESOURCE(id), MAKEINTRESOURCE(type) ); - pRS_pgp = (PBYTE) LoadResource( g_hInst, hRS_pgp ); LockResource( pRS_pgp ); - hpgpsdk = MemLoadLibrary( pRS_pgp ); - } - if (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 ) { - FreeLibrary(hpgpsdk); - } - else { - MemFreeLibrary(hpgpsdk); - UnlockResource( pRS_pgp ); - FreeResource( pRS_pgp ); - } - } - return 0; -} - - int __cdecl pgp_init() { - int r; - if ( !hPGPPRIV ) { // create context for private pgp keys hPGPPRIV = (HANDLE) cpp_create_context(MODE_PGP|MODE_PRIV_KEY); @@ -140,11 +102,7 @@ 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; - - hpgpsdk = 0; - + hpgpsdk = g_hInst; return 0; } @@ -155,14 +113,6 @@ int __cdecl pgp_done() pgpVer = 0; if (hpgpsdk) { r = p_pgp_done(); - if ( isVista ) { - FreeLibrary(hpgpsdk); - } - else { - MemFreeLibrary(hpgpsdk); - UnlockResource( pRS_pgp ); - FreeResource( pRS_pgp ); - } hpgpsdk = 0; } return r; diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp index dacdfda235..ae447897f6 100644 --- a/plugins/CryptoPP/src/main.cpp +++ b/plugins/CryptoPP/src/main.cpp @@ -11,10 +11,6 @@ HANDLE hRSA4096 = NULL; CRITICAL_SECTION localQueueMutex; CRITICAL_SECTION localContextMutex; -char TEMP[MAX_PATH]; -int TEMP_SIZE = 0; -BOOL isVista = 0; - PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -33,11 +29,6 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) { if (dwReason == DLL_PROCESS_ATTACH) { g_hInst = hInst; - #ifdef _DEBUG - isVista = 1; - #else - isVista = ( (DWORD)(LOBYTE(LOWORD(GetVersion()))) == 6 ); - #endif InitializeCriticalSection(&localQueueMutex); InitializeCriticalSection(&localContextMutex); } -- cgit v1.2.3