Lines Matching defs:object
50 * - object management
117 #define D_OBJECT 0x00004000 /* object management */
1082 #define DPROV_MAX_ATTR 64 /* max # of attributes per object */
1084 /* object description */
1089 boolean_t do_destroyed; /* object has been destroyed. */
1090 /* keep object around until all */
1094 /* to the object fail. */
1103 #define DPROV_OBJECT_REFHOLD(object) { \
1104 atomic_inc_32(&(object)->do_refcnt); \
1105 ASSERT((object)->do_refcnt != 0); \
1109 * Releases a reference to an object. When the last
1110 * reference is released, the object is freed.
1112 #define DPROV_OBJECT_REFRELE(object) { \
1113 ASSERT((object)->do_refcnt != 0); \
1115 if (atomic_dec_32_nv(&(object)->do_refcnt) == 0) \
1116 dprov_free_object(object); \
1182 * Find object context. Allows the find object init/find/final
1186 crypto_object_id_t fc_ids[DPROV_MAX_OBJECTS]; /* object ids */
1324 /* object management requests */
1577 /* object management helper functions */
3742 uint_t attribute_count, crypto_object_id_t *object,
3756 session_id, 0, template, attribute_count, object, NULL, NULL,
3767 crypto_session_id_t session_id, crypto_object_id_t object,
3782 session_id, object, template, attribute_count, new_object,
3793 crypto_session_id_t session_id, crypto_object_id_t object,
3807 session_id, object, NULL, 0, NULL, NULL, NULL, NULL, 0, NULL,
3818 crypto_session_id_t session_id, crypto_object_id_t object,
3832 session_id, object, NULL, 0, NULL, size, NULL, NULL, 0, NULL,
3843 crypto_session_id_t session_id, crypto_object_id_t object,
3858 softc, req, session_id, object, template, attribute_count,
3869 crypto_session_id_t session_id, crypto_object_id_t object,
3884 softc, req, session_id, object, template, attribute_count,
3977 crypto_object_id_t *object, crypto_req_handle_t req)
3990 session_id, mechanism, template, attribute_count, object, NULL,
5277 * Helper function to submit object management operations to the taskq.
6795 dprov_object_t *object;
6952 object = softc->ds_sessions[session_id]->ds_objects[i];
6953 if (object != NULL && dprov_object_is_private(object)) {
6954 if (!dprov_object_is_token(object))
6955 /* It's a session object, free it */
6956 DPROV_OBJECT_REFRELE(object);
7001 * taskq dispatcher function for object management operations.
7015 dprov_object_t *object;
7033 /* create the object from the specified template */
7043 /* check object id */
7045 (object = session->ds_objects[object_id]) == NULL) {
7051 * Create a new object from the object passed as
7055 object->do_attr, DPROV_MAX_ATTR,
7062 * newly created object, replacing existing ones if needed.
7072 /* destroy the object */
7079 /* get ptr to object */
7088 * the object size really is, here we just return
7089 * the number of possible attributes of the object.
7107 /* get ptr to object */
7109 (object = session->ds_objects[object_id]) == NULL) {
7114 (void) dprov_get_object_attr_boolean(object,
7117 (void) dprov_get_object_attr_ulong(object,
7142 object_idx = dprov_find_attr(object->do_attr,
7145 /* attribute not found in object */
7152 olen = object->do_attr[object_idx].oa_value_len;
7181 bcopy(object->do_attr[object_idx].oa_value,
7195 * newly created object, replacing existing ones if needed.
7206 int so_idx; /* session object index */
7207 int to_idx; /* token object index */
7216 if ((object = session->ds_objects[so_idx]) == NULL)
7221 if (!dprov_attributes_match(object, template,
7226 /* session object attributes matches template */
7232 * Go through the token object. For each token object
7234 * If there was already an session object id assigned
7235 * to that token object, skip it, since it was returned
7237 * assign a new object id for that token object and
7242 if ((object = softc->ds_objects[to_idx]) == NULL)
7247 if (!dprov_attributes_match(object, template,
7252 /* if the the object has been destroyed, skip it */
7253 if (object->do_destroyed)
7256 /* skip object if it cannot be accessed from session */
7257 if (dprov_object_is_private(object) &&
7262 * Is there already a session object id for this
7263 * token object?
7271 /* object found in session table, skip it */
7274 /* find free session slot for this object */
7285 /* add object to session objects table */
7286 session->ds_objects[so_idx] = object;
7287 DPROV_OBJECT_REFHOLD(object);
7289 /* add object to list of objects to return */
7306 /* return the desired number of object ids */
7796 dprov_object_t *object;
7836 /* get ptr to object */
7837 if ((object = session->ds_objects[object_id]) == NULL) {
7842 (void) dprov_get_object_attr_boolean(object,
7850 (void) dprov_get_object_attr_ulong(object,
7855 object_idx = dprov_find_attr(object->do_attr,
7870 object_idx = dprov_find_attr(object->do_attr,
7884 plaintext_key = object->do_attr[object_idx].oa_value;
7885 plaintext_key_len = object->do_attr[object_idx].oa_value_len;
7933 /* all objects must have an object class attribute */
8736 dprov_key_can_use(dprov_object_t *object, dprov_req_type_t req_type)
8741 /* check if object is allowed for specified operation */
8745 rv = dprov_get_object_attr_boolean(object,
8750 rv = dprov_get_object_attr_boolean(object,
8758 rv = dprov_get_object_attr_boolean(object,
8763 rv = dprov_get_object_attr_boolean(object,
8768 rv = dprov_get_object_attr_boolean(object,
8773 rv = dprov_get_object_attr_boolean(object,
8777 rv = dprov_get_object_attr_boolean(object,
8781 rv = dprov_get_object_attr_boolean(object,
8793 rv = dprov_get_object_attr_boolean(object,
8812 * for a key by reference, it looks up the corresponding object and
8864 dprov_object_t *object;
8879 /* check if object id specified by key is valid */
8880 object = softc->ds_sessions[session_id]->
8882 if (object == NULL) {
8887 /* check if object can be used for operation */
8888 if ((ret = dprov_key_can_use(object, req_type)) !=
8892 if ((ret = dprov_get_object_attr_ulong(object,
8896 if ((ret = dprov_get_object_attr_array(object,
8901 if ((dprov_get_object_attr_ulong(object, DPROV_CKA_VALUE_LEN,
8945 dprov_object_t *object;
8953 /* check if object id specified by key is valid */
8954 object = softc->ds_sessions[session_id]->
8956 if (object == NULL) {
8961 /* check if object can be used for operation */
8962 if ((ret = dprov_key_can_use(object, req_type)) !=
8966 ret_key->ck_attrs = object->do_attr;
8998 * Given the given object template and session, return whether
8999 * an object can be created from that template according to the
9016 /* it's a private object */
9019 * Cannot create private object with SO or public
9026 /* all objects must have an object class attribute */
9103 * Create an object from the specified template. Checks whether the
9104 * object can be created according to its attributes and the state
9105 * of the session. The new session object id is returned. If the
9106 * object is a token object, it is added to the per-instance object
9115 dprov_object_t *object;
9133 /* verify that object can be created */
9139 /* allocate new object */
9140 object = kmem_zalloc(sizeof (dprov_object_t), KM_SLEEP);
9141 if (object == NULL)
9144 /* is it a token object? */
9149 /* token object, add it to the per-instance object table */
9156 softc->ds_objects[i] = object;
9157 object->do_token_idx = i;
9158 DPROV_OBJECT_REFHOLD(object);
9161 /* add object to session object table */
9166 /* no more session object slots */
9167 DPROV_OBJECT_REFRELE(object);
9170 session->ds_objects[i] = object;
9171 DPROV_OBJECT_REFHOLD(object);
9174 /* initialize object from template */
9189 object->do_attr[oattr].oa_type = type;
9190 object->do_attr[oattr].oa_value_len = new_len;
9192 object->do_attr[oattr].oa_value = kmem_zalloc(new_len,
9202 object->do_attr[oattr].oa_value, new_len);
9208 object->do_attr[oattr].oa_type = DPROV_CKA_EXTRACTABLE;
9209 object->do_attr[oattr].oa_value_len = 1;
9210 object->do_attr[oattr].oa_value = kmem_alloc(1, KM_SLEEP);
9211 object->do_attr[oattr].oa_value[0] = B_TRUE;
9216 object->do_attr[oattr].oa_type = DPROV_CKA_PRIVATE;
9217 object->do_attr[oattr].oa_value_len = 1;
9218 object->do_attr[oattr].oa_value = kmem_alloc(1, KM_SLEEP);
9219 object->do_attr[oattr].oa_value[0] = B_FALSE;
9224 object->do_attr[oattr].oa_type = DPROV_CKA_TOKEN;
9225 object->do_attr[oattr].oa_value_len = 1;
9226 object->do_attr[oattr].oa_value = kmem_alloc(1, KM_SLEEP);
9227 object->do_attr[oattr].oa_value[0] = B_FALSE;
9232 object->do_attr[oattr].oa_type = DPROV_CKA_SENSITIVE;
9233 object->do_attr[oattr].oa_value_len = 1;
9234 object->do_attr[oattr].oa_value = kmem_alloc(1, KM_SLEEP);
9235 object->do_attr[oattr].oa_value[0] = B_FALSE;
9242 * Checks whether or not the object matches the specified attributes.
9248 dprov_attributes_match(dprov_object_t *object,
9254 int oa_idx; /* object attribute index */
9261 /* find attribute in object */
9263 oa_idx = dprov_find_attr(object->do_attr, DPROV_MAX_ATTR, type);
9266 /* attribute not found in object */
9270 olen = object->do_attr[oa_idx].oa_value_len;
9282 object->do_attr[oa_idx].oa_value, olen) != 0)
9291 * Destroy the object specified by its session and object id.
9297 dprov_object_t *object;
9299 if ((object = session->ds_objects[object_id]) == NULL)
9305 if (dprov_object_is_token(object)) {
9306 if (!object->do_destroyed) {
9307 object->do_destroyed = B_TRUE;
9309 softc->ds_objects[object->do_token_idx] = NULL;
9310 DPROV_OBJECT_REFRELE(object);
9313 "object %p already destroyed\n", (void *)object));
9317 DPROV_OBJECT_REFRELE(object);
9322 dprov_object_can_modify(dprov_object_t *object,
9327 /* all objects should have an object class attribute */
9328 if (dprov_get_object_attr_ulong(object, DPROV_CKA_CLASS,
9374 * Set the attributes specified by the template in the specified object,
9383 dprov_object_t *object;
9388 if ((object = session->ds_objects[object_id]) == NULL)
9393 if ((error = dprov_object_can_modify(object, template, nattr))
9403 /* find attribute in object */
9405 j = dprov_find_attr(object->do_attr, DPROV_MAX_ATTR, type);
9409 kmem_free(object->do_attr[j].oa_value,
9410 object->do_attr[j].oa_value_len);
9414 if (object->do_attr[j].oa_value == NULL)
9424 /* set object attribute value */
9425 object->do_attr[j].oa_value = kmem_alloc(new_len, KM_SLEEP);
9427 object->do_attr[j].oa_value, new_len);
9428 object->do_attr[j].oa_value_len = new_len;
9431 object->do_attr[j].oa_type = type;
9439 * Free the specified object.
9442 dprov_free_object(dprov_object_t *object)
9446 /* free the object attributes values */
9448 if (object->do_attr[i].oa_value != NULL)
9449 kmem_free(object->do_attr[i].oa_value,
9450 object->do_attr[i].oa_value_len);
9452 /* free the object */
9453 kmem_free(object, sizeof (dprov_object_t));
9457 * Checks whether the specified object is a private or public object.
9460 dprov_object_is_private(dprov_object_t *object)
9465 err = dprov_get_object_attr_boolean(object, DPROV_CKA_PRIVATE, &ret);
9475 * Checks whether the specified object is a token or session object.
9478 dprov_object_is_token(dprov_object_t *object)
9483 err = dprov_get_object_attr_boolean(object, DPROV_CKA_TOKEN, &ret);
9500 dprov_get_object_attr_scalar_common(dprov_object_t *object, uint64_t attr_type,
9507 if ((attr_idx = dprov_find_attr(object->do_attr, DPROV_MAX_ATTR,
9511 oa_value_len = object->do_attr[attr_idx].oa_value_len;
9534 bcopy(object->do_attr[attr_idx].oa_value, (uchar_t *)value + offset,
9541 * Get the value of the a boolean attribute from the specified object.
9544 dprov_get_object_attr_boolean(dprov_object_t *object, uint64_t attr_type,
9551 ret = dprov_get_object_attr_scalar_common(object, attr_type, &val, 1);
9559 * Get the value of a ulong_t attribute from the specified object.
9562 dprov_get_object_attr_ulong(dprov_object_t *object, uint64_t attr_type,
9565 return (dprov_get_object_attr_scalar_common(object, attr_type,
9571 * the specified object. Returns CRYPTO_SUCCESS
9576 dprov_get_object_attr_array(dprov_object_t *object, uint64_t attr_type,
9581 if ((attr_idx = dprov_find_attr(object->do_attr, DPROV_MAX_ATTR,
9585 *array = object->do_attr[attr_idx].oa_value;
9586 *len = object->do_attr[attr_idx].oa_value_len;
9762 dprov_object_t *object;
9766 object = session->ds_objects[i];
9767 if (object != NULL) {
9768 DPROV_OBJECT_REFRELE(object);