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

📄 pgpclientencode.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
📖 第 1 页 / 共 4 页
字号:
			kPGPOptionType_OutputFileRef, fileRef );
			
		PGPFreeFileSpec( fileRef );
	}
	else
	{
		optionList = kPGPOutOfMemoryOptionListRef;
	}
	
	return( optionList );
}

#endif	/* ] */

	static PGPOptionListRef
pgpAllocatedOutputBuffer(
	PGPContextRef	context,
	void			**buffer,
	PGPSize			maximumBufferSize,
	PGPSize			*actualBufferSize, 
    PGPOptionType   type )
{
	PGPOptionListRef				optionList;
	PGPOAllocatedOutputBufferDesc	*descriptor;
	
	if ( IsntNull( buffer ) )
		*buffer	= NULL;
	if ( IsntNull( actualBufferSize ) )
		*actualBufferSize	= 0;
	pgpValidateOptionParam( IsntNull( buffer ) );
	pgpValidateOptionParam( IsntNull( actualBufferSize ) );
	pgpValidateOptionParam( maximumBufferSize > 0 );
	pgpValidateOptionContext( context );
	
	pgpEnterOptionListFunction();

	descriptor = (PGPOAllocatedOutputBufferDesc *)
			pgpContextMemAlloc( context,
				sizeof(*descriptor), kPGPMemoryMgrFlags_Clear);
	if( IsntNull( descriptor ) )
	{
		PGPOptionValue	value;
		
		descriptor->buffer 				= buffer;
		descriptor->maximumBufferSize 	= maximumBufferSize;
		descriptor->actualBufferSize	= actualBufferSize;
		
		value.asPtr = descriptor;
		
		optionList = pgpCreateStandardValueOptionList( context,  
							type,
							&value, sizeof( *descriptor ),
							AllocatedOptionHandlerProc );
	}
	else
	{
		optionList = kPGPOutOfMemoryOptionListRef;
	}
	
	return( optionList );
}

	PGPOptionListRef
PGPOAllocatedOutputBuffer(
	PGPContextRef	context,
	void			**buffer,
	PGPSize			maximumBufferSize,
	PGPSize			*actualBufferSize
    )
{
    return pgpAllocatedOutputBuffer( context, buffer, 
        maximumBufferSize, actualBufferSize, kPGPOptionType_OutputAllocatedBuffer );
}

/* Key container name, actually present on the token */
	PGPOptionListRef
PGPOAllocatedOutputKeyContainer(
	PGPContextRef	context,
	void			**buffer,
	PGPSize			maximumBufferSize,
	PGPSize			*actualBufferSize)
{
    return pgpAllocatedOutputBuffer( context, buffer, 
        maximumBufferSize, actualBufferSize, kPGPOptionType_TokenKeyContainer );
}


/* Not yet supported */
	PGPOptionListRef
PGPOAppendOutput(
	PGPContextRef	context,
	PGPBoolean		appendOutput
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	pgpEnterOptionListFunction();

	value.asUInt = (PGPUInt32)appendOutput;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_AppendOutput,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPODiscardOutput(
	PGPContextRef	context,
	PGPBoolean		discardOutput
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	pgpEnterOptionListFunction();

	value.asUInt = (PGPUInt32)discardOutput;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_DiscardOutput,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}


#if 0

	PGPOptionListRef
PGPOAskUserForOutput(
	PGPContextRef	context,
	PGPBoolean		askUserForOutput
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)askUserForOutput;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_AskUserForOutput,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}
#endif



	PGPOptionListRef
PGPOEncryptToKeyDBObj(
	PGPContextRef	context,
	PGPKeyDBObjRef	objRef
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpKeyDBObjIsValid( objRef ) );
	
	pgpEnterOptionListFunction();

	value.asKeyDBObjRef = objRef;

	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_EncryptToKeyDBObj,
							&value, sizeof( objRef ),
							SpecialOptionHandlerProc );
	
#if PGP_ENCRYPT_DISABLE
	pgpSetOptionListError( optionList, kPGPError_FeatureNotAvailable );
#endif

	return( optionList );
}

	PGPOptionListRef
PGPOEncryptToKeySet(
	PGPContextRef	context,
	PGPKeySetRef	keySetRef
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpKeySetIsValid( keySetRef ) );
	
	pgpEnterOptionListFunction();

	value.asKeySetRef = keySetRef;

	PGPIncKeySetRefCount( keySetRef );

	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_EncryptToKeySet,
							&value, sizeof( keySetRef ),
							SpecialOptionHandlerProc );
	
#if PGP_ENCRYPT_DISABLE
	pgpSetOptionListError( optionList, kPGPError_FeatureNotAvailable );
#endif

	return( optionList );
}

	PGPOptionListRef
PGPOSignWithKey(
	PGPContextRef		context,
	PGPKeyDBObjRef		keyRef,
	PGPOptionListRef	firstOption,
	...)
{
	PGPOptionListRef	optionList;
	
	pgpAssert( pgpContextIsValid( context ) );
	pgpAssert( pgpKeyIsValid( keyRef ) );
	
	pgpEnterOptionListFunction();

	if( pgpKeyIsValid( keyRef ) && pgpContextIsValid( context ) )
	{
		PGPOptionListRef	subOptions;
		PGPOptionValue		value;
		va_list				args;
		
		va_start( args, firstOption );
			subOptions = pgpBuildOptionListArgs( context,
				FALSE, firstOption, args );
		va_end( args );

		value.asKeyDBObjRef = keyRef;
	
		optionList = pgpCreateCustomValueOptionList(
								context,
								kPGPOptionType_SignWithKey,
								kPGPOptionFlag_Default, &value,
								sizeof( keyRef ), subOptions,
								SpecialOptionHandlerProc );
	}
	else
	{
		va_list				args;
		
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		optionList = kPGPBadParamsOptionListRef;
	}
	
#if PGP_SIGN_DISABLE
	pgpSetOptionListError( optionList, kPGPError_FeatureNotAvailable );
#endif

	return( optionList );
}

	PGPOptionListRef
PGPOConventionalEncrypt(
	PGPContextRef	context,
	PGPOptionListRef firstOption,
	...)
{
	PGPOptionListRef	optionList;
	PGPOptionListRef	subOptions;
	va_list				args;
	
	pgpAssert( pgpContextIsValid( context ) );
	pgpEnterOptionListFunction();

	if ( pgpContextIsValid( context ) )
	{
		va_start( args, firstOption );
			subOptions = pgpBuildOptionListArgs( context,
						FALSE, firstOption, args );
		va_end( args );

		optionList = pgpCreateCustomValueOptionList(
						context,  
						kPGPOptionType_ConventionalEncrypt,
						kPGPOptionFlag_Default, NULL,
						0, subOptions, NULL);
	}
	else
	{
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		optionList = kPGPBadParamsOptionListRef;
	}
	
#if PGP_ENCRYPT_DISABLE
	pgpSetOptionListError( optionList, kPGPError_FeatureNotAvailable );
#endif

	return( optionList );
}

	PGPOptionListRef
PGPOPassphraseBuffer(
	PGPContextRef	context,
	const void *	passphrase,
	PGPSize			passphraseLength)
{
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( IsntNull( passphrase ) );
	
	pgpEnterOptionListFunction();

	if( pgpFIPSModeEnabled() )
	{
		pgpValidateOptionParam( passphraseLength != 0 );
	}
	
	return( pgpCreateSensitiveOptionList( context,
				kPGPOptionType_Passphrase, passphrase, passphraseLength ) );
}

	PGPOptionListRef
PGPOPassphrase(
	PGPContextRef	context,
	const char *	passphrase)
{
	PGPSize			passphraseLength;

	pgpValidateOptionContext( context );
	pgpValidateOptionParam( IsntNull( passphrase ) );

	if( pgpFIPSModeEnabled() )
	{
		pgpValidateOptionParam( passphrase[0] != 0 );
	}

	pgpEnterOptionListFunction();

	/* Don't include trailing null, it is not used in the hash operations */
	passphraseLength = strlen( passphrase );
	
	return( pgpCreateSensitiveOptionList( context,
				kPGPOptionType_Passphrase, passphrase, passphraseLength ) );
}


	PGPOptionListRef
PGPOPasskeyBuffer(
	PGPContextRef	context,
	const void *	passkey,
	PGPSize			passkeyLength)
{
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( IsntNull( passkey ) );
	
	pgpEnterOptionListFunction();

	return( pgpCreateSensitiveOptionList( context,
				kPGPOptionType_Passkey, passkey, passkeyLength ) );
}


	PGPOptionListRef
PGPOCachePassphrase(
	PGPContextRef	context,
	PGPUInt32		timeOutSeconds,
	PGPBoolean		globalCache )
{
	PGPOptionListRef		optionList;
	PGPOCachePassphraseDesc	*descriptor;
	
	pgpValidateOptionContext( context );
	
	pgpEnterOptionListFunction();

	descriptor = (PGPOCachePassphraseDesc *)
						pgpContextMemAlloc( context, sizeof(*descriptor), 0);
	if( IsntNull( descriptor ) )
	{
		PGPOptionValue	value;
		
		descriptor->timeOutSeconds	= timeOutSeconds;
		descriptor->globalCache 	= globalCache;
		
		value.asPtr = descriptor;
		
		optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_CachePassphrase,
							&value, sizeof( *descriptor ),
							AllocatedOptionHandlerProc );
	}
	else
	{
		optionList = kPGPOutOfMemoryOptionListRef;
	}

	return( optionList );
}


	PGPOptionListRef
