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

📄 test.h

📁 老外写的加密库cryptlib(版本3.1)
💻 H
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************
*																			*
*						cryptlib Test Routines Header File					*
*						Copyright Peter Gutmann 1995-2003					*
*																			*
****************************************************************************/

/* Define the following to enable/disable various blocks of tests */

#if 1
#define TEST_SELFTEST		/* Perform internal self-test */
#define TEST_LOWLEVEL		/* Test low-level functions */
#define TEST_RANDOM			/* Test randomness functions */
#define TEST_CONFIG			/* Test configuration functions */
#define TEST_MIDLEVEL		/* Test high-level encr/sig.functions */
#endif /* 0 */
#if 1
#define TEST_CERT			/* Test certificate management functions */
#define TEST_KEYSET			/* Test keyset read functions */
#define TEST_CERTPROCESS	/* Test certificate handling/CA management */
#endif /* 0 */
#if 1
#define TEST_HIGHLEVEL		/* Test high-level encr/sig.functions */
#define TEST_ENVELOPE		/* Test enveloping functions */
#endif /* 0 */
#if 1
#define TEST_SESSION		/* Test session functions */
#define TEST_USER			/* Test user management functions */
#endif /* 0 */

/* The crypto device tests are disabled by default since relatively few users
   will have a crypto device set up so leaving them enabled by default would
   just produce a cascade of device-not-present warnings */

/* #define TEST_DEVICE */

/* Some of the device tests can be rather slow, the following defines disable
   these tests for speed reasons.  Note that the Fortezza test can be further
   cut down by not performing the CAW test (which erases any existing data on
   the card), this is turned off by default in testdev.c */

/* #define TEST_DEVICE_FORTEZZA */

/* When commenting out code for testing, the following macro displays a
   warning that the behaviour has been changed as well as the location of
   the change */

#if defined( __MVS__ ) || defined( __VMCMS__ )
  #define KLUDGE_WARN( str )	\
			{ \
			char fileName[ 1000 ]; \
			strncpy( fileName, __FILE__, 1000 ); \
			fileName[ 999 ] = '\0'; \
			__atoe( fileName ); \
			printf( "Kludging " str ", file %s, line %d.\n", fileName, __LINE__ ); \
			}
#else
  #define KLUDGE_WARN( str )	\
			printf( "Kludging " str ", file " __FILE__ ", line %d.\n", __LINE__ );
#endif /* ASCII vs.EBCDIC strings */

/* Include univerally-needed headers */

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/* Various useful types */

#define BOOLEAN	int
#define BYTE	unsigned char
#ifndef TRUE
  #define FALSE	0
  #define TRUE	!FALSE
#endif /* TRUE */

/* Sentinel value used to denote non-data/non-values */

#define SENTINEL		-1000

/* There are a few OSes broken enough not to define the standard exit codes
   (SunOS springs to mind) so we define some sort of equivalent here just
   in case */

#ifndef EXIT_SUCCESS
  #define EXIT_SUCCESS	0
  #define EXIT_FAILURE	!EXIT_SUCCESS
#endif /* EXIT_SUCCESS */

/* If we're using a DOS compiler but not a 32-bit one, record this */

#if defined( __MSDOS__ ) && !defined( __MSDOS32__ )
  #define __MSDOS16__
#endif /* __MSDOS__ && !__MSDOS32__ */

/* It's useful to know if we're running under Windows to enable Windows-
   specific processing */

#if defined( _WINDOWS ) || defined( WIN32 ) || defined( _WIN32 )
  #define __WINDOWS__
#endif /* _WINDOWS || WIN32 || _WIN32 */

/* In certain memory-starved environments we have to kludge things to help
   the compiler along.  The following define tells the compiler to move BSS
   data outside the default data segment */

#if defined( _MSC_VER ) && ( _MSC_VER <= 800 )
  #define FAR_BSS			far
#else
  #define FAR_BSS
#endif /* Win16 */

/* Generic buffer size and dynamically-allocated file I/O buffer size.  The
   generic buffer has to be of a reasonable size so we can handle S/MIME
   signature chains, the file buffer should be less than the 16-bit INT_MAX
   for testing on 16-bit machines */

#if defined( __MSDOS__ ) && defined( __TURBOC__ )
  #define BUFFER_SIZE		4096
  #define FILEBUFFER_SIZE	20000
#else
  #define BUFFER_SIZE		8192
  #define FILEBUFFER_SIZE	40960
#endif /* __MSDOS__ && __TURBOC__ */

/* Try and detect OSes that have threading support, this is needed for some
   operations like async keygen and sleep calls.  Under OSF/1 pthread.h
   includes c_asm.h which contains a declaration

	long asm( const char *,...);

   that conflicts with the gcc asm keyword.  This asm stuff is only used
   when inline asm alternatives to the Posix threading functions are enabled,
   which isn't done by default so in theory we could also fix this by
   defining asm to something else before including pthread.h, but it's safer
   to just disable inclusion of c_asm.h by pre-defining the guard define,
   which should result in a more useful warning if for some reason inline
   threading functions with asm are enabled */

