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

📄 cryptlib.cs

📁 老外写的加密库cryptlib(版本3.1)
💻 CS
📖 第 1 页 / 共 5 页
字号:
		/* The maximum hash size - 256 bits */		public const int MAX_HASHSIZE                             = 32  ;		/* The maximum size of a text string (e.g.key owner name) */		public const int MAX_TEXTSIZE                             = 64  ;		/* A magic value indicating that the default setting for this parameter	   should be used */		public const int USE_DEFAULT                              = -10 ;		/* A magic value for unused parameters */		public const int UNUSED                                   = -11 ;		/* Whether the PKC key is a public or private key */		public const int KEYTYPE_PRIVATE                          = 0   ;	public const int KEYTYPE_PUBLIC                           = 1   ;		/* The type of information polling to perform to get random seed information */		public const int RANDOM_FASTPOLL                          = -10 ;	public const int RANDOM_SLOWPOLL                          = -11 ;		/* Cursor positioning codes for certificate/CRL extensions */		public const int CURSOR_FIRST                             = -20 ;	public const int CURSOR_PREVIOUS                          = -21 ;	public const int CURSOR_NEXT                              = -22 ;	public const int CURSOR_LAST                              = -23 ;		/* Keyset open options */		// CRYPT_KEYOPT_TYPE	public const int KEYOPT_NONE     = 0; // No options	public const int KEYOPT_READONLY = 1; // Open keyset in read-only mode	public const int KEYOPT_CREATE   = 2; // Create a new keyset	public const int KEYOPT_LAST     = 3; // Last possible key option type		/* The various cryptlib objects - these are just integer handles */		//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_CERTIFICATE;	//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_CONTEXT;	//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_DEVICE;	//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_ENVELOPE;	//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_KEYSET;	//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_SESSION;	//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_USER;		/* Sometimes we don't know the exact type of a cryptlib object, so we use a	   generic handle type to identify it */		//CRYPTLIBCONVERTER - NOT NEEDED: typedef int CRYPT_HANDLE;		/****************************************************************************	*																			*	*							Encryption Data Structures						*	*																			*	****************************************************************************/		/* Results returned from the capability query */		//CRYPTLIBCONVERTER - NOT SUPPORTED:	//typedef struct {	//	/* Algorithm information */	//	char algoName[ CRYPT_MAX_TEXTSIZE ];/* Algorithm name */	//	int blockSize;					/* Block size of the algorithm */	//	int minKeySize;					/* Minimum key size in bytes */	//	int keySize;					/* Recommended key size in bytes */	//	int maxKeySize;					/* Maximum key size in bytes */	//	} CRYPT_QUERY_INFO;		/* Results returned from the encoded object query.  These provide	   information on the objects created by cryptExportKey()/	   cryptCreateSignature() */		//CRYPTLIBCONVERTER - NOT SUPPORTED:	//typedef struct {	//	/* The object type */	//	CRYPT_OBJECT_TYPE objectType;	//	//	/* The encryption algorithm and mode */	//	CRYPT_ALGO_TYPE cryptAlgo;	//	CRYPT_MODE_TYPE cryptMode;	//	//	/* The hash algorithm for Signature objects */	//	CRYPT_ALGO_TYPE hashAlgo;	//	//	/* The salt for derived keys */	//	unsigned char salt[ CRYPT_MAX_HASHSIZE ];	//	int saltSize;	//	} CRYPT_OBJECT_INFO;		/* Key information for the public-key encryption algorithms.  These fields	   are not accessed directly, but can be manipulated with the init/set/	   destroyComponents() macros */		//CRYPTLIBCONVERTER - NOT SUPPORTED:	//typedef struct {	//	/* Status information */	//	int isPublicKey;			/* Whether this is a public or private key */	//	//	/* Public components */	//	unsigned char n[ CRYPT_MAX_PKCSIZE ];	/* Modulus */	//	int nLen;					/* Length of modulus in bits */	//	unsigned char e[ CRYPT_MAX_PKCSIZE ];	/* Public exponent */	//	int eLen;					/* Length of public exponent in bits */	//	//	/* Private components */	//	unsigned char d[ CRYPT_MAX_PKCSIZE ];	/* Private exponent */	//	int dLen;					/* Length of private exponent in bits */	//	unsigned char p[ CRYPT_MAX_PKCSIZE ];	/* Prime factor 1 */	//	int pLen;					/* Length of prime factor 1 in bits */	//	unsigned char q[ CRYPT_MAX_PKCSIZE ];	/* Prime factor 2 */	//	int qLen;					/* Length of prime factor 2 in bits */	//	unsigned char u[ CRYPT_MAX_PKCSIZE ];	/* Mult.inverse of q, mod p */	//	int uLen;					/* Length of private exponent in bits */	//	unsigned char e1[ CRYPT_MAX_PKCSIZE ];	/* Private exponent 1 (PKCS) */	//	int e1Len;					/* Length of private exponent in bits */	//	unsigned char e2[ CRYPT_MAX_PKCSIZE ];	/* Private exponent 2 (PKCS) */	//	int e2Len;					/* Length of private exponent in bits */	//	} CRYPT_PKCINFO_RSA;		//CRYPTLIBCONVERTER - NOT SUPPORTED:	//typedef struct {	//	/* Status information */	//	int isPublicKey;			/* Whether this is a public or private key */	//	//	/* Public components */	//	unsigned char p[ CRYPT_MAX_PKCSIZE ];	/* Prime modulus */	//	int pLen;					/* Length of prime modulus in bits */	//	unsigned char q[ CRYPT_MAX_PKCSIZE ];	/* Prime divisor */	//	int qLen;					/* Length of prime divisor in bits */	//	unsigned char g[ CRYPT_MAX_PKCSIZE ];	/* h^( ( p - 1 ) / q ) mod p */	//	int gLen;					/* Length of g in bits */	//	unsigned char y[ CRYPT_MAX_PKCSIZE ];	/* Public random integer */	//	int yLen;					/* Length of public integer in bits */	//	//	/* Private components */	//	unsigned char x[ CRYPT_MAX_PKCSIZE ];	/* Private random integer */	//	int xLen;					/* Length of private integer in bits */	//	} CRYPT_PKCINFO_DLP;		/* Macros to initialise and destroy the structure that stores the components	   of a public key */		//CRYPTLIBCONVERTER - NOT SUPPORTED:	//#define cryptInitComponents( componentInfo, componentKeyType ) \	//	{ memset( ( componentInfo ), 0, sizeof( *componentInfo ) ); \	//	  ( componentInfo )->isPublicKey = ( ( componentKeyType ) ? 1 : 0 ); }		//CRYPTLIBCONVERTER - NOT SUPPORTED:	//#define cryptDestroyComponents( componentInfo ) \	//	memset( ( componentInfo ), 0, sizeof( *componentInfo ) )		/* Macros to set a component of a public key */		//CRYPTLIBCONVERTER - NOT SUPPORTED:	//#define cryptSetComponent( destination, source, length ) \	//	{ memcpy( ( destination ), ( source ), ( ( length ) + 7 ) >> 3 ); \	//	  ( destination##Len ) = length; }		/****************************************************************************	*																			*	*								Status Codes								*	*																			*	****************************************************************************/		/* No error in function call */		public const int OK                                       = 0   ; // No error		/* Error in parameters passed to function */		public const int ERROR_PARAM1                             = -1  ; // Bad argument, parameter 1	public const int ERROR_PARAM2                             = -2  ; // Bad argument, parameter 2	public const int ERROR_PARAM3                             = -3  ; // Bad argument, parameter 3	public const int ERROR_PARAM4                             = -4  ; // Bad argument, parameter 4	public const int ERROR_PARAM5                             = -5  ; // Bad argument, parameter 5	public const int ERROR_PARAM6                             = -6  ; // Bad argument, parameter 6	public const int ERROR_PARAM7                             = -7  ; // Bad argument, parameter 7		/* Errors due to insufficient resources */		public const int ERROR_MEMORY                             = -10 ; // Out of memory	public const int ERROR_NOTINITED                          = -11 ; // Data has not been initialised	public const int ERROR_INITED                             = -12 ; // Data has already been init'd	public const int ERROR_NOSECURE                           = -13 ; // Opn.not avail.at requested sec.level	public const int ERROR_RANDOM                             = -14 ; // No reliable random data available	public const int ERROR_FAILED                             = -15 ; // Operation failed		/* Security violations */		public const int ERROR_NOTAVAIL                           = -20 ; // This type of opn.not available	public const int ERROR_PERMISSION                         = -21 ; // No permiss.to perform this operation	public const int ERROR_WRONGKEY                           = -22 ; // Incorrect key used to decrypt data	public const int ERROR_INCOMPLETE        

⌨️ 快捷键说明

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