Beispiel #1
0
static PGPError
sSendToServerInternal (
		HWND					hwndParent,
		PGPContextRef			context,
		PGPtlsContextRef		tlsContext,
		UINT					uServer,
		PGPKeyServerEntry*		pkeyserver,
		LPSTR					pszUserID,
		PGPKeySetRef			keysetMain,
		PGPKeySetRef			keysetToSend)
{
	PGPError				err				= kPGPError_NoErr;
	PGPKeyServerEntry*		pentryList		= NULL;
	PGPKeyServerSpec*		pserverList		= NULL;
	PGPInt32				iNumEntries		= 0;
	PCLIENTSERVERSTRUCT		pcss			= NULL;
	PGPKeySetRef			keysetFailed	= kInvalidPGPKeySetRef;
	PGPMemoryMgrRef			memMgr;
	PGPPrefRef				clientPrefsRef;

	PGPValidatePtr (keysetToSend);
	PGPValidatePtr (context);
	PGPValidatePtr (pszUserID);
		
	memMgr=PGPGetContextMemoryMgr(context);
	err=PGPclOpenClientPrefs (memMgr,&clientPrefsRef);

	if(IsntPGPError(err))
	{
		err=CLInitKeyServerPrefs(uServer,pkeyserver,
			hwndParent,context,keysetMain,clientPrefsRef,pszUserID,
			&pcss,&pentryList,&pserverList,&iNumEntries);

		PGPclCloseClientPrefs (clientPrefsRef, FALSE);
	}

	if (IsntPGPError (err)) 
	{
		err = PGPSendToKeyServerDialog (context, &(pserverList[0]),
			tlsContext, keysetToSend, &keysetFailed, 
			PGPOUIParentWindowHandle (context, hwndParent),
			PGPOLastOption (context));

		if (PGPKeySetRefIsValid (keysetFailed))
			PGPFreeKeySet (keysetFailed);
	}

	CLUninitKeyServerPrefs(uServer,
		pcss,pentryList,pserverList,iNumEntries);
	
	return err;
}
Beispiel #2
0
static PGPError
sQueryServerInternal (
	HWND					hwndParent,
	PGPContextRef			context,
	PGPtlsContextRef		tlsContext,
	PGPOptionListRef		optionSearch,
	UINT					uServer,
	LPSTR					pszUserID,
	PGPKeySetRef			keysetMain,
	PGPKeySetRef*			pkeysetResult)
{
	PGPError				err				= kPGPError_NoErr;
	PGPKeyServerEntry*		pentryList		= NULL;
	PGPKeyServerSpec*		pserverList		= NULL;
	PGPInt32				iNumEntries		= 0;
	PCLIENTSERVERSTRUCT		pcss			= NULL;
	PGPMemoryMgrRef			memMgr;
	PGPPrefRef				clientPrefsRef;

	PGPValidatePtr (pkeysetResult);
	PGPValidatePtr (context);
	PGPValidatePtr (pszUserID);
		
	memMgr=PGPGetContextMemoryMgr(context);
	err=PGPclOpenClientPrefs (memMgr,&clientPrefsRef);

	if(IsntPGPError(err))
	{
		err=CLInitKeyServerPrefs(uServer,NULL,
			hwndParent,context,keysetMain,clientPrefsRef,pszUserID,
			&pcss,&pentryList,&pserverList,&iNumEntries);

		PGPclCloseClientPrefs (clientPrefsRef, FALSE);
	}

	if (IsntPGPError (err)) 
	{
		err = PGPSearchKeyServerDialog (context, iNumEntries,
			pserverList, tlsContext, 
			FALSE, pkeysetResult, optionSearch,
			PGPOUIParentWindowHandle (context, hwndParent),
			PGPOLastOption (context));
	}

	CLUninitKeyServerPrefs(uServer,
		pcss,pentryList,pserverList,iNumEntries);
	
	return err;
}
Beispiel #3
0
PGPError  
KMGetConventionalPhrase (
		PGPContextRef	context,
		HWND			hwnd, 
		LPSTR			pszPrompt,
		LPSTR*			ppszPhrase)
{
	PGPError			err			= kPGPError_BadParams;
	PGPOptionListRef	optionList	= kInvalidPGPOptionListRef;

	if (!ppszPhrase) return err;

	err = PGPBuildOptionList (context, &optionList,
			PGPOUIOutputPassphrase (context, ppszPhrase),
			PGPOUIParentWindowHandle (context, hwnd),
			PGPOLastOption (context));

	if (IsntPGPError (err))
	{
		// If we have a prompt, use it
		if (NULL!=(int) (pszPrompt))
		{
			err = PGPAppendOptionList (optionList,
				PGPOUIDialogPrompt (context, pszPrompt),
				PGPOLastOption (context));
		}

		if (IsntPGPError (err))
		{
			err = PGPConventionalDecryptionPassphraseDialog (context,
					optionList,
					PGPOLastOption (context));
		}
	}

	if (IsPGPError (err)) 
	{
		if (*ppszPhrase) 
		{
			PGPFreeData (*ppszPhrase);
			*ppszPhrase = NULL;
		}
	}

	if (PGPOptionListRefIsValid (optionList))
		PGPFreeOptionList (optionList);

	return err;
}
Beispiel #4
0
PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID)
{
	#if defined(_WIN64)
		return 0;
	#else
		PGPKeyDBRef 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;
		PGPCountKeysInKeyDB(ContactKeyDB, &dwKeys);
		if (!dwKeys)
			return 0;
		if (dwKeys > 1)
			MessageBox(hDlg, "You selected more than one key. Only the first key will be used.", szModuleName, MB_ICONINFORMATION);

		static PGPKeyID KeyID;

		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);
		return (PVOID)&KeyID;
	#endif
}