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

📄 pgpike.h

📁 可以实现对邮件的加密解密以及签名
💻 H
📖 第 1 页 / 共 2 页
字号:
	PGPikeCipher			cipher;
	PGPUInt32				keyLength;	/* cipher key bit size, must be 0 for all except AES */ 
	PGPikeGroupID			groupID;
} PGPikeTransform;

typedef struct PGPipsecTransform
{
	PGPBoolean				useESP;
	PGPipsecESPTransform	esp;
	
	PGPBoolean				useAH;
	PGPipsecAHTransform		ah;
	
	PGPBoolean				useIPCOMP;
	PGPipsecIPCOMPTransform	ipcomp;
	
	PGPikeGroupID			groupID;
} PGPipsecTransform;

typedef struct PGPipsecDOIParams
{
	PGPipsecSPI				inSPI;
	PGPipsecSPI				outSPI;
	PGPipsecProtocol		protocol;

	union
	{
		struct
		{
			PGPipsecAHTransform		t;
			PGPByte					inAuthKey[kPGPike_AuthMaximumKeySize];
			PGPByte					outAuthKey[kPGPike_AuthMaximumKeySize];
		} ah;
		
		struct
		{
			PGPipsecESPTransform	t;
			PGPByte					inESPKey[kPGPike_ESPMaximumKeySize];
			PGPByte					outESPKey[kPGPike_ESPMaximumKeySize];
			PGPByte					inAuthKey[kPGPike_AuthMaximumKeySize];
			PGPByte					outAuthKey[kPGPike_AuthMaximumKeySize];
			PGPByte					explicitIV[kPGPike_MaxExplicitIVSize];
		} esp;
		
		struct
		{
			PGPipsecIPCOMPTransform	t;
		} ipcomp;
	} u;	
} PGPipsecDOIParams;

typedef struct PGPipsecSA
{
	struct PGPipsecSA *		nextSA;				/* INTERNAL USE ONLY */
	struct PGPipsecSA *		prevSA;				/* INTERNAL USE ONLY */
	PGPUInt32				ipAddress;			/* PreNATted(Original) IP Address */
	PGPBoolean				destIsRange;		/* dest is IP range */
	PGPUInt32				ipAddrStart;		/* IP address */
	PGPUInt32				ipMaskEnd;			/* mask or end range IP address */
	PGPByte					ipProtocol;			/* 0 if all protocols */
	PGPUInt16				ipPort;				/* 0 if all ports */
	
	PGPBoolean				bNATTraversal;		/* NAT Encapsulation is enabled if true */
	PGPBoolean				bIsLocalIPNAT;		/* if non-zero, our local IP is natted */
	PGPBoolean				bIsRemoteIPNAT;		/* if non-zero, remote IP is NATed */
	PGPUInt32				natIPAddress;		/* NATed Dest IP Address, 0 if not NATed */
	PGPUInt16				nboNATPort;			/* NATed Dest Port value */

	PGPUInt32				assignedIP;			/* if non-zero, use as tunnel IP */
	PGPUInt32				assignedDNS;		/* if non-zero, use as tunnel DNS */
	PGPUInt32				assignedWINS;		/* if non-zero, use as tunnel WINS */
	
	PGPBoolean				initiator;			/* was this SA initiated locally */
	PGPBoolean				activeIn;			/* use for inbound data */
	PGPBoolean				activeOut;			/* use for outbound data */
	PGPUInt32				kbLifeTime;			/* max KB to be sent on this SA */
	PGPUInt32				secLifeTime;		/* max seconds this SA will live */
												/* 0 means no limit for either */
	PGPTime					birthTime;
	
	PGPUInt16				numTransforms;
	PGPipsecDOIParams		transform[kPGPike_MaxTransforms];
	
	PGPTime					termSchedule;	/* SA will be terminated, private */
	PGPByte					userData[kPGPike_UserDataSize];/* for your use */
} PGPipsecSA;

