Exemplo n.º 1
0
	static PGPError
sTestGroupValidity( PGPKeySetRef	keySet )
{
	PGPValidity		validity;
	PGPUInt32		numNotFound;
	PGPError		err	= kPGPError_NoErr;
	PGPGroupSetRef	set;
	PGPContextRef	memoryMgr	= NULL;
	
	err	= PGPNewContext( kPGPsdkAPIVersion, &memoryMgr );
	if ( IsntPGPError( err ) )
	{
		err	= PGPNewGroupSet( memoryMgr, &set );
		if ( IsntPGPError( err ) )
		{
			PGPGroupID	id;
			
			err	= PGPNewGroup( set, "test group", "", &id );
			if ( IsntPGPError( err ) )
				err	= sAddAllKeysToGroup( set, id, keySet );
			
			if ( IsntPGPError( err ) )
			{
				err	= PGPGetGroupLowestValidity( set, id, 
							keySet, &validity, &numNotFound );
			}
			
			PGPFreeGroupSet( set );
		}

		PGPFreeContext( memoryMgr );
	}
	
	return( err );
}
Exemplo n.º 2
0
void  
FreeGlobalPGPContext()
{
	if (PGPContextRefIsValid(GlobalContext))
	{
		PGPFreeContext(GlobalContext);
		GlobalContext = NULL;
	}
}
Exemplo n.º 3
0
BOOL UninitPGPsc(HWND hwnd,void *PGPsc,void *PGPtls)
{
	PGPError err;
	PGPContextRef context;
	PGPtlsContextRef tls;

	context=(PGPContextRef)PGPsc;
	tls=(PGPtlsContextRef)PGPtls;

	PGPclCloseLibrary ();

	err=PGPFreeTLSContext(tls);

	err=PGPFreeContext(context);

	OleUninitialize();

	if(IsntPGPError(err))
		return TRUE;

	return FALSE;
}
Exemplo n.º 4
0
int __cdecl _pgp_done()
{
	pgpVer = 0;
	#if defined(_WIN64)
		return 0;
	#else
		__try {
			if(pgpErrMsg) LocalFree(pgpErrMsg);
			if (pszPassphrase) PGPFreeData(pszPassphrase);
			if (pgpKeyDB) PGPFreeKeyDB(pgpKeyDB);
			PGPFreeContext(pgpContext);
			PGPsdkUILibCleanup();
			PGPsdkCleanup();
			pszPassphrase = pgpErrMsg = 0;
			pgpKeyDB = 0;
			pgpContext = 0;
		}
		__except ( EXCEPTION_EXECUTE_HANDLER ) {
			return 0;
		}
		return 1;
	#endif
}
Exemplo n.º 5
0
	PGPError
TestGroupsUtil()
{
	PGPContextRef	context;
	PGPError		err	= kPGPError_NoErr;
	
	err	= PGPNewContext( kPGPsdkAPIVersion, &context );
	if ( IsntPGPError( err ) )
	{
		PGPKeySetRef	keySet;
		
		err	= PGPOpenDefaultKeyRings( context, 0, &keySet );
		if ( IsntPGPError( err ) )
		{
			err	= sTestGroupValidity( keySet );
			
			PGPFreeKeySet( keySet );
		}
		PGPFreeContext( context );
	}
	
	pgpAssertNoErr( err );
	return( err );
}
Exemplo n.º 6
0
static VOID
sSetHotKeys (HWND hwnd)
{
	PGPInt32		ids			= 0;
	PGPHotKeys		hotkeys;
	PGPHotKeys*		phks;
	PGPPrefRef		prefref;
	PGPSize			size;
	PGPError		err;
	PGPContextRef	context;

	err = PGPNewContext (kPGPsdkAPIVersion, &context);
	if (IsPGPError (err))
		return;

	err = PGPclOpenClientPrefs (PGPGetContextMemoryMgr (context), &prefref);
	if (IsPGPError (err))
		return;

	memcpy (&hotkeys, &sDefaultHotKeys, sizeof(hotkeys));
	err = PGPGetPrefData (prefref, kPGPPrefHotKeyData, &size, &phks);

	if (IsntPGPError (err))
	{
		if (size == sizeof (hotkeys))
			memcpy (&hotkeys, phks, size);

		PGPDisposePrefData (prefref, phks);
	}

	if (!sSetSingleHotKey (hwnd, kPurgePassphraseCache, 
			hotkeys.hotkeyPurgePassphraseCache))
	{
		hotkeys.hotkeyPurgePassphraseCache &= ~kPGPHotKeyEnabled;
		ids = IDS_CANNOTSETPURGEHOTKEY;
		goto done;
	}

	if (!sSetSingleHotKey (hwnd, kEncryptCurrentWindow, 
			hotkeys.hotkeyEncrypt))
	{
		hotkeys.hotkeyEncrypt &= ~kPGPHotKeyEnabled;
		ids = IDS_CANNOTSETENCRYPTHOTKEY;
		goto done;
	}

	if (!sSetSingleHotKey (hwnd, kSignCurrentWindow, 
			hotkeys.hotkeySign))
	{
		hotkeys.hotkeySign &= ~kPGPHotKeyEnabled;
		ids = IDS_CANNOTSETSIGNHOTKEY;
		goto done;
	}

	if (!sSetSingleHotKey (hwnd, kEncryptSignCurrentWindow, 
			hotkeys.hotkeyEncryptSign))
	{
		hotkeys.hotkeyEncryptSign &= ~kPGPHotKeyEnabled;
		ids = IDS_CANNOTSETENCRYPTSIGNHOTKEY;
		goto done;
	}

	if (!sSetSingleHotKey (hwnd, kDecryptCurrentWindow, 
			hotkeys.hotkeyDecrypt))
	{
		hotkeys.hotkeyDecrypt &= ~kPGPHotKeyEnabled;
		ids = IDS_CANNOTSETDECRYPTHOTKEY;
		goto done;
	}

///	if (!sSetSingleHotKey (hwnd, kUnmountPGPDisks, 
///			hotkeys.hotkeyDiskUnmount))
///	{
///		ids = IDS_CANNOTSETUNMOUNTHOTKEY;
///		goto done;
///	}

done:
	if (ids)
	{
		PGPSetPrefData (
				prefref, kPGPPrefHotKeyData, sizeof(hotkeys), &hotkeys);
		PGPclCloseClientPrefs (prefref, TRUE);

		PTMessageBox (hwnd, IDS_CAPTION, ids, MB_ICONEXCLAMATION|MB_OK);

		PGPclPreferences (context, hwnd, PGPCL_HOTKEYPREFS, NULL);
	}
	else
		PGPclCloseClientPrefs (prefref, FALSE);

	PGPFreeContext (context);
}