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

📄 perlcryptlib.ph

📁 cryptlib安全工具包
💻 PH
📖 第 1 页 / 共 5 页
字号:
#  should be used 	sub CRYPT_USE_DEFAULT { -100 }# A magic value for unused parameters 	sub CRYPT_UNUSED { -101 }# Cursor positioning codes for certificate/CRL extensions 	sub CRYPT_CURSOR_FIRST { -200 }	sub CRYPT_CURSOR_PREVIOUS { -201 }	sub CRYPT_CURSOR_NEXT { -202 }	sub CRYPT_CURSOR_LAST { -203 }#  The type of information polling to perform to get random seed #  information.  These values have to be negative because they're used#  as magic length values for cryptAddRandom() 	sub CRYPT_RANDOM_FASTPOLL { -300 }	sub CRYPT_RANDOM_SLOWPOLL { -301 }# Whether the PKC key is a public or private key 	sub CRYPT_KEYTYPE_PRIVATE { 0 }	sub CRYPT_KEYTYPE_PUBLIC { 1 }# Keyset open options ##### BEGIN ENUM CRYPT_KEYOPT_TYPE	sub CRYPT_KEYOPT_NONE { 0 }	# No options	sub CRYPT_KEYOPT_READONLY { 1 }	# Open keyset in read-only mode	sub CRYPT_KEYOPT_CREATE { 2 }	# Create a new keyset	sub CRYPT_KEYOPT_LAST { 3 }	# Last possible key option type##### END ENUM CRYPT_KEYOPT_TYPE# The various cryptlib objects - these are just integer handles sub CRYPT_CERTIFICATE { 0 }sub CRYPT_CONTEXT { 0 }sub CRYPT_DEVICE { 0 }sub CRYPT_ENVELOPE { 0 }sub CRYPT_KEYSET { 0 }sub CRYPT_SESSION { 0 }sub CRYPT_USER { 0 }#  Sometimes we don't know the exact type of a cryptlib object, so we use a#  generic handle type to identify it sub CRYPT_HANDLE { 0 }#****************************************************************************#*                                                                           *#*                           Encryption Data Structures                      *#*                                                                           *#****************************************************************************# Results returned from the capability query sub CRYPT_QUERY_INFO{	{	#  Algorithm information      algoName => ' ' x CRYPT_MAX_TEXTSIZE	#  Algorithm name     ,blockSize => 0	#  Block size of the algorithm     ,minKeySize => 0	#  Minimum key size in bytes     ,keySize => 0	#  Recommended key size in bytes     ,maxKeySize => 0	#  Maximum key size in bytes     	}}#  Results returned from the encoded object query.  These provide#  information on the objects created by cryptExportKey()/#  cryptCreateSignature() sub CRYPT_OBJECT_INFO{	{	#  The object type      objectType => 0	#  The encryption algorithm and mode     ,cryptAlgo => 0    ,cryptMode => 0	#  The hash algorithm for Signature objects     ,hashAlgo => 0	#  The salt for derived keys     ,salt => ' ' x CRYPT_MAX_HASHSIZE    ,saltSize => 0    	}}#  Key information for the public-key encryption algorithms.  These fields#  are not accessed directly, but can be manipulated with the init/set/#  destroyComponents() macros sub CRYPT_PKCINFO_RSA{	{	#  Status information      isPublicKey => 0	#  Whether this is a public or private key 	#  Public components     ,n => ' ' x CRYPT_MAX_PKCSIZE	#  Modulus     ,nLen => 0	#  Length of modulus in bits     ,e => ' ' x CRYPT_MAX_PKCSIZE	#  Public exponent     ,eLen => 0	#  Length of public exponent in bits 	#  Private components     ,d => ' ' x CRYPT_MAX_PKCSIZE	#  Private exponent     ,dLen => 0	#  Length of private exponent in bits     ,p => ' ' x CRYPT_MAX_PKCSIZE	#  Prime factor 1     ,pLen => 0	#  Length of prime factor 1 in bits     ,q => ' ' x CRYPT_MAX_PKCSIZE	#  Prime factor 2     ,qLen => 0	#  Length of prime factor 2 in bits     ,u => ' ' x CRYPT_MAX_PKCSIZE	#  Mult.inverse of q, mod p     ,uLen => 0	#  Length of private exponent in bits     ,e1 => ' ' x CRYPT_MAX_PKCSIZE	#  Private exponent 1 (PKCS)     ,e1Len => 0	#  Length of private exponent in bits     ,e2 => ' ' x CRYPT_MAX_PKCSIZE	#  Private exponent 2 (PKCS)     ,e2Len => 0	#  Length of private exponent in bits     	}}sub CRYPT_PKCINFO_DLP{	{	#  Status information      isPublicKey => 0	#  Whether this is a public or private key 	#  Public components     ,p => ' ' x CRYPT_MAX_PKCSIZE	#  Prime modulus     ,pLen => 0	#  Length of prime modulus in bits     ,q => ' ' x CRYPT_MAX_PKCSIZE	#  Prime divisor     ,qLen => 0	#  Length of prime divisor in bits     ,g => ' ' x CRYPT_MAX_PKCSIZE	#  h^( ( p - 1 ) / q ) mod p     ,gLen => 0	#  Length of g in bits     ,y => ' ' x CRYPT_MAX_PKCSIZE	#  Public random integer     ,yLen => 0	#  Length of public integer in bits 	#  Private components     ,x => ' ' x CRYPT_MAX_PKCSIZE	#  Private random integer     ,xLen => 0	#  Length of private integer in bits     	}}sub CRYPT_PKCINFO_ECC{	{	#  Status information      isPublicKey => 0	#  Whether this is a public or private key 	#  Curve     ,p => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Prime defining Fq     ,pLen => 0	#  Length of prime in bits     ,a => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Element in Fq defining curve     ,aLen => 0	#  Length of element a in bits     ,b => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Element in Fq defining curve     ,bLen => 0	#  Length of element b in bits 	#  Generator     ,gx => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Element in Fq defining point     ,gxLen => 0	#  Length of element gx in bits     ,gy => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Element in Fq defining point     ,gyLen => 0	#  Length of element gy in bits     ,r => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Order of point     ,rLen => 0	#  Length of order in bits     ,h => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Optional cofactor     ,hLen => 0	#  Length of cofactor in bits 	#  Public components     ,qx => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Point Q on the curve     ,qxLen => 0	#  Length of point xq in bits     ,qy => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Point Q on the curve     ,qyLen => 0	#  Length of point xy in bits 	#  Private components     ,d => ' ' x CRYPT_MAX_PKCSIZE_ECC	#  Private random integer     ,dLen => 0	#  Length of integer in bits     	}}#  Macros to initialise and destroy the structure that stores the components#  of a public key # C-macro not translated to Perl code but implemented apart: #   #define cryptInitComponents( componentInfo, componentKeyType ) #    { memset( ( componentInfo ), 0, sizeof( *componentInfo ) ); #      ( componentInfo )->isPublicKey = ( ( componentKeyType ) ? 1 : 0 ); }## C-macro not translated to Perl code but implemented apart: #   #define cryptDestroyComponents( componentInfo ) #    memset( ( componentInfo ), 0, sizeof( *componentInfo ) )## Macros to set a component of a public key # C-macro not translated to Perl code but implemented apart: #   #define cryptSetComponent( destination, source, length ) #    { memcpy( ( destination ), ( source ), ( ( length ) + 7 ) >> 3 ); #      ( destination##Len ) = length; }##****************************************************************************#*                                                                           *#*                               Status Codes                                *#*                                                                           *#****************************************************************************# No error in function call 	sub CRYPT_OK { 0 }   # No error # Error in parameters passed to function 	sub CRYPT_ERROR_PARAM1 { -1 }  # Bad argument, parameter 1 	sub CRYPT_ERROR_PARAM2 { -2 }  # Bad argument, parameter 2 	sub CRYPT_ERROR_PARAM3 { -3 }  # Bad argument, parameter 3 	sub CRYPT_ERROR_PARAM4 { -4 }  # Bad argument, parameter 4 	sub CRYPT_ERROR_PARAM5 { -5 }  # Bad argument, parameter 5 	sub CRYPT_ERROR_PARAM6 { -6 }  # Bad argument, parameter 6 	sub CRYPT_ERROR_PARAM7 { -7 }  # Bad argument, parameter 7 # Errors due to insufficient resources 	sub CRYPT_ERROR_MEMORY { -10 } # Out of memory 	sub CRYPT_ERROR_NOTINITED { -11 } # Data has not been initialised 	sub CRYPT_ERROR_INITED { -12 } # Data has already been init'd 	sub CRYPT_ERROR_NOSECURE { -13 } # Opn.not avail.at requested sec.level 	sub CRYPT_ERROR_RANDOM { -14 } # No reliable random data available 	sub CRYPT_ERROR_FAILED { -15 } # Operation failed 	sub CRYPT_ERROR_INTERNAL { -16 } # Internal consistency check failed # Security violations 	sub CRYPT_ERROR_NOTAVAIL { -20 } # This type of opn.not available 	sub CRYPT_ERROR_PERMISSION { -21 } # No permiss.to perform this operation 	sub CRYPT_ERROR_WRONGKEY { -22 } # Incorrect key used to decrypt data 	sub CRYPT_ERROR_INCOMPLETE { -23 } # Operation incomplete/still in progress 	sub CRYPT_ERROR_COMPLETE { -24 } # Operation complete/can't continue 	sub CRYPT_ERROR_TIMEOUT { -25 } # Operation timed out before completion 	sub CRYPT_ERROR_INVALID { -26 } # Invalid/inconsistent information 	sub CRYPT_ERROR_SIGNALLED { -27 } # Resource destroyed by extnl.event # High-level function errors 	sub CRYPT_ERROR_OVERFLOW { -30 } # Resources/space exhausted 	sub CRYPT_ERROR_UNDERFLOW { -31 } # Not enough data available 	sub CRYPT_ERROR_BADDATA { -32 } # Bad/unrecognised data format 	sub CRYPT_ERROR_SIGNATURE { -33 } # Signature/integrity check failed # Data access function errors 	sub CRYPT_ERROR_OPEN { -40 } # Cannot open object 	sub CRYPT_ERROR_READ { -41 } # Cannot read item from object 	sub CRYPT_ERROR_WRITE { -42 } # Cannot write item to object 	sub CRYPT_ERROR_NOTFOUND { -43 } # Requested item not found in object 	sub CRYPT_ERROR_DUPLICATE { -44 } # Item already present in object # Data enveloping errors 	sub CRYPT_ENVELOPE_RESOURCE { -50 } # Need resource to proceed # Macros to examine return values # C-macro not translated to Perl code but implemented apart: #   #define cryptStatusError( status )  ( ( status ) < CRYPT_OK )## C-macro not translated to Perl code but implemented apart: #   #define cryptStatusOK( status )     ( ( status ) == CRYPT_OK )##****************************************************************************#*                                                                           *#*                                   General Functions                       *#*                                                                           *#****************************************************************************# The following is necessary to stop C++ name mangling # Initialise and shut down cryptlib #C_RET cryptInit( void );##C_RET cryptEnd( void );## Query cryptlibs capabilities #C_RET cryptQueryCapability( C_IN CRYPT_ALGO_TYPE cryptAlgo,#                            C_OUT CRYPT_QUERY_INFO C_PTR cryptQueryInfo );## Create and destroy an encryption context #C_RET cryptCreateContext( C_OUT CRYPT_CONTEXT C_PTR cryptContext,#                          C_IN CRYPT_USER cryptUser,#                          C_IN CRYPT_ALGO_TYPE cryptAlgo );##C_RET cryptDestroyContext( C_IN CRYPT_CONTEXT cryptContext );## Generic "destroy an object" function #C_RET cryptDestroyObject( C_IN CRYPT_HANDLE cryptObject );## Generate a key into a context #C_RET cryptGenerateKey( C_IN CRYPT_CONTEXT cryptContext );##C_RET cryptGenerateKeyAsync( C_IN CRYPT_CONTEXT cryptContext );##C_RET cryptAsyncQuery( C_IN CRYPT_HANDLE cryptObject );##C_RET cryptAsyncCancel( C_IN CRYPT_HANDLE cryptObject );## Encrypt/decrypt/hash a block of memory #C_RET cryptEncrypt( C_IN CRYPT_CONTEXT cryptContext, C_INOUT void C_PTR buffer,#                    C_IN int length );##C_RET cryptDecrypt( C_IN CRYPT_CONTEXT cryptContext, C_INOUT void C_PTR buffer,#                    C_IN int length );## Get

⌨️ 快捷键说明

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