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

📄 crypt.h

📁 提供了很多种加密算法和CA认证及相关服务如CMP、OCSP等的开发
💻 H
📖 第 1 页 / 共 4 页
字号:
/****************************************************************************
*																			*
*					  cryptlib Internal General Header File 				*
*						Copyright Peter Gutmann 1992-2002					*
*																			*
****************************************************************************/

#ifndef _CRYPT_DEFINED

#define _CRYPT_DEFINED

/* Various compilers handle includes in subdirectories differently.  Most
   will work with paths from a root directory.  Macintoshes don't recognise
   '/'s as path delimiters, but work around it by scanning all subdirectories
   and treating the files as if they were in the same directory (INC_ALL).
   Microsoft C, in a braindamaged exception to all other compilers, treats
   the subdirectory as the root (INC_CHILD).  The Tandem NSK doesn't have
   subdirectories, and the C compiler zaps '.'s, truncates filenames to 7
   characters, and appends a 'h' to the name (so that asn1misc.h becomes
   asn1mish).  This unfortunately requires a bit of renaming for header
   files.

   There are also a few systems which have somewhat special requirements,
   these get their own OS-specific include defines */

#if ( defined( SYMANTEC_C ) || defined( __BEOS__ ) ) && \
	!defined( INC_ALL )
  #error You need to predefine INC_ALL in your project file
#elif defined( _MSC_VER ) && !defined( INC_CHILD )
  #error You need to predefine INC_CHILD in your project/make file
#endif /* Checks for various compiler/OS-dependant include paths */

/* If we're on a new enough version of VC++ or Metrowerks, set a flag to
   only include header files once */

#if ( defined( _MSC_VER ) && ( _MSC_VER >= 1000 ) ) || defined ( __MWERKS__ )
  #pragma once
#endif /* VC++ 5.0 or higher, Metrowerks */

/* If we're building under Win32, don't haul in the huge amount of cruft 
   which windows.h brings with it.  We need to define these values before
   we include cryptlib.h since this is where windows.h is included */

#if ( defined( _WINDOWS ) || defined( WIN32 ) || defined( _WIN32 ) || \
	  defined( __WIN32__ ) ) && !defined( _SCCTK )
  #define NOATOM				/* Atom Manager routines */
  #define NOMCX				/* Modem Configuration Extensions */
  #define NOCOLOR				/* Screen colors */
  #define NOCTLMGR			/* Control and Dialog routines */
  #define NODEFERWINDOWPOS	/* DeferWindowPos routines */
  #define NODRAWTEXT			/* DrawText() and DT_* */
  #define NOGDI				/* All GDI defines and routines */
  #define NOGDICAPMASKS		/* CC_*, LC_*, PC_*, CP_*, TC_*, RC_ */
  #define NOHELP				/* Help engine interface */
  #define NOICONS				/* IDI_* */
  #define NOKANJI				/* Kanji support stuff */
  #define NOKEYSTATES			/* MK_* */
  #define NOMB				/* MB_* and MessageBox() */
  #define NOMEMMGR			/* GMEM_*, LMEM_*, GHND, LHND, etc */
  #define NOMENUS				/* MF_* */
  #define NOMETAFILE			/* typedef METAFILEPICT */
  #define NOMSG				/* typedef MSG and associated routines */
  #define NOPROFILER			/* Profiler interface */
  #define NORASTEROPS			/* Binary and Tertiary raster ops */
  #define NOSCROLL			/* SB_* and scrolling routines */
  #define NOSERVICE			/* All Service Controller routines, SERVICE_* */
  #define NOSHOWWINDOW		/* SW_* */
  #define NOSOUND				/* Sound driver routines */
  #define NOSYSCOMMANDS		/* SC_* */
  #define NOSYSMETRICS		/* SM_* */
  #define NOTEXTMETRIC		/* typedef TEXTMETRIC and associated routines */
  #define NOVIRTUALKEYCODES	/* VK_* */
  #define NOWH				/* SetWindowsHook and WH_* */
  #define NOWINMESSAGES		/* WM_*, EM_*, LB_*, CB_* */
  #define NOWINOFFSETS		/* GWL_*, GCL_*, associated routines */
  #define NOWINSTYLES			/* WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_* */
  #define OEMRESOURCE			/* OEM Resource values */
#endif /* Win32 */

/* If the global cryptlib header hasn't been included yet, include it now */

#ifndef _CRYPTLIB_DEFINED
  #include "cryptlib.h"
#endif /* _CRYPTLIB_DEFINED */

/****************************************************************************
*																			*
*								OS-Specific Defines							*
*																			*
****************************************************************************/

