#include <QCoreApplication>#include <QDebug>#define PGP_WIN32 1#define _UNICODE 1#include "pgpMsg.h"static const char* kTestMessage = "X-Make-Money-Fast: TRUE\r\n" "MIME-Version: 1.0\r\n" "Subject: Dearest $USER, your assistance is pleased required\r\n" "Date: Fri, 1 Jan 2013 17:57:05 +0900\r\n" "From: \"Mr. Esquire $USER\" <redir.ru.cn@127.200.119.21>\r\n" "To: \"$USER\" <user@127.0.0.1>\r\n" "Content-Type: text/plain\r\n\r\n" "Dear Mr, $USER.\r\n\r\n" "Please considerate this letters by very much seriously because of unportant\r\n" "businesses of the Nigeria consulate bank army. My funds are of full\r\n" "money to send in America, Canada, USA. I am $USER you for helping gold\r\n" "stocks and portfilos with helping for serious of 15 (fiveteen) with cent\r\n" "of profits are of you. Until in confident five days by you responding VERY\r\n" "UNPORTANT| if with government by savings.\r\n\r\n" "By onlying with help us, for serious, businessing.\r\n\r\n" "Sincely.\r\n" " Mr, $USER\r\n";static const char* kTestKey = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n" "Version: PGP Desktop 9.0.0\n" "\n" "lQHYBEJ9ynEBBADOCQLgG600k09qH/78qRDyiBK5vzt57phgV8fS6JDZTPEAue14\n" "rYH6QoXL/XuVcERiRoYl7CFy+5MdU3PTClReFRf2z/Zb9LbOZ3c3X8NmLetmS5N5\n" "5nm3xQT2DDZatLu1GknkEtz9RsS8yo7PP3Qzwqvca0CA/mYAmQpy/HkhsQARAQAB\n" "AAP/bK2SJ7ZRmX7uj9MKxClFuDiQcAvwCnQRShhjXduws/6CzVhFa7dR7TjzrFMr\n" "wfqzB4edsRkp16XdxsVDPhmfwAGvS/jmTfhjO+sP5ww8U28zyxScKA+vagaOn3LE\n" "qDVIZBLTO4Z+llb6BIE835AEKbP2RTNavGzzAbDdRHIxtIUCANS7TC6R5aAeWhB0\n" "+/JbcLwte1mvpuAW5UikR0+cPdQmmJI6qBHgRNMXt9Nhi7LB2VwOEk3qogIK83bf\n" "xDFBox8CAPfxCa+K0PBS5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dPVZkofYHT4f+LMup7Ue3+rGOg\n" "1yOTUanlF0xQHOg4lIayj6lH09aabbE1iwhPgZIe+jVjPqZos3a9zzyLHKSSUVFn\n" "PQBtFxUAFbWGWlhkOU9giQEgBBABAgAKBQJE/jS4AwUBeAAKCRA7s2aeyfsc28v7\n" "B/9nZRjQBZOn4xPky5vy8BxeisD66OsGyJJt7MbJX6lTKgm7jWLHrZXP6572d8kh\n" "jRcxz0MkxkapeMP1BZFMedy1atCaN9dC1p8dt/9CbTRKDf4ZdoZY3LzOWM7aYk3i\n" "1TryXrJxj8dHBtyo9Z9rsKsh+lpSZL33ivuWG80ysEoBgaFCeQNh1nh4MFfnQAXT\n" "Hm4WtqhonqOR6Ztlhm9zp2cQKyTKIHnPjEY95MjMiESe2IBeTI4A2EGY3GygVH3/\n" "9Az7waej72z/yV/2LYsKw6jD4hUGwsL0vPMCD3XdB/a/AG0U83db0504GHa7R8WS\n" "oH96sTgcXFgZ7u4+CB237jMM\n" "=1ufZ\n" "-----END PGP PUBLIC KEY BLOCK-----\n";int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); PGPError result = kPGPError_NoErr; PGPBoolean sdkInitialized = FALSE; PGPMsgContextRef sdkContext = NULL; PGPMsgEncodeOptionsRef encodeOptions = NULL; PGPMsgDecodeOptionsRef decodeOptions = NULL; PGPMsgDecodeResultRef decodeResult = NULL; PGPMsgEncodeResultRef encodeResult = NULL; const PGPByte* rfc822 = NULL; PGPSize rfc822Length = 0; PGPUInt32 numMissingItems = 0; // // SETUP // if (IsPGPError(result = PGPMsgInit (kPGPMsgSDKAPIVersion))) goto Exit; sdkInitialized = TRUE; // enable logging if (IsPGPError(result = PGPMsgSetGlobalLoggingProc (PGPMsgDefaultLogger, NULL))) goto Exit; // create an SDK context if (IsPGPError(result = PGPMsgNewContext (&sdkContext))) goto Exit; // also enable logging for events specific to this context if (IsPGPError(result = PGPMsgSetContextLoggingProc (sdkContext, PGPMsgDefaultLogger, NULL))) goto Exit; // // ENCRYPT AND SIGN // if (IsPGPError(result = PGPMsgNewEncodeOptions (sdkContext, kPGPMsgMessageFormat_PGPMIME, &encodeOptions))) goto Exit; if (IsPGPError(result = PGPMsgEncodeOptionsEncryptTo (encodeOptions, kPGPMsgObjectType_PGPKey, (PGPByte*)kTestKey, strlen(kTestKey)))) goto Exit; if (IsPGPError(result = PGPMsgEncodeOptionsSignWith (encodeOptions, kPGPMsgObjectType_PGPKey, (PGPByte*)kTestKey, strlen(kTestKey)))) goto Exit; if (IsPGPError(result = PGPMsgEncode(sdkContext, (PGPByte*)kTestMessage, strlen(kTestMessage), encodeOptions, &encodeResult))) goto Exit; if (IsPGPError(result = PGPMsgEncodeResultPeekMessage (encodeResult, &rfc822, &rfc822Length))) goto Exit; fwrite (rfc822, rfc822Length, 1, stdout); // // DECRYPT AND VERIFY // if (IsPGPError(result = PGPMsgNewDecodeOptions (sdkContext, &decodeOptions))) goto Exit; // if (IsPGPError(result = PGPMsgDecodeOptionsAddKey (decodeOptions, (PGPByte*)kTestKey, strlen(kTestKey)))) // goto Exit; do { PGPUInt32 i; if (IsPGPError(result = PGPMsgDecode (decodeOptions, rfc822, rfc822Length, &decodeResult, &numMissingItems))) goto Exit; for (i = 1; i <= numMissingItems; ++i) { PGPMsgObjectType objectType; const void* objectData = NULL; PGPSize objectDataLen; PGPUInt32 objectFlags = 0; if (IsPGPError(result = PGPMsgDecodeResultPeekRequiredItem (decodeResult, i, &objectType, &objectFlags, &objectData, &objectDataLen))) goto Exit; if (objectType == kPGPMsgObjectType_PGPKeyID) { /* // locate a key by ID and call one of the following two functions... if (IsPGPError(result = PGPMsgRequiredItemIsMissing (decodeResult, i))) goto Exit; */ // ...or... if (IsPGPError(result = PGPMsgDecodeOptionsAddKey (decodeOptions, (PGPByte*)kTestKey, strlen(kTestKey)))) goto Exit; } } } while (numMissingItems); rfc822 = NULL; rfc822Length = 0; if (IsPGPError(result = PGPMsgDecodeResultPeekMessage (decodeResult, &rfc822, &rfc822Length))) goto Exit; fwrite (rfc822, rfc822Length, 1, stdout); Exit: // // CLEANUP // PGPMsgFreeEncodeResult (encodeResult); PGPMsgFreeEncodeOptions (encodeOptions); PGPMsgFreeDecodeResult (decodeResult); PGPMsgFreeDecodeOptions (decodeOptions); PGPMsgFreeContext (sdkContext); if (sdkInitialized) { PGPMsgCleanup (); } return (result != kPGPError_NoErr); // unix-style result. 0 for OK, 1 for error. // return a.exec();}
QT += coreQT -= guiTARGET = testSymantecCONFIG += consoleTEMPLATE = appSOURCES += main.cppINCLUDEPATH += C:\\[DOCUMENTS]\\[PROGRAMMING]\MSG\pgpmsgsdk420\headersLIBS += C:\\[DOCUMENTS]\\[PROGRAMMING]\MSG\pgpmsgsdk420\libraries\release\PGPMessaging.dll
extern "C" { #include "pgpMsg.h"}
#define _UNICODE 1
#if defined(UNICODE) || defined(_UNICODE) #error UNICODE and _UNICODE should not be defined #endif
PGPMessaging.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2C0
Microsoft Windows [Version 6.1.7601](c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.D:\temp\testSymantec>testSymantec.exe268435969|dbug| Created EncodeOptions.268435713|dbug| Importing key.268435713|dbug| Importing key.X-Make-Money-Fast: TRUEMIME-Version: 1.0Subject: Dearest $USER, your assistance is pleased requiredDate: Fri, 1 Jan 2013 17:57:05 +0900From: "Mr. Esquire $USER" <redir.ru.cn@127.200.119.21>To: "$USER" <user@127.0.0.1>X-PGP-Encoding-Format: MIMEX-PGP-Encoding-Version: 2.0.2Content-Type: multipart/encrypted; boundary="PGP_Universal_88EA64FF_63E76414_5AFF348F_02099815"; protocol="application/pgp-encrypted"--PGP_Universal_88EA64FF_63E76414_5AFF348F_02099815Content-Type: application/pgp-encrypted; x-mac-type=54455854; name=Version.txtContent-Disposition: attachment; filename=Version.txtVersion: 1--PGP_Universal_88EA64FF_63E76414_5AFF348F_02099815Content-Type: application/octet-stream; x-mac-type=70674546; name=Message.pgpContent-Disposition: attachment; filename=Message.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nV7gLf5YmhHVnw3rDKVjxGdD=fvFw-----END PGP MESSAGE-------PGP_Universal_88EA64FF_63E76414_5AFF348F_02099815--268436488|dbug| PGP SDK InitialEvent268436485|dbug| PGP SDK BeginLexEvent268436496|dbug| PGP SDK AnalyzeEvent: encrypted268436482|dbug| PGP SDK RecipientsEvent268436487|dbug| PGP SDK PassphraseEvent268436486|dbug| PGP SDK EndLexEvent268436489|dbug| PGP SDK FinalEvent268435713|dbug| Importing key.268436488|dbug| PGP SDK InitialEvent268436485|dbug| PGP SDK BeginLexEvent268436496|dbug| PGP SDK AnalyzeEvent: encrypted268436482|dbug| PGP SDK RecipientsEvent268436514|dbug| PGP SDK DecryptionEvent268436512|dbug| PGP SDK OutputEvent268436481|dbug| PGP SDK SignatureEvent268436486|dbug| PGP SDK EndLexEvent268436489|dbug| PGP SDK FinalEvent268436488|dbug| PGP SDK InitialEvent268436485|dbug| PGP SDK BeginLexEvent268436500|dbug| PGP SDK AnalyzeEvent: unknown268436512|dbug| PGP SDK OutputEvent268436486|dbug| PGP SDK EndLexEvent268436489|dbug| PGP SDK FinalEventX-Make-Money-Fast: TRUEMIME-Version: 1.0Subject: Dearest $USER, your assistance is pleased requiredDate: Fri, 1 Jan 2013 17:57:05 +0900From: "Mr. Esquire $USER" <redir.ru.cn@127.200.119.21>To: "$USER" <user@127.0.0.1>Content-Type: text/plainContent-Transfer-Encoding: QUOTED-PRINTABLEDear Mr, $USER.Please considerate this letters by very much seriously because of unportantbusinesses of the Nigeria consulate bank army. My funds are of fullmoney to send in America, Canada, USA. I am $USER you for helping goldstocks and portfilos with helping for serious of 15 (fiveteen) with centof profits are of you. Until in confident five days by you responding VERYUNPORTANT| if with government by savings.By onlying with help us, for serious, businessing.Sincely. Mr, $USER268435970|dbug| Freeing EncodeOptions.536870929|dbug| Freeing PGP Messaging SDK context.
#define PGP_UNICODE 1