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

📄 optestutils.c

📁 PGP.Corporation.PGP.SDK.v3.7.2.rar 此前从本站下载的那个缺少几个lib文件
💻 C
📖 第 1 页 / 共 4 页
字号:
						err = memBufPrintf(&outBuf, " %s",tempBuf );CKERR;
			 
						}
					else
					{
						err = memBufPrintf(&outBuf, "??????" );CKERR;
					}
				}
			
			}
			if(VALUE(kFlag_X_509))
			{
				void* certInfo = NULL;
				
				PGPGetKeyDBObjAllocatedDataProperty(sig, kPGPSigProperty_X509LongName, &certInfo, &length);
				if(length)
				{
					err = memBufPrintf(&outBuf, "\n%*s     Name:   %s",(int) strlen(header)," ", certInfo) ;
					PGPFreeData(certInfo);
					CKERR;
				}
				
				if(!selfCert)
				{
					PGPGetKeyDBObjAllocatedDataProperty(sig, kPGPSigProperty_X509IssuerLongName, &certInfo, &length);
					if(length)
					{
						err = memBufPrintf(&outBuf, "\n%*s     Issuer: %s",(int) strlen(header)," ", certInfo) ;
						PGPFreeData(certInfo);
						CKERR;
					}
				}

			}


			err = memBufPrintf(&outBuf, "\n");CKERR;

		}

 	}

 	/* get Key Fingerprint */
	err = PGPGetKeyDBObjDataProperty(theKey, kPGPKeyProperty_Fingerprint, propBuf, sizeof(propBuf), &length); CKERR;
	FormatFingerprintString(tempBuf, (PGPByte *) propBuf, length) ;
	err = memBufPrintf(&outBuf, "\n%*s --- Fingerprint ---\n", (int) strlen(header)," ");CKERR;
	err = memBufPrintf(&outBuf, "%*s%s\n", (int) strlen(header)," ",  tempBuf);CKERR;
	
	/* print out biometric hash word  */
	if(biometric)
	{
  		PGPSize		fingIndex = 0;
		PGPChar8	wordStr[12] = { '\0' };
  		err = memBufPrintf(&outBuf, "\n%*s", (int) strlen(header)," ");CKERR;
		for (fingIndex = 0; fingIndex < length; ++fingIndex)
		{
 				PGPGetHashWordString(propBuf[fingIndex], (fingIndex % 2), wordStr);
				err = memBufPrintf(&outBuf, "%-14s ", wordStr);CKERR;			
				if((fingIndex & 0x3) == 3)
							err = memBufPrintf(&outBuf, "\n%*s", (int) strlen(header)," ");CKERR;

		}
	}
	 

 	/* Enumerate Other Attributes   */
 	for( PGPKeyIterSeek( iter, theKey ), count = 0; 
		 IsntPGPError( PGPKeyIterNextKeyDBObj(iter, kPGPKeyDBObjType_UserID, &userID )); )
	{
		PGPBoolean	isAttributeID;

		err =  PGPGetKeyDBObjBooleanProperty( userID, kPGPUserIDProperty_IsAttribute, &isAttributeID ); CKERR;
		
		if(isAttributeID)
		{
			PGPInt32	attributeType;
			void*		propData	= NULL;

			if(count++ == 0)
			{
				err = memBufPrintf(&outBuf, "\n%*s --- Attributes ---\n", (int) strlen(header)," ");CKERR;
			}

			err = PGPGetKeyDBObjNumericProperty( userID, kPGPUserIDProperty_AttributeType, &attributeType ); CKERR;
			err = PGPGetKeyDBObjAllocatedDataProperty(userID, kPGPUserIDProperty_AttributeData, &propData, &length); CKERR;

			err = memBufPrintf(&outBuf, "%*s", (int) strlen(header)," ");CKERR;
 			
			switch (attributeType)
			{
				case kPGPAttribute_Image:
						err = memBufPrintf(&outBuf, "Photo: %d bytes\n", (int) length);CKERR;
						break;
						
				default:
						err = memBufPrintf(&outBuf, "Other Attribute: %d bytes\n", (int) length);CKERR;
						break;

			} 
			
			if(propData) PGPFreeData(propData);  
  		}
 	}

 
	/* get any ADK */
	 err = PGPNewEmptyInclusiveKeySet (PGPPeekKeyDBObjKeyDB(theKey) , &adkset); CKERR;
	 
 	if( IsntPGPError(PGPGetAdditionalRecipientRequests(theKey, adkset))
		&& IsntPGPError(PGPCountKeys(adkset, &count))
		&& count > 0)
	{
		PGPKeyDBObjRef	adkKey = kInvalidPGPKeyDBObjRef;
		
		/* sanity check */
		err = PGPCountAdditionalRecipientRequests(theKey, &count); ;CKERR;
		if(!count) FAIL("PGPCountAdditionalRecipientRequests Failed");
		
		err = PGPNewKeyIterFromKeySet( adkset ,&adkIter); CKERR
 		err = memBufPrintf(&outBuf, "\n%*s ---- Additional Decryption Keys ----\n", (int) strlen(header)," ");CKERR;
	
		while(IsntPGPError( PGPKeyIterNextKeyDBObj( adkIter, kPGPKeyDBObjType_Key, &adkKey) ))
		{
			PGPKeyID adkKeyID;
			
 		  	PGPGetKeyID(adkKey, &adkKeyID);
 			PGPGetKeyIDString( &adkKeyID, kPGPKeyIDString_Abbreviated, (void*)tempBuf);
			err = memBufPrintf(&outBuf, "%*s%s", (int) strlen(header)," ", tempBuf);CKERR;
 			err = PGPGetPrimaryUserIDName(adkKey, tempBuf, sizeof(tempBuf), &length); CKERR;
			err = memBufPrintf(&outBuf, " %s\n",tempBuf );CKERR;
 	  	}
 	}
	
	
	/* get any Notations */
	if(IsntPGPError(PGPCountNotations(theKey, &count)) && count > 0)
	{
		int i;
		
		err = memBufPrintf(&outBuf, "\n%*s ---- Notations ----\n", (int) strlen(header)," ");CKERR;
		for(i = 0; i < (int)count; i++)
		{
			PGPNotationFlags  notation_flags;
			PGPUInt32 nameLength, valueLength;
			PGPByte *name = NULL;
			PGPByte *value = NULL;
	 			
			err = PGPGetIndexedAllocatedNotation( theKey, i, &notation_flags, &name, &nameLength, &value,&valueLength); CKERR;  
			err = memBufPrintf(&outBuf, "%*s\"%s\" => \"%s\"\n", (int) strlen(header)," ", name, value);
			if(name) PGPFreeData(name);
			if(value) PGPFreeData(value);
			CKERR;
		}
		

	}
	
 
	/* get Key Server */
	if(IsntPGPError( PGPGetKeyDBObjDataProperty(theKey, kPGPKeyProperty_PreferredKeyServer, tempBuf, sizeof(tempBuf), &length)))
	{
		err = memBufPrintf(&outBuf, "\n%*s --- Keyserver ---\n", (int) strlen(header)," ");CKERR;
		err = memBufPrintf(&outBuf, "%*s%s\n", (int) strlen(header)," ",  tempBuf);CKERR;
 	}
	
	
	/* Get CRL Distribution Points  */
	{
		PGPByte* crlpoints = NULL;
		PGPUInt32 i;
		
		if(IsntPGPError( PGPGetCRLDistributionPointsPrintable(theKey, &count, &crlpoints ))  && count  )
		{
			char* p = (char*)crlpoints;
			err = memBufPrintf(&outBuf, "\n%*s ---- CRL Distribution Points ----\n", (int) strlen(header)," ");CKERR;
 		
			for(i = 0; i < count; i++) 
 			{
				err = memBufPrintf(&outBuf, "%*s<%s>\n", (int) strlen(header)," ", p);
				p+= strlen(p) + 1;
 			}
 		}
		
		if(crlpoints) PGPFreeData(crlpoints);
	}
	
	/* key features */
	{
		PGPKeyFeaturesFlags	features	= 0;

		if(IsntPGPError( PGPGetKeyDBObjNumericProperty( theKey, kPGPKeyProperty_Features, (PGPInt32*)&features )) && features != 0)
		{
			err = memBufPrintf(&outBuf, "\n%*s --- Key Features ---\n%*s", (int) strlen(header)," ",strlen(header)," ");CKERR;
			
			if(features & kPGPKeyFeatures_ModificationDetection) 		
					err = memBufPrintf(&outBuf, "Mod-Detect"  );

			if( features & ~kPGPKeyFeatures_ModificationDetection ) 		
				err = memBufPrintf(&outBuf, " %08X", features );
			
			err = memBufPrintf(&outBuf, "\n");
				
 		}
		
	}
	
	/* get ciphers */
 	{
		PGPCipherAlgorithm	*algor	= (PGPCipherAlgorithm*)tempBuf;
		PGPUInt32			algCount = 0;
 		PGPUInt32			algIndex = 0;
 		length = 0;
		

		PGPGetKeyDBObjDataProperty(theKey, kPGPKeyProperty_PreferredAlgorithms, tempBuf, sizeof(tempBuf), &length);
 
		algCount = (PGPUInt32) length / sizeof(PGPCipherAlgorithm);
		if (algCount)
		{
 			err = memBufPrintf(&outBuf, "\n%*s --- Prefered Ciphers ---\n%*s", (int) strlen(header)," ",strlen(header)," ");CKERR;
			
			for (algIndex = 0; algIndex < algCount; ++algIndex)
				{
					err = memBufPrintf(&outBuf,"%s%s", cipher_algor_table(algor[algIndex]), algIndex < algCount -1?", ":"\n"); CKERR;
				}
 		}
 		
   	}

	/* get hashes */
 	{
		PGPHashAlgorithm	*algor	= (PGPHashAlgorithm*)tempBuf;
		PGPUInt32			algCount = 0;
 		PGPUInt32			algIndex = 0;
 	
		length = 0;
		

		PGPGetKeyDBObjDataProperty(theKey, kPGPKeyProperty_PreferredHashAlgorithms, tempBuf, sizeof(tempBuf), &length);
	 
		algCount = (PGPUInt32) length / sizeof(PGPHashAlgorithm);
		if (algCount)
		{
			err = memBufPrintf(&outBuf, "\n%*s --- Prefered Hashes ---\n%*s", (int) strlen(header)," ",strlen(header)," ");CKERR;
			
			for (algIndex = 0; algIndex < algCount; ++algIndex)
			{
				err = memBufPrintf(&outBuf,"%s%s", hash_algor_table(algor[algIndex]), algIndex < algCount -1?", ":"\n"); CKERR;
			}
 		}
 		
   	}

	/* get compression */
 	{
		PGPUInt32			*algor	= (PGPUInt32*)tempBuf;
		PGPUInt32			algCount = 0;
 		PGPUInt32			algIndex = 0;
 		length = 0;
		

		PGPGetKeyDBObjDataProperty(theKey, kPGPKeyProperty_PreferredCompressionAlgorithms, tempBuf, sizeof(tempBuf), &length);
 		
		algCount = (PGPUInt32) length / sizeof(PGPUInt32);
		if (algCount)
		{
			err = memBufPrintf(&outBuf, "\n%*s --- Prefered Compression Algorithms ---\n%*s", (int) strlen(header)," ",strlen(header)," ");CKERR;
 
			for (algIndex = 0; algIndex < algCount; ++algIndex)
			{
				err = memBufPrintf(&outBuf,"%s%s", compression_algor_table(algor[algIndex]), algIndex < algCount -1?", ":"\n"); CKERR;
			}
 		}
 		
   	}

	/* get email modes */
 	{
		PGPPreferredEmailEncoding			*algor	= (PGPPreferredEmailEncoding*)tempBuf;
		PGPUInt32			algCount = 0;
 		PGPUInt32			algIndex = 0;
 		length = 0;
	
		PGPGetKeyDBObjDataProperty(theKey, kPGPKeyProperty_PreferredEmailEncodings, tempBuf, sizeof(tempBuf), &length);
 		
		algCount = (PGPUInt32) length / sizeof(PGPPreferredEmailEncoding);
		if (algCount)
		{
			err = memBufPrintf(&outBuf, "\n%*s --- Prefered Email Modes ---\n%*s", (int) strlen(header)," ",strlen(header)," ");CKERR;
 
			for (algIndex = 0; algIndex < algCount; ++algIndex)
			{
				err = memBufPrintf(&outBuf,"%s%s", email_encoding_table(algor[algIndex]), algIndex < algCount -1?", ":"\n"); CKERR;
			}
 		}
 		
   	}


  	if(dataSize) *dataSize = outBuf.alloc;
 	if(IsNull(buffer))
	{
		FREE(outBuf.data);
		outBuf.data = NULL;
	}
	else
	{
		*buffer = outBuf.data;
	}
  
