⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgpclientkeydb.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
📖 第 1 页 / 共 2 页
字号:
		{
			error = pgpCreateX509CertificateInternal( signingSig, signedKey,
													  newSig, optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}


	PGPError
PGPCreateX509CertificateFromRequest(
	PGPKeyDBObjRef		signingSig,
	PGPKeyDBObjRef		*newSig,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError		error	= kPGPError_NoErr;
	
	pgpAssert( pgpSigIsValid( signingSig ) );
	pgpAssert( IsntNull( newSig ) );
	
	if (IsntNull( newSig ) )
		*newSig	= kInvalidPGPKeyDBObjRef;
	
	pgpEnterPGPErrorFunction();

	if( pgpSigIsValid( signingSig ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;
	
		context = PGPPeekKeyDBObjContext( signingSig );
		va_start( args, firstOption );
		
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpCreateX509CertificateInternal( signingSig, NULL,
													  newSig, optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}


	PGPError
PGPCreateX509CRL(
	PGPKeyDBObjRef		signingSig,
	PGPKeySetRef		revokedSigs,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError		error	= kPGPError_NoErr;
	
	pgpAssert( pgpSigIsValid( signingSig ) );
	pgpAssert( pgpKeySetIsValid( revokedSigs ) );
	
	pgpEnterPGPErrorFunction();

	if( pgpSigIsValid( signingSig ) && pgpKeySetIsValid( revokedSigs ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;
	
		context = PGPPeekKeyDBObjContext( signingSig );
		va_start( args, firstOption );
		
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpCreateX509CRLInternal( signingSig, revokedSigs,
											  optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}

/*____________________________________________________________________________
	Export a key, keyset, or subset of a key to a buffer or file
____________________________________________________________________________*/

	PGPError
PGPExport(
	PGPContextRef		context,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError		error	= kPGPError_NoErr;
	
	pgpAssert( pgpContextIsValid( context ) );
	
	pgpEnterPGPErrorFunction();

	if( pgpContextIsValid( context ) )
	{
		va_list				args;
		PGPOptionListRef	optionList;
	
		va_start( args, firstOption );
		
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpExportInternal( context, optionList );
		}
		va_end( args );

		/* optionList is freed in internal function */
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}

/*____________________________________________________________________________
	Import a keyset from a buffer or file
____________________________________________________________________________*/

	PGPError
PGPImport(
	PGPContextRef		context,
	PGPKeyDBRef			*keys,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError	error	= kPGPError_NoErr;
	
	if( IsntNull( keys ) )
		*keys	= kInvalidPGPKeyDBRef;
		
	pgpEnterPGPErrorFunction();

	if( pgpContextIsValid( context ) && IsntNull( keys ) )
	{
		va_list				args;
		PGPOptionListRef	optionList;
		
		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpImportKeySetInternal( context, keys, optionList );
		}
		va_end( args );

		/* optionList is freed in internal function */
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}

/*____________________________________________________________________________
	Change (top level) key passphrase
____________________________________________________________________________*/

	PGPError
PGPChangePassphrase(
	PGPKeyDBObjRef		key,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError	error	= kPGPError_NoErr;
	
	pgpEnterPGPErrorFunction();

	pgpAssert( pgpKeyIsValid( key ) || pgpSubKeyIsValid( key ) );
	
	if( pgpKeyIsValid( key )  ||  pgpSubKeyIsValid( key ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;

		context = PGPPeekKeyDBObjContext( key );

		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			if( pgpObjectType( key ) == RINGTYPE_KEY )
				error = pgpChangePassphraseInternal( key, optionList );
			else
				error = pgpChangeSubKeyPassphraseInternal( key, optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}

/*____________________________________________________________________________
	Check passphrase validity
____________________________________________________________________________*/

	PGPBoolean
PGPPassphraseIsValid(
	PGPKeyDBObjRef		key,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPBoolean	rslt	= FALSE;
	PGPError	error	= kPGPError_NoErr;
	
	pgpAssert( pgpKeyIsValid( key ) );
	
	pgpEnterBooleanFunction( FALSE );

	if( pgpKeyIsValid( key ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;

		context = PGPPeekKeyDBObjContext( key );

		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			rslt = pgpPassphraseIsValidInternal( key, optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );

		return rslt;
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		return FALSE;
	}
}

/*____________________________________________________________________________
	Set key axiomatic, possibly testing passphrase
____________________________________________________________________________*/

	PGPError
PGPSetKeyAxiomatic(
	PGPKeyDBObjRef		key,
	PGPBoolean			setAxiomatic,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError	error	= kPGPError_NoErr;
	
	pgpAssert( pgpKeyIsValid( key ) );
	
	pgpEnterPGPErrorFunction();

	if( pgpKeyIsValid( key ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;

		context = PGPPeekKeyDBObjContext( key );

		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpSetKeyAxiomaticInternal( key, setAxiomatic, optionList);
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}


/*____________________________________________________________________________
	Get the passkeybuffer to unlock a key, given its passphrase
____________________________________________________________________________*/

	PGPError
PGPGetPasskeyBuffer(
	PGPKeyDBObjRef		key,
	void			   *passkeyBuffer,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError	error	= kPGPError_NoErr;
	
	pgpAssert( pgpKeyIsValid( key ) || pgpSubKeyIsValid( key ) );
	pgpAssert( IsntNull( passkeyBuffer ) );
	
	pgpEnterPGPErrorFunction();

	if( IsntNull( passkeyBuffer ) &&
		( pgpKeyIsValid( key ) || pgpSubKeyIsValid( key ) )  )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;

		context = PGPPeekKeyDBObjContext( key );

		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			if( pgpObjectType( key ) == RINGTYPE_KEY )
				error = pgpGetKeyPasskeyBufferInternal( key, passkeyBuffer,
														optionList );
			else
				error = pgpGetSubKeyPasskeyBufferInternal( key, passkeyBuffer,
														   optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}


/*____________________________________________________________________________
	Add, Remove, or Replace key self-sig options
____________________________________________________________________________*/

	PGPError
PGPAddKeyOptions(
	PGPKeyDBObjRef		key,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError	error	= kPGPError_NoErr;
	
	pgpEnterPGPErrorFunction();

	pgpAssert( pgpKeyIsValid( key ) );
	
	if( pgpKeyIsValid( key ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;

		context = PGPPeekKeyDBObjContext( key );

		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpAddKeyOptionsInternal( key, optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}

	PGPError
PGPRemoveKeyOptions(
	PGPKeyDBObjRef		key,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError	error	= kPGPError_NoErr;
	
	pgpAssert( pgpKeyIsValid( key ) );
	
	pgpEnterPGPErrorFunction();

	if( pgpKeyIsValid( key ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;

		context = PGPPeekKeyDBObjContext( key );

		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpRemoveKeyOptionsInternal( key, optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}

	PGPError
PGPUpdateKeyOptions(
	PGPKeyDBObjRef		key,
	PGPOptionListRef	firstOption,
	...
	)
{
	PGPError	error	= kPGPError_NoErr;
	
	pgpAssert( pgpKeyIsValid( key ) );
	
	pgpEnterPGPErrorFunction();

	if( pgpKeyIsValid( key ) )
	{
		va_list				args;
		PGPContextRef		context;
		PGPOptionListRef	optionList;

		context = PGPPeekKeyDBObjContext( key );

		va_start( args, firstOption );
		optionList = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );

		error = pgpGetOptionListError( optionList );
		if( IsntPGPError( error ) )
		{
			error = pgpUpdateKeyOptionsInternal( key, optionList );
		}
		va_end( args );

		PGPFreeOptionList( optionList );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		error = kPGPError_BadParams;
	}
	
	return( error );
}


/*__Editor_settings____

	Local Variables:
	tab-width: 4
	End:
	vi: ts=4 sw=4
	vim: si
_____________________*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -