コード例 #1
0
ファイル: AddKey.c プロジェクト: ysangkok/pgp-win32-6.5.8
PGPError GenericAddKey(MYSTATE *ms,
					PGPOptionListRef opts,
					char *OperationTarget)
{
	PGPKeySetRef AddKeySet;
	PGPContextRef	context;
	PGPError err;

	err=kPGPError_NoErr;

	context=ms->context;

	ms->fileName=OperationTarget;

	if(ms->Operation!=MS_ADDKEYCLIPBOARD)
		SCSetProgressNewFilename(ms->hPrgDlg,"From '%s'",ms->fileName,TRUE);

	err=PGPImportKeySet(context,&AddKeySet,
		opts,
		PGPOSendNullEvents(context,75),
		PGPOEventHandler(context,AddEvents,ms),
		PGPOLastOption(context));

	SCSetProgressBar(ms->hPrgDlg,100,TRUE);

	if(IsntPGPError(err)) 
	{
		PGPUInt32	numKeys;

		PGPCountKeys( AddKeySet, &numKeys);
		if ( numKeys > 0) 
		{	
			err=PGPclQueryAddKeys (context, 
					ms->tlsContext,ms->hwndWorking,AddKeySet,NULL);
		}
		PGPFreeKeySet (AddKeySet);
	}

	return err;
}
コード例 #2
0
ファイル: KMserver.c プロジェクト: ysangkok/pgp-win32-6.5.8
BOOL 
KMRetrieveCertificate (PKEYMAN pKM) 
{
	PGPKeySetRef	keysetKey		= kInvalidPGPKeySetRef;
	PGPKeySetRef	keysetReturned	= kInvalidPGPKeySetRef;
	PGPUserIDRef	userid			= kInvalidPGPUserIDRef;
	PGPKeyRef		key				= kInvalidPGPKeyRef;
	PGPError		err;

	if (KMSelectedFlags (pKM) == OBJECT_USERID)
	{
		userid = (PGPUserIDRef)KMFocusedObject (pKM);
		key = KMGetKeyFromUserID (pKM, userid);
	}
	else
	{
		key = (PGPKeyRef)KMFocusedObject (pKM);
		PGPGetPrimaryUserID (key, &userid);
	}

	PGPNewSingletonKeySet (key, &keysetKey);
	if (PGPRefIsValid (keysetKey)) 
	{
		err = PGPclRetrieveCertificateFromServer (
									pKM->Context, 
									pKM->tlsContext,
									pKM->hWndParent, 
									pKM->KeySetMain,
									keysetKey,
									userid,
									&keysetReturned);
		PGPFreeKeySet (keysetKey);
	}
	if (err == kPGPError_UserAbort) 
		return FALSE;

	if (IsPGPError (err)) 
	{
		PGPclErrorBox (pKM->hWndParent, err);
	}
	else 
	{
		if (PGPRefIsValid (keysetReturned)) 
		{
			PGPUInt32 u;

			PGPCountKeys (keysetReturned, &u);
			if (u > 0) 
			{
#if 0	// <- set to "1" to enable selective import dialog
				PGPclQueryAddKeys (pKM->Context, pKM->tlsContext,
							pKM->hWndParent, keysetReturned, pKM->KeySetDisp);
#else
				if (pKM->ulOptionFlags & KMF_ENABLECOMMITS) 
				{
					PGPAddKeys (keysetReturned, pKM->KeySetDisp);
					KMCommitKeyRingChanges (pKM);
					KMLoadKeyRingIntoTree (pKM, FALSE, TRUE, FALSE);
					InvalidateRect (pKM->hWndTree, NULL, TRUE);

					KMMessageBox (pKM->hWndParent, IDS_PGP,
							IDS_CERTRETRIEVALSUCCESS, 
							MB_OK|MB_ICONINFORMATION);
				}
#endif
			}
			else 
			{
				KMMessageBox (pKM->hWndParent, IDS_CAPTION,
						IDS_CERTRETRIEVALFAIL, MB_OK|MB_ICONEXCLAMATION);
			}
			PGPFreeKeySet (keysetReturned);
		}
	}
	return TRUE;
}
コード例 #3
0
ファイル: KMserver.c プロジェクト: ysangkok/pgp-win32-6.5.8
BOOL 
KMGetFromServerInternal (
		PKEYMAN		pKM, 
		BOOL		bQueryAdd, 
		BOOL		bWarn,
		BOOL		bGetSigners) 
{
	SERVERSTRUCT	ss;
	PGPKeySetRef	keysetGet		= kInvalidPGPKeySetRef;
	PGPKeySetRef	keysetFound		= kInvalidPGPKeySetRef;
	PGPError		err				= kPGPError_NoErr;

	ss.context = pKM->Context;
	ss.pKM = pKM;
	ss.icount = 0;

	// get selected keys
	if ((KMFocusedObjectType (pKM) == OBJECT_KEY) ||
		(KMFocusedObjectType (pKM) == OBJECT_USERID) ||
		(!bGetSigners)) 
	{
		KMGetSelectedKeys (pKM, &keysetGet, NULL);
		if (PGPRefIsValid (keysetGet)) {
			err = PGPclUpdateKeySetFromServer (pKM->Context, 
										pKM->tlsContext,
										pKM->hWndParent, 
										keysetGet,
										PGPCL_USERIDBASEDSERVER,
										pKM->KeySetMain,
										&keysetFound);
			PGPFreeKeySet (keysetGet);
		}
	}

	// get signing keys
	else {
		KMGetSelectedKeys (pKM, NULL, &ss.icount);
		if (ss.icount) {
			ss.pkeyidList = 
				(PGPKeyID*)malloc ((ss.icount) * sizeof(PGPKeyID));
			ss.icount = 0;
			ss.lpfnCallback = sAddKeyIDToList;
			TreeList_IterateSelected (pKM->hWndTree, &ss);
			err = PGPclSearchServerForKeyIDs (pKM->Context,
								pKM->tlsContext,
								pKM->hWndParent, 
								ss.pkeyidList,
								ss.icount, 
								PGPCL_DEFAULTSERVER,
								pKM->KeySetMain,
								&keysetFound);
			free (ss.pkeyidList);
		}
	}

	if (err == kPGPError_UserAbort) return FALSE;

	if (IsPGPError (err)) {
		if (bWarn) PGPclErrorBox (NULL, err);
	}
	else {
		if (PGPRefIsValid (keysetFound)) {
			PGPUInt32 u;
			PGPCountKeys (keysetFound, &u);
			if (u > 0) {
				if (bQueryAdd) {
					PGPclQueryAddKeys (pKM->Context, pKM->tlsContext,
							pKM->hWndParent, keysetFound, pKM->KeySetDisp);
				}
				else {
					if (pKM->ulOptionFlags & KMF_ENABLECOMMITS) {
						PGPAddKeys (keysetFound, pKM->KeySetDisp);
						PGPCommitKeyRingChanges (pKM->KeySetDisp);
					}
				}
			}
			else {
				KMMessageBox (pKM->hWndParent, IDS_CAPTION,
						IDS_SERVERSEARCHFAIL, MB_OK|MB_ICONEXCLAMATION);
			}
			PGPFreeKeySet (keysetFound);
		}
	}

	return TRUE;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: TonyAlloa/miranda-dev
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<dwKeys;i++) {
			PGPKeyIterNext(KeyIterRef, &PrivateKey);
			PGPOPassphraseIsValid(PrivateKey,
							      PGPOPassphrase(pgpContext, pszPassphrase),
							      PGPOLastOption(pgpContext));
		}

	    PGPFreeKeyList(PrivateKeyList);
	    PGPFreeKeyIter(KeyIterRef);