done:
 	 
	if( PGPKeySetRefIsValid (adkset) )
		PGPFreeKeySet(adkset);
 		
	if( PGPKeySetRefIsValid (revokerset) )
		PGPFreeKeySet(revokerset);
	
	if( PGPKeyIterRefIsValid( revokeIter ) )
		PGPFreeKeyIter( revokeIter );
		
	if( PGPKeyIterRefIsValid(adkIter ) )
		PGPFreeKeyIter( adkIter );
  
	if( PGPKeyIterRefIsValid( iter ) )
		PGPFreeKeyIter( iter );

	if(IsPGPError(err) && IsntNull(outBuf.data))
		FREE(outBuf.data);

	return err;
}

 
/* Header block on tape.

We use traditional DP naming conventions here.  A "block" is a big chunk
of stuff that we do I/O on.  A "record" is a piece of info that we care
about.  Typically many "record"s fit into a "block".  */

#define RECORDSIZE      512
#define NAMSIZ          100
#define TUNMLEN         32
#define TGNMLEN         32
#define SPARSE_EXT_HDR  21
#define SPARSE_IN_HDR   4

struct sparse
{
    char offset[12];
    char numbytes[12];
};

union TARrecord
{
    char charptr[RECORDSIZE];
	
    struct header
	{
        char arch_name[NAMSIZ];
        char mode[8];
        char uid[8];
        char gid[8];
        char size[12];
        char mtime[12];
        char chksum[8];
        char linkflag;
        char arch_linkname[NAMSIZ];
        char magic[8];
        char uname[TUNMLEN];
        char gname[TGNMLEN];
        char devmajor[8];
        char devminor[8];
		
