📄 cryptkrn.h
字号:
attribute messages is that for improved error checking the data types
that these work with are explicitly specified by the user based on
which function they call to get/set them rather than being implicitly
specified by the attribute ID. Because of the explicit typing, the
handlers have to be able to check to make sure that the actual type
matches what the user specified, so we need one message type for
numeric attributes and one for string attributes */
MESSAGE_GETATTRIBUTE, /* Get numeric object attribute */
MESSAGE_GETATTRIBUTE_S, /* Get string object attribute */
MESSAGE_SETATTRIBUTE, /* Set numeric object attribute */
MESSAGE_SETATTRIBUTE_S, /* Set string object attribute */
MESSAGE_DELETEATTRIBUTE, /* Delete object attribute */
/* General messages. The check message is used for informational
purposes only so that problems (e.g. an attempt to use a public key
where a private key is required) can be reported to the user
immediately as a function parameter error rather than appearing much
later as an object use permission error when the kernel blocks the
access. Final access checking is always still done at the kernel
level to avoid the confused deputy problem */
MESSAGE_COMPARE, /* Compare objs. or obj.properties */
MESSAGE_CHECK, /* Check object info */
MESSAGE_SELFTEST, /* Perform a self-test */
/* Messages sent from the kernel to object message handlers. These never
originate from outside the kernel but are generated in response to
other messages to notify an object of a change in its state */
MESSAGE_CHANGENOTIFY, /* Notification of obj.status chge.*/
/* Object-type-specific messages */
MESSAGE_CTX_ENCRYPT, /* Context: Action = encrypt */
MESSAGE_CTX_DECRYPT, /* Context: Action = decrypt */
MESSAGE_CTX_SIGN, /* Context: Action = sign */
MESSAGE_CTX_SIGCHECK, /* Context: Action = sigcheck */
MESSAGE_CTX_HASH, /* Context: Action = hash */
MESSAGE_CTX_GENKEY, /* Context: Generate a key */
MESSAGE_CTX_GENIV, /* Context: Generate an IV */
MESSAGE_CRT_SIGN, /* Cert: Action = sign cert */
MESSAGE_CRT_SIGCHECK, /* Cert: Action = check/verify cert */
MESSAGE_CRT_EXPORT, /* Cert: Export encoded cert data */
MESSAGE_DEV_QUERYCAPABILITY,/* Device: Query capability */
MESSAGE_DEV_EXPORT, /* Device: Action = export key */
MESSAGE_DEV_IMPORT, /* Device: Action = import key */
MESSAGE_DEV_SIGN, /* Device: Action = sign */
MESSAGE_DEV_SIGCHECK, /* Device: Action = sig.check */
MESSAGE_DEV_DERIVE, /* Device: Action = derive key */
MESSAGE_DEV_CREATEOBJECT, /* Device: Create object */
MESSAGE_DEV_CREATEOBJECT_INDIRECT, /* Device: Create obj.from data */
MESSAGE_ENV_PUSHDATA, /* Envelope: Push data */
MESSAGE_ENV_POPDATA, /* Envelope: Pop data */
MESSAGE_KEY_GETKEY, /* Keyset: Instantiate ctx/cert */
MESSAGE_KEY_SETKEY, /* Keyset: Add ctx/cert */
MESSAGE_KEY_DELETEKEY, /* Keyset: Delete key/cert */
MESSAGE_KEY_GETFIRSTCERT, /* Keyset: Get first cert in sequence */
MESSAGE_KEY_GETNEXTCERT, /* Keyset: Get next cert in sequence */
MESSAGE_KEY_CERTMGMT, /* Keyset: Cert management */
MESSAGE_USER_USERMGMT, /* User: User management */
MESSAGE_USER_TRUSTMGMT, /* User: Trust management */
MESSAGE_LAST, /* Last valid message type */
/* Internal-object versions of the above messages */
IMESSAGE_DESTROY = MKINTERNAL( MESSAGE_DESTROY ),
IMESSAGE_INCREFCOUNT = MKINTERNAL( MESSAGE_INCREFCOUNT ),
IMESSAGE_DECREFCOUNT = MKINTERNAL( MESSAGE_DECREFCOUNT ),
IMESSAGE_GETDEPENDENT = MKINTERNAL( MESSAGE_GETDEPENDENT ),
IMESSAGE_SETDEPENDENT = MKINTERNAL( MESSAGE_SETDEPENDENT ),
IMESSAGE_CLONE = MKINTERNAL( MESSAGE_CLONE ),
IMESSAGE_GETATTRIBUTE = MKINTERNAL( MESSAGE_GETATTRIBUTE ),
IMESSAGE_GETATTRIBUTE_S = MKINTERNAL( MESSAGE_GETATTRIBUTE_S ),
IMESSAGE_SETATTRIBUTE = MKINTERNAL( MESSAGE_SETATTRIBUTE ),
IMESSAGE_SETATTRIBUTE_S = MKINTERNAL( MESSAGE_SETATTRIBUTE_S ),
IMESSAGE_DELETEATTRIBUTE = MKINTERNAL( MESSAGE_DELETEATTRIBUTE ),
IMESSAGE_COMPARE = MKINTERNAL( MESSAGE_COMPARE ),
IMESSAGE_CHECK = MKINTERNAL( MESSAGE_CHECK ),
IMESSAGE_SELFTEST = MKINTERNAL( MESSAGE_SELFTEST ),
IMESSAGE_CHANGENOTIFY = MKINTERNAL( MESSAGE_CHANGENOTIFY ),
IMESSAGE_CTX_ENCRYPT = MKINTERNAL( MESSAGE_CTX_ENCRYPT ),
IMESSAGE_CTX_DECRYPT = MKINTERNAL( MESSAGE_CTX_DECRYPT ),
IMESSAGE_CTX_SIGN = MKINTERNAL( MESSAGE_CTX_SIGN ),
IMESSAGE_CTX_SIGCHECK = MKINTERNAL( MESSAGE_CTX_SIGCHECK ),
IMESSAGE_CTX_HASH = MKINTERNAL( MESSAGE_CTX_HASH ),
IMESSAGE_CTX_GENKEY = MKINTERNAL( MESSAGE_CTX_GENKEY ),
IMESSAGE_CTX_GENIV = MKINTERNAL( MESSAGE_CTX_GENIV ),
IMESSAGE_CRT_SIGN = MKINTERNAL( MESSAGE_CRT_SIGN ),
IMESSAGE_CRT_SIGCHECK = MKINTERNAL( MESSAGE_CRT_SIGCHECK ),
IMESSAGE_CRT_EXPORT = MKINTERNAL( MESSAGE_CRT_EXPORT ),
IMESSAGE_DEV_QUERYCAPABILITY = MKINTERNAL( MESSAGE_DEV_QUERYCAPABILITY ),
IMESSAGE_DEV_EXPORT = MKINTERNAL( MESSAGE_DEV_EXPORT ),
IMESSAGE_DEV_IMPORT = MKINTERNAL( MESSAGE_DEV_IMPORT ),
IMESSAGE_DEV_SIGN = MKINTERNAL( MESSAGE_DEV_SIGN ),
IMESSAGE_DEV_SIGCHECK = MKINTERNAL( MESSAGE_DEV_SIGCHECK ),
IMESSAGE_DEV_DERIVE = MKINTERNAL( MESSAGE_DEV_DERIVE ),
IMESSAGE_DEV_CREATEOBJECT = MKINTERNAL( MESSAGE_DEV_CREATEOBJECT ),
IMESSAGE_DEV_CREATEOBJECT_INDIRECT = MKINTERNAL( MESSAGE_DEV_CREATEOBJECT_INDIRECT ),
IMESSAGE_ENV_PUSHDATA = MKINTERNAL( MESSAGE_ENV_PUSHDATA ),
IMESSAGE_ENV_POPDATA = MKINTERNAL( MESSAGE_ENV_POPDATA ),
IMESSAGE_KEY_GETKEY = MKINTERNAL( MESSAGE_KEY_GETKEY ),
IMESSAGE_KEY_SETKEY = MKINTERNAL( MESSAGE_KEY_SETKEY ),
IMESSAGE_KEY_DELETEKEY = MKINTERNAL( MESSAGE_KEY_DELETEKEY ),
IMESSAGE_KEY_GETFIRSTCERT = MKINTERNAL( MESSAGE_KEY_GETFIRSTCERT ),
IMESSAGE_KEY_GETNEXTCERT = MKINTERNAL( MESSAGE_KEY_GETNEXTCERT ),
IMESSAGE_KEY_CERTMGMT = MKINTERNAL( MESSAGE_KEY_CERTMGMT ),
IMESSAGE_USER_USERMGMT = MKINTERNAL( MESSAGE_USER_USERMGMT ),
IMESSAGE_USER_TRUSTMGMT = MKINTERNAL( MESSAGE_USER_TRUSTMGMT ),
IMESSAGE_LAST = MKINTERNAL( MESSAGE_LAST )
} MESSAGE_TYPE;
/* The properties that MESSAGE_COMPARE can compare */
typedef enum {
MESSAGE_COMPARE_NONE, /* No comparison */
MESSAGE_COMPARE_HASH, /* Compare hash value */
MESSAGE_COMPARE_KEYID, /* Compare key IDs */
MESSAGE_COMPARE_KEYID_PGP, /* Compare PGP key IDs */
MESSAGE_COMPARE_KEYID_OPENPGP, /* Compare OpenPGP key IDs */
MESSAGE_COMPARE_SUBJECT, /* Compare subject */
MESSAGE_COMPARE_ISSUERANDSERIALNUMBER, /* Compare iAndS */
MESSAGE_COMPARE_FINGERPRINT, /* Compare cert.fingerprint */
MESSAGE_COMPARE_CERTOBJ, /* Compare cert objects */
MESSAGE_COMPARE_LAST /* Last possible compare type */
} MESSAGE_COMPARE_TYPE;
/* The checks that MESSAGE_CHECK performs. There are a number of variations
of the checking we can perform, either the object is initialised in a
state to perform the required action (meaning that it has to be in the
high state), the object is ready to be initialised for the required
action, for example an encryption context about to have a key loaded for
encryption (meaning that it has to be in the low state), or the check is
on a passive container object that constrains another object (for example
a cert being attached to a context) for which the state isn't important
in this instance. Usually we check to make sure that the cert is in the
high state, but when a cert is being created/imported it may not be in
the high state yet at the time the check is being carried out */
typedef enum {
/* Standard checks, for which the object must be initialised in a state
to perform this operation */
MESSAGE_CHECK_NONE, /* No check */
MESSAGE_CHECK_PKC, /* Public or private key context */
MESSAGE_CHECK_PKC_PRIVATE, /* Private key context */
MESSAGE_CHECK_PKC_ENCRYPT, /* Public encryption context */
MESSAGE_CHECK_PKC_DECRYPT, /* Private decryption context */
MESSAGE_CHECK_PKC_SIGCHECK, /* Public signature check context */
MESSAGE_CHECK_PKC_SIGN, /* Private signature context */
MESSAGE_CHECK_PKC_KA_EXPORT, /* Key agreement - export context */
MESSAGE_CHECK_PKC_KA_IMPORT, /* Key agreement - import context */
MESSAGE_CHECK_CRYPT, /* Conventional encryption context */
MESSAGE_CHECK_HASH, /* Hash context */
MESSAGE_CHECK_MAC, /* MAC context */
/* Checks that an object is ready to be initialised to perform this
operation */
MESSAGE_CHECK_CRYPT_READY, /* Ready for conv.encr. init */
MESSAGE_CHECK_MAC_READY, /* Ready for MAC init */
MESSAGE_CHECK_KEYGEN_READY, /* Ready for key generation */
/* Checks on purely passive container objects that constrain action
objects */
MESSAGE_CHECK_PKC_ENCRYPT_AVAIL,/* Encryption available */
MESSAGE_CHECK_PKC_DECRYPT_AVAIL,/* Decryption available */
MESSAGE_CHECK_PKC_SIGCHECK_AVAIL, /* Signature check available */
MESSAGE_CHECK_PKC_SIGN_AVAIL, /* Signature available */
MESSAGE_CHECK_PKC_KA_EXPORT_AVAIL, /* Key agreement - export available */
MESSAGE_CHECK_PKC_KA_IMPORT_AVAIL, /* Key agreement - import available */
/* Misc.checks for meta-capabilities not directly connected with object
actions. The CA check applies to both PKC contexts and certificates,
when the message is forwarded to a dependent CA cert it's forwarded
as the internal MESSAGE_CHECK_CACERT check type, since
MESSAGE_CHECK_CA requires both a PKC context and a certificate */
MESSAGE_CHECK_CA, /* Cert signing capability */
MESSAGE_CHECK_CACERT, /* Internal value used for CA checks */
MESSAGE_CHECK_LAST /* Last possible check type */
} MESSAGE_CHECK_TYPE;
/* The notifications that a MESSAGE_CHANGENOTIFY can deliver */
typedef enum {
MESSAGE_CHANGENOTIFY_NONE, /* No notification */
MESSAGE_CHANGENOTIFY_STATE, /* Object should save/rest.int.state */
MESSAGE_CHANGENOTIFY_OBJHANDLE, /* Object cloned, handle changed */
MESSAGE_CHANGENOTIFY_OWNERHANDLE, /* Object cloned, owner handle changed */
MESSAGE_CHANGENOTIFY_LAST /* Last possible notification type */
} MESSAGE_CHANGENOTIFY_TYPE;
/* The operations that a MESSAGE_USER_USERMGMT can perform */
typedef enum {
MESSAGE_USERMGMT_NONE, /* No operation */
MESSAGE_USERMGMT_ZEROISE, /* Zeroise users */
MESSAGE_USERMGMT_LAST /* Last possible operation type */
} MESSAGE_USERMGMT_TYPE;
/* The operations that a MESSAGE_USER_TRUSTMGMT can perform */
typedef enum {
MESSAGE_TRUSTMGMT_NONE, /* No operation */
MESSAGE_TRUSTMGMT_ADD, /* Add trusted cert */
MESSAGE_TRUSTMGMT_DELETE, /* Delete trusted cert */
MESSAGE_TRUSTMGMT_CHECK, /* Check trust status of cert */
MESSAGE_TRUSTMGMT_GETISSUER, /* Get trusted issuer cert */
MESSAGE_TRUSTMGMT_LAST /* Last possible operation type */
} MESSAGE_TRUSTMGMT_TYPE;
/* Options for the MESSAGE_SETDEPENDENT message */
typedef enum {
SETDEP_OPTION_NONE, /* No option */
SETDEP_OPTION_NOINCREF, /* Don't inc.dep.objs reference count */
SETDEP_OPTION_INCREF, /* Increment dep.objs reference count */
SETDEP_OPTION_LAST /* Last possible option type */
} MESSAGE_SETDEPENDENT_TYPE;
/* When getting/setting string data that consists of (value, length) pairs,
we pass a pointer to a value-and-length structure rather than a pointer to
the data itself */
typedef struct {
BUFFER_FIXED( length ) \
void *data; /* Data */
int length; /* Length */
} MESSAGE_DATA;
#define setMessageData( msgDataPtr, dataPtr, dataLength ) \
{ \
( msgDataPtr )->data = ( dataPtr ); \
( msgDataPtr )->length = ( dataLength ); \
}
/* Some messages communicate standard data values that are used again and
again, so we predefine values for these that can be used globally */
#define MESSAGE_VALUE_TRUE ( ( void * ) &messageValueTrue )
#define MESSAGE_VALUE_FALSE ( ( void * ) &messageValueFalse )
#define MESSAGE_VALUE_OK ( ( void * ) &messageValueCryptOK )
#define MESSAGE_VALUE_ERROR ( ( void * ) &messageValueCryptError )
#define MESSAGE_VALUE_UNUSED ( ( void * ) &messageValueCryptUnused )
#define MESSAGE_VALUE_DEFAULT ( ( void * ) &messageValueCryptUseDefault )
#define MESSAGE_VALUE_CURSORFIRST ( ( void * ) &messageValueCursorFirst )
#define MESSAGE_VALUE_CURSORNEXT ( ( void * ) &messageValueCursorNext )
#define MESSAGE_VALUE_CURSORPREVIOUS ( ( void * ) &messageValueCursorPrevious )
#define MESSAGE_VALUE_CURSORLAST ( ( void * ) &messageValueCursorLast )
extern const int messageValueTrue, messageValueFalse;
extern const int messageValueCryptOK, messageValueCryptError;
extern const int messageValueCryptUnused, messageValueCryptUseDefault;
extern const int messageValueCursorFirst, messageValueCursorNext;
extern const int messageValueCursorPrevious, messageValueCursorLast;
/* Check for membership within an attribute class */
#define isAttribute( attribute ) \
( ( attribute ) > CRYPT_ATTRIBUTE_NONE && \
( attribute ) < CRYPT_ATTRIBUTE_LAST )
#define isInternalAttribute( attribute ) \
( ( attribute ) > CRYPT_IATTRIBUTE_FIRST && \
( attribute ) < CRYPT_IATTRIBUTE_LAST )
/* Check whether a message is in a given message class, used in object
message handlers */
#define isAttributeMessage( message ) \
( ( message ) >= MESSAGE_GETATTRIBUTE && \
( message ) <= MESSAGE_DELETEATTRIBUTE )
#define isActionMessage( message ) \
( ( message ) >= MESSAGE_CTX_ENCRYPT && \
( message ) <= MESSAGE_CTX_HASH )
#define isMechanismActionMessage( message ) \
( ( message ) >= MESSAGE_DEV_EXPORT && \
( message ) <= MESSAGE_DEV_DERIVE )
/* The following handles correspond to built-in fixed object types that are
available throughout the architecture. Currently there are two objects,
an internal system object that encapsulates the built-in RNG and the
built-in mechanism types (if this ever becomes a bottleneck the two can be
separated into different objects) and a default user object which is used
when there are no explicit user objects being employed */
#define SYSTEM_OBJECT_HANDLE 0 /* Internal system object */
#define DEFAULTUSER_OBJECT_HANDLE 1 /* Default user object */
#define NO_SYSTEM_OBJECTS 2 /* Total number of system objects */
/* We limit the maximum number of objects to a sensible value to prevent
deliberate/accidental DoS attacks. The following represents about 32MB
of object data, which should be a good indication that there are more
objects present than there should be */
#define MAX_OBJECTS 16384
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -