softObject.h revision 1f49a79a97c031bfe0722e2e812dd0e192355be5
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SOFTOBJECT_H
#define _SOFTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <pthread.h>
#include "softKeystoreUtil.h"
#include "softSession.h"
#define SOFTTOKEN_OBJECT_MAGIC 0xECF0B002
#define SOFT_CREATE_OBJ 1
#define SOFT_GEN_KEY 2
/* CKM_SHA1_KEY_DERIVATION */
#define SOFT_UNWRAP_KEY 5
typedef struct biginteger {
} biginteger_t;
/*
* Secret key Struct
*/
typedef struct secret_key_obj {
void *key_sched;
/*
* PKCS11: RSA Public Key Object Attributes
*/
typedef struct rsa_pub_key {
/*
* PKCS11: DSA Public Key Object Attributes
*/
typedef struct dsa_pub_key {
/*
* PKCS11: Diffie-Hellman Public Key Object Attributes
*/
typedef struct dh_pub_key {
} dh_pub_key_t;
/*
* PKCS11: X9.42 Diffie-Hellman Public Key Object Attributes
*/
typedef struct dh942_pub_key {
/*
* PKCS11: Elliptic Curve Public Key Object Attributes
*/
typedef struct ec_pub_key {
} ec_pub_key_t;
/*
* Public Key Main Struct
*/
typedef struct public_key_obj {
union {
} key_type_u;
/*
* PKCS11: RSA Private Key Object Attributes
*/
typedef struct rsa_pri_key {
/*
* PKCS11: DSA Private Key Object Attributes
*/
typedef struct dsa_pri_key {
/*
* PKCS11: Diffie-Hellman Private Key Object Attributes
*/
typedef struct dh_pri_key {
} dh_pri_key_t;
/*
* PKCS11: X9.42 Diffie-Hellman Private Key Object Attributes
*/
typedef struct dh942_pri_key {
/*
* PKCS11: Elliptic Curve Private Key Object Attributes
*/
typedef struct ec_pri_key {
} ec_pri_key_t;
/*
* Private Key Main Struct
*/
typedef struct private_key_obj {
union {
} key_type_u;
/*
* PKCS11: DSA Domain Parameters Object Attributes
*/
typedef struct dsa_dom_key {
/*
* PKCS11: Diffie-Hellman Domain Parameters Object Attributes
*/
typedef struct dh_dom_key {
} dh_dom_key_t;
/*
* PKCS11: X9.42 Diffie-Hellman Domain Parameters Object Attributes
*/
typedef struct dh942_dom_key {
/*
* Domain Parameters Main Struct
*/
typedef struct domain_obj {
union {
} key_type_u;
} domain_obj_t;
typedef struct cert_attr_type {
} cert_attr_t;
/*
* X.509 Public Key Certificate Structure.
* This structure contains only the attributes that are
* NOT modifiable after creation.
* ID, ISSUER, and SUBJECT attributes are kept in the extra_attrlistp
* record.
*/
typedef struct x509_cert {
} x509_cert_t;
/*
* X.509 Attribute Certificiate Structure
* This structure contains only the attributes that are
* NOT modifiable after creation.
* AC_ISSUER, SERIAL_NUMBER, and ATTR_TYPES are kept in the
* extra_attrlistp record so they may be modified.
*/
typedef struct x509_attr_cert {
/*
* Certificate Object Main Struct
*/
typedef struct certificate_obj {
union {
} cert_type_u;
/*
* This structure is used to hold the attributes in the
* Extra Attribute List.
*/
typedef struct attribute_info {
struct attribute_info *next;
typedef attribute_info_t *CK_ATTRIBUTE_INFO_PTR;
/*
* This is the main structure of the Objects.
*/
typedef struct object {
/* Generic common fields. Always present */
/* Fields for access and arbitration */
/* Extra non-boolean attribute list */
/* For each object, only one of these object classes is presented */
union {
/* Session handle that the object belongs to */
typedef struct find_context {
/*
* The following structure is used to link the to-be-freed session
* objects into a linked list. The objects on this linked list have
* not yet been freed via free() after C_DestroyObject() call; instead
* they are added to this list. The actual free will take place when
* the number of objects queued reaches MAX_OBJ_TO_BE_FREED, at which
* time the first object in the list will be freed.
*/
#define MAX_OBJ_TO_BE_FREED 300
typedef struct obj_to_be_freed_list {
/*
* Object type
*/
#define SESSION_PUBLIC 0 /* CKA_TOKEN = 0, CKA_PRIVATE = 0 */
#define TOKEN_OBJECT 2
#define PRIVATE_OBJECT 1
typedef enum {
ALL_TOKEN = 0,
PUBLIC_TOKEN = 1,
PRIVATE_TOKEN = 2
#define IS_TOKEN_OBJECT(objp) \
/*
* Types associated with copying object's content
*/
/* the original session handle */
/*
* The following definitions are the shortcuts
*/
/*
* RSA Public Key Object Attributes
*/
#define OBJ_PUB(o) \
((o)->object_class_u.public_key)
#define KEY_PUB_RSA(k) \
&((k)->key_type_u.rsa_pub_key)
#define OBJ_PUB_RSA_MOD(o) \
#define KEY_PUB_RSA_MOD(k) \
#define OBJ_PUB_RSA_PUBEXPO(o) \
#define KEY_PUB_RSA_PUBEXPO(k) \
#define OBJ_PUB_RSA_MOD_BITS(o) \
#define KEY_PUB_RSA_MOD_BITS(k) \
/*
* DSA Public Key Object Attributes
*/
#define KEY_PUB_DSA(k) \
&((k)->key_type_u.dsa_pub_key)
#define OBJ_PUB_DSA_PRIME(o) \
#define KEY_PUB_DSA_PRIME(k) \
#define OBJ_PUB_DSA_SUBPRIME(o) \
#define KEY_PUB_DSA_SUBPRIME(k) \
#define OBJ_PUB_DSA_BASE(o) \
#define KEY_PUB_DSA_BASE(k) \
#define OBJ_PUB_DSA_VALUE(o) \
#define KEY_PUB_DSA_VALUE(k) \
/*
* Diffie-Hellman Public Key Object Attributes
*/
#define KEY_PUB_DH(k) \
&((k)->key_type_u.dh_pub_key)
#define OBJ_PUB_DH_PRIME(o) \
#define KEY_PUB_DH_PRIME(k) \
#define OBJ_PUB_DH_BASE(o) \
#define KEY_PUB_DH_BASE(k) \
#define OBJ_PUB_DH_VALUE(o) \
#define KEY_PUB_DH_VALUE(k) \
/*
* X9.42 Diffie-Hellman Public Key Object Attributes
*/
#define KEY_PUB_DH942(k) \
&((k)->key_type_u.dh942_pub_key)
#define OBJ_PUB_DH942_PRIME(o) \
#define KEY_PUB_DH942_PRIME(k) \
#define OBJ_PUB_DH942_BASE(o) \
#define KEY_PUB_DH942_BASE(k) \
#define OBJ_PUB_DH942_SUBPRIME(o) \
#define KEY_PUB_DH942_SUBPRIME(k) \
#define OBJ_PUB_DH942_VALUE(o) \
#define KEY_PUB_DH942_VALUE(k) \
/*
* Elliptic Curve Public Key Object Attributes
*/
#define KEY_PUB_EC(k) \
&((k)->key_type_u.ec_pub_key)
#define OBJ_PUB_EC_POINT(o) \
#define KEY_PUB_EC_POINT(k) \
/*
* RSA Private Key Object Attributes
*/
#define OBJ_PRI(o) \
((o)->object_class_u.private_key)
#define KEY_PRI_RSA(k) \
&((k)->key_type_u.rsa_pri_key)
#define OBJ_PRI_RSA_MOD(o) \
#define KEY_PRI_RSA_MOD(k) \
#define OBJ_PRI_RSA_PUBEXPO(o) \
#define KEY_PRI_RSA_PUBEXPO(k) \
#define OBJ_PRI_RSA_PRIEXPO(o) \
#define KEY_PRI_RSA_PRIEXPO(k) \
#define OBJ_PRI_RSA_PRIME1(o) \
#define KEY_PRI_RSA_PRIME1(k) \
#define OBJ_PRI_RSA_PRIME2(o) \
#define KEY_PRI_RSA_PRIME2(k) \
#define OBJ_PRI_RSA_EXPO1(o) \
#define KEY_PRI_RSA_EXPO1(k) \
#define OBJ_PRI_RSA_EXPO2(o) \
#define KEY_PRI_RSA_EXPO2(k) \
#define OBJ_PRI_RSA_COEF(o) \
#define KEY_PRI_RSA_COEF(k) \
/*
* DSA Private Key Object Attributes
*/
#define KEY_PRI_DSA(k) \
&((k)->key_type_u.dsa_pri_key)
#define OBJ_PRI_DSA_PRIME(o) \
#define KEY_PRI_DSA_PRIME(k) \
#define OBJ_PRI_DSA_SUBPRIME(o) \
#define KEY_PRI_DSA_SUBPRIME(k) \
#define OBJ_PRI_DSA_BASE(o) \
#define KEY_PRI_DSA_BASE(k) \
#define OBJ_PRI_DSA_VALUE(o) \
#define KEY_PRI_DSA_VALUE(k) \
/*
* Diffie-Hellman Private Key Object Attributes
*/
#define KEY_PRI_DH(k) \
&((k)->key_type_u.dh_pri_key)
#define OBJ_PRI_DH_PRIME(o) \
#define KEY_PRI_DH_PRIME(k) \
#define OBJ_PRI_DH_BASE(o) \
#define KEY_PRI_DH_BASE(k) \
#define OBJ_PRI_DH_VALUE(o) \
#define KEY_PRI_DH_VALUE(k) \
#define OBJ_PRI_DH_VAL_BITS(o) \
#define KEY_PRI_DH_VAL_BITS(k) \
/*
* X9.42 Diffie-Hellman Private Key Object Attributes
*/
#define KEY_PRI_DH942(k) \
&((k)->key_type_u.dh942_pri_key)
#define OBJ_PRI_DH942_PRIME(o) \
#define KEY_PRI_DH942_PRIME(k) \
#define OBJ_PRI_DH942_BASE(o) \
#define KEY_PRI_DH942_BASE(k) \
#define OBJ_PRI_DH942_SUBPRIME(o) \
#define KEY_PRI_DH942_SUBPRIME(k) \
#define OBJ_PRI_DH942_VALUE(o) \
#define KEY_PRI_DH942_VALUE(k) \
/*
* Elliptic Curve Private Key Object Attributes
*/
#define KEY_PRI_EC(k) \
&((k)->key_type_u.ec_pri_key)
#define OBJ_PRI_EC_VALUE(o) \
#define KEY_PRI_EC_VALUE(k) \
/*
* DSA Domain Parameters Object Attributes
*/
#define OBJ_DOM(o) \
((o)->object_class_u.domain)
#define KEY_DOM_DSA(k) \
&((k)->key_type_u.dsa_dom_key)
#define OBJ_DOM_DSA_PRIME(o) \
#define KEY_DOM_DSA_PRIME(k) \
#define OBJ_DOM_DSA_SUBPRIME(o) \
#define KEY_DOM_DSA_SUBPRIME(k) \
#define OBJ_DOM_DSA_BASE(o) \
#define KEY_DOM_DSA_BASE(k) \
#define OBJ_DOM_DSA_PRIME_BITS(o) \
/*
* Diffie-Hellman Domain Parameters Object Attributes
*/
#define KEY_DOM_DH(k) \
&((k)->key_type_u.dh_dom_key)
#define OBJ_DOM_DH_PRIME(o) \
#define KEY_DOM_DH_PRIME(k) \
#define OBJ_DOM_DH_BASE(o) \
#define KEY_DOM_DH_BASE(k) \
#define OBJ_DOM_DH_PRIME_BITS(o) \
/*
* X9.42 Diffie-Hellman Domain Parameters Object Attributes
*/
#define KEY_DOM_DH942(k) \
&((k)->key_type_u.dh942_dom_key)
#define OBJ_DOM_DH942_PRIME(o) \
#define KEY_DOM_DH942_PRIME(k) \
#define OBJ_DOM_DH942_BASE(o) \
#define KEY_DOM_DH942_BASE(k) \
#define OBJ_DOM_DH942_SUBPRIME(o) \
#define KEY_DOM_DH942_SUBPRIME(k) \
#define OBJ_DOM_DH942_PRIME_BITS(o) \
#define OBJ_DOM_DH942_SUBPRIME_BITS(o) \
/*
* Secret Key Object Attributes
*/
#define OBJ_SEC(o) \
((o)->object_class_u.secret_key)
#define OBJ_SEC_VALUE(o) \
#define OBJ_SEC_VALUE_LEN(o) \
#define OBJ_KEY_SCHED(o) \
#define OBJ_KEY_SCHED_LEN(o) \
#define OBJ_CERT(o) \
((o)->object_class_u.certificate)
/*
* X.509 Key Certificate object attributes
*/
#define X509_CERT(o) \
#define X509_CERT_SUBJECT(o) \
#define X509_CERT_VALUE(o) \
/*
* X.509 Attribute Certificate object attributes
*/
#define X509_ATTR_CERT(o) \
#define X509_ATTR_CERT_OWNER(o) \
#define X509_ATTR_CERT_VALUE(o) \
/*
* key related attributes with CK_BBOOL data type
*/
#define DERIVE_BOOL_ON 0x00000001
#define LOCAL_BOOL_ON 0x00000002
#define SENSITIVE_BOOL_ON 0x00000004
#define SECONDARY_AUTH_BOOL_ON 0x00000008
#define ENCRYPT_BOOL_ON 0x00000010
#define DECRYPT_BOOL_ON 0x00000020
#define SIGN_BOOL_ON 0x00000040
#define SIGN_RECOVER_BOOL_ON 0x00000080
#define VERIFY_BOOL_ON 0x00000100
#define VERIFY_RECOVER_BOOL_ON 0x00000200
#define WRAP_BOOL_ON 0x00000400
#define UNWRAP_BOOL_ON 0x00000800
#define TRUSTED_BOOL_ON 0x00001000
#define EXTRACTABLE_BOOL_ON 0x00002000
#define ALWAYS_SENSITIVE_BOOL_ON 0x00004000
#define NEVER_EXTRACTABLE_BOOL_ON 0x00008000
#define NOT_MODIFIABLE_BOOL_ON 0x00010000
#define PUBLIC_KEY_DEFAULT (ENCRYPT_BOOL_ON|\
#define PRIVATE_KEY_DEFAULT (DECRYPT_BOOL_ON|\
#define SECRET_KEY_DEFAULT (ENCRYPT_BOOL_ON|\
/*
* MAX_KEY_ATTR_BUFLEN
* The maximum buffer size needed for public or private key attributes
* should be 514 bytes. Just to be safe we give a little more space.
*/
#define MAX_KEY_ATTR_BUFLEN 1024
/*
* Flag definitions for obj_delete_sync
*/
/* count to become zero */
/*
* This macro is used to type cast an object handle to a pointer to
* the object struct. Also, it checks to see if the object struct
* is tagged with an object magic number. This is to detect when an
* application passes a bogus object pointer.
* Also, it checks to see if the object is in the deleting state that
* another thread is performing. If not, increment the object reference
* count by one. This is to prevent this object from being deleted by
* other thread.
*/
} else { \
REFCNT_CODE; \
} else { \
} \
} \
}
#define OBJ_REFRELE(object_p) { \
if ((--object_p->obj_refcnt) == 0 && \
} \
}
/*
* Function Prototypes.
*/
uint32_t *);
uint32_t *);
/* Token object related function prototypes */
#ifdef __cplusplus
}
#endif
#endif /* _SOFTOBJECT_H */