        /* The following fields were added for GNU and are not standard.  */
		
        char atime[12];
        char ctime[12];
        char offset[12];
        char longnames[4];
        /* Some compilers would insert the pad themselves, so pad was
			once autoconfigured.  It is simpler to always insert it!  */
        char pad;
        struct sparse sp[SPARSE_IN_HDR];
        char isextended;
        char realsize[12];      /* true size of the sparse file */
#if 0
        char ending_blanks[12]; /* number of nulls at the end of the file,
			if any */
#endif
	}
    header;
	
    struct extended_header
	{
        struct sparse sp[21];
        char isextended;
	}
    ext_hdr;
};
typedef union TARrecord TARrecord;

/* The checksum field is filled with this while the checksum is computed.  */
#define CHKBLANKS       "        "      /* 8 blanks, no null */

/* The magic field is filled with this value if uname and gname are valid,
marking the archive as being in standard POSIX format (though GNU tar
													   itself is not POSIX conforming).  */
#define TMAGIC "ustar  "        /* 7 chars and a null */

/* The magic field is filled with this if this is a GNU format dump entry.
But I suspect this is not true anymore.  */
#define GNUMAGIC "GNUtar "      /* 7 chars and a null */

/* The linkflag defines the type of file.  */
#define LF_OLDNORMAL    '\0'    /* normal disk file, Unix compat */
#define LF_NORMAL       '0'     /* normal disk file */
#define LF_LINK         '1'     /* link to previously dumped file */
#define LF_SYMLINK      '2'     /* symbolic link */
#define LF_CHR          '3'     /* character special file */
#define LF_BLK          '4'     /* block special file */
#define LF_DIR          '5'     /* directory */
#define LF_FIFO         '6'     /* FIFO special file */
#define LF_CONTIG       '7'     /* contiguous file */
/* Further link types may be defined later.  */