/*	When sent a kPGPike_MT_SARequest, pgpIKE will expect that
	all fields below will be filled in.  The approved member is
	irrelevant in that case.
	
	When you are called with kPGPike_MT_PolicyCheck, pgpIKE will
	set everything to 0 except the IP address.  You are expected
	to fill in the other fields with local policy.  The PolicyCheck
	is used for remote-initiated SA negotiation.  Since you cannot
	predict which remote network might be trying to communicate
	with us, you should leave the destIsRange/ipAddrStart/ipMaskEnd
	and ipPort/ipProtocol fields set to 0 for this message.  You
	will be called to check those later with the ClientIDCheck.
*/
typedef struct PGPikeMTSASetup
{
	PGPBoolean				approved;			/* >  */
	
	PGPUInt32				ipAddress;			/* destination */
	PGPUInt32				localIPAddress;		/* source */
	PGPByte					ipProtocol;
	PGPUInt16				ipPort;
	PGPByte *				sharedKey;			/* null if none, data will be copied */
	PGPSize					sharedKeySize; 		/* w/o NULL-terminate */
	PGPBoolean				aggressive;			/* set for aggressive mode */
	PGPBoolean				lightweight;		/* only for SARequest, set to
													TRUE for only 1 retry */
	/* set the fields below to use tunnel mode */
	PGPBoolean				destIsRange;
	PGPUInt32				ipAddrStart;
	PGPUInt32				ipMaskEnd;
	
	PGPBoolean				virtualIP;			/* whether to use mode-cfg */
	PGPikeAuthStyle			authStyle;			/* whether to use xauth/hybrid */
	PGPikeEncapsulateMode	encapsulateMode;	/* Force NAT Traversal mode */
	
	PGPipsecIdentity		idType;				/* only useful in shared key mode */
	PGPByte *				idData;				/* data will be copied */
	PGPSize					idDataSize;			/* this is the Phase 1 ID */
} PGPikeMTSASetup;

/*	
	When you are called with a kPGPike_MT_ClientIDCheck, all fields
	will be set appropriately.  If the destIsRange/ipAddrStart/ipMaskEnd
	triad is permitted to be represented by the IP address, set
	the approved field to true.  This message is only sent in the case
	where the remote side is the initiator and you have already been
	called with a kPGPike_MT_PolicyCheck message.
*/
typedef struct PGPikeMTClientIDCheck
{
	PGPBoolean				approved;		/* >  */
	
	PGPUInt32				ipAddress;
	PGPByte					ipProtocol;
	PGPUInt16				ipPort;
	
	PGPBoolean				destIsRange;
	PGPUInt32				ipAddrStart;
	PGPUInt32				ipMaskEnd;
} PGPikeMTClientIDCheck;

typedef struct PGPikeMTSAEstablished
{
	PGPipsecSA *			sa;
	PGPBoolean				remoteValid;
	PGPByte *				remoteAuthKey;		/* binary exported key data */
	PGPSize					remoteAuthKeySize;
} PGPikeMTSAEstablished;

typedef struct PGPikeMTSAFailed
{
	PGPUInt32				ipAddress;		/* destination */
	PGPByte					ipProtocol;
	PGPUInt16				ipPort;
	
	PGPBoolean				destIsRange;
	PGPUInt32				ipAddrStart;
	PGPUInt32				ipMaskEnd;
	
} PGPikeMTSAFailed;

typedef struct PGPikeMTCert
{
	PGPUInt32				ipAddress;		/*  < */
	PGPKeyDBRef				baseKeyDB;		/* >  */
	PGPKeyDBObjRef			authObj;		/* >  PGP key or X.509 cert */
	
	PGPBoolean				isPassKey;		/* >  */
	void *					pass;			/* >  null-term if passphrase, copied */
	PGPSize					passLength;		/* >  */
} PGPikeMTCert;