#if( ( defined( sun ) && ( OSVERSION > 4 ) ) || defined( __osf__ ) || \
	 defined( __alpha__ ) || defined( __Mach__ ) || defined( _AIX ) || \
	 defined( __linux__ ) )
  #define UNIX_THREADS

  /* We need to include pthread.h at this point because any number of other
     include files perform all sorts of peculiar and unnatural acts in order
     to make their functions (transparently) thread-safe, triggered by the
     detection of values defined in pthread.h.  Because of this we need to
     include it here as a rubber chicken before other files are pulled in
     even though it's not explicitly needed */
  #if defined( __osf__ ) || defined( __alpha__ )
	#define __C_ASM_H		/* See comment in cryptos.h */
  #endif /* Alpha */
  #include <pthread.h>
#endif /* Slowaris || OSF1/DEC Unix || Mach || AIX || Linux */
#if defined( WIN32 ) || defined( _WIN32 )
  #define WINDOWS_THREADS
  #include <process.h>
#endif /* Win32 */
#if defined( __IBMC__ ) && defined( __OS2__ )
  #define OS2_THREADS
#endif /* OS/2 */

/* Try and detect OSes that have widechar support */

#if defined( __WINDOWS__ ) || defined( __linux__ ) || \
	( defined( sun ) && ( OSVERSION > 4 ) ) || defined( __osf__ )
  #define HAS_WIDECHAR
#endif /* OSes with widechar support */

/* If we're running on an EBCDIC system, ensure we're compiled in EBCDIC mode
   to test the conversion of character strings */

#if defined( __MVS__ ) || defined( __VMCMS__ )
  #pragma convlit( suspend )
#endif /* IBM big iron */

/* The key size to use for the PKC routines.  This is the minimum allowed by
   cryptlib, it speeds up the various tests but shouldn't be used in
   practice */

#define PKC_KEYSIZE			512

/* The names of the test key and certificate files.  For flat filesystems we
   give the test files names starting with 'z' so they're easier to find */

#if defined( __VMCMS__ )
  #define TEST_PRIVKEY_FILE			"zkeytest.p15"
  #define TEST_PRIVKEY_ALT_FILE		"zkeytest.p12"
  #define CA_PRIVKEY_FILE			"zkeyca.p15"
  #define ICA_PRIVKEY_FILE			"zkeyica.p15"
  #define SCEPCA_PRIVKEY_FILE		"zkeysca.p15"
  #define USER_PRIVKEY_FILE			"zkeyuser.p15"
  #define DUAL_PRIVKEY_FILE			"zkeydual.p15"
  #define RENEW_PRIVKEY_FILE		"zkeyren.p15"
  #define BIG_PRIVKEY_FILE			"zkeybig.p15"
  #define CMP_PRIVKEY_FILE_TEMPLATE	"zkeycmp.p15"
  #define PNP_PRIVKEY_FILE			"zkeypnp.p15"
  #define SERVER_PRIVKEY_FILE		"zkeysrv.p15"
  #define SSH_PRIVKEY_FILE			"zkeyssh.p15"
  #define TSA_PRIVKEY_FILE			"zkeytsa.p15"

  #define PGP_PUBKEY_FILE			"zpubring.pgp"
  #define PGP_PRIVKEY_FILE			"zsecring.pgp"
  #define OPENPGP_PUBKEY_FILE		"zpubring.gpg"
  #define OPENPGP_PRIVKEY_FILE		"zsecring.gpg"
  #define OPENPGP_PUBKEY_HASH_FILE	"zpubrinh.gpg"
  #define OPENPGP_PRIVKEY_HASH_FILE	"zsecrinh.gpg"
  #define NAIPGP_PUBKEY_FILE		"zpubring.pkr"
  #define NAIPGP_PRIVKEY_FILE		"zsecring.skr"
  #define PKCS12_FILE				"zkey.p12"

  #define CERT_FILE_TEMPLATE		"zcert%d.der"
  #define BASE64CERT_FILE_TEMPLATE	"zcert%d.asc"
  #define BROKEN_CERT_FILE			"zcertb.der"
  #define BROKEN_USER_CERT_FILE		"zcertbus.der"
  #define BROKEN_CA_CERT_FILE		"zcertbca.der"
  #define CERTREQ_FILE_TEMPLATE		"zcertreq%d.der"
  #define CRL_FILE_TEMPLATE			"zcrl%d.der"
  #define CERTCHAIN_FILE_TEMPLATE	"zcertchn%d.der"
  #define RTCS_OK_FILE				"zrtcsrok.der"
  #define OCSP_OK_FILE				"zocsprok.der"
  #define OCSP_REV_FILE				"zocsprrev.der"
  #define OCSP_CA_FILE				"zocspca.der"
  #define CRLCERT_FILE_TEMPLATE		"zcrlcrt%d.der"
  #define CHAINCERT_FILE_TEMPLATE	"zchncrt%d.der"
  #define RTCS_FILE_TEMPLATE		"zrtcsee%do.der"
  #define OCSP_CA_FILE_TEMPLATE		"zocspca%d.der"
  #define OCSP_EEOK_FILE_TEMPLATE	"zocspee%do.der"
  #define OCSP_EEREV_FILE_TEMPLATE	"zocspee%dr.der"
  #define CMP_CA_FILE_TEMPLATE		"zcmpca%d.der"
  #define SCEP_CA_FILE_TEMPLATE		"zscepca%d.der"

  #define SMIME_SIG_FILE_TEMPLATE	"zsmime%d.p7s"
  #define SMIME_ENVELOPED_FILE		"zsmime.p7m"
  #define PGP_ENC_FILE_TEMPLATE		"zenc%d.pgp"
  #define PGP_PKE_FILE_TEMPLATE		"zenc_pk%d.pgp"
  #define OPENPGP_PKE_FILE_TEMPLATE	"zenc_pk%d.gpg"
  #define PGP_SIG_FILE_TEMPLATE		"zsig%d.pgp"
  #define PGP_COPR_FILE_TEMPLATE	"zcopr%d.pgp"

  #define COMPRESS_FILE				"test.h"
