1N/A/*
1N/A * Common Public License Version 0.5
1N/A *
1N/A * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF
1N/A * THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE,
1N/A * REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
1N/A * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
1N/A *
1N/A * 1. DEFINITIONS
1N/A *
1N/A * "Contribution" means:
1N/A * a) in the case of the initial Contributor, the
1N/A * initial code and documentation distributed under
1N/A * this Agreement, and
1N/A *
1N/A * b) in the case of each subsequent Contributor:
1N/A * i) changes to the Program, and
1N/A * ii) additions to the Program;
1N/A *
1N/A * where such changes and/or additions to the Program
1N/A * originate from and are distributed by that
1N/A * particular Contributor. A Contribution 'originates'
1N/A * from a Contributor if it was added to the Program
1N/A * by such Contributor itself or anyone acting on such
1N/A * Contributor's behalf. Contributions do not include
1N/A * additions to the Program which: (i) are separate
1N/A * modules of software distributed in conjunction with
1N/A * the Program under their own license agreement, and
1N/A * (ii) are not derivative works of the Program.
1N/A *
1N/A *
1N/A * "Contributor" means any person or entity that distributes
1N/A * the Program.
1N/A *
1N/A * "Licensed Patents " mean patent claims licensable by a
1N/A * Contributor which are necessarily infringed by the use or
1N/A * sale of its Contribution alone or when combined with the
1N/A * Program.
1N/A *
1N/A * "Program" means the Contributions distributed in
1N/A * accordance with this Agreement.
1N/A *
1N/A * "Recipient" means anyone who receives the Program under
1N/A * this Agreement, including all Contributors.
1N/A *
1N/A * 2. GRANT OF RIGHTS
1N/A *
1N/A * a) Subject to the terms of this Agreement, each
1N/A * Contributor hereby grants Recipient a
1N/A * no - exclusive, worldwide, royalt - free copyright
1N/A * license to reproduce, prepare derivative works of,
1N/A * publicly display, publicly perform, distribute and
1N/A * sublicense the Contribution of such Contributor, if
1N/A * any, and such derivative works, in source code and
1N/A * object code form.
1N/A *
1N/A * b) Subject to the terms of this Agreement, each
1N/A * Contributor hereby grants Recipient a
1N/A * no - exclusive, worldwide, royalt - free patent
1N/A * license under Licensed Patents to make, use, sell,
1N/A * offer to sell, import and otherwise transfer the
1N/A * Contribution of such Contributor, if any, in source
1N/A * code and object code form. This patent license
1N/A * shall apply to the combination of the Contribution
1N/A * and the Program if, at the time the Contribution is
1N/A * added by the Contributor, such addition of the
1N/A * Contribution causes such combination to be covered
1N/A * by the Licensed Patents. The patent license shall
1N/A * not apply to any other combinations which include
1N/A * the Contribution. No hardware per se is licensed
1N/A * hereunder.
1N/A *
1N/A * c) Recipient understands that although each
1N/A * Contributor grants the licenses to its
1N/A * Contributions set forth herein, no assurances are
1N/A * provided by any Contributor that the Program does
1N/A * not infringe the patent or other intellectual
1N/A * property rights of any other entity. Each
1N/A * Contributor disclaims any liability to Recipient
1N/A * for claims brought by any other entity based on
1N/A * infringement of intellectual property rights or
1N/A * otherwise. As a condition to exercising the rights
1N/A * and licenses granted hereunder, each Recipient
1N/A * hereby assumes sole responsibility to secure any
1N/A * other intellectual property rights needed, if any.
1N/A *
1N/A * For example, if a third party patent license is
1N/A * required to allow Recipient to distribute the
1N/A * Program, it is Recipient's responsibility to
1N/A * acquire that license before distributing the
1N/A * Program.
1N/A *
1N/A * d) Each Contributor represents that to its
1N/A * knowledge it has sufficient copyright rights in its
1N/A * Contribution, if any, to grant the copyright
1N/A * license set forth in this Agreement.
1N/A *
1N/A * 3. REQUIREMENTS
1N/A *
1N/A * A Contributor may choose to distribute the Program in
1N/A * object code form under its own license agreement, provided
1N/A * that:
1N/A * a) it complies with the terms and conditions of
1N/A * this Agreement; and
1N/A *
1N/A * b) its license agreement:
1N/A * i) effectively disclaims on behalf of all
1N/A * Contributors all warranties and conditions, express
1N/A * and implied, including warranties or conditions of
1N/A * title and no - infringement, and implied warranties
1N/A * or conditions of merchantability and fitness for a
1N/A * particular purpose;
1N/A *
1N/A * ii) effectively excludes on behalf of all
1N/A * Contributors all liability for damages, including
1N/A * direct, indirect, special, incidental and
1N/A * consequential damages, such as lost profits;
1N/A *
1N/A * iii) states that any provisions which differ from
1N/A * this Agreement are offered by that Contributor
1N/A * alone and not by any other party; and
1N/A *
1N/A * iv) states that source code for the Program is
1N/A * available from such Contributor, and informs
1N/A * licensees how to obtain it in a reasonable manner
1N/A * on or through a medium customarily used for
1N/A * software exchange.
1N/A *
1N/A * When the Program is made available in source code form:
1N/A * a) it must be made available under this Agreement;
1N/A * and
1N/A * b) a copy of this Agreement must be included with
1N/A * each copy of the Program.
1N/A *
1N/A * Contributors may not remove or alter any copyright notices
1N/A * contained within the Program.
1N/A *
1N/A * Each Contributor must identify itself as the originator of
1N/A * its Contribution, if any, in a manner that reasonably
1N/A * allows subsequent Recipients to identify the originator of
1N/A * the Contribution.
1N/A *
1N/A *
1N/A * 4. COMMERCIAL DISTRIBUTION
1N/A *
1N/A * Commercial distributors of software may accept certain
1N/A * responsibilities with respect to end users, business
1N/A * partners and the like. While this license is intended to
1N/A * facilitate the commercial use of the Program, the
1N/A * Contributor who includes the Program in a commercial
1N/A * product offering should do so in a manner which does not
1N/A * create potential liability for other Contributors.
1N/A * Therefore, if a Contributor includes the Program in a
1N/A * commercial product offering, such Contributor ("Commercial
1N/A * Contributor") hereby agrees to defend and indemnify every
1N/A * other Contributor ("Indemnified Contributor") against any
1N/A * losses, damages and costs (collectively "Losses") arising
1N/A * from claims, lawsuits and other legal actions brought by a
1N/A * third party against the Indemnified Contributor to the
1N/A * extent caused by the acts or omissions of such Commercial
1N/A * Contributor in connection with its distribution of the
1N/A * Program in a commercial product offering. The obligations
1N/A * in this section do not apply to any claims or Losses
1N/A * relating to any actual or alleged intellectual property
1N/A * infringement. In order to qualify, an Indemnified
1N/A * Contributor must: a) promptly notify the Commercial
1N/A * Contributor in writing of such claim, and b) allow the
1N/A * Commercial Contributor to control, and cooperate with the
1N/A * Commercial Contributor in, the defense and any related
1N/A * settlement negotiations. The Indemnified Contributor may
1N/A * participate in any such claim at its own expense.
1N/A *
1N/A *
1N/A * For example, a Contributor might include the Program in a
1N/A * commercial product offering, Product X. That Contributor
1N/A * is then a Commercial Contributor. If that Commercial
1N/A * Contributor then makes performance claims, or offers
1N/A * warranties related to Product X, those performance claims
1N/A * and warranties are such Commercial Contributor's
1N/A * responsibility alone. Under this section, the Commercial
1N/A * Contributor would have to defend claims against the other
1N/A * Contributors related to those performance claims and
1N/A * warranties, and if a court requires any other Contributor
1N/A * to pay any damages as a result, the Commercial Contributor
1N/A * must pay those damages.
1N/A *
1N/A *
1N/A * 5. NO WARRANTY
1N/A *
1N/A * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE
1N/A * PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
1N/A * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
1N/A * IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
1N/A * CONDITIONS OF TITLE, NO - INFRINGEMENT, MERCHANTABILITY OR
1N/A * FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
1N/A * responsible for determining the appropriateness of using
1N/A * and distributing the Program and assumes all risks
1N/A * associated with its exercise of rights under this
1N/A * Agreement, including but not limited to the risks and
1N/A * costs of program errors, compliance with applicable laws,
1N/A * damage to or loss of data, programs or equipment, and
1N/A * unavailability or interruption of operations.
1N/A *
1N/A * 6. DISCLAIMER OF LIABILITY
1N/A * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER
1N/A * RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY
1N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
1N/A * OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
1N/A * LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
1N/A * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1N/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1N/A * OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE
1N/A * OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
1N/A * POSSIBILITY OF SUCH DAMAGES.
1N/A *
1N/A * 7. GENERAL
1N/A *
1N/A * If any provision of this Agreement is invalid or
1N/A * unenforceable under applicable law, it shall not affect
1N/A * the validity or enforceability of the remainder of the
1N/A * terms of this Agreement, and without further action by the
1N/A * parties hereto, such provision shall be reformed to the
1N/A * minimum extent necessary to make such provision valid and
1N/A * enforceable.
1N/A *
1N/A *
1N/A * If Recipient institutes patent litigation against a
1N/A * Contributor with respect to a patent applicable to
1N/A * software (including a cros - claim or counterclaim in a
1N/A * lawsuit), then any patent licenses granted by that
1N/A * Contributor to such Recipient under this Agreement shall
1N/A * terminate as of the date such litigation is filed. In
1N/A * addition, If Recipient institutes patent litigation
1N/A * against any entity (including a cros - claim or
1N/A * counterclaim in a lawsuit) alleging that the Program
1N/A * itself (excluding combinations of the Program with other
1N/A * software or hardware) infringes such Recipient's
1N/A * patent(s), then such Recipient's rights granted under
1N/A * Section 2(b) shall terminate as of the date such
1N/A * litigation is filed.
1N/A *
1N/A * All Recipient's rights under this Agreement shall
1N/A * terminate if it fails to comply with any of the material
1N/A * terms or conditions of this Agreement and does not cure
1N/A * such failure in a reasonable period of time after becoming
1N/A * aware of such noncompliance. If all Recipient's rights
1N/A * under this Agreement terminate, Recipient agrees to cease
1N/A * use and distribution of the Program as soon as reasonably
1N/A * practicable. However, Recipient's obligations under this
1N/A * Agreement and any licenses granted by Recipient relating
1N/A * to the Program shall continue and survive.
1N/A *
1N/A * Everyone is permitted to copy and distribute copies of
1N/A * this Agreement, but in order to avoid inconsistency the
1N/A * Agreement is copyrighted and may only be modified in the
1N/A * following manner. The Agreement Steward reserves the right
1N/A * to publish new versions (including revisions) of this
1N/A * Agreement from time to time. No one other than the
1N/A * Agreement Steward has the right to modify this Agreement.
1N/A *
1N/A * IBM is the initial Agreement Steward. IBM may assign the
1N/A * responsibility to serve as the Agreement Steward to a
1N/A * suitable separate entity. Each new version of the
1N/A * Agreement will be given a distinguishing version number.
1N/A * The Program (including Contributions) may always be
1N/A * distributed subject to the version of the Agreement under
1N/A * which it was received. In addition, after a new version of
1N/A * the Agreement is published, Contributor may elect to
1N/A * distribute the Program (including its Contributions) under
1N/A * the new version. Except as expressly stated in Sections
1N/A * 2(a) and 2(b) above, Recipient receives no rights or
1N/A * licenses to the intellectual property of any Contributor
1N/A * under this Agreement, whether expressly, by implication,
1N/A * estoppel or otherwise. All rights in the Program not
1N/A * expressly granted under this Agreement are reserved.
1N/A *
1N/A *
1N/A * This Agreement is governed by the laws of the State of New
1N/A * York and the intellectual property laws of the United
1N/A * States of America. No party to this Agreement will bring a
1N/A * legal action under this Agreement more than one year after
1N/A * the cause of action arose. Each party waives its rights to
1N/A * a jury trial in any resulting litigation.
1N/A *
1N/A *
1N/A *
1N/A * (C) COPYRIGHT International Business Machines Corp. 2001, 2002
1N/A */
1N/A/*
2N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
1N/A */
1N/A
1N/A#include "tpmtok_int.h"
1N/A
1N/A// template_add_attributes()
1N/A//
1N/A// blindly add the given attributes to the template. do no sanity checking
1N/A// at this point. sanity checking will occur later.
1N/A//
1N/ACK_RV
1N/Atemplate_add_attributes(TEMPLATE * tmpl,
1N/A CK_ATTRIBUTE * pTemplate,
1N/A CK_ULONG ulCount)
1N/A{
1N/A CK_ATTRIBUTE * attr = NULL;
1N/A CK_RV rc;
1N/A unsigned int i;
1N/A
1N/A for (i = 0; i < ulCount; i++) {
1N/A if (! is_attribute_defined(pTemplate[i].type)) {
1N/A return (CKR_ATTRIBUTE_TYPE_INVALID);
1N/A }
1N/A attr = (CK_ATTRIBUTE *)malloc(sizeof (CK_ATTRIBUTE) +
1N/A pTemplate[i].ulValueLen);
1N/A if (! attr) {
1N/A return (CKR_HOST_MEMORY);
1N/A }
1N/A attr->type = pTemplate[i].type;
1N/A attr->ulValueLen = pTemplate[i].ulValueLen;
1N/A
1N/A if (attr->ulValueLen != 0) {
1N/A attr->pValue = (CK_BYTE *)attr + sizeof (CK_ATTRIBUTE);
1N/A (void) memcpy(attr->pValue, pTemplate[i].pValue,
1N/A attr->ulValueLen);
1N/A } else
1N/A attr->pValue = NULL;
1N/A
1N/A rc = template_update_attribute(tmpl, attr);
1N/A if (rc != CKR_OK) {
1N/A free(attr);
1N/A return (rc);
1N/A }
1N/A }
1N/A
1N/A return (CKR_OK);
1N/A}
1N/A
1N/A
1N/A// template_add_default_attributes()
1N/A//
1N/ACK_RV
1N/Atemplate_add_default_attributes(TEMPLATE * tmpl,
1N/A CK_ULONG class,
1N/A CK_ULONG subclass,
1N/A CK_ULONG mode)
1N/A{
1N/A CK_RV rc;
1N/A
1N/A // first add the default common attributes
1N/A //
1N/A rc = template_set_default_common_attributes(tmpl);
1N/A if (rc != CKR_OK) {
1N/A return (rc);
1N/A }
1N/A // set the template class - specific default attributes
1N/A //
1N/A switch (class) {
1N/A case CKO_DATA:
1N/A return (data_object_set_default_attributes(tmpl, mode));
1N/A case CKO_CERTIFICATE:
1N/A if (subclass == CKC_X_509)
1N/A return (cert_x509_set_default_attributes(tmpl, mode));
1N/A else
1N/A return (CKR_OK);
1N/A case CKO_PUBLIC_KEY:
1N/A switch (subclass) {
1N/A case CKK_RSA:
1N/A return (rsa_publ_set_default_attributes(
1N/A tmpl, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A
1N/A case CKO_PRIVATE_KEY:
1N/A switch (subclass) {
1N/A case CKK_RSA:
1N/A return (rsa_priv_set_default_attributes(
1N/A tmpl, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A
1N/A case CKO_SECRET_KEY:
1N/A switch (subclass) {
1N/A case CKK_GENERIC_SECRET:
1N/A return (generic_secret_set_default_attributes(
1N/A tmpl, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A
1N/A case CKO_HW_FEATURE:
1N/A switch (subclass) {
1N/A case CKH_CLOCK:
1N/A return (clock_set_default_attributes(
1N/A tmpl));
1N/A case CKH_MONOTONIC_COUNTER:
1N/A return (counter_set_default_attributes(
1N/A tmpl));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A
1N/A case CKO_DOMAIN_PARAMETERS:
1N/A switch (subclass) {
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A}
1N/A
1N/A// template_attribute_find()
1N/A//
1N/A// find the attribute in the list and return (its value
1N/A//
1N/ACK_BBOOL
1N/Atemplate_attribute_find(TEMPLATE * tmpl,
1N/A CK_ATTRIBUTE_TYPE type,
1N/A CK_ATTRIBUTE ** attr)
1N/A{
1N/A DL_NODE * node = NULL;
1N/A CK_ATTRIBUTE * a = NULL;
1N/A
1N/A if (! tmpl || ! attr)
1N/A return (FALSE);
1N/A node = tmpl->attribute_list;
1N/A
1N/A while (node != NULL) {
1N/A a = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A if (type == a->type) {
1N/A *attr = a;
1N/A return (TRUE);
1N/A }
1N/A
1N/A node = node->next;
1N/A }
1N/A
1N/A *attr = NULL;
1N/A return (FALSE);
1N/A}
1N/A
1N/A// template_attribute_find_multiple()
1N/A//
1N/A// find the attributes in the list and return (their values
1N/A//
1N/Avoid
1N/Atemplate_attribute_find_multiple(TEMPLATE * tmpl,
1N/A ATTRIBUTE_PARSE_LIST * parselist,
1N/A CK_ULONG plcount)
1N/A{
1N/A CK_ATTRIBUTE * attr = NULL;
1N/A CK_ULONG i;
1N/A
1N/A for (i = 0; i < plcount; i++) {
1N/A parselist[i].found = template_attribute_find(
1N/A tmpl, parselist[i].type, &attr);
1N/A
1N/A if (parselist[i].found && parselist[i].ptr != NULL)
1N/A (void) memcpy(parselist[i].ptr, attr->pValue,
1N/A parselist[i].len);
1N/A }
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_check_required_attributes(TEMPLATE * tmpl,
1N/A CK_ULONG class,
1N/A CK_ULONG subclass,
1N/A CK_ULONG mode)
1N/A{
1N/A if (class == CKO_DATA)
1N/A return (data_object_check_required_attributes(
1N/A tmpl, mode));
1N/A else if (class == CKO_CERTIFICATE) {
1N/A if (subclass == CKC_X_509)
1N/A return (cert_x509_check_required_attributes(
1N/A tmpl, mode));
1N/A else
1N/A return (cert_vendor_check_required_attributes(
1N/A tmpl, mode));
1N/A } else if (class == CKO_PUBLIC_KEY) {
1N/A switch (subclass) {
1N/A case CKK_RSA:
1N/A return (rsa_publ_check_required_attributes(
1N/A tmpl, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_PRIVATE_KEY) {
1N/A switch (subclass) {
1N/A case CKK_RSA:
1N/A return (rsa_priv_check_required_attributes(
1N/A tmpl, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_SECRET_KEY) {
1N/A switch (subclass) {
1N/A case CKK_GENERIC_SECRET:
1N/A return (
1N/A generic_secret_check_required_attributes(
1N/A tmpl, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_HW_FEATURE) {
1N/A
1N/A switch (subclass) {
1N/A case CKH_CLOCK:
1N/A return (
1N/A clock_check_required_attributes(
1N/A tmpl, mode));
1N/A case CKH_MONOTONIC_COUNTER:
1N/A return (
1N/A counter_check_required_attributes(
1N/A tmpl, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_DOMAIN_PARAMETERS) {
1N/A switch (subclass) {
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A }
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A}
1N/A
1N/A
1N/A// template_check_required_base_attributes()
1N/A//
1N/A// check to make sure that attributes required by Cryptoki are
1N/A// present. does not check to see if the attribute makes sense
1N/A// for the particular object (that is done in the 'validate' routines)
1N/A//
1N/ACK_RV
1N/Atemplate_check_required_base_attributes(TEMPLATE * tmpl,
1N/ACK_ULONG mode)
1N/A{
1N/A CK_ATTRIBUTE * attr;
1N/A CK_BBOOL found;
1N/A
1N/A found = template_attribute_find(tmpl, CKA_CLASS, &attr);
1N/A if (mode == MODE_CREATE && found == FALSE)
1N/A return (CKR_TEMPLATE_INCOMPLETE);
1N/A return (CKR_OK);
1N/A}
1N/A
1N/A
1N/A// template_compare()
1N/A//
1N/ACK_BBOOL
1N/Atemplate_compare(CK_ATTRIBUTE * t1,
1N/A CK_ULONG ulCount,
1N/A TEMPLATE * t2) {
1N/A CK_ATTRIBUTE * attr1 = NULL;
1N/A CK_ATTRIBUTE * attr2 = NULL;
1N/A CK_ULONG i;
1N/A CK_RV rc;
1N/A
1N/A if (! t1 || ! t2)
1N/A return (FALSE);
1N/A attr1 = t1;
1N/A
1N/A for (i = 0; i < ulCount; i++) {
1N/A rc = template_attribute_find(t2, attr1->type, &attr2);
1N/A if (rc == FALSE)
1N/A return (FALSE);
1N/A if (attr1->ulValueLen != attr2->ulValueLen)
1N/A return (FALSE);
1N/A if (memcmp(attr1->pValue, attr2->pValue, attr1->ulValueLen)
1N/A != 0)
1N/A return (FALSE);
1N/A attr1++;
1N/A }
1N/A
1N/A return (TRUE);
1N/A}
1N/A
1N/A// template_copy()
1N/A//
1N/A// This doesn't copy the template items verbatim. The new template is in
1N/A// the reverse order of the old one. This should not have any effect.
1N/A//
1N/A// This is very similar to template_merge(). template_merge() can also
1N/A// be used to copy a list (of unique attributes) but is slower because for
1N/A// each attribute, it must search through the list.
1N/A//
1N/ACK_RV
1N/Atemplate_copy(TEMPLATE *dest, TEMPLATE *src) {
1N/A DL_NODE *node;
1N/A
1N/A if (! dest || ! src) {
1N/A return (CKR_FUNCTION_FAILED);
1N/A }
1N/A node = src->attribute_list;
1N/A
1N/A while (node) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)node->data;
1N/A CK_ATTRIBUTE *new_attr = NULL;
1N/A CK_ULONG len;
1N/A
1N/A len = sizeof (CK_ATTRIBUTE) + attr->ulValueLen;
1N/A
1N/A new_attr = (CK_ATTRIBUTE *)malloc(len);
1N/A if (! new_attr) {
1N/A return (CKR_HOST_MEMORY);
1N/A }
1N/A (void) memcpy(new_attr, attr, len);
1N/A
1N/A new_attr->pValue = (CK_BYTE *)new_attr + sizeof (CK_ATTRIBUTE);
1N/A
1N/A dest->attribute_list = dlist_add_as_first(dest->attribute_list,
1N/A new_attr);
1N/A
1N/A node = node->next;
1N/A }
1N/A
1N/A return (CKR_OK);
1N/A}
1N/A
1N/A
1N/A// template_flatten() - this still gets used when saving token objects to disk
1N/A//
1N/ACK_RV
1N/Atemplate_flatten(TEMPLATE * tmpl,
1N/A CK_BYTE * dest)
1N/A{
1N/A DL_NODE * node = NULL;
1N/A CK_BYTE * ptr = NULL;
1N/A CK_ULONG_32 long_len;
1N/A CK_ATTRIBUTE_32 *attr_32;
1N/A CK_ULONG Val;
1N/A CK_ULONG_32 Val_32;
1N/A CK_ULONG * pVal;
1N/A long_len = sizeof (CK_ULONG);
1N/A
1N/A if (! tmpl || ! dest) {
1N/A return (CKR_FUNCTION_FAILED);
1N/A }
1N/A ptr = dest;
1N/A node = tmpl->attribute_list;
1N/A while (node) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A if (long_len == 4) {
1N/A (void) memcpy(ptr, attr, sizeof (CK_ATTRIBUTE) +
1N/A attr->ulValueLen);
1N/A ptr += sizeof (CK_ATTRIBUTE) + attr->ulValueLen;
1N/A } else {
1N/A attr_32 = malloc(sizeof (CK_ATTRIBUTE_32));
1N/A if (! attr_32) {
1N/A return (CKR_HOST_MEMORY);
1N/A }
1N/A attr_32->type = attr->type;
1N/A attr_32->pValue = 0x00;
1N/A if ((attr->type == CKA_CLASS ||
1N/A attr->type == CKA_KEY_TYPE ||
1N/A attr->type == CKA_MODULUS_BITS ||
1N/A attr->type == CKA_VALUE_BITS ||
1N/A attr->type == CKA_CERTIFICATE_TYPE ||
1N/A attr->type == CKA_VALUE_LEN) &&
1N/A attr->ulValueLen != 0) {
1N/A
1N/A attr_32->ulValueLen = sizeof (CK_ULONG_32);
1N/A
1N/A (void) memcpy(ptr, attr_32,
1N/A sizeof (CK_ATTRIBUTE_32));
1N/A ptr += sizeof (CK_ATTRIBUTE_32);
1N/A
1N/A pVal = (CK_ULONG *)attr->pValue;
1N/A Val = *pVal;
1N/A Val_32 = (CK_ULONG_32)Val;
1N/A (void) memcpy(ptr, &Val_32,
1N/A sizeof (CK_ULONG_32));
1N/A ptr += sizeof (CK_ULONG_32);
1N/A } else {
1N/A attr_32->ulValueLen = attr->ulValueLen;
1N/A (void) memcpy(ptr, attr_32,
1N/A sizeof (CK_ATTRIBUTE_32));
1N/A ptr += sizeof (CK_ATTRIBUTE_32);
1N/A if (attr->ulValueLen != 0) {
1N/A (void) memcpy(ptr, attr->pValue,
1N/A attr->ulValueLen);
1N/A ptr += attr->ulValueLen;
1N/A }
1N/A }
1N/A free(attr_32);
1N/A }
1N/A node = node->next;
1N/A }
1N/A
1N/A return (CKR_OK);
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_unflatten(TEMPLATE ** new_tmpl,
1N/A CK_BYTE * buf,
1N/A CK_ULONG count)
1N/A{
1N/A TEMPLATE * tmpl = NULL;
1N/A CK_ATTRIBUTE * a2 = NULL;
1N/A CK_BYTE *ptr = NULL;
1N/A CK_ULONG i, len;
1N/A CK_RV rc;
1N/A CK_ULONG_32 long_len = sizeof (CK_ULONG);
1N/A CK_ULONG_32 attr_ulong_32;
1N/A CK_ULONG attr_ulong;
1N/A CK_ATTRIBUTE * a1_64 = NULL;
1N/A CK_ATTRIBUTE_32 * a1 = NULL;
1N/A
1N/A if (! new_tmpl || ! buf) {
1N/A return (CKR_FUNCTION_FAILED);
1N/A }
1N/A tmpl = (TEMPLATE *)malloc(sizeof (TEMPLATE));
1N/A if (! tmpl) {
1N/A return (CKR_HOST_MEMORY);
1N/A }
1N/A (void) memset(tmpl, 0x0, sizeof (TEMPLATE));
1N/A
1N/A ptr = buf;
1N/A for (i = 0; i < count; i++) {
1N/A if (long_len == 4) {
1N/A void *aptr = ptr;
1N/A a1_64 = (CK_ATTRIBUTE *)aptr;
1N/A
1N/A len = sizeof (CK_ATTRIBUTE) + a1_64->ulValueLen;
1N/A a2 = (CK_ATTRIBUTE *)malloc(len);
1N/A if (! a2) {
1N/A (void) template_free(tmpl);
1N/A return (CKR_HOST_MEMORY);
1N/A }
1N/A
1N/A (void) memcpy(a2, a1_64, len);
1N/A } else {
1N/A void *aptr = ptr;
1N/A a1 = (CK_ATTRIBUTE_32 *)aptr;
1N/A
1N/A if ((a1->type == CKA_CLASS ||
1N/A a1->type == CKA_KEY_TYPE ||
1N/A a1->type == CKA_MODULUS_BITS ||
1N/A a1->type == CKA_VALUE_BITS ||
1N/A a1->type == CKA_CERTIFICATE_TYPE ||
1N/A a1->type == CKA_VALUE_LEN) &&
1N/A a1->ulValueLen != 0) {
1N/A len = sizeof (CK_ATTRIBUTE) + sizeof (CK_ULONG);
1N/A } else {
1N/A len = sizeof (CK_ATTRIBUTE) + a1->ulValueLen;
1N/A }
1N/A
1N/A a2 = (CK_ATTRIBUTE *)malloc(len);
1N/A if (! a2) {
2N/A (void) template_free(tmpl);
1N/A return (CKR_HOST_MEMORY);
1N/A }
1N/A a2->type = a1->type;
1N/A
1N/A if ((a1->type == CKA_CLASS ||
1N/A a1->type == CKA_KEY_TYPE ||
1N/A a1->type == CKA_MODULUS_BITS ||
1N/A a1->type == CKA_VALUE_BITS ||
1N/A a1->type == CKA_CERTIFICATE_TYPE ||
1N/A a1->type == CKA_VALUE_LEN) &&
1N/A a1->ulValueLen != 0) {
1N/A a2->ulValueLen = sizeof (CK_ULONG);
1N/A {
1N/A CK_ULONG_32 *p32;
1N/A CK_BYTE *pb2;
1N/A void *aptr = a1;
1N/A void *bptr;
1N/A
1N/A pb2 = (CK_BYTE *)aptr;
1N/A pb2 += sizeof (CK_ATTRIBUTE_32);
1N/A bptr = pb2;
1N/A p32 = (CK_ULONG_32 *)bptr;
1N/A attr_ulong_32 = *p32;
1N/A }
1N/A
1N/A attr_ulong = attr_ulong_32;
1N/A
1N/A {
1N/A CK_BYTE *pb2;
1N/A pb2 = (CK_BYTE *)a2;
1N/A pb2 += sizeof (CK_ATTRIBUTE);
1N/A (void) memcpy(pb2,
1N/A (CK_BYTE *)&attr_ulong,
1N/A sizeof (CK_ULONG));
1N/A }
1N/A } else {
1N/A CK_BYTE *pb2, *pb;
1N/A
1N/A a2->ulValueLen = a1->ulValueLen;
1N/A pb2 = (CK_BYTE *)a2;
1N/A pb2 += sizeof (CK_ATTRIBUTE);
1N/A pb = (CK_BYTE *)a1;
1N/A pb += sizeof (CK_ATTRIBUTE_32);
1N/A (void) memcpy(pb2, pb, a1->ulValueLen);
1N/A }
1N/A }
1N/A
1N/A
1N/A if (a2->ulValueLen != 0)
1N/A a2->pValue = (CK_BYTE *)a2 + sizeof (CK_ATTRIBUTE);
1N/A else
1N/A a2->pValue = NULL;
1N/A
1N/A rc = template_update_attribute(tmpl, a2);
1N/A if (rc != CKR_OK) {
1N/A free(a2);
1N/A (void) template_free(tmpl);
1N/A return (rc);
1N/A }
1N/A if (long_len == 4)
1N/A ptr += len;
1N/A else
1N/A ptr += sizeof (CK_ATTRIBUTE_32) + a1->ulValueLen;
1N/A
1N/A
1N/A }
1N/A
2N/A *new_tmpl = tmpl;
1N/A return (CKR_OK);
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_free(TEMPLATE *tmpl) {
1N/A if (! tmpl)
1N/A return (CKR_OK);
1N/A while (tmpl->attribute_list) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)tmpl->attribute_list->data;
1N/A
1N/A if (attr)
1N/A free(attr);
1N/A
1N/A tmpl->attribute_list = dlist_remove_node(tmpl->attribute_list,
1N/A tmpl->attribute_list);
1N/A }
1N/A
1N/A free(tmpl);
1N/A return (CKR_OK);
1N/A}
1N/A
1N/ACK_BBOOL
1N/Atemplate_get_class(TEMPLATE * tmpl,
1N/A CK_ULONG * class,
1N/A CK_ULONG * subclass)
1N/A{
1N/A DL_NODE * node;
1N/A CK_BBOOL found;
1N/A
1N/A if (! tmpl || ! class || ! subclass)
1N/A return (FALSE);
1N/A node = tmpl->attribute_list;
1N/A
1N/A while (node) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A if (attr->type == CKA_CLASS) {
1N/A *class = *(CK_OBJECT_CLASS *)attr->pValue;
1N/A found = TRUE;
1N/A }
1N/A
1N/A if (attr->type == CKA_CERTIFICATE_TYPE)
1N/A *subclass = *(CK_CERTIFICATE_TYPE *)attr->pValue;
1N/A
1N/A if (attr->type == CKA_KEY_TYPE)
1N/A *subclass = *(CK_KEY_TYPE *)attr->pValue;
1N/A
1N/A node = node->next;
1N/A }
1N/A
1N/A return (found);
1N/A}
1N/A
1N/ACK_ULONG
1N/Atemplate_get_count(TEMPLATE *tmpl)
1N/A{
1N/A if (tmpl == NULL)
1N/A return (0);
1N/A return (dlist_length(tmpl->attribute_list));
1N/A}
1N/A
1N/ACK_ULONG
1N/Atemplate_get_size(TEMPLATE *tmpl)
1N/A{
1N/A DL_NODE * node;
1N/A CK_ULONG size = 0;
1N/A
1N/A if (tmpl == NULL)
1N/A return (0);
1N/A node = tmpl->attribute_list;
1N/A while (node) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A size += sizeof (CK_ATTRIBUTE) + attr->ulValueLen;
1N/A
1N/A node = node->next;
1N/A }
1N/A
1N/A return (size);
1N/A}
1N/A
1N/ACK_ULONG
1N/Atemplate_get_compressed_size(TEMPLATE *tmpl)
1N/A{
1N/A DL_NODE * node;
1N/A CK_ULONG size = 0;
1N/A
1N/A if (tmpl == NULL)
1N/A return (0);
1N/A node = tmpl->attribute_list;
1N/A while (node) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A size += sizeof (CK_ATTRIBUTE_32);
1N/A if ((attr->type == CKA_CLASS ||
1N/A attr->type == CKA_KEY_TYPE ||
1N/A attr->type == CKA_MODULUS_BITS ||
1N/A attr->type == CKA_VALUE_BITS ||
1N/A attr->type == CKA_CERTIFICATE_TYPE ||
1N/A attr->type == CKA_VALUE_LEN) &&
1N/A attr->ulValueLen != 0) {
1N/A size += sizeof (CK_ULONG_32);
1N/A } else {
1N/A size += attr->ulValueLen;
1N/A }
1N/A
1N/A node = node->next;
1N/A }
1N/A
1N/A return (size);
1N/A}
1N/A
1N/A/*
1N/A * template_is_okay_to_reveal_attribute()
1N/A *
1N/A * determines whether the specified CK_ATTRIBUTE_TYPE is allowed to
1N/A * be leave the card in the clear. note: the specified template doesn't need
1N/A * to actually posess an attribute of type 'type'. The template is
1N/A * provided mainly to determine the object class and subclass
1N/A *
1N/A * this routine is called by C_GetAttributeValue which exports the attributes
1N/A * in the clear. this routine is NOT called when wrapping a key.
1N/A */
1N/ACK_BBOOL
1N/Atemplate_check_exportability(TEMPLATE *tmpl, CK_ATTRIBUTE_TYPE type)
1N/A{
1N/A CK_ATTRIBUTE * attr = NULL;
1N/A CK_ULONG class;
1N/A CK_ULONG subclass;
1N/A CK_BBOOL val;
1N/A
1N/A if (! tmpl)
1N/A return (FALSE);
1N/A (void) template_get_class(tmpl, &class, &subclass);
1N/A
1N/A if (class != CKO_PRIVATE_KEY && class != CKO_SECRET_KEY)
1N/A return (TRUE);
1N/A val = template_attribute_find(tmpl, CKA_SENSITIVE, &attr);
1N/A if (val) {
1N/A val = *(CK_BBOOL *)attr->pValue;
1N/A if (val == FALSE)
1N/A return (TRUE);
1N/A } else {
1N/A return (FALSE);
1N/A }
1N/A
1N/A if (class == CKO_PRIVATE_KEY) {
1N/A switch (subclass) {
1N/A case CKK_RSA:
1N/A return (rsa_priv_check_exportability(type));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_SECRET_KEY) {
1N/A return (secret_key_check_exportability(type));
1N/A }
1N/A
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_merge(TEMPLATE *dest, TEMPLATE **src)
1N/A{
1N/A DL_NODE *node;
1N/A CK_RV rc;
1N/A
1N/A if (! dest || ! src) {
1N/A return (CKR_FUNCTION_FAILED);
1N/A }
1N/A node = (*src)->attribute_list;
1N/A
1N/A while (node) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A rc = template_update_attribute(dest, attr);
1N/A if (rc != CKR_OK) {
1N/A return (rc);
1N/A }
1N/A node->data = NULL;
1N/A node = node->next;
1N/A }
1N/A
1N/A (void) template_free(*src);
1N/A *src = NULL;
1N/A
1N/A return (CKR_OK);
1N/A}
1N/A
1N/A/*
1N/A * template_set_default_common_attributes()
1N/A *
1N/A * Set the default attributes common to all objects:
1N/A *
1N/A * CKA_TOKEN : FALSE
1N/A * CKA_PRIVATE : TRUE -- Cryptoki leaves this up to the token to decide
1N/A * CKA_MODIFIABLE : TRUE
1N/A * CKA_LABEL : empty string
1N/A */
1N/ACK_RV
1N/Atemplate_set_default_common_attributes(TEMPLATE *tmpl)
1N/A{
1N/A CK_ATTRIBUTE * token_attr;
1N/A CK_ATTRIBUTE * priv_attr;
1N/A CK_ATTRIBUTE * mod_attr;
1N/A CK_ATTRIBUTE * label_attr;
1N/A
1N/A token_attr = (CK_ATTRIBUTE *)malloc(sizeof (CK_ATTRIBUTE) +
1N/A sizeof (CK_BBOOL));
1N/A priv_attr = (CK_ATTRIBUTE *)malloc(sizeof (CK_ATTRIBUTE) +
1N/A sizeof (CK_BBOOL));
1N/A mod_attr = (CK_ATTRIBUTE *)malloc(sizeof (CK_ATTRIBUTE) +
1N/A sizeof (CK_BBOOL));
1N/A label_attr = (CK_ATTRIBUTE *)malloc(sizeof (CK_ATTRIBUTE) + 0);
1N/A
1N/A if (! token_attr || ! priv_attr || ! mod_attr || ! label_attr) {
1N/A if (token_attr) free(token_attr);
1N/A if (priv_attr) free(priv_attr);
1N/A if (mod_attr) free(mod_attr);
1N/A if (label_attr) free(label_attr);
1N/A
1N/A return (CKR_HOST_MEMORY);
1N/A }
1N/A
1N/A token_attr->type = CKA_TOKEN;
1N/A token_attr->ulValueLen = sizeof (CK_BBOOL);
1N/A token_attr->pValue = (CK_BYTE *)token_attr + sizeof (CK_ATTRIBUTE);
1N/A *(CK_BBOOL *)token_attr->pValue = FALSE;
1N/A
1N/A priv_attr->type = CKA_PRIVATE;
1N/A priv_attr->ulValueLen = sizeof (CK_BBOOL);
1N/A priv_attr->pValue = (CK_BYTE *)priv_attr + sizeof (CK_ATTRIBUTE);
1N/A *(CK_BBOOL *)priv_attr->pValue = FALSE;
1N/A
1N/A mod_attr->type = CKA_MODIFIABLE;
1N/A mod_attr->ulValueLen = sizeof (CK_BBOOL);
1N/A mod_attr->pValue = (CK_BYTE *)mod_attr + sizeof (CK_ATTRIBUTE);
1N/A *(CK_BBOOL *)mod_attr->pValue = TRUE;
1N/A
1N/A label_attr->type = CKA_LABEL;
1N/A label_attr->ulValueLen = 0; // empty string
1N/A label_attr->pValue = NULL;
1N/A
1N/A (void) template_update_attribute(tmpl, token_attr);
1N/A (void) template_update_attribute(tmpl, priv_attr);
1N/A (void) template_update_attribute(tmpl, mod_attr);
1N/A (void) template_update_attribute(tmpl, label_attr);
1N/A
1N/A return (CKR_OK);
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_update_attribute(TEMPLATE *tmpl, CK_ATTRIBUTE *new_attr) {
1N/A DL_NODE * node = NULL;
1N/A CK_ATTRIBUTE * attr = NULL;
1N/A
1N/A if (! tmpl || ! new_attr) {
1N/A return (CKR_FUNCTION_FAILED);
1N/A }
1N/A node = tmpl->attribute_list;
1N/A
1N/A while (node != NULL) {
1N/A attr = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A if (new_attr->type == attr->type) {
1N/A free(attr);
1N/A tmpl->attribute_list = dlist_remove_node(
1N/A tmpl->attribute_list, node);
1N/A break;
1N/A }
1N/A
1N/A node = node->next;
1N/A }
1N/A
1N/A tmpl->attribute_list = dlist_add_as_first(
1N/A tmpl->attribute_list, new_attr);
1N/A
1N/A return (CKR_OK);
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_validate_attribute(TEMPLATE * tmpl,
1N/A CK_ATTRIBUTE * attr,
1N/A CK_ULONG class,
1N/A CK_ULONG subclass,
1N/A CK_ULONG mode)
1N/A{
1N/A if (class == CKO_DATA)
1N/A return (data_object_validate_attribute(tmpl, attr, mode));
1N/A else if (class == CKO_CERTIFICATE) {
1N/A if (subclass == CKC_X_509)
1N/A return (cert_x509_validate_attribute(tmpl, attr, mode));
1N/A else
1N/A return (cert_vendor_validate_attribute(tmpl,
1N/A attr, mode));
1N/A } else if (class == CKO_PUBLIC_KEY) {
1N/A
1N/A switch (subclass) {
1N/A case CKK_RSA:
1N/A return (rsa_publ_validate_attribute(tmpl,
1N/A attr, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_PRIVATE_KEY) {
1N/A
1N/A switch (subclass) {
1N/A case CKK_RSA:
1N/A return (rsa_priv_validate_attribute(tmpl,
1N/A attr, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_SECRET_KEY) {
1N/A switch (subclass) {
1N/A case CKK_GENERIC_SECRET:
1N/A return (generic_secret_validate_attribute(tmpl,
1N/A attr, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_HW_FEATURE) {
1N/A
1N/A switch (subclass) {
1N/A case CKH_CLOCK:
1N/A return (clock_validate_attribute(tmpl,
1N/A attr, mode));
1N/A case CKH_MONOTONIC_COUNTER:
1N/A return (counter_validate_attribute(tmpl,
1N/A attr, mode));
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A } else if (class == CKO_DOMAIN_PARAMETERS) {
1N/A switch (subclass) {
1N/A default:
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A }
1N/A }
1N/A return (CKR_ATTRIBUTE_VALUE_INVALID);
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_validate_attributes(TEMPLATE * tmpl,
1N/A CK_ULONG class,
1N/A CK_ULONG subclass,
1N/A CK_ULONG mode)
1N/A{
1N/A DL_NODE *node;
1N/A CK_RV rc = CKR_OK;
1N/A
1N/A node = tmpl->attribute_list;
1N/A
1N/A while (node) {
1N/A CK_ATTRIBUTE *attr = (CK_ATTRIBUTE *)node->data;
1N/A
1N/A rc = template_validate_attribute(tmpl, attr, class,
1N/A subclass, mode);
1N/A if (rc != CKR_OK) {
1N/A return (rc);
1N/A }
1N/A node = node->next;
1N/A }
1N/A
1N/A return (CKR_OK);
1N/A}
1N/A
1N/ACK_RV
1N/Atemplate_validate_base_attribute(TEMPLATE * tmpl,
1N/A CK_ATTRIBUTE * attr,
1N/A CK_ULONG mode)
1N/A{
1N/A if (! tmpl || ! attr) {
1N/A return (CKR_FUNCTION_FAILED);
1N/A }
1N/A switch (attr->type) {
1N/A case CKA_CLASS:
1N/A if ((mode & (MODE_CREATE | MODE_DERIVE |
1N/A MODE_KEYGEN | MODE_UNWRAP)) != 0)
1N/A return (CKR_OK);
1N/A break;
1N/A
1N/A case CKA_TOKEN:
1N/A if ((mode & (MODE_CREATE | MODE_COPY |
1N/A MODE_DERIVE | MODE_KEYGEN | MODE_UNWRAP)) != 0)
1N/A return (CKR_OK);
1N/A break;
1N/A
1N/A case CKA_PRIVATE:
1N/A if ((mode & (MODE_CREATE | MODE_COPY |
1N/A MODE_DERIVE | MODE_KEYGEN | MODE_UNWRAP)) != 0)
1N/A return (CKR_OK);
1N/A break;
1N/A
1N/A case CKA_LABEL:
1N/A return (CKR_OK);
1N/A case CKA_MODIFIABLE:
1N/A if ((mode & (MODE_CREATE | MODE_COPY |
1N/A MODE_DERIVE | MODE_KEYGEN | MODE_UNWRAP)) != 0)
1N/A return (CKR_OK);
1N/A break;
1N/A
1N/A default:
1N/A return (CKR_TEMPLATE_INCONSISTENT);
1N/A }
1N/A
1N/A return (CKR_ATTRIBUTE_READ_ONLY);
1N/A}