#else
	    PGPKeyIterRef KeyIterRef;
	    PGPNewKeyIterFromKeyDB(PrivateKeyDB, &KeyIterRef);

		PGPKeyDBObjRef KeyDBObjRef;
	    for(int i=0;i<dwKeys;i++) {
			PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &KeyDBObjRef);
			PGPOPassphraseIsValid(PrivateKey,
							      PGPOPassphrase(pgpContext, pszPassphrase),
							      PGPOLastOption(pgpContext));
		}

	    PGPFreeKeyIter(KeyIterRef);
#endif
*/
		PGPError err = PGPDecode(pgpContext,
	       PGPOInputBuffer(pgpContext, szEncMsg, lstrlen(szEncMsg)),
	       PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szPlainMsg, 16384, (PGPUInt32 *)&dwPlainMsgLen),
#if (PGP_WIN32 < 0x700)
		   PGPOKeySetRef(pgpContext, PrivateKeyDB),
#else
	       PGPOKeyDBRef(pgpContext, PrivateKeyDB),
#endif
	       PGPOPassphrase(pgpContext, pszPassphrase),
	       PGPOLastOption(pgpContext));

	    if (CheckPGPError(err))
			iTry = 3;
		else
	    if (!dwPlainMsgLen) {
			PGPFreeData(pszPassphrase);
			pszPassphrase = 0;
			iTry++;
		}

    } while(!dwPlainMsgLen && iTry<3);
    
#if (PGP_WIN32 < 0x700)
	PGPFreeKeySet(PrivateKeyDB);
#else
	PGPFreeKeyDB(PrivateKeyDB);
#endif

	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;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: TonyAlloa/miranda-dev
PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID)
{
#if (PGP_WIN32 < 0x700)
	PGPKeySetRef ContactKeyDB;
#else
	PGPKeyDBRef ContactKeyDB;
#endif
    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;
#if (PGP_WIN32 < 0x700)
	PGPCountKeys(ContactKeyDB, &dwKeys);
#else
	PGPCountKeysInKeyDB(ContactKeyDB, &dwKeys);
#endif
    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;

#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;
}
コード例 #6
0
ファイル: keymaint.c プロジェクト: ysangkok/pgp-win32-6.5.8
PGPError markSignatureChainDepths(struct pgpmainBones *mainbPtr,
        PGPKeySetRef bothRingsSet,
        PGPFilterRef depthFilter)
{
    struct pgpfileBones *filebPtr = mainbPtr->filebPtr;
    PGPContextRef context = mainbPtr->pgpContext;
    PGPBoolean compatible = mainbPtr->envbPtr->compatible;

    PGPKeyIterRef keyiter;
    PGPKeyID kid;
    PGPKeySetRef depthSet;
    PGPKeyListRef depthList;
    PGPKeyRef key;
    PGPFilterRef signedByMeFilter = NULL;
    PGPFilterRef usedKeysFilter = NULL;
    PGPFilterRef unusedKeysFilter = NULL;
    char kstr[kPGPMaxKeyIDStringSize];
    char useridstr[ kPGPMaxUserIDSize ];

    PGPError err;
    PGPBoolean firstKeyAtThisDepth;
    PGPUInt32 depth = 0;
    PGPUInt32 count;
    PGPUserValue traceValue;
    /* Trace value contains highest depth in sig chain where this key
       appears.  High bit ='visited' flag - indicates if chain has been
       followed from this point. */

    fprintf(filebPtr->pgpout,
            LANG("\nPass 2: Tracing signature chains...\n"));

    usedKeysFilter = depthFilter;
    err = PGPNegateFilter( usedKeysFilter, &unusedKeysFilter );
    pgpAssertNoErr(err);

    err = PGPFilterKeySet( bothRingsSet, depthFilter, &depthSet);
    pgpAssertNoErr(err);

    err = PGPCountKeys( depthSet, &count);
    pgpAssertNoErr(err);

    if (count == 0) {
        fprintf(filebPtr->pgpout, LANG("No ultimately-trusted keys.") );
        return -1;
    }

    while ( TRUE ) {
        firstKeyAtThisDepth = TRUE;
        err = PGPOrderKeySet(depthSet, kPGPAnyOrdering, &depthList);
        pgpAssertNoErr(err);
        err = PGPNewKeyIter( depthList, &keyiter );
        pgpAssertNoErr(err);
        err = PGPKeyIterRewind( keyiter );
        pgpAssertNoErr(err);
        err = PGPKeyIterNext( keyiter, &key);

        while( key != NULL ) {

            err = pgpGetKeyIDStringCompatFromKey( key, TRUE, compatible,
                    kstr );
            pgpAssertNoErr(err);
            err =  pgpGetUserIDStringFromKey( key, useridstr );
            pgpAssertNoErr(err);

            /* Mark its highest depth level on each key. */

            err = PGPGetKeyUserVal( key, &traceValue);
            pgpAssertNoErr(err);

            if ( (PGPUInt32)traceValue == 0) {
                (PGPUInt32)traceValue = depth;

                err = PGPSetKeyUserVal( key, traceValue);
                pgpAssertNoErr(err);
            }

            err = PGPGetKeyIDFromKey( key, &kid );
            pgpAssertNoErr(err);

            if (firstKeyAtThisDepth) {

                err = PGPNewSigKeyIDFilter(context, &kid, &depthFilter);
                pgpAssertNoErr(err);
                firstKeyAtThisDepth = FALSE;
            } else {

                err = PGPNewSigKeyIDFilter(context, &kid, &signedByMeFilter);
                pgpAssertNoErr(err);
                err = PGPUnionFilters( signedByMeFilter, depthFilter,
                        &depthFilter);
                pgpAssertNoErr(err);
            }

            err = PGPKeyIterNext( keyiter, &key);
        }

        err = PGPIntersectFilters(unusedKeysFilter, depthFilter,
                &depthFilter);

        pgpAssertNoErr(err);

        /* Create next depth level. */
        err = PGPFreeKeySet( depthSet );
        pgpAssertNoErr(err);
        err = PGPFilterKeySet( bothRingsSet, depthFilter, &depthSet);
        pgpAssertNoErr(err);
        err = PGPCountKeys( depthSet, &count);
        pgpAssertNoErr(err);

        err = PGPFreeKeyIter( keyiter );
        pgpAssertNoErr(err);

        if (count == 0) return 0;

        err = PGPUnionFilters( depthFilter, usedKeysFilter, &usedKeysFilter);
        pgpAssertNoErr(err);
        err = PGPNegateFilter( usedKeysFilter, &unusedKeysFilter );
        pgpAssertNoErr(err);
        depth ++;
    }
} /* markSignatureChainDepths */
コード例 #7
0
ファイル: main.cpp プロジェクト: TonyAlloa/miranda-dev
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;
}
コード例 #8
0
PluginError PerformTranslation(
	short trans_id, 
	char* in_file, 
	char* out_file, 
	char** addresses, 
	emsMIMEtypeP  in_mime,
	emsMIMEtypeP* out_mime
)
{
	PluginError pluginReturn			= EMSR_UNKNOWN_FAIL;
	BOOL		bSign					= FALSE;
	PGPError	error					= 0;
	PGPSize		mimeBodyOffset			= 0;
	char		szExe[256];
	char		szDll[256];

	assert(in_file);
	assert(out_file);

	LoadString(g_hinst, IDS_EXE, szExe, sizeof(szExe));
	LoadString(g_hinst, IDS_DLL, szDll, sizeof(szDll));

	switch( trans_id )
	{
		case kEncryptTranslatorID:
		case kSignTranslatorID:
		case kEncryptAndSignTranslatorID:
		{
			char** RecipientList = NULL;
			unsigned long numRecipients = 0;
			PGPOptionListRef pgpOptions = NULL;
			PGPOptionListRef signOptions = NULL;
			char mimeSeparator[kPGPMimeSeparatorSize];
			PRECIPIENTDIALOGSTRUCT prds = NULL;	
		
			// allocate a recipient dialog structure
			prds = (PRECIPIENTDIALOGSTRUCT) 
					calloc(sizeof(RECIPIENTDIALOGSTRUCT), 1);

			if(prds)
			{
				char szTitle[256] = {0x00};		// title for recipient dialog
				UINT recipientReturn = FALSE;	// recipient dialog result

				error = PGPsdkLoadDefaultPrefs(g_pgpContext);
				if (IsPGPError(error))
				{
					PGPclEncDecErrorBox(g_hwndEudoraMainWindow, error);
					return EMSR_UNKNOWN_FAIL;
				}

				error = PGPOpenDefaultKeyRings(g_pgpContext, 
							(PGPKeyRingOpenFlags)0, 
							&(prds->OriginalKeySetRef));

				if (IsPGPError(error))
				{
					PGPclEncDecErrorBox(g_hwndEudoraMainWindow, error);
					return EMSR_UNKNOWN_FAIL;
				}

				if ((trans_id == kEncryptTranslatorID) ||
					(trans_id == kEncryptAndSignTranslatorID))
				{
					if(addresses) // do we have addresses to pass along
					{
						numRecipients = CreateRecipientList(addresses, 
															&RecipientList);
					}

					LoadString(GetModuleHandle("PGPplugin.dll"), 
						IDS_TITLE_RECIPIENTDIALOG, szTitle, sizeof(szTitle));

					prds->Context			= g_pgpContext;
					prds->tlsContext		= g_tlsContext;
					prds->Version			= CurrentPGPrecipVersion;
					prds->hwndParent		= g_hwndEudoraMainWindow;			
					prds->szTitle			= szTitle;
					prds->dwOptions			= PGPCL_ASCIIARMOR;	
			
					prds->dwDisableFlags	= PGPCL_DISABLE_WIPEORIG |
											  PGPCL_DISABLE_ASCIIARMOR |
											  PGPCL_DISABLE_SDA;

					prds->dwNumRecipients	= numRecipients;	
					prds->szRecipientArray	= RecipientList;

					/* Disable FYEO if there's an attachment or HTML */

					if (in_mime && !match_mime_type(in_mime, "text", "plain"))
						prds->dwDisableFlags |= PGPCL_DISABLE_FYEO;

					// If shift is pressed, force the dialog to pop.
					if (GetAsyncKeyState( VK_CONTROL) & 0x8000)
						prds->dwDisableFlags|=PGPCL_DISABLE_AUTOMODE;

					// See who we wish to encrypt this to
					recipientReturn = PGPclRecipientDialog( prds );
				
					if (prds->AddedKeys != NULL)
					{
						PGPUInt32 numKeys;
					
						PGPCountKeys(prds->AddedKeys, &numKeys);
						if (numKeys > 0)
							PGPclQueryAddKeys(g_pgpContext, g_tlsContext, 
								g_hwndEudoraMainWindow, prds->AddedKeys, 
								NULL);
					
						PGPFreeKeySet(prds->AddedKeys);
						prds->AddedKeys = NULL;
					}

					if (!recipientReturn)
					{
						if (RecipientList)
							FreeRecipientList(RecipientList, numRecipients);
						if (prds->SelectedKeySetRef != NULL)
							PGPFreeKeySet(prds->SelectedKeySetRef);
						PGPFreeKeySet(prds->OriginalKeySetRef);
						free(prds);
						return EMSR_UNKNOWN_FAIL;
					}
				}

				if( IsntPGPError(error) )
				{
					error = PGPBuildOptionList(g_pgpContext, &pgpOptions,
								PGPOOutputLineEndType(g_pgpContext, 
									kPGPLineEnd_CRLF),
								PGPOPGPMIMEEncoding(g_pgpContext, 
									TRUE, 
									&mimeBodyOffset, 
									mimeSeparator),     
								PGPOLastOption(g_pgpContext) );
				}

				if(IsntPGPError( error))
				{
					error = EncryptSignFile(g_hinst, g_hwndEudoraMainWindow, 
								g_pgpContext, g_tlsContext, szExe, 
								szDll, in_file, prds, pgpOptions, 
								&signOptions, out_file, 
								((trans_id == 
									kSignTranslatorID) ? FALSE : TRUE ),
								((trans_id == 
									kEncryptTranslatorID) ? FALSE : TRUE ),
								FALSE);

					PGPFreeOptionList(pgpOptions);
					PGPFreeOptionList(signOptions);
				}
				else
				{
					PGPclEncDecErrorBox (NULL, error);
				}

				if (RecipientList)
					FreeRecipientList(RecipientList, numRecipients);
				if (prds->SelectedKeySetRef != NULL)
					PGPFreeKeySet(prds->SelectedKeySetRef);
				PGPFreeKeySet(prds->OriginalKeySetRef);
				free(prds);

				if( IsntPGPError(error) )
				{
					if( out_mime )
					{
						pluginReturn = BuildEncryptedPGPMIMEType( 
													out_mime, 
													mimeSeparator );

						if(EMSR_OK == pluginReturn)
						{
							pluginReturn = AddMIMEParam(*out_mime, 
														"PGPFormat", 
														"PGPMIME-encrypted" );
						}
					}
				}
			}

			break;
		}

		case kDecryptTranslatorID:
		case kVerifyTranslatorID:
		{
			char *szTempFile = NULL;
			BOOL bFYEO = FALSE;
			void *pOutput = NULL;
			PGPSize outSize = 0;

			error = DecryptVerifyFile(g_hinst, g_hwndEudoraMainWindow, 
						g_pgpContext, g_tlsContext, szExe, szDll, in_file, 
						TRUE, FALSE, &szTempFile, &pOutput, &outSize, &bFYEO);

			if( IsntPGPError(error) ) 
			{
				if ((bFYEO)||(GetSecureViewerPref((void *)g_pgpContext)))
					TempestViewer((void *)g_pgpContext,NULL,pOutput,outSize,
						bFYEO);

				CopyFile(szTempFile, out_file, FALSE);
				DeleteFile(szTempFile);

				if( out_mime )
				{
					ParseFileForMIMEType( out_file, out_mime );
				}

				if ((bFYEO)||(GetSecureViewerPref((void *)g_pgpContext)))
					pluginReturn = EMSR_UNKNOWN_FAIL;
				else
					pluginReturn = EMSR_OK;
			}

			if (szTempFile != NULL)
				PGPFreeData(szTempFile);
			if (pOutput != NULL)
				PGPFreeData(pOutput);
			break;
		}

	}

	return pluginReturn;
}
コード例 #9
0
ファイル: KMRevoke.c プロジェクト: ysangkok/pgp-win32-6.5.8
BOOL 
KMAddRevoker (PKEYMAN pKM) 
{
	PGPKeySetRef	keysetToChoose		= kInvalidPGPKeySetRef;
	PGPKeySetRef	keysetToRemove		= kInvalidPGPKeySetRef;
	PGPKeySetRef	keysetThisKey		= kInvalidPGPKeySetRef;
	PGPKeySetRef	keysetSelected		= kInvalidPGPKeySetRef;
	PGPFilterRef	filterRSA			= kInvalidPGPFilterRef;
	PGPError		err					= kPGPError_NoErr;
	PGPByte*		pbyte				= NULL;
	BOOL			bRet				= FALSE;
	PGPUInt32		uCount				= 0;
	PGPBoolean		bSyncWithServer		= FALSE;

	PGPPrefRef		prefref;
	PGPSize			size;
	PGPKeyRef		key;
	CHAR			szPrompt[256];


	key = (PGPKeyRef)KMFocusedObject (pKM);

	PGPclOpenClientPrefs (PGPGetContextMemoryMgr (pKM->Context), &prefref);
	PGPGetPrefBoolean (prefref, kPGPPrefKeyServerSyncOnAdd, 
						&bSyncWithServer);
	PGPclCloseClientPrefs (prefref, FALSE);

	err = PGPNewKeySet (pKM->Context, &keysetToChoose); CKERR;
	err = PGPAddKeys (pKM->KeySetMain, keysetToChoose); CKERR;
	err = PGPCommitKeyRingChanges (keysetToChoose); CKERR;

	err = PGPNewKeyEncryptAlgorithmFilter (pKM->Context, 
						kPGPPublicKeyAlgorithm_RSA, &filterRSA); CKERR;
	err = PGPFilterKeySet (pKM->KeySetMain, 
						filterRSA, &keysetToRemove); CKERR;

	err = PGPCommitKeyRingChanges (keysetToRemove); CKERR;
	err = PGPRemoveKeys (keysetToRemove, keysetToChoose); CKERR;
	err = PGPCommitKeyRingChanges (keysetToChoose); CKERR;

	err = PGPCountKeys (keysetToChoose, &uCount); CKERR;
	if (uCount <= 1) {
		KMMessageBox (pKM->hWndParent, IDS_PGP, IDS_NOTENOUGHKEYSTOADDREVOKER,
						MB_OK|MB_ICONINFORMATION);
		goto done;
	}

	err = PGPFreeKeySet (keysetToRemove); CKERR;
	err = PGPNewSingletonKeySet (key, &keysetToRemove); CKERR;
	err = PGPRemoveKeys (keysetToRemove, keysetToChoose); CKERR;

	err = PGPCommitKeyRingChanges (keysetToChoose); CKERR;

	LoadString (g_hInst, IDS_ADDREVOKERPROMPT, szPrompt, sizeof(szPrompt));
	err = PGPclSelectKeys (pKM->Context, pKM->tlsContext, 
					pKM->hWndParent, szPrompt,
					keysetToChoose, pKM->KeySetMain, &keysetSelected);

	if (IsntPGPError (err) && PGPKeySetRefIsValid (keysetSelected))
	{
		if (KMMessageBox (pKM->hWndParent, IDS_CAPTION, 
				IDS_ADDREVOKERCONFIRM, MB_YESNO|MB_ICONEXCLAMATION) == IDYES) 
		{
			err = KMGetKeyPhrase (pKM->Context, pKM->tlsContext,
									pKM->hWndParent, NULL, 
									pKM->KeySetMain, key, 
									NULL, &pbyte, &size); CKERR;

			// update from server
			if (IsntPGPError (err) && bSyncWithServer) {
				if (!KMGetFromServerInternal (pKM, FALSE, FALSE, FALSE)) {
					if (KMMessageBox (pKM->hWndParent, IDS_CAPTION, 
								IDS_QUERYCONTINUEADDING, 	
								MB_YESNO|MB_ICONEXCLAMATION) == IDNO) 
					{
						err = kPGPError_UserAbort;
					}
				}
			}
		
			if (IsntPGPError (err)) {
				err = PGPAddKeyOptions (key, 
					PGPORevocationKeySet (pKM->Context, keysetSelected),
					pbyte ?
						PGPOPasskeyBuffer (pKM->Context, pbyte, size) :
						PGPONullOption (pKM->Context),
					PGPOLastOption (pKM->Context)); CKERR;
			}
		}
		else
			err = kPGPError_UserAbort;
	}

	// send to server
	if (IsntPGPError (err) && bSyncWithServer) {
		KMSendToServer (pKM, PGPCL_DEFAULTSERVER);
	}

	if (IsntPGPError (err)) {
		KMCommitKeyRingChanges (pKM);
		bRet = TRUE;

		if (bSyncWithServer) {
			KMMessageBox (pKM->hWndParent, IDS_PGP, IDS_ADDEDSENTREVOKERS,
						MB_OK|MB_ICONINFORMATION);
		}
		else {
			KMMessageBox (pKM->hWndParent, IDS_PGP, IDS_ADDEDREVOKERS,
						MB_OK|MB_ICONINFORMATION);
		}
	}

done :
	if (NULL!=(int) (pbyte))
		KMFreePasskey (pbyte, size);
	if (PGPKeySetRefIsValid (keysetToChoose))
		PGPFreeKeySet (keysetToChoose);
	if (PGPKeySetRefIsValid (keysetToRemove))
		PGPFreeKeySet (keysetToRemove);
	if (PGPKeySetRefIsValid (keysetThisKey))
		PGPFreeKeySet (keysetThisKey);
	if (PGPKeySetRefIsValid (keysetSelected))
		PGPFreeKeySet (keysetSelected);
	if (PGPFilterRefIsValid (filterRSA))
		PGPFreeFilter (filterRSA);

	PGPclErrorBox (pKM->hWndParent, err);

	return bRet;
}
コード例 #10
0
BOOL 
EncryptSignRichEditText(char** ppBuffer, 
						long* pLength, 
						BOOL bEncrypt, 
						BOOL bSign, 
						char** pAddresses, 
						long NumAddresses,
						char* pAttachments,
						char** ppOutAttachments)
{
	BOOL ReturnValue = FALSE;
	void* pOutput = NULL;
	long outSize = 0;
	PGPError error = kPGPError_NoErr;
	PGPOptionListRef userOptions = NULL;
	PGPclRecipientDialogStruct *prds = NULL;	
	char szExe[256];
	char szDll[256];

	LoadString(g_hinst, IDS_EXE, szExe, sizeof(szExe));
	LoadString(g_hinst, IDS_DLL, szDll, sizeof(szDll));

	// allocate a recipient dialog structure
	prds = (PGPclRecipientDialogStruct *) 
			calloc(sizeof(PGPclRecipientDialogStruct), 1);

	if (!prds)
	{
		PGPclErrorBox(g_hwndEudoraMainWindow, kPGPError_OutOfMemory);
		return FALSE;
	}

	error =	PGPclOpenDefaultKeyrings(g_pgpContext, 
				kPGPOpenKeyDBFileOptions_Mutable, &(prds->keydbOriginal));

	if (IsPGPError(error))
		error =	PGPclOpenDefaultKeyrings(g_pgpContext, 
					kPGPOpenKeyDBFileOptions_None, &(prds->keydbOriginal));

	if (IsPGPError(error))
	{
		char szTitle[255];
		char szBuffer[1024];
		
		LoadString(g_hinst, IDS_DLL, szTitle, 254);
		LoadString(g_hinst, IDS_Q_NOKEYRINGS, szBuffer, 1023);
		
		if (MessageBox(g_hwndEudoraMainWindow, szBuffer, szTitle, MB_YESNO))
		{
			char szPath[MAX_PATH];
			
			PGPclGetPath(kPGPclPGPkeysExeFile, szPath, MAX_PATH-1);
			PGPclExecute(szPath, SW_SHOW);
		}
		
		return S_FALSE;
	}

	if(prds && bEncrypt)
	{
		char szTitle[256]		= {0x00};	// title for recipient dialog
		UINT recipientReturn	= FALSE;	// recipient dialog result

		LoadString(GetModuleHandle("PGPplugin.dll"), 
			IDS_TITLE_RECIPIENTDIALOG, szTitle, sizeof(szTitle));

		if( IsntPGPError(error) )
		{
			prds->context			= g_pgpContext;
			prds->tlsContext		= g_tlsContext;
			prds->Version			= kPGPCurrentRecipVersion;
			prds->hwndParent		= g_hwndEudoraMainWindow;
			prds->szTitle			= szTitle;
			prds->dwOptions			= kPGPclASCIIArmor;	

			prds->dwDisableFlags	= kPGPclDisableWipeOriginal |
									  kPGPclDisableASCIIArmor |
									  kPGPclDisableSelfDecryptingArchive |
									  kPGPclDisableInputIsText;

			prds->dwNumRecipients	= NumAddresses;	
			prds->szRecipientArray	= pAddresses;

			// If shift is pressed, force the dialog to pop.
			if (GetAsyncKeyState( VK_CONTROL) & 0x8000)
				prds->dwDisableFlags |= kPGPclDisableAutoMode;

			// See who we wish to encrypt this to
			recipientReturn = PGPclRecipientDialog( prds );
		}

		if (prds->keydbAdded != NULL)
		{
			PGPUInt32 numKeys;
			PGPKeySetRef keySet;

			PGPNewKeySet(prds->keydbAdded, &keySet);
			PGPCountKeys(keySet, &numKeys);
			if (numKeys > 0)
				PGPclImportKeys(g_pgpContext, g_tlsContext, prds->hwndParent,
					keySet, prds->keydbOriginal, 
					kPGPclNoDialogForValidSingletons);

			PGPFreeKeySet(keySet);
			PGPFreeKeyDB(prds->keydbAdded);
			prds->keydbAdded = NULL;
		}

		if (!recipientReturn)
		{
			if (prds->keydbSelected != NULL)
				PGPFreeKeyDB(prds->keydbSelected);

			PGPFreeKeyDB(prds->keydbOriginal);
			free(prds);
			return FALSE;
		}
	}

	if( IsntPGPError(error) )
	{
		error = EncryptSignBuffer(g_hinst, g_hwndEudoraMainWindow,
					g_pgpContext, g_tlsContext, szExe, szDll,
					*ppBuffer, *pLength, prds, NULL, &userOptions, &pOutput,
					&outSize, bEncrypt, bSign, FALSE, FALSE);
	}
	else
	{
		PGPclEncDecErrorBox(g_hwndEudoraMainWindow, error);
	}

	*pLength = outSize;

	if( IsntPGPError(error) )
	{
		if( pOutput )
		{
			*ppBuffer = (char*)HeapReAlloc(	GetProcessHeap(), 
											HEAP_ZERO_MEMORY, 
											*ppBuffer, 
											*pLength + 1);

			if(*ppBuffer)
			{
				ReturnValue = TRUE;
				memcpy(*ppBuffer, (char*)pOutput, *pLength);
				*(*ppBuffer + *pLength) = 0x00; // NULL terminate the string
				memset(pOutput, 0x00, *pLength);
			}
			else 
			{
				error = kPGPError_OutOfMemory;
			}

			PGPFreeData(pOutput);
		}
	}
	
	// are there attachments?
	if(IsntPGPError(error) && pAttachments && *pAttachments) 
	{
		error = EncryptAttachments(	pAttachments, 
									ppOutAttachments,
									prds,
									userOptions,
									bEncrypt,
									bSign);

	}

	if(userOptions != NULL)
	{
		PGPFreeOptionList(userOptions);
	}

	if (prds)
	{
		if (prds->keydbSelected != NULL)
			PGPFreeKeyDB(prds->keydbSelected);

		PGPFreeKeyDB(prds->keydbOriginal);
		free(prds);
	}

	return ReturnValue;
}
コード例 #11
0
ファイル: keyadd.c プロジェクト: ysangkok/pgp-unix-6.5.8
int addToKeyring(struct pgpmainBones *mainbPtr, char* keyfile,
                 PGPFileSpecRef ringFileSpec, char *origRingFileName )