/* Note that the standards committee allows only capital A through
capital Z for user-defined expansion.  This means that defining
something as, say '8' is a *bad* idea.  */

/* This is a dir entry that contains the names of files that were in the
dir at the time the dump was made.  */
#define LF_DUMPDIR      'D'

/* Identifies the NEXT file on the tape as having a long linkname.  */
#define LF_LONGLINK     'K'

/* Identifies the NEXT file on the tape as having a long name.  */
#define LF_LONGNAME     'L'

/* This is the continuation of a file that began on another volume.  */
#define LF_MULTIVOL     'M'

/* For storing filenames that didn't fit in 100 characters.  */
#define LF_NAMES        'N'

/* This is for sparse files.  */
#define LF_SPARSE       'S'

/* This file is a tape/volume header.  Ignore it on extraction.  */
#define LF_VOLHDR       'V'

 
/* The following two blocks of #define's are unused in GNU tar.  */

/* Bits used in the mode field - values in octal */
#define  TSUID    04000         /* set UID on execution */
#define  TSGID    02000         /* set GID on execution */
#define  TSVTX    01000         /* save text (sticky bit) */

/* File permissions */
#define  TUREAD   00400         /* read by owner */
#define  TUWRITE  00200         /* write by owner */
#define  TUEXEC   00100         /* execute/search by owner */
#define  TGREAD   00040         /* read by group */
#define  TGWRITE  00020         /* write by group */
#define  TGEXEC   00010         /* execute/search by group */
#define  TOREAD   00004         /* read by other */
#define  TOWRITE  00002         /* write by other */
#define  TOEXEC   00001         /* execute/search by other */

 

/* End of Standard Archive Format description.  */

static  void strcatchar(char *s1, char c)
{
	int i = (int)strlen(s1);
	
	s1[i++] = c;
	s1[i] = 0;
}
 

⌨️ 快捷键说明

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