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

📄 pgpclientencode.c

📁 vc环境下的pgp源码
💻 C
📖 第 1 页 / 共 4 页
字号:
}

	PGPOptionListRef
PGPOEventHandler(
	PGPContextRef	context,
	PGPEventHandlerProcPtr	handler,
	PGPUserValue			userValue)
{
	PGPOptionListRef		optionList;
	PGPOEventHandlerDesc	*descriptor;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( IsntNull( handler ) );
	
	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
	{
		optionList = kPGPOutOfMemoryOptionListRef;
	}

	return( optionList );
}

	PGPOptionListRef
PGPOSendNullEvents(
	PGPContextRef	context,
	PGPTimeInterval approxInterval)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
		
	pgpValidateOptionContext( context );

	value.asInterval = approxInterval;
	
	optionList = pgpCreateStandardValueOptionList( context, 
						kPGPOptionType_SendNullEvents,
						&value, sizeof( approxInterval ), NULL );
	
	return( optionList );
}

	PGPOptionListRef
PGPOArmorOutput(
	PGPContextRef	context,
	PGPBoolean		armorOutput
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)armorOutput;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_ArmorOutput,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPODataIsASCII(
	PGPContextRef	context,
	PGPBoolean		dataIsASCII
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)dataIsASCII;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_DataIsASCII,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOClearSign(
	PGPContextRef	context,
	PGPBoolean		clearSign
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)clearSign;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_ClearSign,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOForYourEyesOnly(
	PGPContextRef	context,
	PGPBoolean		forYourEyesOnly
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)forYourEyesOnly;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_ForYourEyesOnly,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOSendEventIfKeyFound(
	PGPContextRef	context,
	PGPBoolean		sendEventIfKeyFound
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)sendEventIfKeyFound;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_SendEventIfKeyFound,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOPassThroughIfUnrecognized(
	PGPContextRef	context,
	PGPBoolean		passThroughIfUnrecognized
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)passThroughIfUnrecognized;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_PassThroughIfUnrecognized,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOPassThroughClearSigned(
	PGPContextRef	context,
	PGPBoolean		passThroughClearSigned
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)passThroughClearSigned;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_PassThroughClearSigned,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOPassThroughKeys(
	PGPContextRef	context,
	PGPBoolean		passThroughKeys
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)passThroughKeys;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_PassThroughKeys,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPORecursivelyDecode(
	PGPContextRef	context,
	PGPBoolean		recurse
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)recurse;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_RecursivelyDecode,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOAskUserForEntropy(
	PGPContextRef	context,
	PGPBoolean		askUserForEntropy
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)askUserForEntropy;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_AskUserForEntropy,
							&value, sizeof( PGPUInt32 ), NULL);

	
	return( optionList );
}

	PGPOptionListRef
PGPORawPGPInput(
	PGPContextRef	context,
	PGPBoolean		rawPGPInput
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)rawPGPInput;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_RawPGPInput,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOCompression(
	PGPContextRef	context,
	PGPBoolean		compression
	)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );

	value.asUInt = (PGPUInt32)compression;
	
	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_Compression,
							&value, sizeof( PGPUInt32 ), NULL);

	return( optionList );
}

	PGPOptionListRef
PGPOKeySetRef(
	PGPContextRef	context,
	PGPKeySetRef 	keySetRef)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpKeySetIsValid( keySetRef ) );
	
	value.asKeySetRef = keySetRef;
	
	PGPIncKeySetRefCount( keySetRef );

	optionList = pgpCreateStandardValueOptionList( context,  
						kPGPOptionType_KeySetRef,
						&value, sizeof( keySetRef ),
						SpecialOptionHandlerProc );
	
	return( optionList );
}

	PGPOptionListRef
PGPOExportKeySet(
	PGPContextRef	context,
	PGPKeySetRef 	keySetRef)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpKeySetIsValid( keySetRef ) );
	
	value.asKeySetRef = keySetRef;
	
	PGPIncKeySetRefCount( keySetRef );

	optionList = pgpCreateStandardValueOptionList( context,  
						kPGPOptionType_ExportKeySet,
						&value, sizeof( keySetRef ),
						SpecialOptionHandlerProc );
	
	return( optionList );
}

	PGPOptionListRef
PGPOExportKey(
	PGPContextRef	context,
	PGPKeyRef	 	keyRef)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpKeyIsValid( keyRef ) );
	
	value.asKeyRef = keyRef;

	pgpIncKeyRefCount( keyRef );

	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_ExportKey,
							&value, sizeof( keyRef ),
							SpecialOptionHandlerProc );
	
	return( optionList );
}

	PGPOptionListRef
