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

📄 pgpkeypriv.h

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 H
📖 第 1 页 / 共 5 页
字号:
	PGPKeyDBObj *	up;						/* If not a key, parent obj */
											/* If a key, keydb */
	PGPUserValue	userVal;				/* User settable value */
	union {
		PGPUInt32				id;			/* ID to retrieve info */
		PGPKeyDBObjInfo *		info;		/* Cached info about obj */
	}				 idinfo;
	PGPUInt32		 objflags;
		/* flags includes:
		 *		type of object - key vs sig vs userid vs subkey etc
		 *		deleted flag
		 *		"info vs id present" flag for idinfo field
		 */

	DEBUG_STRUCT_CONSTRUCTOR( PGPKeyDBObj )
};
/* objflags for private use, in addition to object type flags */
#define kPGPKeyDBObjType_CRL			(1UL << 4)
#define kPGPKeyDBObjFlags_Deleted		0x80000000
#define kPGPKeyDBObjFlags_Dummy			0x40000000
/* X509 means a dummy key whose id is the hash of the X.509 subject name */
/* Such keys have their "data" pointer pointing at the cert sig */
#define kPGPKeyDBObjFlags_X509			0x20000000
/* ID present in idinfo field rather than info */
#define kPGPKeyDBObjFlags_ID			0x10000000


typedef struct ObjDataHeader {
	PGPByte const *	data;
	PGPSize			len;
	PGPUInt32		refcount;
} ObjDataHeader;


struct PGPKeyInfo {
	PGPUInt32			id;				/* ID to retrieve info */
	PGPByte				pkalg;			/* PK algorithm */
	PGPUInt16			keybits;		/* Key size in bits */
	PGPByte				keyID[8];		/* Key ID */
	PGPUInt32			creationtime;	/* Time key was created */
	PGPUInt16			validityperiod;/* creation to expiration */
	ObjDataHeader *		data;			/* Raw data of object */

	PGPUInt32		pos;				/* Backing store data */
	PGPUInt32		flags;				/* Extra info about the object */
	PGPByte			fp20n;				/* First byte from fp20n, for x509 */
	PGPKeyDBObj *	util;				/* Used during trust calcs */
	PGPKeyDBObj *	sigsby;				/* Chain of sigs by this key */
	PGPKeyDBObj *	left;				/* Keys with lesser keyids */
	PGPKeyDBObj *	right;				/* Keys with greater keyids */
	PGPByte			signedTrust;		/* Trust from sigs on key */
	PGPByte			trust;				/* User-specified trust on key */
	void *			regexp;				/* reg exp during trust calculation */

	PGPInt32		tokenNum1;			/* token number, starting from 1, if 
	                                       KEYISTOKEN */

	DEBUG_STRUCT_CONSTRUCTOR( PGPKeyInfo )
};
/* Access the key flags field */
#define KEYF_TRUSTTMP		0x80		/* Temporary used during trust calc */
#define KEYF_V3				0x40		/* V2 or V3 key (earlier than V4) */
#define KEYF_VBUG			0x20		/* Sec key V3 should be V2 */
#define KEYF_SEC			0x10		/* Key is a secret key */
#define KEYF_TOKEN			0x08		/* Secret part of key is on a token */
#define KEYF_VALIDATED		0x04		/* Secret part has been validated */

#define KEYISV3(k) (((k)->flags & KEYF_V3) != 0)
#define KEYSETV3(k) ((k)->flags |= KEYF_V3)
#define KEYCLEARV3(k) ((k)->flags &= ~KEYF_V3)
#define KEYHASVERSIONBUG(k) (((k)->flags & KEYF_VBUG) != 0)
#define KEYSETVERSIONBUG(k) ((k)->flags |= KEYF_VBUG)
#define KEYCLEARVERSIONBUG(k) ((k)->flags &= ~KEYF_VBUG)
#define KEYISSEC(k) (((k)->flags & KEYF_SEC) != 0)
#define KEYSETSEC(k) ((k)->flags |= KEYF_SEC)
#define KEYCLEARSEC(k) ((k)->flags &= ~KEYF_SEC)
#define KEYISTOKEN(k) (((k)->flags & KEYF_TOKEN) != 0)
#define KEYSETTOKEN(k) ((k)->flags |= KEYF_TOKEN)
#define KEYCLEARTOKEN(k) ((k)->flags &= ~KEYF_TOKEN)
#define KEYISVALIDATED(k) (((k)->flags & KEYF_VALIDATED) != 0)
#define KEYSETVALIDATED(k) ((k)->flags |= KEYF_VALIDATED)
#define KEYCLEARVALIDATED(k) ((k)->flags &= ~KEYF_VALIDATED)