/* To build the static .LIB under Win32, uncomment the following define (this
   it not recommended since the init/shutdown is no longer thread-safe).  In
   theory it should be possible to detect the build of a DLL vs a LIB with
   the _DLL define which is set when the /MD (multithreaded DLL) option is
   used, however fscking VC++ only defines _DLL when /MD is used *and* it's
   linked with the MT DLL runtime.  If it's linked with the statically
   linked runtime, _DLL isn't defined, which would result in the unsafe
   LIB version being built as a DLL */

/* #define STATIC_LIB */

/* Try and figure out if we're running under Windows and/or Win32.  We have
   to jump through all sorts of hoops later on, not helped by the fact that
   the method of detecting Windows at compile time changes with different
   versions of Visual C (it's different for each of VC 2.0, 2.1, 4.0, and
   4.1.  It actually remains the same after 4.1) */

#if !defined( __WINDOWS__ ) && ( defined( _Windows ) || defined( _WINDOWS ) )
  #define __WINDOWS__
#endif /* !__WINDOWS__ && ( _Windows || _WINDOWS ) */
#if !defined( __WIN32__ ) && ( defined( WIN32 ) || defined( _WIN32 ) )
  #ifndef __WINDOWS__
	#define __WINDOWS__
  #endif /* __WINDOWS__ */
  #define __WIN32__
#endif /* !__WIN32__ && ( WIN32 || _WIN32 ) */
#if defined( __WINDOWS__ ) && !defined( __WIN32__ )
  #define __WIN16__
#endif /* __WINDOWS__ && !__WIN32__ */

/* In some cases we're using a DOS or Windows system as a cross-development
   platform, if we are we add extra defines to turn off some Windows-
   specific features */

#ifdef _SCCTK
  #define __IBM4758__
#endif /* IBM 4758 cross-compiled under Windows */

/* Fix up a type clash with a Windows predefined type - for some reason BYTE
   and WORD are unsigned, but LONG is signed (actually DWORD is the Windows
   unsigned type, the counterpoint CHAR, SHORT and LONG types are all signed,
   but DWORD is a Windows-ism which all the Unix types will LART me for if I
   start using it).  Some OS/2 compilers can do this as well */

#if defined( __WINDOWS__ ) || defined( __OS2__ )
  #undef LONG
#endif /* Windows || OS/2 */

/* If we're compiling under VC++ with the maximum level of warning, turn off
   some of the more irritating warnings */

#if defined( _MSC_VER )
  #pragma warning( disable: 4018 )	/* Comparing signed <-> unsigned value */
  #pragma warning( disable: 4127 )	/* Conditional is constant: while( TRUE ) */
#endif /* Visual C++ */

/* If we're using a DOS compiler and it's not a 32-bit one, record this.
   __MSDOS__ is predefined by a number of compilers, so we use __MSDOS16__
   for stuff which is 16-bit DOS specific, and __MSDOS32__ for stuff which
   is 32-bit DOS specific */

#if defined( __MSDOS__ ) && !defined( __MSDOS32__ )
  #define __MSDOS16__
#endif /* 16-bit DOS */

/* Make the Tandem NSK and Macintosh defines look a bit more like the usual
   ANSI defines used to identify the other OS types */

#ifdef __TANDEM
  #define __TANDEM__
#endif /* Tandem */

#if defined( __MWERKS__ ) || defined( SYMANTEC_C ) || defined( __MRC__ )
  #define __MAC__
#endif /* Macintosh */

/* If we're compiling on the AS/400, make enums a fixed size rather than
   using the variable-length values which IBM compilers default to, and force
   strings into a readonly segment (by default they're writeable) */

#if defined( __OS400__ ) || defined( __ILEC400__ )
  #define __AS400__
  #pragma enumsize( 4 )
  #pragma strings( readonly )
#endif /* AS/400 */

/* Some encryption algorithms which rely on longints having 32 bits won't
   work on 64- or 128-bit machines due to problems with sign extension and
   whatnot.  The following define can be used to enable special handling for
   processors with a > 32 bit word size */

#include <limits.h>
#if ULONG_MAX > 0xFFFFFFFFUL
  #define _BIG_WORDS
#endif /* 64-bit system */

/* Some useful types.  We have to jump through all sorts of hoops for
   Windoze */

#ifdef __WIN32__
  #define BOOLEAN			int
#else
  typedef int				BOOLEAN;
#endif /* __WIN32__ */
typedef unsigned char		BYTE;
#if !defined( __WINDOWS__ ) || defined( __WIN32__ )
  typedef unsigned short	WORD;