typedef struct PGPikeMTRemoteCert
{
	PGPBoolean				approved;		/* >  */
	PGPBoolean				valid;			/* >  */
	PGPUInt32				ipAddress;		/*  < */
	PGPKeyDBObjRef			remoteObj;		/*  < PGPkey or X.509 cert */
	PGPKeyDBRef				remoteKeyDB;	/*  < any other keys/certs are part of
													this cert's chain */
} PGPikeMTRemoteCert;

typedef struct PGPikeMTPacket
{
	PGPUInt32				ipAddress;	/* source or destination */
	PGPUInt16				port;		/* usually UDP 500, but might not be */
	PGPSize					packetSize;
	PGPByte *				packet;		/* msg *sender* must free this */
} PGPikeMTPacket;

typedef struct PGPikeMTIdentity
{
	PGPBoolean				active;			/* TRUE = set it, FALSE= dead */
	PGPUInt32				ipAddress;		/* Gateway IP */
	PGPUInt32				assignedIP;
	PGPUInt32				assignedDNS;
	PGPUInt32				assignedWINS;
} PGPikeMTIdentity;

typedef struct PGPikeMTAlert
{
	PGPikeAlert				alert;
	PGPUInt32				ipAddress;
	PGPikeInternalAlert		value;	/* used if alert is kPGPike_AL_None */
	PGPBoolean				remoteGenerated;
} PGPikeMTAlert;

typedef PGPUInt32 PGPikeAESKeyLengthMask;

#define kPGPike_AESKeyLength128 1
#define kPGPike_AESKeyLength192 2
#define kPGPike_AESKeyLength256 4
#define kPGPike_AESKeyLengthAll	7

typedef struct PGPikeAllowedAlgorithms
{
	PGPBoolean				cast5;
	PGPBoolean				tripleDES;
	PGPBoolean				singleDES;
	PGPikeAESKeyLengthMask	aes;
	PGPBoolean				espNULL;
	
	PGPBoolean				sha1;
	PGPBoolean				md5;
	PGPBoolean				sha2_256;
	PGPBoolean				sha2_384;
	PGPBoolean				sha2_512;
	PGPBoolean				noAuth;
		
	PGPBoolean				lzs;
	PGPBoolean				deflate;
	
	PGPBoolean				modpOne768;
	PGPBoolean				modpTwo1024;
	PGPBoolean				modpFive1536;

	PGPBoolean				ec2n163;
	PGPBoolean				ec2n283;

	PGPBoolean				modp2048;
	PGPBoolean				modp3072;
	PGPBoolean				modp4096;
	PGPBoolean				modp6144;
	PGPBoolean				modp8192;

} PGPikeAllowedAlgorithms;

typedef struct PGPikeMTPref
{
	PGPikePref					pref;
	
	union
	{
		struct
		{
			PGPUInt32			kbLifeTimeIKE;
			PGPUInt32			secLifeTimeIKE;
			PGPUInt32			kbLifeTimeIPSEC;
			PGPUInt32			secLifeTimeIPSEC;
		} expiration;			/* kPGPike_PF_Expiration */
		
		struct
		{
			PGPUInt32			numTransforms;
			PGPikeTransform *	t;
		} ikeProposals;			/* kPGPike_PF_IKEProposals */

		
		struct
		{
			PGPUInt32			numTransforms;
			PGPipsecTransform *	t;
		} ipsecProposals;		/* kPGPike_PF_IPSECProposals */
		
		PGPikeAllowedAlgorithms	allowedAlgorithms;
			/*kPGPike_PF_AllowedAlgorithms*/
	} u;
} PGPikeMTPref;

/* This message will be sent to check extended authentication. The buffer
	will be freed after your callback is called, so if you need it,
	copy the data elsewhere. You must retrieve the information and then
	send an AuthCheck message back to IKE with the contents filled in,
	and all contents preserved other than what you filled in. The message
	you send back is your memory, IKE will not free it. */