struct PGPUserIDInfo
{
	PGPUInt32		 id;				/* ID to retrieve info */
	ObjDataHeader *	data;				/* Raw data of object */
	PGPByte			validity;			/* Stored validity */

	PGPUInt32		pos;				/* Backing store data */
	PGPUInt32		flags;				/* Extra info about the object */
	PGPByte			oldvalidity;		/* Old 4-level validity */
	PGPByte			confidence;			/* Stored confidence */
	PGPUInt16		valid;				/* Computed validity */

	DEBUG_STRUCT_CONSTRUCTOR( PGPUserIDInfo )
};

/* Access the name flags field */
#define NAMEF_ATTR			0x80		/* Attribute userid */

#define NAMEISATTR(n) (((n)->flags & NAMEF_ATTR) != 0)
#define NAMESETATTR(n) ((n)->flags |= NAMEF_ATTR)
#define NAMECLEARATTR(n) ((n)->flags &= ~NAMEF_ATTR)



struct PGPSigInfo
{
	PGPUInt32			id;				/* ID to retrieve info */
	ObjDataHeader *		data;			/* Raw data of object */
	PGPByte				type;			/* Sig type (regular, revoke...) */
	PGPByte				hashalg;		/* Hash alg used by sig */
	PGPByte				trustLevel;	/* 0: regular sig, 1: trust, 2: meta */
	PGPByte				trustValue;	/* Used if trustLevel>0 */
	PGPUInt32			tstamp;		/* Creation date */
	PGPUInt32			sigvalidity;	/* Time until expiration */

	PGPUInt32		pos;				/* Backing store data */
	PGPUInt32		flags;				/* Extra info about the object */
	PGPByte			trust;
	PGPByte			version;			/* V3 vs V4 signature */
	PGPKeyDBObj *	by;					/* Key which created sig */
	PGPKeyDBObj *	by2;				/* Alternate signer, for trust calc */
	PGPKeyDBObj *	nextby;				/* Next sig by same key */
	void *			regexp;				/* Reg exp for propagating trust */

	DEBUG_STRUCT_CONSTRUCTOR( PGPSigInfo )
};

/* Access the sig flags field */
#define SIGF_EXPORTABLE		0x80	/* Sig can be exported to others */
#define SIGF_USESREGEXP	 	0x40	/* (Trust) sig qualified with regexp */
#define SIGF_REVOCABLE		0x20	/* Sig can be revoked */
#define SIGF_X509			0x10	/* Sig is an imported X.509 cert */
#define SIGF_PRIMARYUID	 	0x08	/* Sig says it's on primary userid */
#define SIGF_DISTPOINT		0x04	/* Sig has a distribution point */
#define SIGF_NONFIVE		0x02	/* Extralen != 5 */

#define SIGSETEXPORTABLE(s)			(s)->flags |= SIGF_EXPORTABLE
#define SIGSETNONEXPORTABLE(s)		(s)->flags &= ~SIGF_EXPORTABLE
#define SIGISEXPORTABLE(s)			(((s)->flags & SIGF_EXPORTABLE)!=0)
#define SIGSETUSESREGEXP(s)			(s)->flags |= SIGF_USESREGEXP
#define SIGCLEARUSESREGEXP(s)		(s)->flags &= ~SIGF_USESREGEXP
#define SIGUSESREGEXP(s)			(((s)->flags & SIGF_USESREGEXP)!=0)
#define SIGSETREVOCABLE(s)			(s)->flags |= SIGF_REVOCABLE
#define SIGSETNONREVOCABLE(s)		(s)->flags &= ~SIGF_REVOCABLE
#define SIGISREVOCABLE(s)			(((s)->flags & SIGF_REVOCABLE)!=0)
#define SIGSETX509(s)				(s)->flags |= SIGF_X509
#define SIGCLEARX509(s)				(s)->flags &= ~SIGF_X509
#define SIGISX509(s)				(((s)->flags & SIGF_X509)!=0)
#define SIGSETPRIMARYUID(s)			(s)->flags |= SIGF_PRIMARYUID
#define SIGCLEARPRIMARYUID(s)		(s)->flags &= ~SIGF_PRIMARYUID
#define SIGISPRIMARYUID(s)			(((s)->flags & SIGF_PRIMARYUID)!=0)
#define SIGSETDISTPOINT(s)			(s)->flags |= SIGF_DISTPOINT
#define SIGCLEARDISTPOINT(s)		(s)->flags &= ~SIGF_DISTPOINT
#define SIGHASDISTPOINT(s)			(((s)->flags & SIGF_DISTPOINT)!=0)

