Lines Matching refs:object

135 meta_clone_template_setup(meta_object_t *object,
142 * by the object manager.
165 * If there are still any token object in the list, need to
180 * successful, a reader-lock on the object will be held to indicate
185 meta_handle2object(CK_OBJECT_HANDLE hObject, meta_object_t **object)
191 *object = NULL;
201 *object = NULL;
207 *object = tmp_object;
215 * Creates a new metaobject, but does not yet add it to the object list.
216 * Once the caller has finished initializing the object (by setting
217 * object attributes), meta_object_add should be called. This two-step
218 * process prevents others from seeing the object until fully intitialized.
222 meta_object_alloc(meta_session_t *session, meta_object_t **object)
227 /* Allocate memory for the object. */
247 /* Initialize the object fields. */
255 *object = new_object;
265 * being kept in the metaslot object. The following 4 attributes
276 meta_object_t *object)
278 CK_BBOOL is_sensitive = object->isSensitive;
279 CK_BBOOL is_extractable = object->isExtractable;
293 if (object->isFreeObject != FREE_ENABLED) {
304 if (object->isFreeObject <= FREE_DISABLED) {
310 is_private = object->isPrivate;
334 if (object->isFreeObject <= FREE_DISABLED) {
342 * time we've looked at the object
344 if (object->isFreeObject == FREE_UNCHECKED) {
355 if (object->isFreeObject == FREE_UNCHECKED) {
366 object->isFreeObject = FREE_DISABLED;
378 if (object->isFreeObject == FREE_UNCHECKED) {
382 object->isFreeObject = FREE_DISABLED;
383 object->isFreeToken = FREE_DISABLED;
386 object->isFreeObject = FREE_ENABLED;
388 object->isFreeToken = FREE_ENABLED;
390 object->isFreeObject = FREE_DISABLED;
396 object->isToken = is_token;
397 object->isPrivate = is_private;
398 object->isSensitive = is_sensitive;
399 object->isExtractable = is_extractable;
409 * which would be called to create an object before it is added.
419 * this object, because this object will be destroyed when that session
433 /* Add object to the list of objects. */
443 * Removes the object from the list of valid meta objects. Note
445 * resources (memory, object clones, etc). Cleaning up of
450 meta_object_deactivate(meta_object_t *object, boolean_t have_list_lock,
457 (void) pthread_rwlock_rdlock(&object->object_lock);
460 (void) pthread_mutex_lock(&object->isClosingObject_lock);
461 if (object->isClosingObject) {
463 (void) pthread_mutex_unlock(&object->isClosingObject_lock);
464 OBJRELEASE(object);
467 object->isClosingObject = B_TRUE;
468 (void) pthread_mutex_unlock(&object->isClosingObject_lock);
470 if (object->isToken || (object->isFreeToken == FREE_ENABLED)) {
474 list_lock = &object->creator_session->object_list_lock;
475 list_head = &object->creator_session->object_list_head;
479 * Remove object from the object list. Once removed, it will not
480 * be possible for another thread to begin using the object.
488 object->magic_marker = METASLOT_OBJECT_BADMAGIC;
491 * that will miss the "error cleanup" situation where object is not yet
492 * in the list (object->next == NULL && object->prev == NULL)
494 if (*list_head == object) {
496 if (object->next) {
497 *list_head = object->next;
498 object->next->prev = NULL;
503 } else if (object->next != NULL || object->prev != NULL) {
504 if (object->next) {
505 object->prev->next = object->next;
506 object->next->prev = object->prev;
509 object->prev->next = NULL;
519 * Wait for anyone already using object to finish, by obtaining
522 * up the object.
524 (void) pthread_rwlock_unlock(&object->object_lock); /* rdlock */
525 (void) pthread_rwlock_wrlock(&object->object_lock);
526 (void) pthread_rwlock_unlock(&object->object_lock); /* wrlock */
536 * Performs final object cleanup, releasing any allocated memory and
540 * Caller is assumed to have only reference to object, but should have
544 * object from the underlying slot.
547 meta_object_dealloc(meta_session_t *session, meta_object_t *object,
554 /* First, delete all the clones of this object on other slots. */
560 clone = object->clones[slotnum];
563 if (nukeSourceObj || (!object->isToken &&
564 !(object->isFreeToken == FREE_ENABLED &&
569 object->creator_session->session_flags :
588 object->clones[slotnum] = NULL;
592 dealloc_attributes(object->attributes, object->num_attributes);
594 free(object->clones);
595 free(object->tried_create_clone);
597 if (object->clone_template) {
598 for (i = 0; i < object->clone_template_size; i++) {
599 free(((object->clone_template)[i]).pValue);
601 free(object->clone_template);
604 /* Cleanup remaining object fields. */
605 (void) pthread_rwlock_destroy(&object->object_lock);
606 (void) pthread_rwlock_destroy(&object->attribute_lock);
607 (void) pthread_mutex_destroy(&object->isClosingObject_lock);
608 (void) pthread_mutex_destroy(&object->clone_create_lock);
610 meta_object_delay_free(object);
620 meta_slot_object_alloc(slot_object_t **object) {
627 *object = new_object;
636 meta_slot_object_activate(slot_object_t *object,
639 object->creator_session = creator_session;
645 slot = &(slots[object->creator_session->slotnum]);
648 INSERT_INTO_LIST(slot->tokenobject_list_head, object);
651 slot_session_t *session = object->creator_session;
655 INSERT_INTO_LIST(session->object_list_head, object);
660 * This set tells the slot object that we are in the token list,
661 * but does not cause harm with the metaobject knowing the object
665 object->isToken = isToken;
672 * Remove the specified slot object from the appropriate object list.
675 meta_slot_object_deactivate(slot_object_t *object)
680 if (object->isToken) {
684 slot = &(slots[object->creator_session->slotnum]);
689 list_head = &object->creator_session->object_list_head;
690 list_lock = &object->creator_session->object_list_lock;
694 REMOVE_FROM_LIST(*list_head, object);
703 meta_slot_object_dealloc(slot_object_t *object)
706 free(object);
718 meta_object_copyin(meta_object_t *object)
729 (void) pthread_rwlock_wrlock(&object->attribute_lock);
732 if (object->attributes != NULL) {
736 slot_object = object->clones[object->master_clone_slotnum];
738 rv = meta_get_slot_session(object->master_clone_slotnum, &session,
739 object->creator_session->session_flags);
746 * for this object
749 &(object->attributes), &(object->num_attributes));
757 * Some attributes are required by the given object type.
761 attrs = calloc(object->num_attributes, sizeof (CK_ATTRIBUTE));
768 for (i = 0; i < object->num_attributes; i++) {
770 ((object->attributes[i]).attribute).type;
772 num_attrs = object->num_attributes;
811 if (!object->attributes[i].canBeEmptyValue) {
835 /* store these values into the meta object */
838 object->attributes, object->num_attributes);
845 (void) pthread_rwlock_unlock(&object->attribute_lock);
871 * Create an object to be used for wrapping and unwrapping.
960 * Create a clone of a non-sensitive and extractable object.
965 clone_by_create(meta_object_t *object, slot_object_t *new_clone,
971 if (object->attributes == NULL) {
972 rv = meta_object_copyin(object);
978 if (object->clone_template == NULL) {
979 rv = meta_clone_template_setup(object, object->attributes,
980 object->num_attributes);
986 if (object->isFreeToken == FREE_ENABLED) {
989 object->clone_template,
990 object->clone_template_size, B_FALSE, &truevalue);
993 object->clone_template,
994 object->clone_template_size, B_FALSE, &falsevalue);
999 dst_slot_session->hSession, object->clone_template,
1000 object->clone_template_size, &(new_clone->hObject));
1004 object->clone_template, object->clone_template_size,
1235 * This is called if the object to be cloned is a sensitive object
1238 clone_by_wrap(meta_object_t *object, slot_object_t *new_clone,
1260 slot_object = object->clones[object->master_clone_slotnum];
1262 rv = meta_get_slot_session(object->master_clone_slotnum,
1263 &src_slot_session, object->creator_session->session_flags);
1269 * get the object class and key type for unwrap template
1357 /* explicitly force the unwrapped object to be not sensitive */
1402 * a non-sensitive object, then, get all the attributes
1403 * and create the object in the destination slot
1416 * If the object is wrapping with RSA public key, need
1510 * copy of the object.
1515 meta_object_get_clone(meta_object_t *object,
1523 if (object->clones[slot_num] != NULL) {
1524 *clone = object->clones[slot_num];
1528 if ((object->isSensitive) && (object->isToken) &&
1531 * if the object is a sensitive token object, and auto
1538 /* object attributes can't be extracted and attributes are not known */
1539 if ((!object->isExtractable) && (object->attributes == NULL)) {
1543 (void) pthread_mutex_lock(&object->clone_create_lock);
1546 if (object->clones[slot_num] != NULL) {
1547 *clone = object->clones[slot_num];
1552 * has an attempt already been made to create this object in
1554 * that means this object can't be created in this slot.
1556 if (object->tried_create_clone[slot_num]) {
1557 (void) pthread_mutex_unlock(&object->clone_create_lock);
1565 object->tried_create_clone[slot_num] = B_TRUE;
1568 * If this object is sensitive and we do not have not copied in the
1574 if (object->isSensitive && object->attributes == NULL) {
1575 rv = clone_by_wrap(object, newclone, slot_session);
1577 rv = clone_by_create(object, newclone, slot_session);
1584 object->clones[slot_num] = newclone;
1585 meta_slot_object_activate(newclone, slot_session, object->isToken);
1590 (void) pthread_mutex_unlock(&object->clone_create_lock);
1602 * Create a clone template for the specified object.
1605 meta_clone_template_setup(meta_object_t *object,
1619 (void) pthread_rwlock_rdlock(&object->attribute_lock);
1624 object->isFreeToken == FREE_DISABLED)) {
1640 (void) pthread_rwlock_unlock(&object->attribute_lock);
1645 object->attributes[i].attribute.pValue,
1650 (void) pthread_rwlock_unlock(&object->attribute_lock);
1652 object->clone_template = clone_template;
1653 object->clone_template_size = c;
1663 * Search for an existing metaobject, using the object handle of a clone
1672 meta_object_t *object = NULL, *tmp_obj;
1691 object = tmp_obj;
1696 if (object != NULL) {
1703 if (object != NULL) {
1711 if (object != NULL) {
1712 /* found the object, no need to look further */
1713 return (object);
1729 object = tmp_obj;
1732 if (object != NULL) {
1739 return (object);
1745 meta_object_t *object, *tmp_object;
1748 /* get a write lock on the token object list */
1751 object = tokenobject_list_head;
1753 /* go through each object and delete the one with matching type */
1754 while (object != NULL) {
1755 tmp_object = object->next;
1758 ((object->isPrivate) && (token_type == PRIVATE_TOKEN)) ||
1759 ((!object->isPrivate) && (token_type == PUBLIC_TOKEN))) {
1760 rv = meta_object_deactivate(object, B_TRUE, B_FALSE);
1765 rv = meta_object_dealloc(NULL, object, B_FALSE);
1771 object = tmp_object;
1779 * This function adds the to-be-freed meta object to a linked list.
1782 * object (FIFO) in the list.
1791 /* Add the newly deleted object at the end of the list */
1803 * Free the first object in the list only if
1816 * This function checks if the object passed can be a freeobject.
1823 meta_freeobject_check(meta_session_t *session, meta_object_t *object,
1830 * If key migration is turned off, or the object does not has any of
1835 (!object->isToken && !object->isSensitive &&
1853 * If this call is for an object creation, look inside the template
1888 if (object->isToken)
1889 object->isFreeToken = FREE_ALLOWED_KEY;
1891 object->isFreeToken = FREE_DISABLED;
1893 object->isFreeObject = FREE_ALLOWED_KEY;
1898 object->isFreeToken = FREE_DISABLED;
1899 object->isFreeObject = FREE_DISABLED;
1916 meta_freeobject_set(meta_object_t *object, CK_ATTRIBUTE *tmpl,
1921 if (object->isFreeObject < FREE_ALLOWED_KEY)
1926 if (object->isSensitive) {
1931 object->isFreeObject = FREE_ENABLED;
1935 if (object->isPrivate) {
1940 object->isFreeObject = FREE_ENABLED;
1944 if (object->isToken) {
1945 object->isToken = B_FALSE;
1946 object->isFreeToken = FREE_ENABLED;
1947 object->isFreeObject = FREE_ENABLED;
1949 object->isFreeToken = FREE_DISABLED;
1953 * turned off because the object doesn't not need to be a FreeObject.
1955 if (object->isFreeObject == FREE_ALLOWED_KEY)
1956 object->isFreeObject = FREE_DISABLED;
1961 object->isFreeToken = FREE_DISABLED;
1962 object->isFreeObject = FREE_DISABLED;
1967 * This function sets the CKA_TOKEN flag on a given object template depending
1970 * If the object is a token, but the slot is not the system keystore or has
2005 * is streamlined because we know what the object is and this should
2010 meta_freeobject_clone_maker(meta_session_t *session, meta_object_t *object,
2027 rv = clone_by_create(object, slot_object, slot_session);
2029 object->clones[slotnum] = slot_object;
2040 * This function is called when a object is a FreeObject.
2042 * What we are given is an object that has been generated on a provider
2045 * 2) it was to be a private/sensitive object that we modified so we could know
2050 meta_freeobject_clone(meta_session_t *session, meta_object_t *object)
2057 if (object->attributes == NULL) {
2058 rv = meta_object_copyin(object);
2063 if (object->isPrivate) {
2065 CK_ULONG slotnum = object->master_clone_slotnum;
2073 rv = attribute_set_value(attr, object->attributes,
2074 object->num_attributes);
2087 object->clones[slotnum]->hObject, attr, 1, &new_clone);
2093 * keystore set in metaslot or has object management
2095 * object to metaslot's keystore and let the failover.
2100 if (object->clones[keystore_slotnum] == NULL) {
2102 object, keystore_slotnum);
2107 object->master_clone_slotnum = keystore_slotnum;
2113 /* Remove the old object */
2116 object->clones[slotnum]->hObject);
2123 object->clones[slotnum]->hObject = new_clone;
2125 object->clones[slotnum] = NULL;
2131 if (object->isSensitive) {
2133 CK_ULONG slotnum = object->master_clone_slotnum;
2138 rv = attribute_set_value(attr, object->attributes,
2139 object->num_attributes);
2148 object->clones[slotnum]->hObject, attr, 1);
2154 if (object->isFreeToken == FREE_ENABLED || failover) {
2156 if (object->clones[keystore_slotnum] == NULL) {
2157 rv = meta_freeobject_clone_maker(session, object,
2162 object->master_clone_slotnum = keystore_slotnum;
2164 object->isFreeToken = FREE_ENABLED;
2167 object->isFreeObject = FREE_ENABLED;
2171 object->isFreeToken = FREE_DISABLED;
2172 object->isFreeObject = FREE_DISABLED;