PGPOSessionKey(
	PGPContextRef	context,
	const void *	sessionKey,
	PGPSize			sessionKeyLength)
{
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( IsntNull( sessionKey ) );
	
	pgpEnterOptionListFunction();

	return( pgpCreateSensitiveOptionList( context,
				kPGPOptionType_SessionKey, sessionKey, sessionKeyLength ) );
}


	PGPOptionListRef
PGPODetachedSig(
	PGPContextRef	context,
	PGPOptionListRef firstOption,
	...)
{
	PGPOptionListRef	optionList;
	PGPOptionListRef	subOptions;
	va_list				args;
	
	pgpAssert( pgpContextIsValid( context ) );

	pgpEnterOptionListFunction();

	if ( pgpContextIsValid( context )  )
	{
		va_start( args, firstOption );
			subOptions = pgpBuildOptionListArgs( context,
				FALSE, firstOption, args );
		va_end( args );

		optionList = pgpCreateCustomValueOptionList( context, 
								kPGPOptionType_DetachedSignature,
								kPGPOptionFlag_Default, NULL,
								0, subOptions, NULL);
	}
	else
	{
		va_start( args, firstOption );
		pgpFreeVarArgOptionList( firstOption, args);
		va_end( args );
		
		optionList = kPGPBadParamsOptionListRef;
	}
	
	return( optionList );
}

#if 0
/* Not supported */
	PGPOptionListRef
PGPOMailHeaders(
	PGPContextRef	context,
	PGPOptionListRef firstOption,
	...)
{
	PGPOptionListRef	optionList;
	PGPOptionListRef	subOptions;
	va_list				args;
	
	pgpAssert( pgpContextIsValid( context ) );

	va_start( args, firstOption );
		subOptions = pgpBuildOptionListArgs( context,
			FALSE, firstOption, args );
	va_end( args );

	optionList = pgpCreateCustomValueOptionList( context, 
							kPGPOptionType_MailHeaders,
							kPGPOptionFlag_Default, NULL,
							0, subOptions, NULL);
	
	return( optionList );
}
#endif

	PGPOptionListRef
PGPOCipherAlgorithm(
	PGPContextRef	context,
	PGPCipherAlgorithm	algorithm
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	pgpEnterOptionListFunction();

	value.asCipherAlgorithm = algorithm;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_CipherAlgorithm,
							&value, sizeof( algorithm ), NULL);
	
	return( optionList );
}

	PGPOptionListRef
PGPOHashAlgorithm(
	PGPContextRef		context,
	PGPHashAlgorithm	algorithm
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
		
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( algorithm == kPGPHashAlgorithm_MD5 ||
		algorithm == kPGPHashAlgorithm_SHA ||
		algorithm == kPGPHashAlgorithm_RIPEMD160 );

	pgpEnterOptionListFunction();

	value.asHashAlgorithm = algorithm;
	
	optionList = pgpCreateStandardValueOptionList( context, 
						kPGPOptionType_HashAlgorithm,
						&value, sizeof( algorithm ), NULL );
	
	return( optionList );
}

	PGPOptionListRef
PGPOFailBelowValidity(
	PGPContextRef	context,
	PGPValidity		minValidity)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	pgpEnterOptionListFunction();

	value.asValidity = minValidity;
	
	optionList = pgpCreateStandardValueOptionList( context,  
						kPGPOptionType_FailBelowValidity,
						&value, sizeof( minValidity ), NULL );
	
	return( optionList );
}

	PGPOptionListRef
PGPOWarnBelowValidity(
	PGPContextRef	context,
	PGPValidity		minValidity)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	pgpEnterOptionListFunction();

	value.asValidity = minValidity;
	
	optionList = pgpCreateStandardValueOptionList( context, 
						kPGPOptionType_WarnBelowValidity,
						&value, sizeof( minValidity ), NULL );
	
	return( optionList );
}

	PGPOptionListRef
PGPOEventHandler(
	PGPContextRef	context,
	PGPEventHandlerProcPtr	handler,
	PGPUserValue			userValue)
{
	PGPOptionListRef		optionList;
	PGPOEventHandlerDesc	*descriptor;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( IsntNull( handler ) );
	
	pgpEnterOptionListFunction();

	descriptor = (PGPOEventHandlerDesc *)
						pgpContextMemAlloc( context, sizeof(*descriptor), 0);
	if( IsntNull( descriptor ) )
	{
		PGPOptionValue	value;
		
		descriptor->handlerProc = handler;
		descriptor->userValue 	= userValue;
		
		value.asPtr = descriptor;
		
		optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_EventHandler,
							&value, sizeof( *descriptor ),
							AllocatedOptionHandlerProc );
	}
	else

⌨️ 快捷键说明

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