PGPOExportUserID(
	PGPContextRef	context,
	PGPUserIDRef 	useridRef)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpUserIDIsValid( useridRef ) );
	
	value.asUserIDRef = useridRef;

	pgpIncUserIDRefCount( useridRef );

	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_ExportUserID,
							&value, sizeof( useridRef ),
							SpecialOptionHandlerProc );
	
	return( optionList );
}

	PGPOptionListRef
PGPOExportSig(
	PGPContextRef	context,
	PGPSigRef	 	sigRef)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;
	
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpSigIsValid( sigRef ) );
	
	value.asSigRef = sigRef;

	pgpIncSigRefCount( sigRef );

	optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_ExportSig,
							&value, sizeof( sigRef ),
							SpecialOptionHandlerProc );
	
	return( optionList );
}


	PGPOptionListRef
PGPOKeyGenParams(
	PGPContextRef			context,
	PGPPublicKeyAlgorithm	pubKeyAlg,
	PGPUInt32				bits)
{
	PGPOptionListRef		optionList;
	PGPOKeyGenParamsDesc	*descriptor;

	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pubKeyAlg >= kPGPPublicKeyAlgorithm_First &&
		pubKeyAlg <= kPGPPublicKeyAlgorithm_Last );
	pgpValidateOptionParam( bits >= 512 );

	descriptor = (PGPOKeyGenParamsDesc *)
						pgpContextMemAlloc( context, sizeof(*descriptor), 0);
	if( IsntNull( descriptor ) )
	{
		PGPOptionValue	value;

		descriptor->pkalg	= pubKeyAlg;
		descriptor->bits 	= bits;

		value.asPtr = descriptor;

		optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_KeyGenParams,
							&value, sizeof( *descriptor ),
							AllocatedOptionHandlerProc );
	}
	else
	{
		optionList = kPGPOutOfMemoryOptionListRef;
	}
	
	return( optionList );
}

	PGPOptionListRef
PGPOKeyGenName(
	PGPContextRef	context,
	const void	*	name,
	PGPSize			nameLength)
{
	pgpValidateOptionContext( context );
	pgpValidateOptionParam( IsntNull( name ) );
	pgpValidateOptionParam( nameLength >= 1 );
	pgpValidateOptionParam( nameLength < 256 );
	
	return( pgpCreateBufferOptionList( context,
				kPGPOptionType_KeyGenName, name, nameLength ) );
}

	PGPOptionListRef
PGPOExpiration(
	PGPContextRef	context,
	PGPUInt32		expirationDays)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;

	pgpValidateOptionContext( context );

	value.asUInt = expirationDays;

	optionList = pgpCreateStandardValueOptionList( context, 
							kPGPOptionType_Expiration,
							&value, sizeof( expirationDays ), NULL);
	
	return( optionList );
}

	PGPOptionListRef
PGPOCreationDate(
	PGPContextRef	context,
	PGPTime			creationDate)
{
	PGPOptionListRef	optionList;
	PGPOptionValue		value;

	pgpValidateOptionContext( context );

	value.asTime = creationDate;

	optionList = pgpCreateStandardValueOptionList( context, 
							kPGPOptionType_CreationDate,
							&value, sizeof( creationDate ), NULL);
	
	return( optionList );
}

	PGPOptionListRef
PGPOAdditionalRecipientRequestKeySet(
	PGPContextRef	context,
	PGPKeySetRef	arKeySetRef,
	PGPByte			arkclass
	)
{
	PGPOptionListRef	optionList;
	PGPOAdditionalRecipientRequestKeySetDesc	*descriptor;

	pgpValidateOptionContext( context );
	pgpValidateOptionParam( pgpKeySetIsValid( arKeySetRef ) );

	descriptor = (PGPOAdditionalRecipientRequestKeySetDesc *)
						pgpContextMemAlloc( context, sizeof(*descriptor), 0);
	if( IsntNull( descriptor ) )
	{
		PGPOptionValue	value;

		descriptor->arKeySetRef	= arKeySetRef;
		descriptor->arkclass 	= arkclass;

		value.asPtr = descriptor;

		PGPIncKeySetRefCount( arKeySetRef );

		optionList = pgpCreateStandardValueOptionList( context,  
							kPGPOptionType_AdditionalRecipientRequestKeySet,
							&value, sizeof( *descriptor ),
							AllocatedOptionHandlerProc );
	}
	else
	{
		optionList = kPGPOutOfMemoryOptionListRef;
	}
	
	return( optionList );
}

	PGPOptionListRef
PGPORevocationKeySet(
	PGPContextRef	context,
	PGPKeySetRef	raKeySetRef

⌨️ 快捷键说明

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