typedef struct PGPCRLInfo
{
	PGPUInt32			id;				/* ID to retrieve info */
	ObjDataHeader *		data;			/* Raw data of object */
	PGPUInt32			flags;			/* Extra info about the object */
	PGPByte				version;		/* Version of subpacket */
	PGPByte				trust;			/* Trust info */
	PGPUInt32			tstamp;			/* Issuance date of CRL */
	PGPUInt32			tstampnext;		/* Next-issuance date of CRL */
} PGPCRLInfo;

#define CRLF_X509			 0x80	/* Crl is an X509 CRL */
#define CRLF_DPOINT			 0x40	/* Crl has a distribution point */

#define CRLSETX509(c)				(c)->flags |= CRLF_X509
#define CRLCLEARX509(c)				(c)->flags &= ~CRLF_X509
#define CRLISX509(c)				(((c)->flags & CRLF_X509)!=0)
#define CRLSETDPOINT(c)				(c)->flags |= CRLF_DPOINT
#define CRLCLEARDPOINT(c)			(c)->flags &= ~CRLF_DPOINT
#define CRLHASDPOINT(c)				(((c)->flags & CRLF_DPOINT)!=0)



typedef struct PGPUnkInfo
{
	PGPUInt32			id;				/* ID to retrieve info */
	ObjDataHeader *		data;			/* Raw data of object */
	PGPByte				trust;
} PGPUnkInfo;


union PGPKeyDBObjInfo {
	PGPKeyInfo			keyinfo;
	PGPUserIDInfo		useridinfo;
	PGPSigInfo			siginfo;
	PGPCRLInfo			crlinfo;
	PGPUnkInfo			unkinfo;

	DEBUG_STRUCT_CONSTRUCTOR( PGPKeyDBObjInfo )
};




#define CHECKREMOVED(x)		\
if (IsNull(x) || pgpKeyDBObjIsDeleted(x))	\
	return kPGPError_ItemWasDeleted



PGP_BEGIN_C_DECLARATIONS





/* pgpEnumeratedSet.c */
PGPError				pgpNewKeyListSet( PGPKeyDB *db,PGPKeyDBObjRef *keylist,
							PGPUInt32 nkeys, PGPKeySetRef *newSet );


/* pgpKeyBack.c */

PGPError				pgpFetchObjectData_back( PGPContextRef context,
							PGPUInt32 id, PGPByte **bufptr, PGPSize *buflen );
PGPError				pgpGetKeyByKeyID_back( PGPContextRef context,
							PGPUInt32 dbid, PGPKeyID const *keyIDIn,
							PGPBoolean dummyOK, PGPBoolean deletedOK,
							PGPUInt32 *outID );
PGPError				pgpKeyEncrypt_back( PGPContextRef context,
							PGPUInt32 id, PGPByte const *inbuf,
							PGPSize inbuflen, PGPPublicKeyMessageFormat format,
							PGPByte **outbuf, PGPSize *outbuflen );
PGPError				pgpKeyDecrypt_back( PGPContextRef context,
							PGPUInt32 id, PGPByte const *passphrase,
							PGPSize pplen, PGPBoolean hashedPhrase,
							PGPUInt32 cacheTimeOut, PGPBoolean cacheGlobal,
							PGPByte const *inbuf, PGPSize inbuflen,
							PGPPublicKeyMessageFormat format,
							PGPByte **outbuf, PGPSize *outbuflen );
