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

📄 cryptlib.bas

📁 cryptlib安全工具包
💻 BAS
📖 第 1 页 / 共 5 页
字号:
    CRYPT_CERTACTION_ISSUE_CRL      ' CRL issue     CRYPT_CERTACTION_REVOKE_CERT    ' Cert revocation     CRYPT_CERTACTION_EXPIRE_CERT    ' Cert expiry     CRYPT_CERTACTION_CLEANUP        ' Clean up on restart     CRYPT_CERTACTION_LAST           ' Last possible cert store log action     End Enum'****************************************************************************'*                                                                           *'*                               General Constants                           *'*                                                                           *'****************************************************************************' The maximum user key size - 2048 bits   Public Const CRYPT_MAX_KEYSIZE As Long = 256' The maximum IV size - 256 bits   Public Const CRYPT_MAX_IVSIZE As Long = 32'  The maximum public-key component size - 4096 bits, and maximum component'  size for ECCs - 256 bits   Public Const CRYPT_MAX_PKCSIZE As Long = 512  Public Const CRYPT_MAX_PKCSIZE_ECC As Long = 32' The maximum hash size - 256 bits   Public Const CRYPT_MAX_HASHSIZE As Long = 32' The maximum size of a text string (e.g.key owner name)   Public Const CRYPT_MAX_TEXTSIZE As Long = 64'  A magic value indicating that the default setting for this parameter'  should be used   Public Const CRYPT_USE_DEFAULT As Long = -100' A magic value for unused parameters   Public Const CRYPT_UNUSED As Long = -101' Cursor positioning codes for certificate/CRL extensions   Public Const CRYPT_CURSOR_FIRST As Long = -200  Public Const CRYPT_CURSOR_PREVIOUS As Long = -201  Public Const CRYPT_CURSOR_NEXT As Long = -202  Public Const CRYPT_CURSOR_LAST As Long = -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()   Public Const CRYPT_RANDOM_FASTPOLL As Long = -300  Public Const CRYPT_RANDOM_SLOWPOLL As Long = -301' Whether the PKC key is a public or private key   Public Const CRYPT_KEYTYPE_PRIVATE As Long = 0  Public Const CRYPT_KEYTYPE_PUBLIC As Long = 1' Keyset open options Public Enum CRYPT_KEYOPT_TYPE    CRYPT_KEYOPT_NONE               ' No options     CRYPT_KEYOPT_READONLY           ' Open keyset in read-only mode     CRYPT_KEYOPT_CREATE             ' Create a new keyset     CRYPT_KEYOPT_LAST               ' Last possible key option type     End Enum' The various cryptlib objects - these are just integer handles REM  CRYPT_CERTIFICATE = LongREM  CRYPT_CONTEXT = LongREM  CRYPT_DEVICE = LongREM  CRYPT_ENVELOPE = LongREM  CRYPT_KEYSET = LongREM  CRYPT_SESSION = LongREM  CRYPT_USER = Long'  Sometimes we don't know the exact type of a cryptlib object, so we use a'  generic handle type to identify it REM  CRYPT_HANDLE = Long'****************************************************************************'*                                                                           *'*                           Encryption Data Structures                      *'*                                                                           *'****************************************************************************' Results returned from the capability query Public Type CRYPT_QUERY_INFO     ' Algorithm information     algoName(CRYPT_MAX_TEXTSIZE-1) As Byte' Algorithm name     blockSize As Long                  ' Block size of the algorithm     minKeySize As Long                 ' Minimum key size in bytes     keySize As Long                    ' Recommended key size in bytes     maxKeySize As Long                 ' Maximum key size in bytes     End Type'  Results returned from the encoded object query.  These provide'  information on the objects created by cryptExportKey()/'  cryptCreateSignature() Public Type CRYPT_OBJECT_INFO     ' The object type     objectType As CRYPT_OBJECT_TYPE    ' The encryption algorithm and mode     cryptAlgo As CRYPT_ALGO_TYPE    cryptMode As CRYPT_MODE_TYPE    ' The hash algorithm for Signature objects     hashAlgo As CRYPT_ALGO_TYPE    ' The salt for derived keys     salt(CRYPT_MAX_HASHSIZE-1) As Byte    saltSize As Long    End Type'  Key information for the public-key encryption algorithms.  These fields'  are not accessed directly, but can be manipulated with the init/set/'  destroyComponents() macros Public Type CRYPT_PKCINFO_RSA     ' Status information     isPublicKey As Long            ' Whether this is a public or private key     ' Public components     n(CRYPT_MAX_PKCSIZE-1) As Byte   ' Modulus     nLen As Long                   ' Length of modulus in bits     e(CRYPT_MAX_PKCSIZE-1) As Byte   ' Public exponent     eLen As Long                   ' Length of public exponent in bits     ' Private components     d(CRYPT_MAX_PKCSIZE-1) As Byte   ' Private exponent     dLen As Long                   ' Length of private exponent in bits     p(CRYPT_MAX_PKCSIZE-1) As Byte   ' Prime factor 1     pLen As Long                   ' Length of prime factor 1 in bits     q(CRYPT_MAX_PKCSIZE-1) As Byte   ' Prime factor 2     qLen As Long                   ' Length of prime factor 2 in bits     u(CRYPT_MAX_PKCSIZE-1) As Byte   ' Mult.inverse of q, mod p     uLen As Long                   ' Length of private exponent in bits     e1(CRYPT_MAX_PKCSIZE-1) As Byte  ' Private exponent 1 (PKCS)     e1Len As Long                  ' Length of private exponent in bits     e2(CRYPT_MAX_PKCSIZE-1) As Byte  ' Private exponent 2 (PKCS)     e2Len As Long                  ' Length of private exponent in bits     End TypePublic Type CRYPT_PKCINFO_DLP     ' Status information     isPublicKey As Long            ' Whether this is a public or private key     ' Public components     p(CRYPT_MAX_PKCSIZE-1) As Byte   ' Prime modulus     pLen As Long                   ' Length of prime modulus in bits     q(CRYPT_MAX_PKCSIZE-1) As Byte   ' Prime divisor     qLen As Long                   ' Length of prime divisor in bits     g(CRYPT_MAX_PKCSIZE-1) As Byte   ' h^( ( p - 1 ) / q ) mod p     gLen As Long                   ' Length of g in bits     y(CRYPT_MAX_PKCSIZE-1) As Byte   ' Public random integer     yLen As Long                   ' Length of public integer in bits     ' Private components     x(CRYPT_MAX_PKCSIZE-1) As Byte   ' Private random integer     xLen As Long                   ' Length of private integer in bits     End TypePublic Type CRYPT_PKCINFO_ECC     ' Status information     isPublicKey As Long            ' Whether this is a public or private key     ' Curve     p(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Prime defining Fq     pLen As Long                   ' Length of prime in bits     a(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Element in Fq defining curve     aLen As Long                   ' Length of element a in bits     b(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Element in Fq defining curve     bLen As Long                   ' Length of element b in bits     ' Generator     gx(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Element in Fq defining point     gxLen As Long                  ' Length of element gx in bits     gy(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Element in Fq defining point     gyLen As Long                  ' Length of element gy in bits     r(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Order of point     rLen As Long                   ' Length of order in bits     h(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Optional cofactor     hLen As Long                   ' Length of cofactor in bits     ' Public components     qx(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Point Q on the curve     qxLen As Long                  ' Length of point xq in bits     qy(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Point Q on the curve     qyLen As Long                  ' Length of point xy in bits     ' Private components     d(CRYPT_MAX_PKCSIZE_ECC-1) As Byte' Private random integer     dLen As Long                   ' Length of integer in bits     End Type'  Macros to initialise and destroy the structure that stores the components'  of a public key ' C-macro not translated to Visual Basic code: '   #define cryptInitComponents( componentInfo, componentKeyType ) '    { memset( ( componentInfo ), 0, sizeof( *componentInfo ) ); '      ( componentInfo )->isPublicKey = ( ( componentKeyType ) ? 1 : 0 ); }'' C-macro not translated to Visual Basic code: '   #define cryptDestroyComponents( componentInfo ) '    memset( ( componentInfo ), 0, sizeof( *componentInfo ) )'' Macros to set a component of a public key ' C-macro not translated to Visual Basic code: '   #define cryptSetComponent( destination, source, length ) '    { memcpy( ( destination ), ( source ), ( ( length ) + 7 ) >> 3 ); '      ( destination##Len ) = length; }''****************************************************************************'*                                                                           *'*                               Status Codes                                *'*                                                                           *'****************************************************************************' No error in function call   Public Const CRYPT_OK As Long = 0   ' No error ' Error in parameters passed to function   Public Const CRYPT_ERROR_PARAM1 As Long = -1  ' Bad argument, parameter 1   Public Const CRYPT_ERROR_PARAM2 As Long = -2  ' Bad argument, parameter 2   Public Const CRYPT_ERROR_PARAM3 As Long = -3  ' Bad argument, parameter 3   Public Const CRYPT_ERROR_PARAM4 As Long = -4  ' Bad argument, parameter 4   Public Const CRYPT_ERROR_PARAM5 As Long = -5  ' Bad argument, parameter 5   Public Const CRYPT_ERROR_PARAM6 As Long = -6  ' Bad argument, parameter 6   Public Const CRYPT_ERROR_PARAM7 As Long = -7  ' Bad argument, parameter 7 ' Errors due to insufficient resources   Public Const CRYPT_ERROR_MEMORY As Long = -10 ' Out of memory   Public Const CRYPT_ERROR_NOTINITED As Long = -11 ' Data has not been initialised   Public Const CRYPT_ERROR_INITED As Long = -12 ' Data has already been init'd   Public Const CRYPT_ERROR_NOSECURE As Long = -13 ' Opn.not avail.at requested sec.level   Public Const CRYPT_ERROR_RANDOM As Long = -14 ' No reliable random data available   Public Const CRYPT_ERROR_FAILED As Long = -15 ' Operation failed   Public Const CRYPT_ERROR_INTERNAL As Long = -16 ' Internal consistency check failed ' Security violations   Public Const CRYPT_ERROR_NOTAVAIL As Long = -20 ' This type of opn.not available   Public Const CRYPT_ERROR_PERMISSION As Long = -21 ' No permiss.to perform this operation   Public Const CRYPT_ERROR_WRONGKEY As Long = -22 ' Incorrect key used to decrypt data   Public Const CRYPT_ERROR_INCOMPLETE As Long = -23 ' Operation incomplete/still in progress   Public Const CRYPT_ERROR_COMPLETE As Long = -24 ' Operation complete/can't continue   Public Const CRYPT_ERROR_TIMEOUT As Long = -25 ' Operation timed out before completion   Public Const CRYPT_ERROR_INVALID As Long = -26 ' Invalid/inconsistent information   Public Const CRYPT_ERROR_SIGNALLED As Long = -27 ' Resource destroyed by extnl.event ' High-level function errors   Public Const CRYPT_ERROR_OVERFLOW As Long = -30 ' Resources/space exhausted   Public Const CRYPT_ERROR_UNDERFLOW As Long = -31 ' Not enough data available   Public Const CRYPT_ERROR_BADDATA As Long = -32 ' Bad/unrecognised data format   Public Const CRYPT_ERROR_SIGNATURE As Long = -33 ' Signature/integrity check failed ' Data access function errors   Public Const CRYPT_ERROR_OPEN As Long = -40 ' Cannot open object   Public Const CRYPT_ERROR_READ As Long = -41 ' Cannot read item from object   Public Const CRYPT_ERROR_WRITE As Long = -42 ' Cannot write item to object   Public Const CRYPT_ERROR_NOTFOUND As Long = -43 ' Requested item not found in object   Public Const CRYPT_ERROR_DUPLICATE As Long = -44 ' Item already present in object ' Data enveloping errors   Public Const CRYPT_ENVELOPE_RESOURCE As Long = -50 ' Need resource to proceed ' Macros to examine return values ' C-macro not translated to Visual Basic code: '   #define cryptStatusError( status )  ( ( status ) < CRYPT_OK )'' C-macro not translated to Visual Basic 

⌨️ 快捷键说明

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