#endif /* !__WINDOWS__ || __WIN32__ */
#ifdef __WIN32__
  #define LONG				unsigned long
#else
  typedef unsigned long		LONG;
#endif  /* __WIN32__ */

/* If we're using DOS or Windows as a cross-development platform, we need
   the OS-specific value defined initially to get the types right but don't
   want it defined later on since the target platform won't really be
   running DOS or Windows, so we undefine it after the types have been sorted
   out */

#ifdef __IBM4758__
  #undef __MSDOS__
  #undef __WINDOWS__
  #undef __WIN32__
#endif /* IBM 4758 */

/* If we're building the Win32 kernel driver version, include the DDK
   headers */

#if defined( __WIN32__ ) && defined( NT_DRIVER )
  #include <ntddk.h>
#endif /* NT kernel driver */

/* In 16-bit environments the BSS data is large enough that it overflows the
   (64K) BSS segment.  Because of this we move as much of it as possible into
   its own segment with the following define */

#if defined( __WIN16__ )
  #define FAR_BSS	far
#else
  #define FAR_BSS
#endif /* 16-bit systems */

/* Some systems (typically 16-bit ones) have rather limited amounts of memory
   available, if we're building on one of these we limit the size of some
   of the bufers we use (mostly for stack data, which is limited to 64K
   total) */

#if defined( __MSDOS16__ ) || defined( __WIN16__ ) || defined( __TANDEM__ )
  #define CONSERVE_MEMORY
#endif /* MSDOS || Win16 || Tandem */

/* Many newer Unix versions support threads (some claim to support them but
   don't really, in the sense that half the functions don't work properly).
   UnixWare may support them, but it's not possible to tell because a 
   preprocessor bug prevents the code from being compiled.

   The following define enables the creation of the multithreaded version of 
   cryptlib unless it's specifically disabled with NO_THREADS */

#if defined( __UNIX__ ) && !defined( NO_THREADS )
  #if( ( defined( sun ) && ( OSVERSION > 4 ) ) || defined( __osf__ ) || \
	   defined( __Mach__ ) || defined( _AIX ) || defined( __linux__ ) )
	#define USE_THREADS
  #endif /* Slowaris || OSF1 || Mach || AIX || Linux */
#endif /* __UNIX__ && !NO_THREADS */

/* If we're running under Windows, enable network access, ODBC (if the
   compiler understands ODBC), and LDAP keyset access */

#ifdef __WINDOWS__
  #define NET_TCP
  #if !( defined( __BORLANDC__ ) && ( __BORLANDC__ < 0x500 ) )
	#define DBX_ODBC
  #endif /* Old Borland C++ */
  #define DBX_LDAP
#endif /* Windows */

/* If we're running under Unix, enable network access */

#ifdef __UNIX__
  #define NET_TCP
#endif /* Unix */

/* On systems which support dynamic loading, we bind various drivers and
   libraries at runtime rather than at compile time.  Under Windows this is
   fairly easy but under Unix it's only supported selectively and may be
   buggy or platform-specific */

#if defined( __WINDOWS__ ) || ( defined( __UNIX__ ) && \
		( ( defined( sun ) && OSVERSION > 4 ) || defined( __linux__ ) ) )
  #define DYNAMIC_LOAD

  /* Macros to map OS-specific dynamic-load values to generic ones */
  #if defined( __WINDOWS__ )
	#define INSTANCE_HANDLE		HINSTANCE
	#define NULL_INSTANCE		( HINSTANCE ) NULL
	#define DynamicLoad( name )	LoadLibrary( name )
	#define DynamicUnload		FreeLibrary
	#define DynamicBind			GetProcAddress
  #elif defined( __UNIX__ )
	#include <dlfcn.h>

	#define INSTANCE_HANDLE		void *
	#define NULL_INSTANCE		NULL
	#define DynamicLoad( name )	dlopen( name, RTLD_LAZY )
	#define DynamicUnload		dlclose
	#define DynamicBind			dlsym
  #endif /* OS-specific instance handles */
#endif /* Windows || Some Unix versions */

/* Win32 consists of Win95/98 and WinNT/2000, Win95 doesn't have a number of 
   the functions and services which exist in NT so we need to adapt the code
   based on the Win32 variant.  The following flag records which OS variant
   we're crawling under */

#ifdef __WIN32__
  extern BOOLEAN isWin95;
#endif /* Win32 */

/* Boolean constants */

#ifndef TRUE
  #define FALSE			0
  #define TRUE			!FALSE
#endif /* Boolean values */

/* If the endianness is not defined and the compiler can tell us what
   endianness we've got, use this in preference to all other methods.  This

⌨️ 快捷键说明

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