PGPInt32				pgpKeyVerify_back( PGPContextRef context,
							PGPUInt32 id, PGPByte const *inbuf,
							PGPSize inbuflen, PGPHashAlgorithm hashalg,
							PGPByte const *hash, PGPSize hashlen,
							PGPPublicKeyMessageFormat format);
PGPError				pgpKeySign_back( PGPContextRef context, PGPUInt32 id,
							PGPByte const *passphrase, PGPSize pplen,
							PGPBoolean hashedPhrase, PGPUInt32 cacheTimeOut,
							PGPBoolean cacheGlobal, PGPHashAlgorithm hashalg,
							PGPByte const *hash, PGPSize hashlen,
							PGPPublicKeyMessageFormat format,
							PGPByte **outbuf, PGPSize *outbuflen );
PGPBoolean				pgpSecPassphraseOK_back( PGPContextRef context,
							PGPUInt32 id, PGPByte const *passphrase,
							PGPSize pplen, PGPBoolean hashedPhrase,
							PGPUInt32 cacheTimeOut, PGPBoolean cacheGlobal );
PGPError				pgpKeyMaxSizes_back( PGPContextRef context,
							PGPUInt32 id, PGPUInt32 *maxEncryption,
							PGPUInt32 *maxDecryption, PGPUInt32 *maxSignature,
							PGPPublicKeyMessageFormat format );
PGPError				pgpSecProperties_back( PGPContextRef context,
							PGPUInt32 id, PGPBoolean *needsPassphrase,
							PGPBoolean *isSecretShared,
							PGPCipherAlgorithm *lockAlg, PGPUInt32 *lockBits );
PGPError				pgpFetchKeyInfo_back( PGPContextRef context,
							PGPUInt32 id, PGPByte **bufptr, PGPSize *bufsize );
PGPError				pgpOpenKeyDBFile_back(PGPContextRef cdkContext,
							PGPOpenKeyDBFileOptions openFlags,
							PFLFileSpecRef pubFileRef,
							PFLFileSpecRef privFileRef, PGPUInt32 * kdbid,
							PGPUInt32 * numKeys, PGPUInt32 ** keyArray,
							PGPSize * keyArraySize );
PGPError				pgpNewKeyDB_back( PGPContextRef context,
							PGPUInt32 *keydbid );
PGPError				pgpKeyDBArray_back( PGPContextRef cdkContext,
							PGPUInt32 kdbid, PGPUInt32 * numKeys,
							PGPUInt32 ** keyArray, PGPSize * keyArraySize );
PGPError				pgpUpdateKeyDB_back(PGPContextRef context,
							PGPUInt32 kdbid, PGPUInt32 * numNewKeys,
							PGPUInt32 ** newKeyArray,
							PGPSize * newKeyArraySize,
							PGPUInt32 ** changedkeylist,
							PGPSize * changedkeylistsize );
PGPError				pgpKeyDBFlush_back( PGPContextRef context,
							PGPUInt32 id, PGPUInt32 **changedkeylist,
							PGPSize *changedkeylistsize );
void					pgpFreeKeyDB_back( PGPContextRef context,
							PGPUInt32 id );
PGPError				pgpSetKeyEnabled_back( PGPContextRef context,
							PGPUInt32 id, PGPBoolean enable );
PGPError				pgpSetKeyAxiomatic_back( PGPContextRef context,
							PGPUInt32 id, PGPBoolean setAxiomatic,
							PGPBoolean checkPassphrase,
							char const *passphrase, PGPSize passphraseLength,
							PGPBoolean hashedPhrase, PGPUInt32 cacheTimeOut,
							PGPBoolean cacheGlobal);
PGPError				pgpPropagateTrust_back( PGPContextRef context,
							PGPUInt32 setid, PGPUInt32 *keylist,
							PGPSize keylistsize, PGPUInt32 altid,
							PGPUInt32 const timenow,
							PGPUInt32 **changedkeylist,
							PGPSize *changedkeylistsize );
PGPError				pgpCheckKeyRingSigs_back( PGPContextRef context,
							PGPUInt32 setid, PGPUInt32 *keylist,

⌨️ 快捷键说明

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