#elif defined( __OS400__ )
  #define TEST_PRIVKEY_FILE			"testlib/zkeytest"
  #define TEST_PRIVKEY_ALT_FILE		"testlib/zkeytsta"
  #define CA_PRIVKEY_FILE			"testlib/zkeyca"
  #define ICA_PRIVKEY_FILE			"testlib/zkeyica"
  #define SCEPCA_PRIVKEY_FILE		"testlib/zkeysca"
  #define USER_PRIVKEY_FILE			"testlib/zkeyuser"
  #define DUAL_PRIVKEY_FILE			"testlib/zkeydual"
  #define RENEW_PRIVKEY_FILE		"testlib/zkeyren"
  #define BIG_PRIVKEY_FILE			"testlib/zkeybig"
  #define CMP_PRIVKEY_FILE_TEMPLATE	"testlib/zkeycmp"
  #define PNP_PRIVKEY_FILE			"testlib/zkeypnp"
  #define SERVER_PRIVKEY_FILE		"testlib/zkeysrv"
  #define SSH_PRIVKEY_FILE			"testlib/zkeyssh"
  #define TSA_PRIVKEY_FILE			"testlib/zkeytsa"

  #define PGP_PUBKEY_FILE			"testlib/zpubring"
  #define PGP_PRIVKEY_FILE			"testlib/zsecring"
  #define OPENPGP_PUBKEY_FILE		"testlib/zpubringg"
  #define OPENPGP_PRIVKEY_FILE		"testlib/zsecringg"
  #define OPENPGP_PUBKEY_HASH_FILE	"testlib/zpubrinhg"
  #define OPENPGP_PRIVKEY_HASH_FILE	"testlib/zsecrinhg"
  #define NAIPGP_PUBKEY_FILE		"testlib/zpubringp"
  #define NAIPGP_PRIVKEY_FILE		"testlib/zsecrings"
  #define PKCS12_FILE				"testlib/zkey"

  #define CERT_FILE_TEMPLATE		"testlib/zcert%d"
  #define BASE64CERT_FILE_TEMPLATE	"testlib/zcerta%d"
  #define BROKEN_CERT_FILE			"testlib/zcertb"
  #define BROKEN_USER_CERT_FILE		"testlib/zcertbus"
  #define BROKEN_CA_CERT_FILE		"testlib/zcertbca"
  #define CERTREQ_FILE_TEMPLATE		"testlib/zcertreq%d"
  #define CRL_FILE_TEMPLATE			"testlib/zcrl%d"
  #define CERTCHAIN_FILE_TEMPLATE	"testlib/zcertchn%d"
  #define RTCS_OK_FILE				"testlib/zrtcsrok"
  #define OCSP_OK_FILE				"testlib/zocsprok"
  #define OCSP_REV_FILE				"testlib/zocsprrev"
  #define OCSP_CA_FILE				"testlib/zocspca"
  #define CRLCERT_FILE_TEMPLATE		"testlib/zcrlcrt%d"
  #define CHAINCERT_FILE_TEMPLATE	"testlib/zchncrt%d"
  #define RTCS_FILE_TEMPLATE		"testlib/zrtcsee%do"
  #define OCSP_CA_FILE_TEMPLATE		"testlib/zocspca%d"
  #define OCSP_EEOK_FILE_TEMPLATE	"testlib/zocspee%do"
  #define OCSP_EEREV_FILE_TEMPLATE	"testlib/zocspee%dr"
  #define CMP_CA_FILE_TEMPLATE		"testlib/zcmpca%d"
  #define SCEP_CA_FILE_TEMPLATE		"testlib/zscepca%d"

  #define SMIME_SIG_FILE_TEMPLATE	"testlib/zsmime%d"
  #define SMIME_ENVELOPED_FILE		"testlib/zsmimem"
  #define PGP_ENC_FILE_TEMPLATE		"testlib/zenc%d"
  #define PGP_PKE_FILE_TEMPLATE		"testlib/zenc_pkp%d"
  #define OPENPGP_PKE_FILE_TEMPLATE	"testlib/enc_pkg%d"

⌨️ 快捷键说明

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