cryptlib.pas

来自「提供了很多种加密算法和CA认证及相关服务如CMP、OCSP等的开发」· PAS 代码 · 共 1,269 行 · 第 1/5 页

PAS
1,269
字号
  CRYPT_CMPSTATUS_EXT_INCORRECTDATA                 = $080;
  CRYPT_CMPSTATUS_EXT_MISSINGTIMESTAMP              = $100;
  CRYPT_CMPSTATUS_EXT_BADPOP                        = $200;
  CRYPT_CMPSTATUS_EXT_LAST                          = $400; {  Last possible value  }

{  Protocol version information  }

  CRYPT_PROTOCOLVERSION_SSL                         = 0; {  SSL 3.0  }
  CRYPT_PROTOCOLVERSION_TLS                         = 1; {  SSL/TLS 3.1  }

{  The certificate export format type, which defines the format in which a
   certificate object is exported  }


type
  CRYPT_CERTFORMAT_TYPE = (
    CRYPT_CERTFORMAT_NONE,                            {  No certificate format  }
    CRYPT_CERTFORMAT_CERTIFICATE,                     {  DER-encoded certificate  }
    CRYPT_CERTFORMAT_CERTCHAIN,                       {  PKCS #7 certificate chain  }
    CRYPT_CERTFORMAT_TEXT_CERTIFICATE,                {  base-64 wrapped cert  }
    CRYPT_CERTFORMAT_TEXT_CERTCHAIN,                  {  base-64 wrapped cert chain  }
    CRYPT_CERTFORMAT_LAST                             {  Last possible cert.format type  }

    );

{  CMP request types  }

  CRYPT_REQUESTTYPE_TYPE = (
    CRYPT_REQUESTTYPE_NONE,                           {  No request type  }
    CRYPT_REQUESTTYPE_INITIALISATION,                 {  Initialisation request  }
    CRYPT_REQUESTTYPE_CERTIFICATE,                    {  Certification request  }
    CRYPT_REQUESTTYPE_KEYUPDATE,                      {  Key update request  }
    CRYPT_REQUESTTYPE_REVOCATION,                     {  Cert revocation request  }
    CRYPT_REQUESTTYPE_LAST                            {  Last possible request type  }

    );

const
    CRYPT_REQUESTTYPE_INITIALIZATION: CRYPT_REQUESTTYPE_TYPE = CRYPT_REQUESTTYPE_INITIALISATION;

type

{  Key ID types  }

  CRYPT_KEYID_TYPE = (
    CRYPT_KEYID_NONE,                                 {  No key ID type  }
    CRYPT_KEYID_NAME,                                 {  Key owner name  }
    CRYPT_KEYID_EMAIL,                                {  Key owner email address  }
    CRYPT_KEYID_LAST                                  {  Last possible key ID type  }

    );

{  The encryption object types  }

  CRYPT_OBJECT_TYPE = (
    CRYPT_OBJECT_NONE,                                {  No object type  }
    CRYPT_OBJECT_ENCRYPTED_KEY,                       {  Conventionally encrypted key  }
    CRYPT_OBJECT_PKCENCRYPTED_KEY,                    {  PKC-encrypted key  }
    CRYPT_OBJECT_KEYAGREEMENT,                        {  Key agreement information  }
    CRYPT_OBJECT_SIGNATURE,                           {  Signature  }
    CRYPT_OBJECT_LAST                                 {  Last possible object type  }

    );

{  Object/attribute error type information  }

  CRYPT_ERRTYPE_TYPE = (
    CRYPT_ERRTYPE_NONE,                               {  No error information  }
    CRYPT_ERRTYPE_ATTR_SIZE,                          {  Attribute data too small or large  }
    CRYPT_ERRTYPE_ATTR_VALUE,                         {  Attribute value is invalid  }
    CRYPT_ERRTYPE_ATTR_ABSENT,                        {  Required attribute missing  }
    CRYPT_ERRTYPE_ATTR_PRESENT,                       {  Non-allowed attribute present  }
    CRYPT_ERRTYPE_CONSTRAINT,                         {  Cert: Constraint violation in object  }
    CRYPT_ERRTYPE_ISSUERCONSTRAINT,                   {  Cert: Constraint viol.in issuing cert  }
    CRYPT_ERRTYPE_LAST                                {  Last possible error info type  }

    );

{  Cert store management action type  }

  CRYPT_CERTACTION_TYPE = (
    CRYPT_CERTACTION_NONE,                            {  No log action  }
    CRYPT_CERTACTION_CREATE,                          {  Create cert store  }
    CRYPT_CERTACTION_CONNECT,                         {  Connect to cert store  }
    CRYPT_CERTACTION_DISCONNECT,                      {  Disconnect from cert store  }
    CRYPT_CERTACTION_ERROR,                           {  Error information  }
    CRYPT_CERTACTION_ADDUSER,                         {  Add PKI user  }
    CRYPT_CERTACTION_REQUEST_CERT,                    {  Cert request  }
    CRYPT_CERTACTION_REQUEST_RENEWAL,                 {  Cert renewal request  }
    CRYPT_CERTACTION_REQUEST_REVOCATION,              {  Cert revocation request  }
    CRYPT_CERTACTION_CERT_CREATION,                   {  Cert creation  }
    CRYPT_CERTACTION_CERT_CREATION_COMPLETE,          {  Confirmation of cert creation  }
    CRYPT_CERTACTION_CERT_CREATION_DROP,              {  Cancellation of cert creation  }
    CRYPT_CERTACTION_CERT_CREATION_REVERSE,           {  Cancel of creation w.revocation  }
    CRYPT_CERTACTION_RESTART_CLEANUP,                 {  Delete reqs after restart  }
    CRYPT_CERTACTION_RESTART_REVOKE_CERT,             {  Complete revocation after restart  }
    CRYPT_CERTACTION_ISSUE_CERT,                      {  Cert issue  }
    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  }

    );

{****************************************************************************
*                                                                           *
*                               General Constants                           *
*                                                                           *
****************************************************************************}

{  The maximum user key size - 2048 bits  }


const
  CRYPT_MAX_KEYSIZE                                 = 256;

{  The maximum IV size - 256 bits  }

  CRYPT_MAX_IVSIZE                                  = 32;

{  The maximum public-key component size - 4096 bits  }

  CRYPT_MAX_PKCSIZE                                 = 512;

{  The maximum hash size - 256 bits  }

  CRYPT_MAX_HASHSIZE                                = 32;

{  The maximum size of a text string (eg key owner name)  }

  CRYPT_MAX_TEXTSIZE                                = 64;

{  A magic value indicating that the default setting for this parameter
   should be used  }

  CRYPT_USE_DEFAULT                                 = -10;

{  A magic value for unused parameters  }

  CRYPT_UNUSED                                      = -11;

{  Whether the PKC key is a public or private key  }

  CRYPT_KEYTYPE_PRIVATE                             = 0;
  CRYPT_KEYTYPE_PUBLIC                              = 1;

{  The type of information polling to perform to get random seed information  }

  CRYPT_RANDOM_FASTPOLL                             = -10;
  CRYPT_RANDOM_SLOWPOLL                             = -11;

{  Cursor positioning codes for certificate/CRL extensions  }

  CRYPT_CURSOR_FIRST                                = -20;
  CRYPT_CURSOR_PREVIOUS                             = -21;
  CRYPT_CURSOR_NEXT                                 = -22;
  CRYPT_CURSOR_LAST                                 = -23;

{  Options passed to cryptOpenKeyset()  }


type
  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  }

    );

{  Macros to convert to and from the bit counts used for some encryption
   parameters  }

{ C-macro not translated to Delphi code:
{   #define bitsToBytes(bits)   ( ( ( bits ) + 7 ) >> 3 ) }
{ C-macro not translated to Delphi code:
{   #define bytesToBits(bytes)  ( ( bytes ) << 3 ) }

{  The various cryptlib objects - these are just integer handles  }

  CRYPT_CERTIFICATE = Integer;
  CRYPT_CONTEXT = Integer;
  CRYPT_DEVICE = Integer;
  CRYPT_ENVELOPE = Integer;
  CRYPT_KEYSET = Integer;
  CRYPT_SESSION = Integer;
  CRYPT_USER = Integer;

{  Sometimes we don't know the exact type of a cryptlib object, so we use a
   generic handle type to identify it  }

  CRYPT_HANDLE = Integer;

{****************************************************************************
*                                                                           *
*                           Encryption Data Structures                      *
*                                                                           *
****************************************************************************}

{  Results returned from the encryption capability query  }

  CRYPT_QUERY_INFO = record
    { Algorithm information }
    algoName: array[0..CRYPT_MAX_TEXTSIZE - 1] of char; { The algorithm name }
    blockSize: Integer;                               { The block size of the algorithm }
    minKeySize: Integer;                              { Minimum key size in bytes }
    keySize: Integer;                                 { Recommended key size in bytes }
    maxKeySize: Integer;                              { Maximum key size in bytes }


  end;

{  Results returned from the encryption object query.  These provide
   information on the objects created by cryptExportKey()/
   cryptCreateSignature()  }

  CRYPT_OBJECT_INFO = record
    { The object type }
    objectType: CRYPT_OBJECT_TYPE;                    { The object type }

    { The encryption algorithm and mode }
    cryptAlgo: CRYPT_ALGO;                            { The encryption algorithm }
    cryptMode: CRYPT_MODE;                            { The encryption mode }

    { The hash algorithm for Signature objects }
    hashAlgo: CRYPT_ALGO;                             { Hash algorithm }

    { The salt for derived keys }
    salt: array[0..CRYPT_MAX_HASHSIZE - 1] of byte;
    saltSize: Integer;


  end;

{  Key information for the public-key encryption algorithms.  These fields
   are not accessed directly, but can be manipulated with the init/set/
   destroyComponents() macros  }

  CRYPT_PKCINFO_RSA = record
    { Status information }
    isPublicKey: Integer;                             { Whether this is a public or private key }

    { Public components }
    n: array[0..CRYPT_MAX_PKCSIZE - 1] of byte;       { Modulus }
    nLen: Integer;                                    { Length of modulus in bits }
    e: array[0..CRYPT_MAX_PKCSIZE - 1] of byte;       { Public exponent }
    eLen: Integer;                                    { Length of public exponent in bits }

    { Private components }
    d: array[0..CRYPT_MAX_PKCSIZE - 1] of byte;       { Private exponent }
    dLen: Integer;                                    { Length of private exponent in bits }
    p: array[0..CRYPT_MAX_PKCSIZE - 1] of byte;       { Prime factor 1 }

⌨️ 快捷键说明

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