typedef struct PGPikeMTAuthCheck
{
	PGPBoolean			success;		/* set to true unless user aborts */
	PGPUInt32			gatewayIP;
	PGPikeXAuthType		xauthType;
	PGPUInt16			transactionID;	/* private */
	PGPBoolean			includeType;	/* private */
	
	PGPBoolean			useUserName;
	PGPBoolean			usePassword;
	PGPBoolean			usePasscode;
	PGPBoolean			useMessage;
	PGPBoolean			useChallenge;
	PGPBoolean			useDomain;
	
	char				userName[kPGPike_XAuthStringLen];
	char				password[kPGPike_XAuthStringLen];
	char				passcode[kPGPike_XAuthStringLen];
	char				message[kPGPike_XAuthMessageLen];
	char				challenge[kPGPike_XAuthStringLen];
	char				domain[kPGPike_XAuthStringLen];
	PGPSize				challengeSize;
} PGPikeMTAuthCheck;

enum PGPikeMessageType_
{
	/*
		Message types followed by ">" may be sent to PGPike
		Message typed followed by "<" may be sent by PGPike
	*/
	kPGPike_MT_Idle			= 0,	/* >  call this often		*/
	kPGPike_MT_SARequest,			/* >  PGPikeMTSASetup		*/
	kPGPike_MT_SARequestFailed,		/*  < PGPikeMTSAFailed		*/
	kPGPike_MT_SAEstablished,		/*  < PGPikeMTSAEstablished	*/
	kPGPike_MT_SARekey,				/* >  PGPipsecSA			*/
	kPGPike_MT_SADied,				/* >< PGPipsecSA			*/
	kPGPike_MT_SAUpdate,			/*  < PGPipsecSA			*/
	kPGPike_MT_SAKillAll,			/* >  none					*/
	
	kPGPike_MT_PolicyCheck,			/*  < PGPikeMTSASetup		*/
	kPGPike_MT_ClientIDCheck,		/*  < PGPikeMTClientIDCheck	*/
	kPGPike_MT_AuthCheck,			/* >< PGPikeMTAuthCheck		*/	
	kPGPike_MT_LocalPGPCert,		/*  < PGPikeMTCert			*/
	kPGPike_MT_LocalX509Cert,		/*  < PGPikeMTCert			*/
	kPGPike_MT_RemoteCert,			/*  < PGPikeMTRemoteCert	*/
	kPGPike_MT_Identity,			/*  < PGPikeMTIdentity		*/
	
	kPGPike_MT_Packet,				/* >< PGPikeMTPacket		*/
	kPGPike_MT_Alert,				/*  < PGPikeMTAlert			*/
	
	kPGPike_MT_Pref,				/* >  PGPikeMTPref			*/
	
	kPGPike_MT_DebugLog,			/*  < char *				*/

	PGP_ENUM_FORCE( PGPikeMessageType_ )
};
PGPENUM_TYPEDEF( PGPikeMessageType_, PGPikeMessageType );

typedef PGPError (* PGPikeMessageProcPtr)(
					PGPikeContextRef		ike,
					void *					inUserData,
					PGPikeMessageType		msg,
					void *					data );

PGPError 	PGPNewIKEContext(
					PGPContextRef			context,
					PGPikeMessageProcPtr	ikeMessageProc,
					void *					inUserData,
					PGPikeContextRef *		outRef );

PGPError 	PGPFreeIKEContext(
					PGPikeContextRef		ref );

/*	Any error from PGPikeProcessMessage is fatal.  Non-fatal
	errors are sent through the kPGPike_MT_Alert message.  */

PGPError	PGPikeProcessMessage(
					PGPikeContextRef		ref,
					PGPikeMessageType		msg,
					void *					data );


#if PGP_WIN32
# pragma pack(pop)
#endif

PGP_END_C_DECLARATIONS

#endif /* ] Included_PGPike_h */


/*__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 + -