Lines Matching defs:object

140 meta_clone_template_setup(meta_object_t *object,
147 * by the object manager.
170 * If there are still any token object in the list, need to
185 * successful, a reader-lock on the object will be held to indicate
190 meta_handle2object(CK_OBJECT_HANDLE hObject, meta_object_t **object)
196 *object = NULL;
206 *object = NULL;
212 *object = tmp_object;
220 * Creates a new metaobject, but does not yet add it to the object list.
221 * Once the caller has finished initializing the object (by setting
222 * object attributes), meta_object_add should be called. This two-step
223 * process prevents others from seeing the object until fully initialized.
227 meta_object_alloc(meta_session_t *session, meta_object_t **object)
232 /* Allocate memory for the object. */
252 /* Initialize the object fields. */
260 *object = new_object;
270 * being kept in the metaslot object. The following 4 attributes
281 meta_object_t *object)
283 CK_BBOOL is_sensitive = object->isSensitive;
284 CK_BBOOL is_extractable = object->isExtractable;
298 if (object->isFreeObject != FREE_ENABLED) {
309 if (object->isFreeObject <= FREE_DISABLED) {
315 is_private = object->isPrivate;
339 if (object->isFreeObject <= FREE_DISABLED) {
347 * time we've looked at the object
349 if (object->isFreeObject == FREE_UNCHECKED) {
360 if (object->isFreeObject == FREE_UNCHECKED) {
371 object->isFreeObject = FREE_DISABLED;
383 if (object->isFreeObject == FREE_UNCHECKED) {
387 object->isFreeObject = FREE_DISABLED;
388 object->isFreeToken = FREE_DISABLED;
391 object->isFreeObject = FREE_ENABLED;
393 object->isFreeToken = FREE_ENABLED;
395 object->isFreeObject = FREE_DISABLED;
401 object->isToken = is_token;
402 object->isPrivate = is_private;
403 object->isSensitive = is_sensitive;
404 object->isExtractable = is_extractable;
414 * which would be called to create an object before it is added.
424 * this object, because this object will be destroyed when that session
438 /* Add object to the list of objects. */
448 * Removes the object from the list of valid meta objects. Note
450 * resources (memory, object clones, etc). Cleaning up of
455 meta_object_deactivate(meta_object_t *object, boolean_t have_list_lock,
462 (void) pthread_rwlock_rdlock(&object->object_lock);
465 (void) pthread_mutex_lock(&object->isClosingObject_lock);
466 if (object->isClosingObject) {
468 (void) pthread_mutex_unlock(&object->isClosingObject_lock);
469 OBJRELEASE(object);
472 object->isClosingObject = B_TRUE;
473 (void) pthread_mutex_unlock(&object->isClosingObject_lock);
475 if (object->isToken || (object->isFreeToken == FREE_ENABLED)) {
479 list_lock = &object->creator_session->object_list_lock;
480 list_head = &object->creator_session->object_list_head;
484 * Remove object from the object list. Once removed, it will not
485 * be possible for another thread to begin using the object.
493 object->magic_marker = METASLOT_OBJECT_BADMAGIC;
496 * that will miss the "error cleanup" situation where object is not yet
497 * in the list (object->next == NULL && object->prev == NULL)
499 if (*list_head == object) {
501 if (object->next) {
502 *list_head = object->next;
503 object->next->prev = NULL;
508 } else if (object->next != NULL || object->prev != NULL) {
509 if (object->next) {
510 object->prev->next = object->next;
511 object->next->prev = object->prev;
514 object->prev->next = NULL;
524 * Wait for anyone already using object to finish, by obtaining
527 * up the object.
529 (void) pthread_rwlock_unlock(&object->object_lock); /* rdlock */
530 (void) pthread_rwlock_wrlock(&object->object_lock);
531 (void) pthread_rwlock_unlock(&object->object_lock); /* wrlock */
541 * Performs final object cleanup, releasing any allocated memory and
545 * Caller is assumed to have only reference to object, but should have
549 * object from the underlying slot.
552 meta_object_dealloc(meta_session_t *session, meta_object_t *object,
559 /* First, delete all the clones of this object on other slots. */
565 clone = object->clones[slotnum];
568 if (nukeSourceObj || (!object->isToken &&
569 !(object->isFreeToken == FREE_ENABLED &&
574 object->creator_session->session_flags :
593 object->clones[slotnum] = NULL;
597 dealloc_attributes(object->attributes, object->num_attributes);
599 free(object->clones);
600 free(object->tried_create_clone);
602 if (object->clone_template) {
603 for (i = 0; i < object->clone_template_size; i++) {
604 free(((object->clone_template)[i]).pValue);
606 free(object->clone_template);
609 /* Cleanup remaining object fields. */
610 (void) pthread_rwlock_destroy(&object->object_lock);
611 (void) pthread_rwlock_destroy(&object->attribute_lock);
612 (void) pthread_mutex_destroy(&object->isClosingObject_lock);
613 (void) pthread_mutex_destroy(&object->clone_create_lock);
615 meta_object_delay_free(object);
627 meta_slot_object_alloc(slot_object_t **object) {
634 *object = new_object;
643 meta_slot_object_activate(slot_object_t *object,
646 object->creator_session = creator_session;
652 slot = &(slots[object->creator_session->slotnum]);
655 INSERT_INTO_LIST(slot->tokenobject_list_head, object);
658 slot_session_t *session = object->creator_session;
662 INSERT_INTO_LIST(session->object_list_head, object);
667 * This set tells the slot object that we are in the token list,
668 * but does not cause harm with the metaobject knowing the object
672 object->isToken = isToken;
679 * Remove the specified slot object from the appropriate object list.
682 meta_slot_object_deactivate(slot_object_t *object)
687 if (object->isToken) {
691 slot = &(slots[object->creator_session->slotnum]);
696 list_head = &object->creator_session->object_list_head;
697 list_lock = &object->creator_session->object_list_lock;
701 REMOVE_FROM_LIST(*list_head, object);
710 meta_slot_object_dealloc(slot_object_t *object)
713 free(object);
725 meta_object_copyin(meta_object_t *object)
736 (void) pthread_rwlock_wrlock(&object->attribute_lock);
739 if (object->attributes != NULL) {
743 slot_object = object->clones[object->master_clone_slotnum];
745 rv = meta_get_slot_session(object->master_clone_slotnum, &session,
746 object->creator_session->session_flags);
753 * for this object
756 &(object->attributes), &(object->num_attributes));
764 * Some attributes are required by the given object type.
768 attrs = calloc(object->num_attributes, sizeof (CK_ATTRIBUTE));
775 for (i = 0; i < object->num_attributes; i++) {
777 ((object->attributes[i]).attribute).type;
779 num_attrs = object->num_attributes;
818 if (!object->attributes[i].canBeEmptyValue) {
842 /* store these values into the meta object */
845 object->attributes, object->num_attributes);
852 (void) pthread_rwlock_unlock(&object->attribute_lock);
878 * Create an object to be used for wrapping and unwrapping.
967 * Create a clone of a non-sensitive and extractable object.
972 clone_by_create(meta_object_t *object, slot_object_t *new_clone,
978 if (object->attributes == NULL) {
979 rv = meta_object_copyin(object);
985 if (object->clone_template == NULL) {
986 rv = meta_clone_template_setup(object, object->attributes,
987 object->num_attributes);
993 if (object->isFreeToken == FREE_ENABLED) {
996 object->clone_template,
997 object->clone_template_size, B_FALSE, &truevalue);
1000 object->clone_template,
1001 object->clone_template_size, B_FALSE, &falsevalue);
1006 dst_slot_session->hSession, object->clone_template,
1007 object->clone_template_size, &(new_clone->hObject));
1011 object->clone_template, object->clone_template_size,
1242 * This is called if the object to be cloned is a sensitive object
1245 clone_by_wrap(meta_object_t *object, slot_object_t *new_clone,
1267 slot_object = object->clones[object->master_clone_slotnum];
1269 rv = meta_get_slot_session(object->master_clone_slotnum,
1270 &src_slot_session, object->creator_session->session_flags);
1276 * get the object class and key type for unwrap template
1366 /* explicitly force the unwrapped object to be not sensitive */
1411 * a non-sensitive object, then, get all the attributes
1412 * and create the object in the destination slot
1425 * If the object is wrapping with RSA public key, need
1519 * copy of the object.
1524 meta_object_get_clone(meta_object_t *object,
1532 if (object->clones[slot_num] != NULL) {
1533 *clone = object->clones[slot_num];
1537 if ((object->isSensitive) && (object->isToken) &&
1540 * if the object is a sensitive token object, and auto
1547 /* object attributes can't be extracted and attributes are not known */
1548 if ((!object->isExtractable) && (object->attributes == NULL)) {
1552 (void) pthread_mutex_lock(&object->clone_create_lock);
1555 if (object->clones[slot_num] != NULL) {
1556 *clone = object->clones[slot_num];
1561 * has an attempt already been made to create this object in
1563 * that means this object can't be created in this slot.
1565 if (object->tried_create_clone[slot_num]) {
1566 (void) pthread_mutex_unlock(&object->clone_create_lock);
1574 object->tried_create_clone[slot_num] = B_TRUE;
1577 * If this object is sensitive and we do not have not copied in the
1583 if (object->isSensitive && object->attributes == NULL) {
1584 rv = clone_by_wrap(object, newclone, slot_session);
1586 rv = clone_by_create(object, newclone, slot_session);
1593 object->clones[slot_num] = newclone;
1594 meta_slot_object_activate(newclone, slot_session, object->isToken);
1599 (void) pthread_mutex_unlock(&object->clone_create_lock);
1611 * Create a clone template for the specified object.
1614 meta_clone_template_setup(meta_object_t *object,
1628 (void) pthread_rwlock_rdlock(&object->attribute_lock);
1633 object->isFreeToken == FREE_DISABLED)) {
1649 (void) pthread_rwlock_unlock(&object->attribute_lock);
1654 object->attributes[i].attribute.pValue,
1659 (void) pthread_rwlock_unlock(&object->attribute_lock);
1661 object->clone_template = clone_template;
1662 object->clone_template_size = c;
1672 * Search for an existing metaobject, using the object handle of a clone
1681 meta_object_t *object = NULL, *tmp_obj;
1700 object = tmp_obj;
1705 if (object != NULL) {
1712 if (object != NULL) {
1720 if (object != NULL) {
1721 /* found the object, no need to look further */
1722 return (object);
1738 object = tmp_obj;
1741 if (object != NULL) {
1748 return (object);
1754 meta_object_t *object, *tmp_object;
1757 /* get a write lock on the token object list */
1760 object = tokenobject_list_head;
1762 /* go through each object and delete the one with matching type */
1763 while (object != NULL) {
1764 tmp_object = object->next;
1767 ((object->isPrivate) && (token_type == PRIVATE_TOKEN)) ||
1768 ((!object->isPrivate) && (token_type == PUBLIC_TOKEN))) {
1769 rv = meta_object_deactivate(object, B_TRUE, B_FALSE);
1774 rv = meta_object_dealloc(NULL, object, B_FALSE);
1780 object = tmp_object;
1788 * This function adds the to-be-freed meta object to a linked list.
1791 * object (FIFO) in the list.
1800 /* Add the newly deleted object at the end of the list */
1812 * Free the first object in the list only if
1825 * This function checks if the object passed can be a freeobject.
1832 meta_freeobject_check(meta_session_t *session, meta_object_t *object,
1839 * If key migration is turned off, or the object does not has any of
1844 (!object->isToken && !object->isSensitive &&
1862 * If this call is for an object creation, look inside the template
1897 if (object->isToken)
1898 object->isFreeToken = FREE_ALLOWED_KEY;
1900 object->isFreeToken = FREE_DISABLED;
1902 object->isFreeObject = FREE_ALLOWED_KEY;
1907 object->isFreeToken = FREE_DISABLED;
1908 object->isFreeObject = FREE_DISABLED;
1925 meta_freeobject_set(meta_object_t *object, CK_ATTRIBUTE *tmpl,
1930 if (object->isFreeObject < FREE_ALLOWED_KEY)
1935 if (object->isSensitive) {
1940 object->isFreeObject = FREE_ENABLED;
1944 if (object->isPrivate) {
1949 object->isFreeObject = FREE_ENABLED;
1953 if (object->isToken) {
1954 object->isToken = B_FALSE;
1955 object->isFreeToken = FREE_ENABLED;
1956 object->isFreeObject = FREE_ENABLED;
1958 object->isFreeToken = FREE_DISABLED;
1962 * turned off because the object doesn't not need to be a FreeObject.
1964 if (object->isFreeObject == FREE_ALLOWED_KEY)
1965 object->isFreeObject = FREE_DISABLED;
1970 object->isFreeToken = FREE_DISABLED;
1971 object->isFreeObject = FREE_DISABLED;
1976 * This function sets the CKA_TOKEN flag on a given object template depending
1979 * If the object is a token, but the slot is not the system keystore or has
2014 * is streamlined because we know what the object is and this should
2019 meta_freeobject_clone_maker(meta_session_t *session, meta_object_t *object,
2036 rv = clone_by_create(object, slot_object, slot_session);
2038 object->clones[slotnum] = slot_object;
2049 * This function is called when a object is a FreeObject.
2051 * What we are given is an object that has been generated on a provider
2054 * 2) it was to be a private/sensitive object that we modified so we could know
2059 meta_freeobject_clone(meta_session_t *session, meta_object_t *object)
2066 if (object->attributes == NULL) {
2067 rv = meta_object_copyin(object);
2072 if (object->isPrivate) {
2074 CK_ULONG slotnum = object->master_clone_slotnum;
2082 rv = attribute_set_value(attr, object->attributes,
2083 object->num_attributes);
2096 object->clones[slotnum]->hObject, attr, 1, &new_clone);
2102 * keystore set in metaslot or has object management
2104 * object to metaslot's keystore and let the failover.
2109 if (object->clones[keystore_slotnum] == NULL) {
2111 object, keystore_slotnum);
2116 object->master_clone_slotnum = keystore_slotnum;
2122 /* Remove the old object */
2125 object->clones[slotnum]->hObject);
2132 object->clones[slotnum]->hObject = new_clone;
2134 object->clones[slotnum] = NULL;
2140 if (object->isSensitive) {
2142 CK_ULONG slotnum = object->master_clone_slotnum;
2147 rv = attribute_set_value(attr, object->attributes,
2148 object->num_attributes);
2157 object->clones[slotnum]->hObject, attr, 1);
2163 if (object->isFreeToken == FREE_ENABLED || failover) {
2165 if (object->clones[keystore_slotnum] == NULL) {
2166 rv = meta_freeobject_clone_maker(session, object,
2171 object->master_clone_slotnum = keystore_slotnum;
2173 object->isFreeToken = FREE_ENABLED;
2176 object->isFreeObject = FREE_ENABLED;
2180 object->isFreeToken = FREE_DISABLED;
2181 object->isFreeObject = FREE_DISABLED;