{
    PGPContextRef context = mainbPtr->pgpContext;
    struct pgpfileBones *filebPtr = mainbPtr->filebPtr;

    PGPFileSpecRef  keyFileSpec = kPGPInvalidRef;
    PGPKeySetRef    ringSet = kPGPInvalidRef;
#ifdef NOTPREFERREDMETHOD
    PGPKeySetRef    keySet = kPGPInvalidRef;
#endif /* NOTPREFERREDMETHOD */
    PGPKeySetRef    emptyKeySet = kPGPInvalidRef;
    PGPError err,er2;
    char *ringfile = NULL;
    PGPEnv *env = mainbPtr->envbPtr->m_env;
    PGPInt32 pri;
    PGPBoolean compatible = mainbPtr->envbPtr->compatible;


    err = PGPGetFullPathFromFileSpec( ringFileSpec, &ringfile );
    pgpAssertNoErr(err);

    /* Manually open the input file, gives us an early out if it is
       missing */

    err = PGPNewFileSpecFromFullPath(context, keyfile, &keyFileSpec);
    if(err) {
        pgpShowError( filebPtr, err, __FILE__,__LINE__);
        goto done;
    }

    /* add the keys to a in memory key set, then
       do one add operation at end to the target key set */
    err = PGPNewKeySet(context, &emptyKeySet);
    if(IsPGPError(err))
        goto done;
    mainbPtr->workingRingSet = emptyKeySet;

    /* Get or create target keySet. Must be both public and secret
       keyrings, in case the input contains new secret keys. */

    err = pgpOpenKeyringsFromPubringSpec( mainbPtr, ringFileSpec, &ringSet,
                                          kPGPKeyRingOpenFlags_Mutable);
    if(err) {
        /* XXX The error msg context here may differ from 262 */
        fprintf(filebPtr->pgpout, ringFileSpec ? LANG(
                    "\nKey ring file '%s' cannot be created.\n")
                : LANG("Default ring file cannot be created"),
                origRingFileName);
        goto done;
    }

    /*
     *	mark key set so that we know what was added
     */
    err = pgpMarkKeySet(ringSet);
    pgpAssertNoErr(err);

    /* Allow eventhandler in dodecode.c to do the remaining work */

    fprintf(filebPtr->pgpout,LANG("\nLooking for new keys...\n"));

    err = PGPDecode(
              context,
              PGPOInputFile( context, keyFileSpec ),
              PGPOKeySetRef( context, ringSet ),
              PGPOSendEventIfKeyFound( context, TRUE ),
              PGPOEventHandler( context, addHandler, (PGPUserValue) mainbPtr ),
              PGPOLastOption( context )
          );

    if(err) {
        pgpShowError( filebPtr, err,__FILE__,__LINE__ );
        goto done;
    }
    else
    {
        /* count number of keys before add */
        PGPUInt32	countBefore = 0;

        err = PGPCountKeys(ringSet, &countBefore);
        pgpAssertNoErr(err);

        err = PGPAddKeys(mainbPtr->workingRingSet, ringSet);
        if(IsntPGPError(err) && PGPKeySetNeedsCommit(ringSet))
        {
            /*
             *	show what was added
             */

            PGPUInt32	keys = 0;
            PGPSize dummy,uids,sigs,rvks;

            err = PGPCountKeys(ringSet, &keys);
            pgpAssertNoErr(err);

            keys -= countBefore;

            fprintf(filebPtr->pgpout,
                    LANG("\n\nSummary of changes : \n"));

            err = pgpShowKeySetUnmarked( filebPtr, ringSet, &dummy, &uids,
                                         &sigs, &rvks );
            pgpAssertNoErr(err);

            if(keys || uids || sigs || rvks)
            {
                fprintf(filebPtr->pgpout, LANG("\nAdded :\n"));
                if (keys)
                    fprintf(filebPtr->pgpout,
                            LANG("%4d new key(s)\n"), keys);
                if (sigs)
                    fprintf(filebPtr->pgpout,
                            LANG("%4d new signatures(s)\n"), sigs);
                if (uids)
                    fprintf(filebPtr->pgpout,
                            LANG("%4d new user ID(s)\n"), uids);
                if (rvks)
                    fprintf(filebPtr->pgpout,
                            LANG("%4d new revocation(s)\n"), rvks);
            }
            else
            {
                fprintf(filebPtr->pgpout,
                        LANG("No new keys found."));
            }

            PGPCommitKeyRingChanges(ringSet);
        }
    }

#ifdef NOTPREFERREDMETHOD
    /* Rather than calling this here, we call it from the callback
       Copy all keys from keySet which aren't in ringSet already */
    err = addToWorkingRingSet( mainbPtr, keySet );
#endif /* NOTPREFERREDMETHOD */

done:
    if(emptyKeySet != kPGPInvalidRef)
    {
        er2 = PGPFreeKeySet(emptyKeySet);
        pgpAssertNoErr(er2);
    }

#ifdef NOTPREFERREDMETHOD
    if( keySet != kPGPInvalidRef ) {
        er2 = PGPFreeKeySet( keySet );
        pgpAssertNoErr(er2);
    }
#endif /* NOTPREFERREDMETHOD */

    if( ringSet != kPGPInvalidRef ) {
        er2 = PGPFreeKeySet( ringSet );
        pgpAssertNoErr(er2);
        mainbPtr->workingRingSet = NULL;
    }

    if( keyFileSpec != kPGPInvalidRef ) {
        er2 = PGPFreeFileSpec(keyFileSpec);
        pgpAssertNoErr(er2);
    }

    if(!compatible && IsPGPError(err) &&
            pgpenvGetInt( env, PGPENV_VERBOSE, &pri, &er2 ) ) {
        pgpShowError(filebPtr, err,__FILE__,__LINE__);
    }
    if(ringfile)
        PGPFreeData(ringfile);

    return err ? -1 : 0;
}
コード例 #12
0
PGPError GetRecipients(HWND hwnd,
					   char *szNames, 
					   PGPContextRef pgpContext, 
					   PGPtlsContextRef tlsContext,
					   RECIPIENTDIALOGSTRUCT *prds)
{
    HINSTANCE		hWAB = NULL;
    LPWABOPEN		pWABOpen = NULL;
    LPADRBOOK		pAdrBook = NULL; 
    LPWABOBJECT		pWABObject = NULL;
	AdrBookTable *	pTable = NULL;
	UINT			nNumEntries = 0;
	UINT			nIndex;
	DWORD			dwNumRecips = 0;
	BOOL			bGotRecipients = FALSE;
	BOOL			bAddressBook = FALSE;
	char			szTitle[256];
	char *			szName;
	char *			szEmail;
	char *			szNewRecipient;
	char **			szOldRecipients;
	char **			szRecipientArray = NULL;
	PGPKeySetRef	pubKeySet = NULL;
	PGPError		err = kPGPError_NoErr;

	if (LoadWAB(&hWAB, &pWABOpen, &pAdrBook, &pWABObject))
		if (ReadWAB(pAdrBook, pWABObject, &pTable, &nNumEntries))
			bAddressBook = TRUE;

	szName = strtok(szNames, ",;");
	while (szName)
	{
		szEmail = szName;

		if (bAddressBook)
		{
			for (nIndex=0; nIndex<nNumEntries; nIndex++)
			{
				if ((!_stricmp(szName, pTable[nIndex].szName)) &&
					(pTable[nIndex].szEmail != NULL))
				{
					szEmail = pTable[nIndex].szEmail;
					nIndex = nNumEntries;
				}
			}
		}

		szNewRecipient = (char *) calloc(sizeof(char), strlen(szEmail)+1);
		strcpy(szNewRecipient, szEmail);
		
		szOldRecipients = szRecipientArray;
		szRecipientArray = (char **) calloc(sizeof(char *), dwNumRecips+1);

		if (dwNumRecips > 0)
		{
			UINT i;

			for (i=0; i<dwNumRecips; i++)
				(szRecipientArray)[i] = szOldRecipients[i];
		}

		(szRecipientArray)[dwNumRecips] = szNewRecipient;
		dwNumRecips++;
		szName = strtok(NULL, ",;");
	}

	UIGetString(szTitle, sizeof(szTitle), IDS_RECIPIENTDIALOG);

	prds->Version = CurrentPGPrecipVersion;
	prds->hwndParent = hwnd;
	prds->szTitle = "Recipient Selection";
	prds->Context = pgpContext;
	prds->tlsContext = tlsContext;
	prds->SelectedKeySetRef = NULL;
	prds->szRecipientArray = szRecipientArray;
	prds->dwNumRecipients = dwNumRecips;
	prds->dwOptions = PGPCL_ASCIIARMOR;
	prds->dwFlags = 0;
	prds->dwDisableFlags = PGPCL_DISABLE_ASCIIARMOR |
							PGPCL_DISABLE_WIPEORIG |
							PGPCL_DISABLE_SDA;
	prds->AddedKeys = NULL;

	bGotRecipients = PGPclRecipientDialog(prds);

	if (prds->AddedKeys != NULL)
	{
		PGPUInt32 numKeys;

		PGPCountKeys(prds->AddedKeys, &numKeys);
		if (numKeys > 0)
			PGPclQueryAddKeys(pgpContext, tlsContext, hwnd, 
				prds->AddedKeys, NULL);

		PGPFreeKeySet(prds->AddedKeys);
		prds->AddedKeys = NULL;
	}

	if (bGotRecipients != TRUE)
	{
		err = kPGPError_UserAbort;
		goto GetRecipientsError;
	}

	FreeWAB(hWAB, pAdrBook, pWABObject, pTable, nNumEntries);
	return err;

GetRecipientsError:

	FreeRecipients(prds);
	FreeWAB(hWAB, pAdrBook, pWABObject, pTable, nNumEntries);
	return err;
}