📄 cryptlib.h
字号:
/* OCSP revocation status */
enum { CRYPT_OCSPSTATUS_NOTREVOKED, CRYPT_OCSPSTATUS_REVOKED,
CRYPT_OCSPSTATUS_UNKNOWN };
/* The amount of detail to include in signatures when signing certificate
objects */
typedef enum {
CRYPT_SIGNATURELEVEL_NONE, /* Include only signature */
CRYPT_SIGNATURELEVEL_SIGNERCERT,/* Include signer cert */
CRYPT_SIGNATURELEVEL_ALL, /* Include all relevant info */
CRYPT_SIGNATURELEVEL_LAST /* Last possible sig.level type */
} CRYPT_SIGNATURELEVEL_TYPE;
/* The certificate export format type, which defines the format in which a
certificate object is exported */
typedef enum {
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_XML_CERTIFICATE, /* XML wrapped cert */
CRYPT_CERTFORMAT_XML_CERTCHAIN, /* XML wrapped cert chain */
#ifdef _CRYPT_DEFINED
CRYPT_ICERTFORMAT_CERTSET, /* SET OF Certificate */
CRYPT_ICERTFORMAT_CERTSEQUENCE, /* SEQUENCE OF Certificate */
CRYPT_ICERTFORMAT_DATA, /* Non-signed object data */
#endif /* CRYPT_DEFINED */
CRYPT_CERTFORMAT_LAST /* Last possible cert.format type */
#ifdef _CRYPT_DEFINED
/* The following is used as an internal format specifier when the format
is autodetected, to tell the base64 decoding code to strip MIME
headers before the base64 data */
, CRYPT_ICERTFORMAT_SMIME_CERTIFICATE,/* S/MIME cert.request or cert chain */
CRYPT_CERTFORMAT_LAST_EXTERNAL = CRYPT_CERTFORMAT_XML_CERTCHAIN + 1
#endif /* _CRYPT_DEFINED */
} CRYPT_CERTFORMAT_TYPE;
/* CMP request types */
typedef enum {
CRYPT_REQUESTTYPE_NONE, /* No request type */
CRYPT_REQUESTTYPE_INITIALISATION, /* Initialisation request */
CRYPT_REQUESTTYPE_INITIALIZATION = CRYPT_REQUESTTYPE_INITIALISATION,
CRYPT_REQUESTTYPE_CERTIFICATE, /* Certification request */
CRYPT_REQUESTTYPE_KEYUPDATE, /* Key update request */
CRYPT_REQUESTTYPE_REVOCATION, /* Cert revocation request */
CRYPT_REQUESTTYPE_PKIBOOT, /* PKIBoot request */
CRYPT_REQUESTTYPE_LAST /* Last possible request type */
} CRYPT_REQUESTTYPE_TYPE;
/* Key ID types */
typedef enum {
CRYPT_KEYID_NONE, /* No key ID type */
CRYPT_KEYID_NAME, /* Key owner name */
CRYPT_KEYID_EMAIL, /* Key owner email address */
#ifdef _CRYPT_DEFINED
/* Internal key ID types */
CRYPT_IKEYID_KEYID, /* SubjectKeyIdentifier/internal ID */
CRYPT_IKEYID_PGPKEYID, /* PGP/OpenPGP key ID */
CRYPT_IKEYID_CERTID, /* Certificate hash */
CRYPT_IKEYID_ISSUERID, /* Hashed issuerAndSerialNumber */
CRYPT_IKEYID_ISSUERANDSERIALNUMBER, /* issuerAndSerialNumber */
#endif /* _CRYPT_DEFINED */
CRYPT_KEYID_LAST /* Last possible key ID type */
#ifdef _CRYPT_DEFINED
, CRYPT_KEYID_LAST_EXTERNAL = CRYPT_IKEYID_KEYID/* Last external key ID */
#endif /* _CRYPT_DEFINED */
} CRYPT_KEYID_TYPE;
/* The encryption object types */
typedef enum {
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 */
} CRYPT_OBJECT_TYPE;
/* Object/attribute error type information */
typedef enum {
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 */
} CRYPT_ERRTYPE_TYPE;
/* Cert store management action type */
typedef enum {
CRYPT_CERTACTION_NONE, /* No cert management 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 */
#ifdef _CRYPT_DEFINED
/* User-settable action types for cert mgmt.actions */
, CRYPT_CERTACTION_FIRST_USER = CRYPT_CERTACTION_ISSUE_CERT,
CRYPT_CERTACTION_LAST_USER = CRYPT_CERTACTION_LAST - 1
#endif /* _CRYPT_DEFINED */
} CRYPT_CERTACTION_TYPE;
/****************************************************************************
* *
* General Constants *
* *
****************************************************************************/
/* The maximum user key size - 2048 bits */
#define CRYPT_MAX_KEYSIZE 256
/* The maximum IV size - 256 bits */
#define CRYPT_MAX_IVSIZE 32
/* The maximum public-key component size - 4096 bits */
#define CRYPT_MAX_PKCSIZE 512
/* The maximum hash size - 256 bits */
#define CRYPT_MAX_HASHSIZE 32
/* The maximum size of a text string (e.g.key owner name) */
#define CRYPT_MAX_TEXTSIZE 64
/* A magic value indicating that the default setting for this parameter
should be used */
#define CRYPT_USE_DEFAULT -10
/* A magic value for unused parameters */
#define CRYPT_UNUSED -11
/* Whether the PKC key is a public or private key */
#define CRYPT_KEYTYPE_PRIVATE 0
#define CRYPT_KEYTYPE_PUBLIC 1
/* The type of information polling to perform to get random seed information */
#define CRYPT_RANDOM_FASTPOLL -10
#define CRYPT_RANDOM_SLOWPOLL -11
/* Cursor positioning codes for certificate/CRL extensions */
#define CRYPT_CURSOR_FIRST -20
#define CRYPT_CURSOR_PREVIOUS -21
#define CRYPT_CURSOR_NEXT -22
#define CRYPT_CURSOR_LAST -23
/* Keyset open options */
typedef enum {
CRYPT_KEYOPT_NONE, /* No options */
CRYPT_KEYOPT_READONLY, /* Open keyset in read-only mode */
CRYPT_KEYOPT_CREATE, /* Create a new keyset */
#ifdef _CRYPT_DEFINED
/* Internal keyset options */
CRYPT_IKEYOPT_EXCLUSIVEACCESS, /* As _NONE but open for exclusive access */
#endif /* _CRYPT_DEFINED */
CRYPT_KEYOPT_LAST /* Last possible key option type */
#ifdef _CRYPT_DEFINED
, CRYPT_KEYOPT_LAST_EXTERNAL = CRYPT_IKEYOPT_EXCLUSIVEACCESS
/* Last external keyset option */
#endif /* _CRYPT_DEFINED */
} CRYPT_KEYOPT_TYPE;
/* The various cryptlib objects - these are just integer handles */
typedef int CRYPT_CERTIFICATE;
typedef int CRYPT_CONTEXT;
typedef int CRYPT_DEVICE;
typedef int CRYPT_ENVELOPE;
typedef int CRYPT_KEYSET;
typedef int CRYPT_SESSION;
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 */
typedef int CRYPT_HANDLE;
/****************************************************************************
* *
* Encryption Data Structures *
* *
****************************************************************************/
/* Results returned from the capability query */
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() */
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 */
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;
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;
/* Mac
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -