19126SWyllys.Ingersoll@Sun.COM /*
29126SWyllys.Ingersoll@Sun.COM * Common Public License Version 0.5
39126SWyllys.Ingersoll@Sun.COM *
49126SWyllys.Ingersoll@Sun.COM * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF
59126SWyllys.Ingersoll@Sun.COM * THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE,
69126SWyllys.Ingersoll@Sun.COM * REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
79126SWyllys.Ingersoll@Sun.COM * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
89126SWyllys.Ingersoll@Sun.COM *
99126SWyllys.Ingersoll@Sun.COM * 1. DEFINITIONS
109126SWyllys.Ingersoll@Sun.COM *
119126SWyllys.Ingersoll@Sun.COM * "Contribution" means:
129126SWyllys.Ingersoll@Sun.COM * a) in the case of the initial Contributor, the
139126SWyllys.Ingersoll@Sun.COM * initial code and documentation distributed under
149126SWyllys.Ingersoll@Sun.COM * this Agreement, and
159126SWyllys.Ingersoll@Sun.COM *
169126SWyllys.Ingersoll@Sun.COM * b) in the case of each subsequent Contributor:
179126SWyllys.Ingersoll@Sun.COM * i) changes to the Program, and
189126SWyllys.Ingersoll@Sun.COM * ii) additions to the Program;
199126SWyllys.Ingersoll@Sun.COM *
209126SWyllys.Ingersoll@Sun.COM * where such changes and/or additions to the Program
219126SWyllys.Ingersoll@Sun.COM * originate from and are distributed by that
229126SWyllys.Ingersoll@Sun.COM * particular Contributor. A Contribution 'originates'
239126SWyllys.Ingersoll@Sun.COM * from a Contributor if it was added to the Program
249126SWyllys.Ingersoll@Sun.COM * by such Contributor itself or anyone acting on such
259126SWyllys.Ingersoll@Sun.COM * Contributor's behalf. Contributions do not include
269126SWyllys.Ingersoll@Sun.COM * additions to the Program which: (i) are separate
279126SWyllys.Ingersoll@Sun.COM * modules of software distributed in conjunction with
289126SWyllys.Ingersoll@Sun.COM * the Program under their own license agreement, and
299126SWyllys.Ingersoll@Sun.COM * (ii) are not derivative works of the Program.
309126SWyllys.Ingersoll@Sun.COM *
319126SWyllys.Ingersoll@Sun.COM *
329126SWyllys.Ingersoll@Sun.COM * "Contributor" means any person or entity that distributes
339126SWyllys.Ingersoll@Sun.COM * the Program.
349126SWyllys.Ingersoll@Sun.COM *
359126SWyllys.Ingersoll@Sun.COM * "Licensed Patents " mean patent claims licensable by a
369126SWyllys.Ingersoll@Sun.COM * Contributor which are necessarily infringed by the use or
379126SWyllys.Ingersoll@Sun.COM * sale of its Contribution alone or when combined with the
389126SWyllys.Ingersoll@Sun.COM * Program.
399126SWyllys.Ingersoll@Sun.COM *
409126SWyllys.Ingersoll@Sun.COM * "Program" means the Contributions distributed in
419126SWyllys.Ingersoll@Sun.COM * accordance with this Agreement.
429126SWyllys.Ingersoll@Sun.COM *
439126SWyllys.Ingersoll@Sun.COM * "Recipient" means anyone who receives the Program under
449126SWyllys.Ingersoll@Sun.COM * this Agreement, including all Contributors.
459126SWyllys.Ingersoll@Sun.COM *
469126SWyllys.Ingersoll@Sun.COM * 2. GRANT OF RIGHTS
479126SWyllys.Ingersoll@Sun.COM *
489126SWyllys.Ingersoll@Sun.COM * a) Subject to the terms of this Agreement, each
499126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a
509126SWyllys.Ingersoll@Sun.COM * no - exclusive, worldwide, royalt - free copyright
519126SWyllys.Ingersoll@Sun.COM * license to reproduce, prepare derivative works of,
529126SWyllys.Ingersoll@Sun.COM * publicly display, publicly perform, distribute and
539126SWyllys.Ingersoll@Sun.COM * sublicense the Contribution of such Contributor, if
549126SWyllys.Ingersoll@Sun.COM * any, and such derivative works, in source code and
559126SWyllys.Ingersoll@Sun.COM * object code form.
569126SWyllys.Ingersoll@Sun.COM *
579126SWyllys.Ingersoll@Sun.COM * b) Subject to the terms of this Agreement, each
589126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a
599126SWyllys.Ingersoll@Sun.COM * no - exclusive, worldwide, royalt - free patent
609126SWyllys.Ingersoll@Sun.COM * license under Licensed Patents to make, use, sell,
619126SWyllys.Ingersoll@Sun.COM * offer to sell, import and otherwise transfer the
629126SWyllys.Ingersoll@Sun.COM * Contribution of such Contributor, if any, in source
639126SWyllys.Ingersoll@Sun.COM * code and object code form. This patent license
649126SWyllys.Ingersoll@Sun.COM * shall apply to the combination of the Contribution
659126SWyllys.Ingersoll@Sun.COM * and the Program if, at the time the Contribution is
669126SWyllys.Ingersoll@Sun.COM * added by the Contributor, such addition of the
679126SWyllys.Ingersoll@Sun.COM * Contribution causes such combination to be covered
689126SWyllys.Ingersoll@Sun.COM * by the Licensed Patents. The patent license shall
699126SWyllys.Ingersoll@Sun.COM * not apply to any other combinations which include
709126SWyllys.Ingersoll@Sun.COM * the Contribution. No hardware per se is licensed
719126SWyllys.Ingersoll@Sun.COM * hereunder.
729126SWyllys.Ingersoll@Sun.COM *
739126SWyllys.Ingersoll@Sun.COM * c) Recipient understands that although each
749126SWyllys.Ingersoll@Sun.COM * Contributor grants the licenses to its
759126SWyllys.Ingersoll@Sun.COM * Contributions set forth herein, no assurances are
769126SWyllys.Ingersoll@Sun.COM * provided by any Contributor that the Program does
779126SWyllys.Ingersoll@Sun.COM * not infringe the patent or other intellectual
789126SWyllys.Ingersoll@Sun.COM * property rights of any other entity. Each
799126SWyllys.Ingersoll@Sun.COM * Contributor disclaims any liability to Recipient
809126SWyllys.Ingersoll@Sun.COM * for claims brought by any other entity based on
819126SWyllys.Ingersoll@Sun.COM * infringement of intellectual property rights or
829126SWyllys.Ingersoll@Sun.COM * otherwise. As a condition to exercising the rights
839126SWyllys.Ingersoll@Sun.COM * and licenses granted hereunder, each Recipient
849126SWyllys.Ingersoll@Sun.COM * hereby assumes sole responsibility to secure any
859126SWyllys.Ingersoll@Sun.COM * other intellectual property rights needed, if any.
869126SWyllys.Ingersoll@Sun.COM *
879126SWyllys.Ingersoll@Sun.COM * For example, if a third party patent license is
889126SWyllys.Ingersoll@Sun.COM * required to allow Recipient to distribute the
899126SWyllys.Ingersoll@Sun.COM * Program, it is Recipient's responsibility to
909126SWyllys.Ingersoll@Sun.COM * acquire that license before distributing the
919126SWyllys.Ingersoll@Sun.COM * Program.
929126SWyllys.Ingersoll@Sun.COM *
939126SWyllys.Ingersoll@Sun.COM * d) Each Contributor represents that to its
949126SWyllys.Ingersoll@Sun.COM * knowledge it has sufficient copyright rights in its
959126SWyllys.Ingersoll@Sun.COM * Contribution, if any, to grant the copyright
969126SWyllys.Ingersoll@Sun.COM * license set forth in this Agreement.
979126SWyllys.Ingersoll@Sun.COM *
989126SWyllys.Ingersoll@Sun.COM * 3. REQUIREMENTS
999126SWyllys.Ingersoll@Sun.COM *
1009126SWyllys.Ingersoll@Sun.COM * A Contributor may choose to distribute the Program in
1019126SWyllys.Ingersoll@Sun.COM * object code form under its own license agreement, provided
1029126SWyllys.Ingersoll@Sun.COM * that:
1039126SWyllys.Ingersoll@Sun.COM * a) it complies with the terms and conditions of
1049126SWyllys.Ingersoll@Sun.COM * this Agreement; and
1059126SWyllys.Ingersoll@Sun.COM *
1069126SWyllys.Ingersoll@Sun.COM * b) its license agreement:
1079126SWyllys.Ingersoll@Sun.COM * i) effectively disclaims on behalf of all
1089126SWyllys.Ingersoll@Sun.COM * Contributors all warranties and conditions, express
1099126SWyllys.Ingersoll@Sun.COM * and implied, including warranties or conditions of
1109126SWyllys.Ingersoll@Sun.COM * title and no - infringement, and implied warranties
1119126SWyllys.Ingersoll@Sun.COM * or conditions of merchantability and fitness for a
1129126SWyllys.Ingersoll@Sun.COM * particular purpose;
1139126SWyllys.Ingersoll@Sun.COM *
1149126SWyllys.Ingersoll@Sun.COM * ii) effectively excludes on behalf of all
1159126SWyllys.Ingersoll@Sun.COM * Contributors all liability for damages, including
1169126SWyllys.Ingersoll@Sun.COM * direct, indirect, special, incidental and
1179126SWyllys.Ingersoll@Sun.COM * consequential damages, such as lost profits;
1189126SWyllys.Ingersoll@Sun.COM *
1199126SWyllys.Ingersoll@Sun.COM * iii) states that any provisions which differ from
1209126SWyllys.Ingersoll@Sun.COM * this Agreement are offered by that Contributor
1219126SWyllys.Ingersoll@Sun.COM * alone and not by any other party; and
1229126SWyllys.Ingersoll@Sun.COM *
1239126SWyllys.Ingersoll@Sun.COM * iv) states that source code for the Program is
1249126SWyllys.Ingersoll@Sun.COM * available from such Contributor, and informs
1259126SWyllys.Ingersoll@Sun.COM * licensees how to obtain it in a reasonable manner
1269126SWyllys.Ingersoll@Sun.COM * on or through a medium customarily used for
1279126SWyllys.Ingersoll@Sun.COM * software exchange.
1289126SWyllys.Ingersoll@Sun.COM *
1299126SWyllys.Ingersoll@Sun.COM * When the Program is made available in source code form:
1309126SWyllys.Ingersoll@Sun.COM * a) it must be made available under this Agreement;
1319126SWyllys.Ingersoll@Sun.COM * and
1329126SWyllys.Ingersoll@Sun.COM * b) a copy of this Agreement must be included with
1339126SWyllys.Ingersoll@Sun.COM * each copy of the Program.
1349126SWyllys.Ingersoll@Sun.COM *
1359126SWyllys.Ingersoll@Sun.COM * Contributors may not remove or alter any copyright notices
1369126SWyllys.Ingersoll@Sun.COM * contained within the Program.
1379126SWyllys.Ingersoll@Sun.COM *
1389126SWyllys.Ingersoll@Sun.COM * Each Contributor must identify itself as the originator of
1399126SWyllys.Ingersoll@Sun.COM * its Contribution, if any, in a manner that reasonably
1409126SWyllys.Ingersoll@Sun.COM * allows subsequent Recipients to identify the originator of
1419126SWyllys.Ingersoll@Sun.COM * the Contribution.
1429126SWyllys.Ingersoll@Sun.COM *
1439126SWyllys.Ingersoll@Sun.COM *
1449126SWyllys.Ingersoll@Sun.COM * 4. COMMERCIAL DISTRIBUTION
1459126SWyllys.Ingersoll@Sun.COM *
1469126SWyllys.Ingersoll@Sun.COM * Commercial distributors of software may accept certain
1479126SWyllys.Ingersoll@Sun.COM * responsibilities with respect to end users, business
1489126SWyllys.Ingersoll@Sun.COM * partners and the like. While this license is intended to
1499126SWyllys.Ingersoll@Sun.COM * facilitate the commercial use of the Program, the
1509126SWyllys.Ingersoll@Sun.COM * Contributor who includes the Program in a commercial
1519126SWyllys.Ingersoll@Sun.COM * product offering should do so in a manner which does not
1529126SWyllys.Ingersoll@Sun.COM * create potential liability for other Contributors.
1539126SWyllys.Ingersoll@Sun.COM * Therefore, if a Contributor includes the Program in a
1549126SWyllys.Ingersoll@Sun.COM * commercial product offering, such Contributor ("Commercial
1559126SWyllys.Ingersoll@Sun.COM * Contributor") hereby agrees to defend and indemnify every
1569126SWyllys.Ingersoll@Sun.COM * other Contributor ("Indemnified Contributor") against any
1579126SWyllys.Ingersoll@Sun.COM * losses, damages and costs (collectively "Losses") arising
1589126SWyllys.Ingersoll@Sun.COM * from claims, lawsuits and other legal actions brought by a
1599126SWyllys.Ingersoll@Sun.COM * third party against the Indemnified Contributor to the
1609126SWyllys.Ingersoll@Sun.COM * extent caused by the acts or omissions of such Commercial
1619126SWyllys.Ingersoll@Sun.COM * Contributor in connection with its distribution of the
1629126SWyllys.Ingersoll@Sun.COM * Program in a commercial product offering. The obligations
1639126SWyllys.Ingersoll@Sun.COM * in this section do not apply to any claims or Losses
1649126SWyllys.Ingersoll@Sun.COM * relating to any actual or alleged intellectual property
1659126SWyllys.Ingersoll@Sun.COM * infringement. In order to qualify, an Indemnified
1669126SWyllys.Ingersoll@Sun.COM * Contributor must: a) promptly notify the Commercial
1679126SWyllys.Ingersoll@Sun.COM * Contributor in writing of such claim, and b) allow the
1689126SWyllys.Ingersoll@Sun.COM * Commercial Contributor to control, and cooperate with the
1699126SWyllys.Ingersoll@Sun.COM * Commercial Contributor in, the defense and any related
1709126SWyllys.Ingersoll@Sun.COM * settlement negotiations. The Indemnified Contributor may
1719126SWyllys.Ingersoll@Sun.COM * participate in any such claim at its own expense.
1729126SWyllys.Ingersoll@Sun.COM *
1739126SWyllys.Ingersoll@Sun.COM *
1749126SWyllys.Ingersoll@Sun.COM * For example, a Contributor might include the Program in a
1759126SWyllys.Ingersoll@Sun.COM * commercial product offering, Product X. That Contributor
1769126SWyllys.Ingersoll@Sun.COM * is then a Commercial Contributor. If that Commercial
1779126SWyllys.Ingersoll@Sun.COM * Contributor then makes performance claims, or offers
1789126SWyllys.Ingersoll@Sun.COM * warranties related to Product X, those performance claims
1799126SWyllys.Ingersoll@Sun.COM * and warranties are such Commercial Contributor's
1809126SWyllys.Ingersoll@Sun.COM * responsibility alone. Under this section, the Commercial
1819126SWyllys.Ingersoll@Sun.COM * Contributor would have to defend claims against the other
1829126SWyllys.Ingersoll@Sun.COM * Contributors related to those performance claims and
1839126SWyllys.Ingersoll@Sun.COM * warranties, and if a court requires any other Contributor
1849126SWyllys.Ingersoll@Sun.COM * to pay any damages as a result, the Commercial Contributor
1859126SWyllys.Ingersoll@Sun.COM * must pay those damages.
1869126SWyllys.Ingersoll@Sun.COM *
1879126SWyllys.Ingersoll@Sun.COM *
1889126SWyllys.Ingersoll@Sun.COM * 5. NO WARRANTY
1899126SWyllys.Ingersoll@Sun.COM *
1909126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE
1919126SWyllys.Ingersoll@Sun.COM * PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
1929126SWyllys.Ingersoll@Sun.COM * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
1939126SWyllys.Ingersoll@Sun.COM * IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
1949126SWyllys.Ingersoll@Sun.COM * CONDITIONS OF TITLE, NO - INFRINGEMENT, MERCHANTABILITY OR
1959126SWyllys.Ingersoll@Sun.COM * FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
1969126SWyllys.Ingersoll@Sun.COM * responsible for determining the appropriateness of using
1979126SWyllys.Ingersoll@Sun.COM * and distributing the Program and assumes all risks
1989126SWyllys.Ingersoll@Sun.COM * associated with its exercise of rights under this
1999126SWyllys.Ingersoll@Sun.COM * Agreement, including but not limited to the risks and
2009126SWyllys.Ingersoll@Sun.COM * costs of program errors, compliance with applicable laws,
2019126SWyllys.Ingersoll@Sun.COM * damage to or loss of data, programs or equipment, and
2029126SWyllys.Ingersoll@Sun.COM * unavailability or interruption of operations.
2039126SWyllys.Ingersoll@Sun.COM *
2049126SWyllys.Ingersoll@Sun.COM * 6. DISCLAIMER OF LIABILITY
2059126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER
2069126SWyllys.Ingersoll@Sun.COM * RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY
2079126SWyllys.Ingersoll@Sun.COM * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
2089126SWyllys.Ingersoll@Sun.COM * OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
2099126SWyllys.Ingersoll@Sun.COM * LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
2109126SWyllys.Ingersoll@Sun.COM * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2119126SWyllys.Ingersoll@Sun.COM * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2129126SWyllys.Ingersoll@Sun.COM * OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE
2139126SWyllys.Ingersoll@Sun.COM * OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
2149126SWyllys.Ingersoll@Sun.COM * POSSIBILITY OF SUCH DAMAGES.
2159126SWyllys.Ingersoll@Sun.COM *
2169126SWyllys.Ingersoll@Sun.COM * 7. GENERAL
2179126SWyllys.Ingersoll@Sun.COM *
2189126SWyllys.Ingersoll@Sun.COM * If any provision of this Agreement is invalid or
2199126SWyllys.Ingersoll@Sun.COM * unenforceable under applicable law, it shall not affect
2209126SWyllys.Ingersoll@Sun.COM * the validity or enforceability of the remainder of the
2219126SWyllys.Ingersoll@Sun.COM * terms of this Agreement, and without further action by the
2229126SWyllys.Ingersoll@Sun.COM * parties hereto, such provision shall be reformed to the
2239126SWyllys.Ingersoll@Sun.COM * minimum extent necessary to make such provision valid and
2249126SWyllys.Ingersoll@Sun.COM * enforceable.
2259126SWyllys.Ingersoll@Sun.COM *
2269126SWyllys.Ingersoll@Sun.COM *
2279126SWyllys.Ingersoll@Sun.COM * If Recipient institutes patent litigation against a
2289126SWyllys.Ingersoll@Sun.COM * Contributor with respect to a patent applicable to
2299126SWyllys.Ingersoll@Sun.COM * software (including a cros - claim or counterclaim in a
2309126SWyllys.Ingersoll@Sun.COM * lawsuit), then any patent licenses granted by that
2319126SWyllys.Ingersoll@Sun.COM * Contributor to such Recipient under this Agreement shall
2329126SWyllys.Ingersoll@Sun.COM * terminate as of the date such litigation is filed. In
2339126SWyllys.Ingersoll@Sun.COM * addition, If Recipient institutes patent litigation
2349126SWyllys.Ingersoll@Sun.COM * against any entity (including a cros - claim or
2359126SWyllys.Ingersoll@Sun.COM * counterclaim in a lawsuit) alleging that the Program
2369126SWyllys.Ingersoll@Sun.COM * itself (excluding combinations of the Program with other
2379126SWyllys.Ingersoll@Sun.COM * software or hardware) infringes such Recipient's
2389126SWyllys.Ingersoll@Sun.COM * patent(s), then such Recipient's rights granted under
2399126SWyllys.Ingersoll@Sun.COM * Section 2(b) shall terminate as of the date such
2409126SWyllys.Ingersoll@Sun.COM * litigation is filed.
2419126SWyllys.Ingersoll@Sun.COM *
2429126SWyllys.Ingersoll@Sun.COM * All Recipient's rights under this Agreement shall
2439126SWyllys.Ingersoll@Sun.COM * terminate if it fails to comply with any of the material
2449126SWyllys.Ingersoll@Sun.COM * terms or conditions of this Agreement and does not cure
2459126SWyllys.Ingersoll@Sun.COM * such failure in a reasonable period of time after becoming
2469126SWyllys.Ingersoll@Sun.COM * aware of such noncompliance. If all Recipient's rights
2479126SWyllys.Ingersoll@Sun.COM * under this Agreement terminate, Recipient agrees to cease
2489126SWyllys.Ingersoll@Sun.COM * use and distribution of the Program as soon as reasonably
2499126SWyllys.Ingersoll@Sun.COM * practicable. However, Recipient's obligations under this
2509126SWyllys.Ingersoll@Sun.COM * Agreement and any licenses granted by Recipient relating
2519126SWyllys.Ingersoll@Sun.COM * to the Program shall continue and survive.
2529126SWyllys.Ingersoll@Sun.COM *
2539126SWyllys.Ingersoll@Sun.COM * Everyone is permitted to copy and distribute copies of
2549126SWyllys.Ingersoll@Sun.COM * this Agreement, but in order to avoid inconsistency the
2559126SWyllys.Ingersoll@Sun.COM * Agreement is copyrighted and may only be modified in the
2569126SWyllys.Ingersoll@Sun.COM * following manner. The Agreement Steward reserves the right
2579126SWyllys.Ingersoll@Sun.COM * to publish new versions (including revisions) of this
2589126SWyllys.Ingersoll@Sun.COM * Agreement from time to time. No one other than the
2599126SWyllys.Ingersoll@Sun.COM * Agreement Steward has the right to modify this Agreement.
2609126SWyllys.Ingersoll@Sun.COM *
2619126SWyllys.Ingersoll@Sun.COM * IBM is the initial Agreement Steward. IBM may assign the
2629126SWyllys.Ingersoll@Sun.COM * responsibility to serve as the Agreement Steward to a
2639126SWyllys.Ingersoll@Sun.COM * suitable separate entity. Each new version of the
2649126SWyllys.Ingersoll@Sun.COM * Agreement will be given a distinguishing version number.
2659126SWyllys.Ingersoll@Sun.COM * The Program (including Contributions) may always be
2669126SWyllys.Ingersoll@Sun.COM * distributed subject to the version of the Agreement under
2679126SWyllys.Ingersoll@Sun.COM * which it was received. In addition, after a new version of
2689126SWyllys.Ingersoll@Sun.COM * the Agreement is published, Contributor may elect to
2699126SWyllys.Ingersoll@Sun.COM * distribute the Program (including its Contributions) under
2709126SWyllys.Ingersoll@Sun.COM * the new version. Except as expressly stated in Sections
2719126SWyllys.Ingersoll@Sun.COM * 2(a) and 2(b) above, Recipient receives no rights or
2729126SWyllys.Ingersoll@Sun.COM * licenses to the intellectual property of any Contributor
2739126SWyllys.Ingersoll@Sun.COM * under this Agreement, whether expressly, by implication,
2749126SWyllys.Ingersoll@Sun.COM * estoppel or otherwise. All rights in the Program not
2759126SWyllys.Ingersoll@Sun.COM * expressly granted under this Agreement are reserved.
2769126SWyllys.Ingersoll@Sun.COM *
2779126SWyllys.Ingersoll@Sun.COM *
2789126SWyllys.Ingersoll@Sun.COM * This Agreement is governed by the laws of the State of New
2799126SWyllys.Ingersoll@Sun.COM * York and the intellectual property laws of the United
2809126SWyllys.Ingersoll@Sun.COM * States of America. No party to this Agreement will bring a
2819126SWyllys.Ingersoll@Sun.COM * legal action under this Agreement more than one year after
2829126SWyllys.Ingersoll@Sun.COM * the cause of action arose. Each party waives its rights to
2839126SWyllys.Ingersoll@Sun.COM * a jury trial in any resulting litigation.
2849126SWyllys.Ingersoll@Sun.COM *
2859126SWyllys.Ingersoll@Sun.COM *
2869126SWyllys.Ingersoll@Sun.COM *
2879126SWyllys.Ingersoll@Sun.COM * (C) COPYRIGHT International Business Machines Corp. 2001, 2002
2889126SWyllys.Ingersoll@Sun.COM */
2899126SWyllys.Ingersoll@Sun.COM /*
2909126SWyllys.Ingersoll@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2919126SWyllys.Ingersoll@Sun.COM * Use is subject to license terms.
2929126SWyllys.Ingersoll@Sun.COM */
2939126SWyllys.Ingersoll@Sun.COM
2949126SWyllys.Ingersoll@Sun.COM #include "tpmtok_int.h"
2959126SWyllys.Ingersoll@Sun.COM
2969126SWyllys.Ingersoll@Sun.COM #define LOG(x) logit(LOG_DEBUG, x)
2979126SWyllys.Ingersoll@Sun.COM
2989126SWyllys.Ingersoll@Sun.COM /*
2999126SWyllys.Ingersoll@Sun.COM * NOTES:
3009126SWyllys.Ingersoll@Sun.COM * In many cases the specificaiton does not allow returns
3019126SWyllys.Ingersoll@Sun.COM * of CKR_ARGUMENTSB_BAD. We break the spec, since validation of parameters
3029126SWyllys.Ingersoll@Sun.COM * to the function are best represented by this return code (where
3039126SWyllys.Ingersoll@Sun.COM * specific RC's such as CKR_INVALID_SESSION do not exist).
3049126SWyllys.Ingersoll@Sun.COM * NOTE NOTE NOTE NOTE
3059126SWyllys.Ingersoll@Sun.COM * The parameter checking on the update operations may need to be
3069126SWyllys.Ingersoll@Sun.COM * modified (as well as the encrypt/decrypt) to call the std API
3079126SWyllys.Ingersoll@Sun.COM * anyway with sanatized parameters since on error, the encrypt/decrypt
3089126SWyllys.Ingersoll@Sun.COM * sign operations are all supposed to complete.
3099126SWyllys.Ingersoll@Sun.COM * Therefor the parameter checking here might need to be done in
3109126SWyllys.Ingersoll@Sun.COM * the STDLL instead of the API.
3119126SWyllys.Ingersoll@Sun.COM * This would affect ALL the Multipart operations which have
3129126SWyllys.Ingersoll@Sun.COM * an init followed by one or more operations.
3139126SWyllys.Ingersoll@Sun.COM *
3149126SWyllys.Ingersoll@Sun.COM * Globals for the API
3159126SWyllys.Ingersoll@Sun.COM */
3169126SWyllys.Ingersoll@Sun.COM API_Proc_Struct_t *Anchor = NULL;
3179126SWyllys.Ingersoll@Sun.COM static unsigned int Initialized = 0;
3189126SWyllys.Ingersoll@Sun.COM static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;
3199126SWyllys.Ingersoll@Sun.COM struct ST_FCN_LIST FuncList;
3209126SWyllys.Ingersoll@Sun.COM CK_FUNCTION_LIST PK11_Functions;
3219453SWyllys.Ingersoll@Sun.COM extern pthread_rwlock_t obj_list_rw_mutex;
3229126SWyllys.Ingersoll@Sun.COM
3239453SWyllys.Ingersoll@Sun.COM
3249126SWyllys.Ingersoll@Sun.COM static void
tpmtoken_fork_prepare()3259453SWyllys.Ingersoll@Sun.COM tpmtoken_fork_prepare()
3269453SWyllys.Ingersoll@Sun.COM {
3279453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&global_mutex);
3289453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&pkcs_mutex);
3299453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&obj_list_mutex);
3309453SWyllys.Ingersoll@Sun.COM (void) pthread_rwlock_wrlock(&obj_list_rw_mutex);
3319453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&sess_list_mutex);
3329453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&login_mutex);
3339453SWyllys.Ingersoll@Sun.COM if (Anchor) {
3349453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&Anchor->ProcMutex);
3359453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&Anchor->SessListMutex);
3369453SWyllys.Ingersoll@Sun.COM }
3379453SWyllys.Ingersoll@Sun.COM }
3389453SWyllys.Ingersoll@Sun.COM
3399453SWyllys.Ingersoll@Sun.COM static void
tpmtoken_fork_parent()3409453SWyllys.Ingersoll@Sun.COM tpmtoken_fork_parent()
3419126SWyllys.Ingersoll@Sun.COM {
3429126SWyllys.Ingersoll@Sun.COM if (Anchor) {
3439453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&Anchor->SessListMutex);
3449453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&Anchor->ProcMutex);
3459453SWyllys.Ingersoll@Sun.COM }
3469453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&login_mutex);
3479453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&sess_list_mutex);
3489453SWyllys.Ingersoll@Sun.COM (void) pthread_rwlock_unlock(&obj_list_rw_mutex);
3499453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&obj_list_mutex);
3509453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&pkcs_mutex);
3519453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
3529453SWyllys.Ingersoll@Sun.COM }
3539453SWyllys.Ingersoll@Sun.COM
3549453SWyllys.Ingersoll@Sun.COM static void
tpmtoken_fork_child()3559453SWyllys.Ingersoll@Sun.COM tpmtoken_fork_child()
3569453SWyllys.Ingersoll@Sun.COM {
3579453SWyllys.Ingersoll@Sun.COM if (Anchor) {
3589453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&Anchor->SessListMutex);
3599453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&Anchor->ProcMutex);
3609453SWyllys.Ingersoll@Sun.COM }
3619453SWyllys.Ingersoll@Sun.COM
3629453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&login_mutex);
3639453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&sess_list_mutex);
3649453SWyllys.Ingersoll@Sun.COM (void) pthread_rwlock_unlock(&obj_list_rw_mutex);
3659453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&obj_list_mutex);
3669453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&pkcs_mutex);
3679453SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
3689453SWyllys.Ingersoll@Sun.COM
3699453SWyllys.Ingersoll@Sun.COM if (Anchor) {
3709453SWyllys.Ingersoll@Sun.COM Terminate_All_Process_Sessions();
3719126SWyllys.Ingersoll@Sun.COM free(Anchor);
3729126SWyllys.Ingersoll@Sun.COM Anchor = NULL;
3739126SWyllys.Ingersoll@Sun.COM }
3749453SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Finalize)
3759453SWyllys.Ingersoll@Sun.COM FuncList.ST_Finalize(0);
3769453SWyllys.Ingersoll@Sun.COM
3779126SWyllys.Ingersoll@Sun.COM logterm();
3789126SWyllys.Ingersoll@Sun.COM loginit();
3799126SWyllys.Ingersoll@Sun.COM }
3809126SWyllys.Ingersoll@Sun.COM
3819126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
3829126SWyllys.Ingersoll@Sun.COM CK_RV
C_CancelFunction(CK_SESSION_HANDLE hSession)3839126SWyllys.Ingersoll@Sun.COM C_CancelFunction(CK_SESSION_HANDLE hSession)
3849126SWyllys.Ingersoll@Sun.COM {
3859126SWyllys.Ingersoll@Sun.COM LOG("C_CancelFunction");
3869126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
3879126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
3889126SWyllys.Ingersoll@Sun.COM }
3899126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_NOT_PARALLEL);
3909126SWyllys.Ingersoll@Sun.COM }
3919126SWyllys.Ingersoll@Sun.COM
3929126SWyllys.Ingersoll@Sun.COM CK_RV
C_CloseAllSessions(CK_SLOT_ID slotID)3939126SWyllys.Ingersoll@Sun.COM C_CloseAllSessions(CK_SLOT_ID slotID)
3949126SWyllys.Ingersoll@Sun.COM {
3959126SWyllys.Ingersoll@Sun.COM Session_Struct_t *pCur, *pPrev;
3969126SWyllys.Ingersoll@Sun.COM CK_RV rv;
3979126SWyllys.Ingersoll@Sun.COM /*
3989126SWyllys.Ingersoll@Sun.COM * Although why does modutil do a close all sessions. It is a single
3999126SWyllys.Ingersoll@Sun.COM * application it can only close its sessions...
4009126SWyllys.Ingersoll@Sun.COM * And all sessions should be closed anyhow.
4019126SWyllys.Ingersoll@Sun.COM */
4029126SWyllys.Ingersoll@Sun.COM LOG("CloseAllSessions");
4039126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE)
4049126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
405*10346Swyllys.ingersoll@sun.com
406*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available || (slotID > NUMBER_SLOTS_MANAGED))
4079126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
4089126SWyllys.Ingersoll@Sun.COM /*
4099126SWyllys.Ingersoll@Sun.COM * Proc Mutex is locked when we remove from the seesion list in
4109126SWyllys.Ingersoll@Sun.COM * Close SEssion. Therefore we don't need to do any locking
4119126SWyllys.Ingersoll@Sun.COM * the atomic operations are controled when we use the linked list
4129126SWyllys.Ingersoll@Sun.COM */
4139453SWyllys.Ingersoll@Sun.COM pCur = (Anchor ? Anchor->SessListBeg : NULL);
4149126SWyllys.Ingersoll@Sun.COM while (pCur) {
4159126SWyllys.Ingersoll@Sun.COM /*
4169126SWyllys.Ingersoll@Sun.COM * Session owned by the slot we are working on
4179126SWyllys.Ingersoll@Sun.COM * There is a basic problem here. We are using th pCur
4189126SWyllys.Ingersoll@Sun.COM * to point to the current one, however we delete it from
4199126SWyllys.Ingersoll@Sun.COM * the linked list and can no longer go Forward. So we
4209126SWyllys.Ingersoll@Sun.COM * have to use the fact that this is a doubly linked list
4219126SWyllys.Ingersoll@Sun.COM * and get the previous pointer. After deletion, the next
4229126SWyllys.Ingersoll@Sun.COM * pointer of this block will point to the next one in the
4239126SWyllys.Ingersoll@Sun.COM * list.
4249126SWyllys.Ingersoll@Sun.COM * If the value is Null, then this was the first one in
4259126SWyllys.Ingersoll@Sun.COM * the list and we just set pCur to the SessListBeg.
4269126SWyllys.Ingersoll@Sun.COM */
4279126SWyllys.Ingersoll@Sun.COM if (pCur->SltId == slotID) {
4289126SWyllys.Ingersoll@Sun.COM pPrev = pCur->Previous;
4299126SWyllys.Ingersoll@Sun.COM rv = C_CloseSession((CK_SESSION_HANDLE)pCur);
4309126SWyllys.Ingersoll@Sun.COM if (rv == CKR_OK ||
4319126SWyllys.Ingersoll@Sun.COM rv == CKR_SESSION_CLOSED ||
4329126SWyllys.Ingersoll@Sun.COM rv == CKR_SESSION_HANDLE_INVALID) {
4339126SWyllys.Ingersoll@Sun.COM if (pPrev == NULL) {
4349126SWyllys.Ingersoll@Sun.COM pCur = Anchor->SessListBeg;
4359126SWyllys.Ingersoll@Sun.COM } else {
4369126SWyllys.Ingersoll@Sun.COM pCur = pPrev->Next;
4379126SWyllys.Ingersoll@Sun.COM }
4389126SWyllys.Ingersoll@Sun.COM } else {
4399126SWyllys.Ingersoll@Sun.COM return (rv);
4409126SWyllys.Ingersoll@Sun.COM }
4419126SWyllys.Ingersoll@Sun.COM } else {
4429126SWyllys.Ingersoll@Sun.COM pCur = pCur->Next;
4439126SWyllys.Ingersoll@Sun.COM }
4449126SWyllys.Ingersoll@Sun.COM }
4459126SWyllys.Ingersoll@Sun.COM LOG("CloseAllSessions OK");
4469126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
4479126SWyllys.Ingersoll@Sun.COM }
4489126SWyllys.Ingersoll@Sun.COM CK_RV
C_CloseSession(CK_SESSION_HANDLE hSession)4499126SWyllys.Ingersoll@Sun.COM C_CloseSession(CK_SESSION_HANDLE hSession)
4509126SWyllys.Ingersoll@Sun.COM {
4519126SWyllys.Ingersoll@Sun.COM CK_RV rv;
4529126SWyllys.Ingersoll@Sun.COM Session_Struct_t *sessp;
4539126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
4549126SWyllys.Ingersoll@Sun.COM LOG("C_CloseSession");
4559126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
4569126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
4579126SWyllys.Ingersoll@Sun.COM }
4589126SWyllys.Ingersoll@Sun.COM /* Validate Session */
4599126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
4609126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
4619126SWyllys.Ingersoll@Sun.COM }
4629126SWyllys.Ingersoll@Sun.COM
4639126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_CloseSession) {
4649126SWyllys.Ingersoll@Sun.COM /* Map the Session to the slot session */
4659126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_CloseSession(rSession);
4669126SWyllys.Ingersoll@Sun.COM
4679126SWyllys.Ingersoll@Sun.COM if (rv == CKR_OK) {
4689126SWyllys.Ingersoll@Sun.COM sessp = (Session_Struct_t *)hSession;
4699126SWyllys.Ingersoll@Sun.COM RemoveFromSessionList(sessp);
4709126SWyllys.Ingersoll@Sun.COM }
4719126SWyllys.Ingersoll@Sun.COM } else {
4729126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
4739126SWyllys.Ingersoll@Sun.COM }
4749126SWyllys.Ingersoll@Sun.COM return (rv);
4759126SWyllys.Ingersoll@Sun.COM }
4769126SWyllys.Ingersoll@Sun.COM
4779126SWyllys.Ingersoll@Sun.COM CK_RV
C_CopyObject(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phNewObject)4789126SWyllys.Ingersoll@Sun.COM C_CopyObject(
4799126SWyllys.Ingersoll@Sun.COM CK_SESSION_HANDLE hSession,
4809126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
4819126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
4829126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount,
4839126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phNewObject)
4849126SWyllys.Ingersoll@Sun.COM {
4859126SWyllys.Ingersoll@Sun.COM CK_RV rv;
4869126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
4879126SWyllys.Ingersoll@Sun.COM LOG("C_CopyObject");
4889126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
4899126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
4909126SWyllys.Ingersoll@Sun.COM }
4919126SWyllys.Ingersoll@Sun.COM if (!Valid_Session((Session_Struct_t *)hSession, &rSession)) {
4929126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
4939126SWyllys.Ingersoll@Sun.COM }
4949126SWyllys.Ingersoll@Sun.COM if (!phNewObject) {
4959126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
4969126SWyllys.Ingersoll@Sun.COM }
4979126SWyllys.Ingersoll@Sun.COM /*
4989126SWyllys.Ingersoll@Sun.COM * A null template with a count will cause the lower layer
4999126SWyllys.Ingersoll@Sun.COM * to have problems.
5009126SWyllys.Ingersoll@Sun.COM * Template with 0 count is not a problem.
5019126SWyllys.Ingersoll@Sun.COM */
5029126SWyllys.Ingersoll@Sun.COM if (!pTemplate && ulCount) {
5039126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
5049126SWyllys.Ingersoll@Sun.COM }
5059126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_CopyObject) {
5069126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_CopyObject(rSession, hObject, pTemplate,
5079126SWyllys.Ingersoll@Sun.COM ulCount, phNewObject);
5089126SWyllys.Ingersoll@Sun.COM } else {
5099126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
5109126SWyllys.Ingersoll@Sun.COM }
5119126SWyllys.Ingersoll@Sun.COM return (rv);
5129126SWyllys.Ingersoll@Sun.COM }
5139126SWyllys.Ingersoll@Sun.COM
5149126SWyllys.Ingersoll@Sun.COM CK_RV
C_CreateObject(CK_SESSION_HANDLE hSession,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phObject)5159126SWyllys.Ingersoll@Sun.COM C_CreateObject(
5169126SWyllys.Ingersoll@Sun.COM CK_SESSION_HANDLE hSession,
5179126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
5189126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount,
5199126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phObject)
5209126SWyllys.Ingersoll@Sun.COM {
5219126SWyllys.Ingersoll@Sun.COM CK_RV rv;
5229126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
5239126SWyllys.Ingersoll@Sun.COM
5249126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
5259126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
5269126SWyllys.Ingersoll@Sun.COM }
5279126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
5289126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
5299126SWyllys.Ingersoll@Sun.COM }
5309126SWyllys.Ingersoll@Sun.COM if (! pTemplate) {
5319126SWyllys.Ingersoll@Sun.COM return (CKR_TEMPLATE_INCOMPLETE);
5329126SWyllys.Ingersoll@Sun.COM }
5339126SWyllys.Ingersoll@Sun.COM if (ulCount == 0) {
5349126SWyllys.Ingersoll@Sun.COM return (CKR_TEMPLATE_INCOMPLETE);
5359126SWyllys.Ingersoll@Sun.COM }
5369126SWyllys.Ingersoll@Sun.COM if (! phObject) {
5379126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
5389126SWyllys.Ingersoll@Sun.COM }
5399126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_CreateObject) {
5409126SWyllys.Ingersoll@Sun.COM // Map the Session to the slot session
5419126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_CreateObject(rSession, pTemplate,
5429126SWyllys.Ingersoll@Sun.COM ulCount, phObject);
5439126SWyllys.Ingersoll@Sun.COM } else {
5449126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
5459126SWyllys.Ingersoll@Sun.COM }
5469126SWyllys.Ingersoll@Sun.COM return (rv);
5479126SWyllys.Ingersoll@Sun.COM }
5489126SWyllys.Ingersoll@Sun.COM
5499126SWyllys.Ingersoll@Sun.COM CK_RV
C_Decrypt(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pEncryptedData,CK_ULONG ulEncryptedDataLen,CK_BYTE_PTR pData,CK_ULONG_PTR pulDataLen)5509126SWyllys.Ingersoll@Sun.COM C_Decrypt(CK_SESSION_HANDLE hSession,
5519126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedData,
5529126SWyllys.Ingersoll@Sun.COM CK_ULONG ulEncryptedDataLen,
5539126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
5549126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDataLen)
5559126SWyllys.Ingersoll@Sun.COM {
5569126SWyllys.Ingersoll@Sun.COM CK_RV rv;
5579126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
5589126SWyllys.Ingersoll@Sun.COM
5599126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
5609126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
5619126SWyllys.Ingersoll@Sun.COM }
5629126SWyllys.Ingersoll@Sun.COM if (!Valid_Session((Session_Struct_t *)hSession, &rSession)) {
5639126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
5649126SWyllys.Ingersoll@Sun.COM }
5659126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Decrypt) {
5669126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_Decrypt(rSession, pEncryptedData,
5679126SWyllys.Ingersoll@Sun.COM ulEncryptedDataLen, pData, pulDataLen);
5689126SWyllys.Ingersoll@Sun.COM } else {
5699126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
5709126SWyllys.Ingersoll@Sun.COM }
5719126SWyllys.Ingersoll@Sun.COM return (rv);
5729126SWyllys.Ingersoll@Sun.COM }
5739126SWyllys.Ingersoll@Sun.COM
5749126SWyllys.Ingersoll@Sun.COM CK_RV
C_DecryptDigestUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pEncryptedPart,CK_ULONG ulEncryptedPartLen,CK_BYTE_PTR pPart,CK_ULONG_PTR pulPartLen)5759126SWyllys.Ingersoll@Sun.COM C_DecryptDigestUpdate(
5769126SWyllys.Ingersoll@Sun.COM CK_SESSION_HANDLE hSession,
5779126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedPart,
5789126SWyllys.Ingersoll@Sun.COM CK_ULONG ulEncryptedPartLen,
5799126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
5809126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulPartLen)
5819126SWyllys.Ingersoll@Sun.COM {
5829126SWyllys.Ingersoll@Sun.COM CK_RV rv;
5839126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
5849126SWyllys.Ingersoll@Sun.COM
5859126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
5869126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
5879126SWyllys.Ingersoll@Sun.COM }
5889126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
5899126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
5909126SWyllys.Ingersoll@Sun.COM }
5919126SWyllys.Ingersoll@Sun.COM if (! pEncryptedPart || ! pulPartLen) {
5929126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
5939126SWyllys.Ingersoll@Sun.COM }
5949126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DecryptDigestUpdate) {
5959126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DecryptDigestUpdate(rSession, pEncryptedPart,
5969126SWyllys.Ingersoll@Sun.COM ulEncryptedPartLen, pPart, pulPartLen);
5979126SWyllys.Ingersoll@Sun.COM } else {
5989126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
5999126SWyllys.Ingersoll@Sun.COM }
6009126SWyllys.Ingersoll@Sun.COM return (rv);
6019126SWyllys.Ingersoll@Sun.COM }
6029126SWyllys.Ingersoll@Sun.COM
6039126SWyllys.Ingersoll@Sun.COM CK_RV
C_DecryptFinal(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pLastPart,CK_ULONG_PTR pulLastPartLen)6049126SWyllys.Ingersoll@Sun.COM C_DecryptFinal(CK_SESSION_HANDLE hSession,
6059126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pLastPart,
6069126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulLastPartLen)
6079126SWyllys.Ingersoll@Sun.COM {
6089126SWyllys.Ingersoll@Sun.COM CK_RV rv;
6099126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
6109126SWyllys.Ingersoll@Sun.COM
6119126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
6129126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
6139126SWyllys.Ingersoll@Sun.COM }
6149126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
6159126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
6169126SWyllys.Ingersoll@Sun.COM }
6179126SWyllys.Ingersoll@Sun.COM /*
6189126SWyllys.Ingersoll@Sun.COM * It is acceptable to have a Null pointer for the data since
6199126SWyllys.Ingersoll@Sun.COM * it is trying to get the length of the last part....
6209126SWyllys.Ingersoll@Sun.COM * The spec is unclear if a second call to Final is needed
6219126SWyllys.Ingersoll@Sun.COM * if there is no data in the last part.
6229126SWyllys.Ingersoll@Sun.COM */
6239126SWyllys.Ingersoll@Sun.COM if (! pulLastPartLen) {
6249126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
6259126SWyllys.Ingersoll@Sun.COM }
6269126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DecryptFinal) {
6279126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DecryptFinal(rSession, pLastPart,
6289126SWyllys.Ingersoll@Sun.COM pulLastPartLen);
6299126SWyllys.Ingersoll@Sun.COM } else {
6309126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
6319126SWyllys.Ingersoll@Sun.COM }
6329126SWyllys.Ingersoll@Sun.COM return (rv);
6339126SWyllys.Ingersoll@Sun.COM }
6349126SWyllys.Ingersoll@Sun.COM
6359126SWyllys.Ingersoll@Sun.COM CK_RV
C_DecryptInit(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)6369126SWyllys.Ingersoll@Sun.COM C_DecryptInit(CK_SESSION_HANDLE hSession,
6379126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
6389126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
6399126SWyllys.Ingersoll@Sun.COM {
6409126SWyllys.Ingersoll@Sun.COM CK_RV rv;
6419126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
6429126SWyllys.Ingersoll@Sun.COM
6439126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
6449126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
6459126SWyllys.Ingersoll@Sun.COM }
6469126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
6479126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
6489126SWyllys.Ingersoll@Sun.COM }
6499126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
6509126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
6519126SWyllys.Ingersoll@Sun.COM }
6529126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DecryptInit) {
6539126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DecryptInit(rSession, pMechanism, hKey);
6549126SWyllys.Ingersoll@Sun.COM } else {
6559126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
6569126SWyllys.Ingersoll@Sun.COM }
6579126SWyllys.Ingersoll@Sun.COM return (rv);
6589126SWyllys.Ingersoll@Sun.COM }
6599126SWyllys.Ingersoll@Sun.COM
6609126SWyllys.Ingersoll@Sun.COM CK_RV
C_DecryptUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pEncryptedPart,CK_ULONG ulEncryptedPartLen,CK_BYTE_PTR pPart,CK_ULONG_PTR pulPartLen)6619126SWyllys.Ingersoll@Sun.COM C_DecryptUpdate(CK_SESSION_HANDLE hSession,
6629126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedPart,
6639126SWyllys.Ingersoll@Sun.COM CK_ULONG ulEncryptedPartLen,
6649126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
6659126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulPartLen)
6669126SWyllys.Ingersoll@Sun.COM {
6679126SWyllys.Ingersoll@Sun.COM CK_RV rv;
6689126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
6699126SWyllys.Ingersoll@Sun.COM
6709126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
6719126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
6729126SWyllys.Ingersoll@Sun.COM }
6739126SWyllys.Ingersoll@Sun.COM if (!Valid_Session((Session_Struct_t *)hSession, &rSession)) {
6749126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
6759126SWyllys.Ingersoll@Sun.COM }
6769126SWyllys.Ingersoll@Sun.COM if (!pEncryptedPart || !pulPartLen) {
6779126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
6789126SWyllys.Ingersoll@Sun.COM }
6799126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DecryptUpdate) {
6809126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DecryptUpdate(rSession, pEncryptedPart,
6819126SWyllys.Ingersoll@Sun.COM ulEncryptedPartLen, pPart, pulPartLen);
6829126SWyllys.Ingersoll@Sun.COM } else {
6839126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
6849126SWyllys.Ingersoll@Sun.COM }
6859126SWyllys.Ingersoll@Sun.COM return (rv);
6869126SWyllys.Ingersoll@Sun.COM }
6879126SWyllys.Ingersoll@Sun.COM
6889126SWyllys.Ingersoll@Sun.COM CK_RV
C_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pEncryptedPart,CK_ULONG ulEncryptedPartLen,CK_BYTE_PTR pPart,CK_ULONG_PTR pulPartLen)6899126SWyllys.Ingersoll@Sun.COM C_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession,
6909126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedPart,
6919126SWyllys.Ingersoll@Sun.COM CK_ULONG ulEncryptedPartLen,
6929126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
6939126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulPartLen)
6949126SWyllys.Ingersoll@Sun.COM {
6959126SWyllys.Ingersoll@Sun.COM CK_RV rv;
6969126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
6979126SWyllys.Ingersoll@Sun.COM
6989126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
6999126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
7009126SWyllys.Ingersoll@Sun.COM }
7019126SWyllys.Ingersoll@Sun.COM // Validate Session
7029126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
7039126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
7049126SWyllys.Ingersoll@Sun.COM }
7059126SWyllys.Ingersoll@Sun.COM // May have to let these go through and let the STDLL handle them
7069126SWyllys.Ingersoll@Sun.COM if (! pEncryptedPart || ! pulPartLen) {
7079126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
7089126SWyllys.Ingersoll@Sun.COM }
7099126SWyllys.Ingersoll@Sun.COM // Get local pointers to session
7109126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DecryptVerifyUpdate) {
7119126SWyllys.Ingersoll@Sun.COM // Map the Session to the slot session
7129126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DecryptVerifyUpdate(rSession,
7139126SWyllys.Ingersoll@Sun.COM pEncryptedPart, ulEncryptedPartLen, pPart, pulPartLen);
7149126SWyllys.Ingersoll@Sun.COM } else {
7159126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
7169126SWyllys.Ingersoll@Sun.COM }
7179126SWyllys.Ingersoll@Sun.COM return (rv);
7189126SWyllys.Ingersoll@Sun.COM }
7199126SWyllys.Ingersoll@Sun.COM
7209126SWyllys.Ingersoll@Sun.COM CK_RV
C_DeriveKey(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hBaseKey,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulAttributeCount,CK_OBJECT_HANDLE_PTR phKey)7219126SWyllys.Ingersoll@Sun.COM C_DeriveKey(CK_SESSION_HANDLE hSession,
7229126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
7239126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hBaseKey,
7249126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
7259126SWyllys.Ingersoll@Sun.COM CK_ULONG ulAttributeCount,
7269126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phKey)
7279126SWyllys.Ingersoll@Sun.COM {
7289126SWyllys.Ingersoll@Sun.COM CK_RV rv;
7299126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
7309126SWyllys.Ingersoll@Sun.COM
7319126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
7329126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
7339126SWyllys.Ingersoll@Sun.COM }
7349126SWyllys.Ingersoll@Sun.COM if (!Valid_Session((Session_Struct_t *)hSession, &rSession)) {
7359126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
7369126SWyllys.Ingersoll@Sun.COM }
7379126SWyllys.Ingersoll@Sun.COM
7389126SWyllys.Ingersoll@Sun.COM if (!pMechanism) {
7399126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
7409126SWyllys.Ingersoll@Sun.COM }
7419126SWyllys.Ingersoll@Sun.COM if (!pTemplate && ulAttributeCount) {
7429126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
7439126SWyllys.Ingersoll@Sun.COM }
7449126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DeriveKey) {
7459126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DeriveKey(rSession, pMechanism,
7469126SWyllys.Ingersoll@Sun.COM hBaseKey, pTemplate, ulAttributeCount, phKey);
7479126SWyllys.Ingersoll@Sun.COM } else {
7489126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
7499126SWyllys.Ingersoll@Sun.COM }
7509126SWyllys.Ingersoll@Sun.COM return (rv);
7519126SWyllys.Ingersoll@Sun.COM }
7529126SWyllys.Ingersoll@Sun.COM
7539126SWyllys.Ingersoll@Sun.COM CK_RV
C_DestroyObject(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject)7549126SWyllys.Ingersoll@Sun.COM C_DestroyObject(CK_SESSION_HANDLE hSession,
7559126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject)
7569126SWyllys.Ingersoll@Sun.COM {
7579126SWyllys.Ingersoll@Sun.COM CK_RV rv;
7589126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
7599126SWyllys.Ingersoll@Sun.COM
7609126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
7619126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
7629126SWyllys.Ingersoll@Sun.COM }
7639126SWyllys.Ingersoll@Sun.COM if (!Valid_Session((Session_Struct_t *)hSession, &rSession)) {
7649126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
7659126SWyllys.Ingersoll@Sun.COM }
7669126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DestroyObject) {
7679126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DestroyObject(rSession, hObject);
7689126SWyllys.Ingersoll@Sun.COM } else {
7699126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
7709126SWyllys.Ingersoll@Sun.COM }
7719126SWyllys.Ingersoll@Sun.COM return (rv);
7729126SWyllys.Ingersoll@Sun.COM }
7739126SWyllys.Ingersoll@Sun.COM
7749126SWyllys.Ingersoll@Sun.COM CK_RV
C_Digest(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pDigest,CK_ULONG_PTR pulDigestLen)7759126SWyllys.Ingersoll@Sun.COM C_Digest(CK_SESSION_HANDLE hSession,
7769126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
7779126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
7789126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pDigest,
7799126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDigestLen)
7809126SWyllys.Ingersoll@Sun.COM {
7819126SWyllys.Ingersoll@Sun.COM CK_RV rv;
7829126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
7839126SWyllys.Ingersoll@Sun.COM
7849126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
7859126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
7869126SWyllys.Ingersoll@Sun.COM }
7879126SWyllys.Ingersoll@Sun.COM if (!Valid_Session((Session_Struct_t *)hSession, &rSession)) {
7889126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
7899126SWyllys.Ingersoll@Sun.COM }
7909126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Digest) {
7919126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_Digest(rSession, pData, ulDataLen,
7929126SWyllys.Ingersoll@Sun.COM pDigest, pulDigestLen);
7939126SWyllys.Ingersoll@Sun.COM } else {
7949126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
7959126SWyllys.Ingersoll@Sun.COM }
7969126SWyllys.Ingersoll@Sun.COM return (rv);
7979126SWyllys.Ingersoll@Sun.COM }
7989126SWyllys.Ingersoll@Sun.COM
7999126SWyllys.Ingersoll@Sun.COM CK_RV
C_DigestEncryptUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen,CK_BYTE_PTR pEncryptedPart,CK_ULONG_PTR pulEncryptedPartLen)8009126SWyllys.Ingersoll@Sun.COM C_DigestEncryptUpdate(CK_SESSION_HANDLE hSession,
8019126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
8029126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen,
8039126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedPart,
8049126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulEncryptedPartLen)
8059126SWyllys.Ingersoll@Sun.COM {
8069126SWyllys.Ingersoll@Sun.COM CK_RV rv;
8079126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
8089126SWyllys.Ingersoll@Sun.COM
8099126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
8109126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
8119126SWyllys.Ingersoll@Sun.COM }
8129126SWyllys.Ingersoll@Sun.COM if (! pPart || ! pulEncryptedPartLen) {
8139126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
8149126SWyllys.Ingersoll@Sun.COM }
8159126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
8169126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
8179126SWyllys.Ingersoll@Sun.COM }
8189126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DigestEncryptUpdate) {
8199126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DigestEncryptUpdate(rSession, pPart,
8209126SWyllys.Ingersoll@Sun.COM ulPartLen, pEncryptedPart, pulEncryptedPartLen);
8219126SWyllys.Ingersoll@Sun.COM } else {
8229126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
8239126SWyllys.Ingersoll@Sun.COM }
8249126SWyllys.Ingersoll@Sun.COM return (rv);
8259126SWyllys.Ingersoll@Sun.COM }
8269126SWyllys.Ingersoll@Sun.COM
8279126SWyllys.Ingersoll@Sun.COM CK_RV
C_DigestFinal(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pDigest,CK_ULONG_PTR pulDigestLen)8289126SWyllys.Ingersoll@Sun.COM C_DigestFinal(CK_SESSION_HANDLE hSession,
8299126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pDigest,
8309126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDigestLen)
8319126SWyllys.Ingersoll@Sun.COM {
8329126SWyllys.Ingersoll@Sun.COM CK_RV rv;
8339126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
8349126SWyllys.Ingersoll@Sun.COM
8359126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
8369126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
8379126SWyllys.Ingersoll@Sun.COM }
8389126SWyllys.Ingersoll@Sun.COM if (! pulDigestLen) {
8399126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
8409126SWyllys.Ingersoll@Sun.COM }
8419126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
8429126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
8439126SWyllys.Ingersoll@Sun.COM }
8449126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DigestFinal) {
8459126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DigestFinal(rSession, pDigest, pulDigestLen);
8469126SWyllys.Ingersoll@Sun.COM } else {
8479126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
8489126SWyllys.Ingersoll@Sun.COM }
8499126SWyllys.Ingersoll@Sun.COM return (rv);
8509126SWyllys.Ingersoll@Sun.COM }
8519126SWyllys.Ingersoll@Sun.COM
8529126SWyllys.Ingersoll@Sun.COM CK_RV
C_DigestInit(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism)8539126SWyllys.Ingersoll@Sun.COM C_DigestInit(CK_SESSION_HANDLE hSession,
8549126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism)
8559126SWyllys.Ingersoll@Sun.COM {
8569126SWyllys.Ingersoll@Sun.COM CK_RV rv;
8579126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
8589126SWyllys.Ingersoll@Sun.COM
8599126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
8609126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
8619126SWyllys.Ingersoll@Sun.COM }
8629126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
8639126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
8649126SWyllys.Ingersoll@Sun.COM }
8659126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
8669126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
8679126SWyllys.Ingersoll@Sun.COM }
8689126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DigestInit) {
8699126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DigestInit(rSession, pMechanism);
8709126SWyllys.Ingersoll@Sun.COM } else {
8719126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
8729126SWyllys.Ingersoll@Sun.COM }
8739126SWyllys.Ingersoll@Sun.COM return (rv);
8749126SWyllys.Ingersoll@Sun.COM }
8759126SWyllys.Ingersoll@Sun.COM
8769126SWyllys.Ingersoll@Sun.COM CK_RV
C_DigestKey(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hKey)8779126SWyllys.Ingersoll@Sun.COM C_DigestKey(CK_SESSION_HANDLE hSession,
8789126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
8799126SWyllys.Ingersoll@Sun.COM {
8809126SWyllys.Ingersoll@Sun.COM CK_RV rv;
8819126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
8829126SWyllys.Ingersoll@Sun.COM
8839126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
8849126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
8859126SWyllys.Ingersoll@Sun.COM }
8869126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
8879126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
8889126SWyllys.Ingersoll@Sun.COM }
8899126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DigestKey) {
8909126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DigestKey(rSession, hKey);
8919126SWyllys.Ingersoll@Sun.COM } else {
8929126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
8939126SWyllys.Ingersoll@Sun.COM }
8949126SWyllys.Ingersoll@Sun.COM return (rv);
8959126SWyllys.Ingersoll@Sun.COM }
8969126SWyllys.Ingersoll@Sun.COM
8979126SWyllys.Ingersoll@Sun.COM CK_RV
C_DigestUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen)8989126SWyllys.Ingersoll@Sun.COM C_DigestUpdate(CK_SESSION_HANDLE hSession,
8999126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
9009126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen)
9019126SWyllys.Ingersoll@Sun.COM {
9029126SWyllys.Ingersoll@Sun.COM CK_RV rv;
9039126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
9049126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
9059126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
9069126SWyllys.Ingersoll@Sun.COM }
9079126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
9089126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
9099126SWyllys.Ingersoll@Sun.COM }
9109126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_DigestUpdate) {
9119126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_DigestUpdate(rSession, pPart, ulPartLen);
9129126SWyllys.Ingersoll@Sun.COM } else {
9139126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
9149126SWyllys.Ingersoll@Sun.COM }
9159126SWyllys.Ingersoll@Sun.COM return (rv);
9169126SWyllys.Ingersoll@Sun.COM }
9179126SWyllys.Ingersoll@Sun.COM
9189126SWyllys.Ingersoll@Sun.COM CK_RV
C_Encrypt(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pEncryptedData,CK_ULONG_PTR pulEncryptedDataLen)9199126SWyllys.Ingersoll@Sun.COM C_Encrypt(CK_SESSION_HANDLE hSession,
9209126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
9219126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
9229126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedData,
9239126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulEncryptedDataLen)
9249126SWyllys.Ingersoll@Sun.COM {
9259126SWyllys.Ingersoll@Sun.COM CK_RV rv;
9269126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
9279126SWyllys.Ingersoll@Sun.COM
9289126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
9299126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
9309126SWyllys.Ingersoll@Sun.COM }
9319126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
9329126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
9339126SWyllys.Ingersoll@Sun.COM }
9349126SWyllys.Ingersoll@Sun.COM // Get local pointers to session
9359126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Encrypt) {
9369126SWyllys.Ingersoll@Sun.COM // Map the Session to the slot session
9379126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_Encrypt(rSession, pData, ulDataLen,
9389126SWyllys.Ingersoll@Sun.COM pEncryptedData, pulEncryptedDataLen);
9399126SWyllys.Ingersoll@Sun.COM } else {
9409126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
9419126SWyllys.Ingersoll@Sun.COM }
9429126SWyllys.Ingersoll@Sun.COM return (rv);
9439126SWyllys.Ingersoll@Sun.COM }
9449126SWyllys.Ingersoll@Sun.COM
9459126SWyllys.Ingersoll@Sun.COM CK_RV
C_EncryptFinal(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pLastEncryptedPart,CK_ULONG_PTR pulLastEncryptedPartLen)9469126SWyllys.Ingersoll@Sun.COM C_EncryptFinal(CK_SESSION_HANDLE hSession,
9479126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pLastEncryptedPart,
9489126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulLastEncryptedPartLen)
9499126SWyllys.Ingersoll@Sun.COM {
9509126SWyllys.Ingersoll@Sun.COM CK_RV rv;
9519126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
9529126SWyllys.Ingersoll@Sun.COM
9539126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
9549126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
9559126SWyllys.Ingersoll@Sun.COM }
9569126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
9579126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
9589126SWyllys.Ingersoll@Sun.COM }
9599126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_EncryptFinal) {
9609126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_EncryptFinal(rSession,
9619126SWyllys.Ingersoll@Sun.COM pLastEncryptedPart, pulLastEncryptedPartLen);
9629126SWyllys.Ingersoll@Sun.COM } else {
9639126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
9649126SWyllys.Ingersoll@Sun.COM }
9659126SWyllys.Ingersoll@Sun.COM return (rv);
9669126SWyllys.Ingersoll@Sun.COM }
9679126SWyllys.Ingersoll@Sun.COM
9689126SWyllys.Ingersoll@Sun.COM CK_RV
C_EncryptInit(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)9699126SWyllys.Ingersoll@Sun.COM C_EncryptInit(CK_SESSION_HANDLE hSession,
9709126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
9719126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
9729126SWyllys.Ingersoll@Sun.COM {
9739126SWyllys.Ingersoll@Sun.COM CK_RV rv;
9749126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
9759126SWyllys.Ingersoll@Sun.COM
9769126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
9779126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
9789126SWyllys.Ingersoll@Sun.COM }
9799126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
9809126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
9819126SWyllys.Ingersoll@Sun.COM }
9829126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
9839126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
9849126SWyllys.Ingersoll@Sun.COM }
9859126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_EncryptInit) {
9869126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_EncryptInit(rSession, pMechanism, hKey);
9879126SWyllys.Ingersoll@Sun.COM } else {
9889126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
9899126SWyllys.Ingersoll@Sun.COM }
9909126SWyllys.Ingersoll@Sun.COM return (rv);
9919126SWyllys.Ingersoll@Sun.COM }
9929126SWyllys.Ingersoll@Sun.COM
9939126SWyllys.Ingersoll@Sun.COM CK_RV
C_EncryptUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen,CK_BYTE_PTR pEncryptedPart,CK_ULONG_PTR pulEncryptedPartLen)9949126SWyllys.Ingersoll@Sun.COM C_EncryptUpdate(CK_SESSION_HANDLE hSession,
9959126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
9969126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen,
9979126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedPart,
9989126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulEncryptedPartLen)
9999126SWyllys.Ingersoll@Sun.COM {
10009126SWyllys.Ingersoll@Sun.COM CK_RV rv;
10019126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
10029126SWyllys.Ingersoll@Sun.COM
10039126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
10049126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
10059126SWyllys.Ingersoll@Sun.COM }
10069126SWyllys.Ingersoll@Sun.COM if (!pPart || !pulEncryptedPartLen) {
10079126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
10089126SWyllys.Ingersoll@Sun.COM }
10099126SWyllys.Ingersoll@Sun.COM if (!Valid_Session((Session_Struct_t *)hSession, &rSession)) {
10109126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
10119126SWyllys.Ingersoll@Sun.COM }
10129126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_EncryptUpdate) {
10139126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_EncryptUpdate(rSession, pPart, ulPartLen,
10149126SWyllys.Ingersoll@Sun.COM pEncryptedPart, pulEncryptedPartLen);
10159126SWyllys.Ingersoll@Sun.COM } else {
10169126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
10179126SWyllys.Ingersoll@Sun.COM }
10189126SWyllys.Ingersoll@Sun.COM return (rv);
10199126SWyllys.Ingersoll@Sun.COM }
10209126SWyllys.Ingersoll@Sun.COM
10219126SWyllys.Ingersoll@Sun.COM CK_RV
do_finalize(CK_VOID_PTR pReserved)10229126SWyllys.Ingersoll@Sun.COM do_finalize(CK_VOID_PTR pReserved)
10239126SWyllys.Ingersoll@Sun.COM {
10249126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
10259126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
10269126SWyllys.Ingersoll@Sun.COM }
10279126SWyllys.Ingersoll@Sun.COM if (pReserved != NULL) {
10289126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
10299126SWyllys.Ingersoll@Sun.COM }
10309126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&global_mutex);
10319453SWyllys.Ingersoll@Sun.COM if (Anchor)
10329453SWyllys.Ingersoll@Sun.COM Terminate_All_Process_Sessions();
10339453SWyllys.Ingersoll@Sun.COM
10349126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Finalize)
10359126SWyllys.Ingersoll@Sun.COM FuncList.ST_Finalize(0);
10369126SWyllys.Ingersoll@Sun.COM
10379126SWyllys.Ingersoll@Sun.COM free(Anchor);
10389126SWyllys.Ingersoll@Sun.COM Anchor = NULL;
10399453SWyllys.Ingersoll@Sun.COM
10409126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
10419126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
10429126SWyllys.Ingersoll@Sun.COM }
10439126SWyllys.Ingersoll@Sun.COM
10449126SWyllys.Ingersoll@Sun.COM CK_RV
C_Finalize(CK_VOID_PTR pReserved)10459126SWyllys.Ingersoll@Sun.COM C_Finalize(CK_VOID_PTR pReserved) {
10469126SWyllys.Ingersoll@Sun.COM return (do_finalize(pReserved));
10479126SWyllys.Ingersoll@Sun.COM }
10489126SWyllys.Ingersoll@Sun.COM
10499126SWyllys.Ingersoll@Sun.COM CK_RV
C_FindObjects(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE_PTR phObject,CK_ULONG ulMaxObjectCount,CK_ULONG_PTR pulObjectCount)10509126SWyllys.Ingersoll@Sun.COM C_FindObjects(CK_SESSION_HANDLE hSession,
10519126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phObject,
10529126SWyllys.Ingersoll@Sun.COM CK_ULONG ulMaxObjectCount,
10539126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulObjectCount)
10549126SWyllys.Ingersoll@Sun.COM {
10559126SWyllys.Ingersoll@Sun.COM CK_RV rv;
10569126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
10579126SWyllys.Ingersoll@Sun.COM
10589126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
10599126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
10609126SWyllys.Ingersoll@Sun.COM }
10619126SWyllys.Ingersoll@Sun.COM if (! phObject || ! pulObjectCount) {
10629126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
10639126SWyllys.Ingersoll@Sun.COM }
10649126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
10659126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
10669126SWyllys.Ingersoll@Sun.COM }
10679126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_FindObjects) {
10689126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_FindObjects(rSession, phObject,
10699126SWyllys.Ingersoll@Sun.COM ulMaxObjectCount, pulObjectCount);
10709126SWyllys.Ingersoll@Sun.COM } else {
10719126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
10729126SWyllys.Ingersoll@Sun.COM }
10739126SWyllys.Ingersoll@Sun.COM return (rv);
10749126SWyllys.Ingersoll@Sun.COM }
10759126SWyllys.Ingersoll@Sun.COM
10769126SWyllys.Ingersoll@Sun.COM CK_RV
C_FindObjectsFinal(CK_SESSION_HANDLE hSession)10779126SWyllys.Ingersoll@Sun.COM C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
10789126SWyllys.Ingersoll@Sun.COM {
10799126SWyllys.Ingersoll@Sun.COM CK_RV rv;
10809126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
10819126SWyllys.Ingersoll@Sun.COM
10829126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
10839126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
10849126SWyllys.Ingersoll@Sun.COM }
10859126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
10869126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
10879126SWyllys.Ingersoll@Sun.COM }
10889126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_FindObjectsFinal) {
10899126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_FindObjectsFinal(rSession);
10909126SWyllys.Ingersoll@Sun.COM } else {
10919126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
10929126SWyllys.Ingersoll@Sun.COM }
10939126SWyllys.Ingersoll@Sun.COM return (rv);
10949126SWyllys.Ingersoll@Sun.COM }
10959126SWyllys.Ingersoll@Sun.COM
10969126SWyllys.Ingersoll@Sun.COM CK_RV
C_FindObjectsInit(CK_SESSION_HANDLE hSession,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)10979126SWyllys.Ingersoll@Sun.COM C_FindObjectsInit(CK_SESSION_HANDLE hSession,
10989126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
10999126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount)
11009126SWyllys.Ingersoll@Sun.COM {
11019126SWyllys.Ingersoll@Sun.COM CK_RV rv;
11029126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
11039126SWyllys.Ingersoll@Sun.COM
11049126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
11059126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
11069126SWyllys.Ingersoll@Sun.COM }
11079126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
11089126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
11099126SWyllys.Ingersoll@Sun.COM }
11109126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_FindObjectsInit) {
11119126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_FindObjectsInit(rSession, pTemplate, ulCount);
11129126SWyllys.Ingersoll@Sun.COM } else {
11139126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
11149126SWyllys.Ingersoll@Sun.COM }
11159126SWyllys.Ingersoll@Sun.COM return (rv);
11169126SWyllys.Ingersoll@Sun.COM }
11179126SWyllys.Ingersoll@Sun.COM
11189126SWyllys.Ingersoll@Sun.COM CK_RV
C_GenerateKey(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,CK_OBJECT_HANDLE_PTR phKey)11199126SWyllys.Ingersoll@Sun.COM C_GenerateKey(CK_SESSION_HANDLE hSession,
11209126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
11219126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
11229126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount,
11239126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phKey)
11249126SWyllys.Ingersoll@Sun.COM {
11259126SWyllys.Ingersoll@Sun.COM CK_RV rv;
11269126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
11279126SWyllys.Ingersoll@Sun.COM
11289126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
11299126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
11309126SWyllys.Ingersoll@Sun.COM }
11319126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
11329126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
11339126SWyllys.Ingersoll@Sun.COM }
11349126SWyllys.Ingersoll@Sun.COM if (! phKey) {
11359126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
11369126SWyllys.Ingersoll@Sun.COM }
11379126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
11389126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
11399126SWyllys.Ingersoll@Sun.COM }
11409126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GenerateKey) {
11419126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GenerateKey(rSession, pMechanism,
11429126SWyllys.Ingersoll@Sun.COM pTemplate, ulCount, phKey);
11439126SWyllys.Ingersoll@Sun.COM } else {
11449126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
11459126SWyllys.Ingersoll@Sun.COM }
11469126SWyllys.Ingersoll@Sun.COM return (rv);
11479126SWyllys.Ingersoll@Sun.COM }
11489126SWyllys.Ingersoll@Sun.COM
11499126SWyllys.Ingersoll@Sun.COM CK_RV
C_GenerateKeyPair(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_ATTRIBUTE_PTR pPublicKeyTemplate,CK_ULONG ulPublicKeyAttributeCount,CK_ATTRIBUTE_PTR pPrivateKeyTemplate,CK_ULONG ulPrivateKeyAttributeCount,CK_OBJECT_HANDLE_PTR phPublicKey,CK_OBJECT_HANDLE_PTR phPrivateKey)11509126SWyllys.Ingersoll@Sun.COM C_GenerateKeyPair(CK_SESSION_HANDLE hSession,
11519126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
11529126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pPublicKeyTemplate,
11539126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPublicKeyAttributeCount,
11549126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
11559126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPrivateKeyAttributeCount,
11569126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phPublicKey,
11579126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phPrivateKey)
11589126SWyllys.Ingersoll@Sun.COM {
11599126SWyllys.Ingersoll@Sun.COM CK_RV rv;
11609126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
11619126SWyllys.Ingersoll@Sun.COM
11629126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
11639126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
11649126SWyllys.Ingersoll@Sun.COM }
11659126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
11669126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
11679126SWyllys.Ingersoll@Sun.COM }
11689126SWyllys.Ingersoll@Sun.COM if (! phPublicKey || ! phPrivateKey) {
11699126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
11709126SWyllys.Ingersoll@Sun.COM }
11719126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
11729126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
11739126SWyllys.Ingersoll@Sun.COM }
11749126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GenerateKeyPair) {
11759126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GenerateKeyPair(rSession,
11769126SWyllys.Ingersoll@Sun.COM pMechanism, pPublicKeyTemplate,
11779126SWyllys.Ingersoll@Sun.COM ulPublicKeyAttributeCount, pPrivateKeyTemplate,
11789126SWyllys.Ingersoll@Sun.COM ulPrivateKeyAttributeCount, phPublicKey, phPrivateKey);
11799126SWyllys.Ingersoll@Sun.COM } else {
11809126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
11819126SWyllys.Ingersoll@Sun.COM }
11829126SWyllys.Ingersoll@Sun.COM return (rv);
11839126SWyllys.Ingersoll@Sun.COM }
11849126SWyllys.Ingersoll@Sun.COM
11859126SWyllys.Ingersoll@Sun.COM CK_RV
C_GenerateRandom(CK_SESSION_HANDLE hSession,CK_BYTE_PTR RandomData,CK_ULONG ulRandomLen)11869126SWyllys.Ingersoll@Sun.COM C_GenerateRandom(CK_SESSION_HANDLE hSession,
11879126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR RandomData,
11889126SWyllys.Ingersoll@Sun.COM CK_ULONG ulRandomLen)
11899126SWyllys.Ingersoll@Sun.COM {
11909126SWyllys.Ingersoll@Sun.COM CK_RV rv;
11919126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
11929126SWyllys.Ingersoll@Sun.COM
11939126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
11949126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
11959126SWyllys.Ingersoll@Sun.COM }
11969126SWyllys.Ingersoll@Sun.COM if (! RandomData)
11979126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
11989126SWyllys.Ingersoll@Sun.COM
11999126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
12009126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
12019126SWyllys.Ingersoll@Sun.COM }
12029126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GenerateRandom) {
12039126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GenerateRandom(rSession, RandomData,
12049126SWyllys.Ingersoll@Sun.COM ulRandomLen);
12059126SWyllys.Ingersoll@Sun.COM } else {
12069126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
12079126SWyllys.Ingersoll@Sun.COM }
12089126SWyllys.Ingersoll@Sun.COM return (rv);
12099126SWyllys.Ingersoll@Sun.COM }
12109126SWyllys.Ingersoll@Sun.COM
12119126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetAttributeValue(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)12129126SWyllys.Ingersoll@Sun.COM C_GetAttributeValue(CK_SESSION_HANDLE hSession,
12139126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
12149126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
12159126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount)
12169126SWyllys.Ingersoll@Sun.COM {
12179126SWyllys.Ingersoll@Sun.COM CK_RV rv;
12189126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
12199126SWyllys.Ingersoll@Sun.COM
12209126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
12219126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
12229126SWyllys.Ingersoll@Sun.COM }
12239126SWyllys.Ingersoll@Sun.COM if (! pTemplate) {
12249126SWyllys.Ingersoll@Sun.COM return (CKR_TEMPLATE_INCOMPLETE);
12259126SWyllys.Ingersoll@Sun.COM }
12269126SWyllys.Ingersoll@Sun.COM if (ulCount == 0) {
12279126SWyllys.Ingersoll@Sun.COM return (CKR_TEMPLATE_INCOMPLETE);
12289126SWyllys.Ingersoll@Sun.COM }
12299126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
12309126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
12319126SWyllys.Ingersoll@Sun.COM }
12329126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GetAttributeValue) {
12339126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GetAttributeValue(rSession, hObject,
12349126SWyllys.Ingersoll@Sun.COM pTemplate, ulCount);
12359126SWyllys.Ingersoll@Sun.COM } else {
12369126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
12379126SWyllys.Ingersoll@Sun.COM }
12389126SWyllys.Ingersoll@Sun.COM return (rv);
12399126SWyllys.Ingersoll@Sun.COM }
12409126SWyllys.Ingersoll@Sun.COM
12419126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR ppFunctionList)12429126SWyllys.Ingersoll@Sun.COM C_GetFunctionList(CK_FUNCTION_LIST_PTR_PTR ppFunctionList)
12439126SWyllys.Ingersoll@Sun.COM {
12449126SWyllys.Ingersoll@Sun.COM _init();
12459126SWyllys.Ingersoll@Sun.COM
12469126SWyllys.Ingersoll@Sun.COM PK11_Functions.version.major = VERSION_MAJOR;
12479126SWyllys.Ingersoll@Sun.COM PK11_Functions.version.minor = VERSION_MINOR;
12489126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Initialize = C_Initialize;
12499126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Finalize = C_Finalize;
12509126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetInfo = C_GetInfo;
12519126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetFunctionList = C_GetFunctionList;
12529126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetSlotList = C_GetSlotList;
12539126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetSlotInfo = C_GetSlotInfo;
12549126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetTokenInfo = C_GetTokenInfo;
12559126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetMechanismList = C_GetMechanismList;
12569126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetMechanismInfo = C_GetMechanismInfo;
12579126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_InitToken = C_InitToken;
12589126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_InitPIN = C_InitPIN;
12599126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SetPIN = C_SetPIN;
12609126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_OpenSession = C_OpenSession;
12619126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_CloseSession = C_CloseSession;
12629126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_CloseAllSessions = C_CloseAllSessions;
12639126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetSessionInfo = C_GetSessionInfo;
12649126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetOperationState = C_GetOperationState;
12659126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SetOperationState = C_SetOperationState;
12669126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Login = C_Login;
12679126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Logout = C_Logout;
12689126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_CreateObject = C_CreateObject;
12699126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_CopyObject = C_CopyObject;
12709126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DestroyObject = C_DestroyObject;
12719126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetObjectSize = C_GetObjectSize;
12729126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetAttributeValue = C_GetAttributeValue;
12739126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SetAttributeValue = C_SetAttributeValue;
12749126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_FindObjectsInit = C_FindObjectsInit;
12759126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_FindObjects = C_FindObjects;
12769126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_FindObjectsFinal = C_FindObjectsFinal;
12779126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_EncryptInit = C_EncryptInit;
12789126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Encrypt = C_Encrypt;
12799126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_EncryptUpdate = C_EncryptUpdate;
12809126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_EncryptFinal = C_EncryptFinal;
12819126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DecryptInit = C_DecryptInit;
12829126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Decrypt = C_Decrypt;
12839126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DecryptUpdate = C_DecryptUpdate;
12849126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DecryptFinal = C_DecryptFinal;
12859126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DigestInit = C_DigestInit;
12869126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Digest = C_Digest;
12879126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DigestUpdate = C_DigestUpdate;
12889126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DigestKey = C_DigestKey;
12899126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DigestFinal = C_DigestFinal;
12909126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SignInit = C_SignInit;
12919126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Sign = C_Sign;
12929126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SignUpdate = C_SignUpdate;
12939126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SignFinal = C_SignFinal;
12949126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SignRecoverInit = C_SignRecoverInit;
12959126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SignRecover = C_SignRecover;
12969126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_VerifyInit = C_VerifyInit;
12979126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_Verify = C_Verify;
12989126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_VerifyUpdate = C_VerifyUpdate;
12999126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_VerifyFinal = C_VerifyFinal;
13009126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_VerifyRecoverInit = C_VerifyRecoverInit;
13019126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_VerifyRecover = C_VerifyRecover;
13029126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DigestEncryptUpdate = C_DigestEncryptUpdate;
13039126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DecryptDigestUpdate = C_DecryptDigestUpdate;
13049126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SignEncryptUpdate = C_SignEncryptUpdate;
13059126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DecryptVerifyUpdate = C_DecryptVerifyUpdate;
13069126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GenerateKey = C_GenerateKey;
13079126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GenerateKeyPair = C_GenerateKeyPair;
13089126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_WrapKey = C_WrapKey;
13099126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_UnwrapKey = C_UnwrapKey;
13109126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_DeriveKey = C_DeriveKey;
13119126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_SeedRandom = C_SeedRandom;
13129126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GenerateRandom = C_GenerateRandom;
13139126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_GetFunctionStatus = C_GetFunctionStatus;
13149126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_CancelFunction = C_CancelFunction;
13159126SWyllys.Ingersoll@Sun.COM PK11_Functions.C_WaitForSlotEvent = C_WaitForSlotEvent;
13169126SWyllys.Ingersoll@Sun.COM if (ppFunctionList) {
13179126SWyllys.Ingersoll@Sun.COM (*ppFunctionList) = &PK11_Functions;
13189126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
13199126SWyllys.Ingersoll@Sun.COM } else {
13209126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
13219126SWyllys.Ingersoll@Sun.COM }
13229126SWyllys.Ingersoll@Sun.COM }
13239126SWyllys.Ingersoll@Sun.COM
13249126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
13259126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetFunctionStatus(CK_SESSION_HANDLE hSession)13269126SWyllys.Ingersoll@Sun.COM C_GetFunctionStatus(CK_SESSION_HANDLE hSession)
13279126SWyllys.Ingersoll@Sun.COM {
13289126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
13299126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
13309126SWyllys.Ingersoll@Sun.COM }
13319126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_NOT_PARALLEL); // PER Specification PG 170
13329126SWyllys.Ingersoll@Sun.COM }
13339126SWyllys.Ingersoll@Sun.COM
13349126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetInfo(CK_INFO_PTR pInfo)13359126SWyllys.Ingersoll@Sun.COM C_GetInfo(CK_INFO_PTR pInfo)
13369126SWyllys.Ingersoll@Sun.COM {
13379126SWyllys.Ingersoll@Sun.COM TOKEN_DATA td;
13389126SWyllys.Ingersoll@Sun.COM TSS_HCONTEXT hContext;
13399126SWyllys.Ingersoll@Sun.COM
13409126SWyllys.Ingersoll@Sun.COM if (! API_Initialized()) {
13419126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
13429126SWyllys.Ingersoll@Sun.COM }
13439126SWyllys.Ingersoll@Sun.COM if (! pInfo) {
13449126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
13459126SWyllys.Ingersoll@Sun.COM }
13469126SWyllys.Ingersoll@Sun.COM (void) memset(pInfo, 0, sizeof (*pInfo));
13479126SWyllys.Ingersoll@Sun.COM pInfo->cryptokiVersion.major = 2;
13489126SWyllys.Ingersoll@Sun.COM pInfo->cryptokiVersion.minor = 20;
13499126SWyllys.Ingersoll@Sun.COM
1350*10346Swyllys.ingersoll@sun.com if (open_tss_context(&hContext) == 0) {
1351*10346Swyllys.ingersoll@sun.com /*
1352*10346Swyllys.ingersoll@sun.com * Only populate the TPM info if we can establish
1353*10346Swyllys.ingersoll@sun.com * a context, but don't return failure because
1354*10346Swyllys.ingersoll@sun.com * the framework needs to know some of the info.
1355*10346Swyllys.ingersoll@sun.com */
1356*10346Swyllys.ingersoll@sun.com (void) token_get_tpm_info(hContext, &td);
13579126SWyllys.Ingersoll@Sun.COM
1358*10346Swyllys.ingersoll@sun.com (void) Tspi_Context_Close(hContext);
13599126SWyllys.Ingersoll@Sun.COM
1360*10346Swyllys.ingersoll@sun.com (void) memcpy(pInfo->manufacturerID,
1361*10346Swyllys.ingersoll@sun.com &(td.token_info.manufacturerID),
1362*10346Swyllys.ingersoll@sun.com sizeof (pInfo->manufacturerID) - 1);
13639126SWyllys.Ingersoll@Sun.COM
1364*10346Swyllys.ingersoll@sun.com pInfo->flags = td.token_info.flags;
1365*10346Swyllys.ingersoll@sun.com }
13669126SWyllys.Ingersoll@Sun.COM (void) strcpy((char *)pInfo->libraryDescription,
13679126SWyllys.Ingersoll@Sun.COM "PKCS11 Interface for TPM");
13689126SWyllys.Ingersoll@Sun.COM
13699126SWyllys.Ingersoll@Sun.COM pInfo->libraryVersion.major = 1;
13709126SWyllys.Ingersoll@Sun.COM pInfo->libraryVersion.minor = 0;
13719126SWyllys.Ingersoll@Sun.COM
13729126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
13739126SWyllys.Ingersoll@Sun.COM }
13749126SWyllys.Ingersoll@Sun.COM
13759126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetMechanismInfo(CK_SLOT_ID slotID,CK_MECHANISM_TYPE type,CK_MECHANISM_INFO_PTR pInfo)13769126SWyllys.Ingersoll@Sun.COM C_GetMechanismInfo(CK_SLOT_ID slotID,
13779126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_TYPE type,
13789126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_INFO_PTR pInfo)
13799126SWyllys.Ingersoll@Sun.COM {
13809126SWyllys.Ingersoll@Sun.COM CK_RV rv;
1381*10346Swyllys.ingersoll@sun.com if (API_Initialized() == FALSE)
13829126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
1383*10346Swyllys.ingersoll@sun.com
1384*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available || (slotID > NUMBER_SLOTS_MANAGED))
13859126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
1386*10346Swyllys.ingersoll@sun.com
13879126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GetMechanismInfo) {
13889126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GetMechanismInfo(slotID, type, pInfo);
13899126SWyllys.Ingersoll@Sun.COM } else {
13909126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
13919126SWyllys.Ingersoll@Sun.COM }
13929126SWyllys.Ingersoll@Sun.COM return (rv);
13939126SWyllys.Ingersoll@Sun.COM }
13949126SWyllys.Ingersoll@Sun.COM
13959126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetMechanismList(CK_SLOT_ID slotID,CK_MECHANISM_TYPE_PTR pMechanismList,CK_ULONG_PTR pulCount)13969126SWyllys.Ingersoll@Sun.COM C_GetMechanismList(CK_SLOT_ID slotID,
13979126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_TYPE_PTR pMechanismList,
13989126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulCount)
13999126SWyllys.Ingersoll@Sun.COM {
14009126SWyllys.Ingersoll@Sun.COM CK_RV rv;
14019126SWyllys.Ingersoll@Sun.COM
1402*10346Swyllys.ingersoll@sun.com if (API_Initialized() == FALSE)
14039126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
1404*10346Swyllys.ingersoll@sun.com
14059126SWyllys.Ingersoll@Sun.COM if (! pulCount)
14069126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
14079126SWyllys.Ingersoll@Sun.COM
1408*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available || (slotID > NUMBER_SLOTS_MANAGED))
14099126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
14109126SWyllys.Ingersoll@Sun.COM
14119126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GetMechanismList) {
14129126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GetMechanismList(slotID,
14139126SWyllys.Ingersoll@Sun.COM pMechanismList, pulCount);
14149126SWyllys.Ingersoll@Sun.COM } else {
14159126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
14169126SWyllys.Ingersoll@Sun.COM }
14179126SWyllys.Ingersoll@Sun.COM if (rv == CKR_OK) {
14189126SWyllys.Ingersoll@Sun.COM if (pMechanismList) {
14199126SWyllys.Ingersoll@Sun.COM unsigned long i;
14209126SWyllys.Ingersoll@Sun.COM for (i = 0; i < *pulCount; i++) {
14219126SWyllys.Ingersoll@Sun.COM logit(LOG_DEBUG, "Mechanism[%d] 0x%08X ",
14229126SWyllys.Ingersoll@Sun.COM i, pMechanismList[i]);
14239126SWyllys.Ingersoll@Sun.COM }
14249126SWyllys.Ingersoll@Sun.COM }
14259126SWyllys.Ingersoll@Sun.COM }
14269126SWyllys.Ingersoll@Sun.COM return (rv);
14279126SWyllys.Ingersoll@Sun.COM }
14289126SWyllys.Ingersoll@Sun.COM
14299126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetObjectSize(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ULONG_PTR pulSize)14309126SWyllys.Ingersoll@Sun.COM C_GetObjectSize(CK_SESSION_HANDLE hSession,
14319126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
14329126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSize)
14339126SWyllys.Ingersoll@Sun.COM {
14349126SWyllys.Ingersoll@Sun.COM CK_RV rv;
14359126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
14369126SWyllys.Ingersoll@Sun.COM
14379126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
14389126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
14399126SWyllys.Ingersoll@Sun.COM }
14409126SWyllys.Ingersoll@Sun.COM if (! pulSize) {
14419126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
14429126SWyllys.Ingersoll@Sun.COM }
14439126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
14449126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
14459126SWyllys.Ingersoll@Sun.COM }
14469126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GetObjectSize) {
14479126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GetObjectSize(rSession, hObject, pulSize);
14489126SWyllys.Ingersoll@Sun.COM } else {
14499126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
14509126SWyllys.Ingersoll@Sun.COM }
14519126SWyllys.Ingersoll@Sun.COM return (rv);
14529126SWyllys.Ingersoll@Sun.COM }
14539126SWyllys.Ingersoll@Sun.COM
14549126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetOperationState(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pOperationState,CK_ULONG_PTR pulOperationStateLen)14559126SWyllys.Ingersoll@Sun.COM C_GetOperationState(CK_SESSION_HANDLE hSession,
14569126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pOperationState,
14579126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulOperationStateLen)
14589126SWyllys.Ingersoll@Sun.COM {
14599126SWyllys.Ingersoll@Sun.COM CK_RV rv;
14609126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
14619126SWyllys.Ingersoll@Sun.COM
14629126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
14639126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
14649126SWyllys.Ingersoll@Sun.COM }
14659126SWyllys.Ingersoll@Sun.COM if (! pulOperationStateLen) {
14669126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
14679126SWyllys.Ingersoll@Sun.COM }
14689126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
14699126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
14709126SWyllys.Ingersoll@Sun.COM }
14719126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GetOperationState) {
14729126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GetOperationState(rSession,
14739126SWyllys.Ingersoll@Sun.COM pOperationState, pulOperationStateLen);
14749126SWyllys.Ingersoll@Sun.COM } else {
14759126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
14769126SWyllys.Ingersoll@Sun.COM }
14779126SWyllys.Ingersoll@Sun.COM return (rv);
14789126SWyllys.Ingersoll@Sun.COM }
14799126SWyllys.Ingersoll@Sun.COM
14809126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetSessionInfo(CK_SESSION_HANDLE hSession,CK_SESSION_INFO_PTR pInfo)14819126SWyllys.Ingersoll@Sun.COM C_GetSessionInfo(CK_SESSION_HANDLE hSession,
14829126SWyllys.Ingersoll@Sun.COM CK_SESSION_INFO_PTR pInfo)
14839126SWyllys.Ingersoll@Sun.COM {
14849126SWyllys.Ingersoll@Sun.COM CK_RV rv;
14859126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
14869126SWyllys.Ingersoll@Sun.COM
14879126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
14889126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
14899126SWyllys.Ingersoll@Sun.COM }
14909126SWyllys.Ingersoll@Sun.COM if (! pInfo) {
14919126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
14929126SWyllys.Ingersoll@Sun.COM }
14939126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
14949126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
14959126SWyllys.Ingersoll@Sun.COM }
14969126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GetSessionInfo) {
14979126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GetSessionInfo(rSession, pInfo);
14989126SWyllys.Ingersoll@Sun.COM } else {
14999126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
15009126SWyllys.Ingersoll@Sun.COM }
15019126SWyllys.Ingersoll@Sun.COM return (rv);
15029126SWyllys.Ingersoll@Sun.COM }
15039126SWyllys.Ingersoll@Sun.COM
15049126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetSlotInfo(CK_SLOT_ID slotID,CK_SLOT_INFO_PTR pInfo)15059126SWyllys.Ingersoll@Sun.COM C_GetSlotInfo(CK_SLOT_ID slotID,
15069126SWyllys.Ingersoll@Sun.COM CK_SLOT_INFO_PTR pInfo)
15079126SWyllys.Ingersoll@Sun.COM {
1508*10346Swyllys.ingersoll@sun.com if (API_Initialized() == FALSE)
15099126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
1510*10346Swyllys.ingersoll@sun.com
1511*10346Swyllys.ingersoll@sun.com if (!pInfo)
15129126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
1513*10346Swyllys.ingersoll@sun.com
1514*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available || (slotID > NUMBER_SLOTS_MANAGED))
15159126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
15169126SWyllys.Ingersoll@Sun.COM
15179126SWyllys.Ingersoll@Sun.COM copy_slot_info(slotID, pInfo);
15189126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
15199126SWyllys.Ingersoll@Sun.COM }
15209126SWyllys.Ingersoll@Sun.COM
15219126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
15229126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetSlotList(CK_BBOOL tokenPresent,CK_SLOT_ID_PTR pSlotList,CK_ULONG_PTR pulCount)15239126SWyllys.Ingersoll@Sun.COM C_GetSlotList(CK_BBOOL tokenPresent,
15249126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID_PTR pSlotList,
15259126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulCount)
15269126SWyllys.Ingersoll@Sun.COM {
15279126SWyllys.Ingersoll@Sun.COM CK_ULONG count;
15289126SWyllys.Ingersoll@Sun.COM CK_SLOT_INFO slotInfo;
15299126SWyllys.Ingersoll@Sun.COM
15309126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE)
15319126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
15329126SWyllys.Ingersoll@Sun.COM
15339126SWyllys.Ingersoll@Sun.COM if (pulCount == NULL)
15349126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
15359126SWyllys.Ingersoll@Sun.COM
15369126SWyllys.Ingersoll@Sun.COM count = 0;
1537*10346Swyllys.ingersoll@sun.com /*
1538*10346Swyllys.ingersoll@sun.com * If we can't talk to the TPM, present no slots
1539*10346Swyllys.ingersoll@sun.com */
1540*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available) {
1541*10346Swyllys.ingersoll@sun.com *pulCount = 0;
1542*10346Swyllys.ingersoll@sun.com return (CKR_OK);
1543*10346Swyllys.ingersoll@sun.com }
15449126SWyllys.Ingersoll@Sun.COM
15459126SWyllys.Ingersoll@Sun.COM copy_slot_info(TPM_SLOTID, &slotInfo);
15469126SWyllys.Ingersoll@Sun.COM if ((slotInfo.flags & CKF_TOKEN_PRESENT))
15479126SWyllys.Ingersoll@Sun.COM count++;
15489126SWyllys.Ingersoll@Sun.COM
15499126SWyllys.Ingersoll@Sun.COM *pulCount = count;
15509126SWyllys.Ingersoll@Sun.COM
15519126SWyllys.Ingersoll@Sun.COM if (pSlotList == NULL) {
15529126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
15539126SWyllys.Ingersoll@Sun.COM } else {
15549126SWyllys.Ingersoll@Sun.COM if (*pulCount < count)
15559126SWyllys.Ingersoll@Sun.COM return (CKR_BUFFER_TOO_SMALL);
15569126SWyllys.Ingersoll@Sun.COM pSlotList[0] = TPM_SLOTID;
15579126SWyllys.Ingersoll@Sun.COM }
15589126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
15599126SWyllys.Ingersoll@Sun.COM }
15609126SWyllys.Ingersoll@Sun.COM
15619126SWyllys.Ingersoll@Sun.COM CK_RV
C_GetTokenInfo(CK_SLOT_ID slotID,CK_TOKEN_INFO_PTR pInfo)15629126SWyllys.Ingersoll@Sun.COM C_GetTokenInfo(CK_SLOT_ID slotID,
15639126SWyllys.Ingersoll@Sun.COM CK_TOKEN_INFO_PTR pInfo)
15649126SWyllys.Ingersoll@Sun.COM {
15659126SWyllys.Ingersoll@Sun.COM CK_RV rv;
15669126SWyllys.Ingersoll@Sun.COM
1567*10346Swyllys.ingersoll@sun.com if (API_Initialized() == FALSE)
15689126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
1569*10346Swyllys.ingersoll@sun.com
1570*10346Swyllys.ingersoll@sun.com if (!pInfo)
15719126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
1572*10346Swyllys.ingersoll@sun.com
1573*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available || (slotID > NUMBER_SLOTS_MANAGED))
15749126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
1575*10346Swyllys.ingersoll@sun.com
15769126SWyllys.Ingersoll@Sun.COM slotID = TPM_SLOTID;
15779126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_GetTokenInfo) {
15789126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_GetTokenInfo(slotID, pInfo);
15799126SWyllys.Ingersoll@Sun.COM } else {
15809126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
15819126SWyllys.Ingersoll@Sun.COM }
15829126SWyllys.Ingersoll@Sun.COM return (rv);
15839126SWyllys.Ingersoll@Sun.COM }
15849126SWyllys.Ingersoll@Sun.COM
15859126SWyllys.Ingersoll@Sun.COM CK_RV
C_Initialize(CK_VOID_PTR pVoid)15869126SWyllys.Ingersoll@Sun.COM C_Initialize(CK_VOID_PTR pVoid)
15879126SWyllys.Ingersoll@Sun.COM {
15889126SWyllys.Ingersoll@Sun.COM CK_RV rv = CKR_OK;
15899126SWyllys.Ingersoll@Sun.COM CK_C_INITIALIZE_ARGS *pArg;
15909126SWyllys.Ingersoll@Sun.COM extern CK_RV ST_Initialize(void *,
15919126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID, unsigned char *);
15929126SWyllys.Ingersoll@Sun.COM
15939126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_lock(&global_mutex);
15949126SWyllys.Ingersoll@Sun.COM if (! Anchor) {
15959126SWyllys.Ingersoll@Sun.COM Anchor = (API_Proc_Struct_t *)malloc(
15969126SWyllys.Ingersoll@Sun.COM sizeof (API_Proc_Struct_t));
15979126SWyllys.Ingersoll@Sun.COM if (Anchor == NULL) {
15989126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
15999126SWyllys.Ingersoll@Sun.COM return (CKR_HOST_MEMORY);
16009126SWyllys.Ingersoll@Sun.COM }
16019126SWyllys.Ingersoll@Sun.COM } else {
16029126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
16039126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_ALREADY_INITIALIZED);
16049126SWyllys.Ingersoll@Sun.COM }
16059126SWyllys.Ingersoll@Sun.COM /*
16069126SWyllys.Ingersoll@Sun.COM * if pVoid is NULL, then everything is OK. The applicaiton
16079126SWyllys.Ingersoll@Sun.COM * will not be doing multi thread accesses. We can use the OS
16089126SWyllys.Ingersoll@Sun.COM * locks anyhow.
16099126SWyllys.Ingersoll@Sun.COM */
16109126SWyllys.Ingersoll@Sun.COM if (pVoid != NULL) {
16119126SWyllys.Ingersoll@Sun.COM int supplied_ok;
16129126SWyllys.Ingersoll@Sun.COM pArg = (CK_C_INITIALIZE_ARGS *)pVoid;
16139126SWyllys.Ingersoll@Sun.COM
16149126SWyllys.Ingersoll@Sun.COM /*
16159126SWyllys.Ingersoll@Sun.COM * ALL supplied function pointers need to have the value
16169126SWyllys.Ingersoll@Sun.COM * either NULL or no - NULL.
16179126SWyllys.Ingersoll@Sun.COM */
16189126SWyllys.Ingersoll@Sun.COM supplied_ok = (pArg->CreateMutex == NULL &&
16199126SWyllys.Ingersoll@Sun.COM pArg->DestroyMutex == NULL &&
16209126SWyllys.Ingersoll@Sun.COM pArg->LockMutex == NULL &&
16219126SWyllys.Ingersoll@Sun.COM pArg->UnlockMutex == NULL) ||
16229126SWyllys.Ingersoll@Sun.COM (pArg->CreateMutex != NULL &&
16239126SWyllys.Ingersoll@Sun.COM pArg->DestroyMutex != NULL &&
16249126SWyllys.Ingersoll@Sun.COM pArg->LockMutex != NULL &&
16259126SWyllys.Ingersoll@Sun.COM pArg->UnlockMutex != NULL);
16269126SWyllys.Ingersoll@Sun.COM
16279126SWyllys.Ingersoll@Sun.COM if (!supplied_ok) {
16289126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
16299126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
16309126SWyllys.Ingersoll@Sun.COM }
16319126SWyllys.Ingersoll@Sun.COM /* Check for a pReserved set */
16329126SWyllys.Ingersoll@Sun.COM if (pArg->pReserved != NULL) {
16339126SWyllys.Ingersoll@Sun.COM free(Anchor);
16349126SWyllys.Ingersoll@Sun.COM Anchor = NULL;
16359126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
16369126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
16379126SWyllys.Ingersoll@Sun.COM }
16389126SWyllys.Ingersoll@Sun.COM /*
16399126SWyllys.Ingersoll@Sun.COM * When the CKF_OS_LOCKING_OK flag isn't set and mutex
16409126SWyllys.Ingersoll@Sun.COM * function pointers are supplied by an application,
16419126SWyllys.Ingersoll@Sun.COM * return (an error. We must be able to use our own primitives.
16429126SWyllys.Ingersoll@Sun.COM */
16439126SWyllys.Ingersoll@Sun.COM if (!(pArg->flags & CKF_OS_LOCKING_OK) &&
16449126SWyllys.Ingersoll@Sun.COM (pArg->CreateMutex != NULL)) {
16459126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
16469126SWyllys.Ingersoll@Sun.COM return (CKR_CANT_LOCK);
16479126SWyllys.Ingersoll@Sun.COM }
16489126SWyllys.Ingersoll@Sun.COM }
16499126SWyllys.Ingersoll@Sun.COM (void) memset((char *)Anchor, 0, sizeof (API_Proc_Struct_t));
16509126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_init(&(Anchor->ProcMutex), NULL);
16519126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_init(&(Anchor->SessListMutex), NULL);
16529126SWyllys.Ingersoll@Sun.COM Anchor->Pid = getpid();
16539126SWyllys.Ingersoll@Sun.COM
16549126SWyllys.Ingersoll@Sun.COM rv = ST_Initialize((void *)&FuncList, 0, NULL);
16559126SWyllys.Ingersoll@Sun.COM (void) pthread_mutex_unlock(&global_mutex);
16569126SWyllys.Ingersoll@Sun.COM return (rv);
16579126SWyllys.Ingersoll@Sun.COM }
16589126SWyllys.Ingersoll@Sun.COM
16599126SWyllys.Ingersoll@Sun.COM CK_RV
C_InitPIN(CK_SESSION_HANDLE hSession,CK_CHAR_PTR pPin,CK_ULONG ulPinLen)16609126SWyllys.Ingersoll@Sun.COM C_InitPIN(CK_SESSION_HANDLE hSession,
16619126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pPin,
16629126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPinLen)
16639126SWyllys.Ingersoll@Sun.COM {
16649126SWyllys.Ingersoll@Sun.COM CK_RV rv;
16659126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
16669126SWyllys.Ingersoll@Sun.COM
1667*10346Swyllys.ingersoll@sun.com if (API_Initialized() == FALSE)
16689126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
1669*10346Swyllys.ingersoll@sun.com
1670*10346Swyllys.ingersoll@sun.com if (! pPin && ulPinLen)
16719126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
1672*10346Swyllys.ingersoll@sun.com
1673*10346Swyllys.ingersoll@sun.com if (! Valid_Session((Session_Struct_t *)hSession, &rSession))
16749126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
16759126SWyllys.Ingersoll@Sun.COM
1676*10346Swyllys.ingersoll@sun.com if (rSession.slotID > NUMBER_SLOTS_MANAGED)
16779126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
1678*10346Swyllys.ingersoll@sun.com
1679*10346Swyllys.ingersoll@sun.com if (FuncList.ST_InitPIN)
16809126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_InitPIN(rSession, pPin, ulPinLen);
1681*10346Swyllys.ingersoll@sun.com else
16829126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
1683*10346Swyllys.ingersoll@sun.com
16849126SWyllys.Ingersoll@Sun.COM return (rv);
16859126SWyllys.Ingersoll@Sun.COM }
16869126SWyllys.Ingersoll@Sun.COM
16879126SWyllys.Ingersoll@Sun.COM CK_RV
C_InitToken(CK_SLOT_ID slotID,CK_CHAR_PTR pPin,CK_ULONG ulPinLen,CK_CHAR_PTR pLabel)16889126SWyllys.Ingersoll@Sun.COM C_InitToken(CK_SLOT_ID slotID,
16899126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pPin,
16909126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPinLen,
16919126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pLabel)
16929126SWyllys.Ingersoll@Sun.COM {
16939126SWyllys.Ingersoll@Sun.COM CK_RV rv;
16949126SWyllys.Ingersoll@Sun.COM
1695*10346Swyllys.ingersoll@sun.com if (API_Initialized() == FALSE)
16969126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
1697*10346Swyllys.ingersoll@sun.com
1698*10346Swyllys.ingersoll@sun.com if (! pPin && ulPinLen)
1699*10346Swyllys.ingersoll@sun.com return (CKR_ARGUMENTS_BAD);
1700*10346Swyllys.ingersoll@sun.com
1701*10346Swyllys.ingersoll@sun.com if (! pLabel)
17029126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
1703*10346Swyllys.ingersoll@sun.com
1704*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available)
1705*10346Swyllys.ingersoll@sun.com return (CKR_SLOT_ID_INVALID);
1706*10346Swyllys.ingersoll@sun.com
1707*10346Swyllys.ingersoll@sun.com if (FuncList.ST_InitToken)
17089126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_InitToken(slotID, pPin, ulPinLen, pLabel);
1709*10346Swyllys.ingersoll@sun.com else
17109126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
1711*10346Swyllys.ingersoll@sun.com
17129126SWyllys.Ingersoll@Sun.COM return (rv);
17139126SWyllys.Ingersoll@Sun.COM }
17149126SWyllys.Ingersoll@Sun.COM
17159126SWyllys.Ingersoll@Sun.COM CK_RV
C_Login(CK_SESSION_HANDLE hSession,CK_USER_TYPE userType,CK_CHAR_PTR pPin,CK_ULONG ulPinLen)17169126SWyllys.Ingersoll@Sun.COM C_Login(CK_SESSION_HANDLE hSession,
17179126SWyllys.Ingersoll@Sun.COM CK_USER_TYPE userType,
17189126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pPin,
17199126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPinLen)
17209126SWyllys.Ingersoll@Sun.COM {
17219126SWyllys.Ingersoll@Sun.COM CK_RV rv;
17229126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
17239126SWyllys.Ingersoll@Sun.COM
17249126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
17259126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
17269126SWyllys.Ingersoll@Sun.COM }
17279126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
17289126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
17299126SWyllys.Ingersoll@Sun.COM }
17309126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Login) {
17319126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_Login(rSession, userType, pPin, ulPinLen);
17329126SWyllys.Ingersoll@Sun.COM } else {
17339126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
17349126SWyllys.Ingersoll@Sun.COM }
17359126SWyllys.Ingersoll@Sun.COM return (rv);
17369126SWyllys.Ingersoll@Sun.COM }
17379126SWyllys.Ingersoll@Sun.COM
17389126SWyllys.Ingersoll@Sun.COM CK_RV
C_Logout(CK_SESSION_HANDLE hSession)17399126SWyllys.Ingersoll@Sun.COM C_Logout(CK_SESSION_HANDLE hSession)
17409126SWyllys.Ingersoll@Sun.COM {
17419126SWyllys.Ingersoll@Sun.COM CK_RV rv;
17429126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
17439126SWyllys.Ingersoll@Sun.COM
17449126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
17459126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
17469126SWyllys.Ingersoll@Sun.COM }
17479126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
17489126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
17499126SWyllys.Ingersoll@Sun.COM }
17509126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Logout) {
17519126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_Logout(rSession);
17529126SWyllys.Ingersoll@Sun.COM } else {
17539126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
17549126SWyllys.Ingersoll@Sun.COM }
17559126SWyllys.Ingersoll@Sun.COM return (rv);
17569126SWyllys.Ingersoll@Sun.COM }
17579126SWyllys.Ingersoll@Sun.COM
17589126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
17599126SWyllys.Ingersoll@Sun.COM CK_RV
C_OpenSession(CK_SLOT_ID slotID,CK_FLAGS flags,CK_VOID_PTR pApplication,CK_NOTIFY Notify,CK_SESSION_HANDLE_PTR phSession)17609126SWyllys.Ingersoll@Sun.COM C_OpenSession(
17619126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID slotID,
17629126SWyllys.Ingersoll@Sun.COM CK_FLAGS flags,
17639126SWyllys.Ingersoll@Sun.COM CK_VOID_PTR pApplication,
17649126SWyllys.Ingersoll@Sun.COM CK_NOTIFY Notify,
17659126SWyllys.Ingersoll@Sun.COM CK_SESSION_HANDLE_PTR phSession)
17669126SWyllys.Ingersoll@Sun.COM {
17679126SWyllys.Ingersoll@Sun.COM CK_RV rv;
17689126SWyllys.Ingersoll@Sun.COM Session_Struct_t *apiSessp;
17699126SWyllys.Ingersoll@Sun.COM
1770*10346Swyllys.ingersoll@sun.com if (API_Initialized() == FALSE)
17719126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
1772*10346Swyllys.ingersoll@sun.com
1773*10346Swyllys.ingersoll@sun.com if (!global_shm->token_available || (slotID > NUMBER_SLOTS_MANAGED))
17749126SWyllys.Ingersoll@Sun.COM return (CKR_SLOT_ID_INVALID);
1775*10346Swyllys.ingersoll@sun.com
1776*10346Swyllys.ingersoll@sun.com if (! phSession)
17779126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
1778*10346Swyllys.ingersoll@sun.com
1779*10346Swyllys.ingersoll@sun.com if ((flags & CKF_SERIAL_SESSION) == 0)
17809126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_PARALLEL_NOT_SUPPORTED);
1781*10346Swyllys.ingersoll@sun.com
17829126SWyllys.Ingersoll@Sun.COM if ((apiSessp = (Session_Struct_t *)malloc(
1783*10346Swyllys.ingersoll@sun.com sizeof (Session_Struct_t))) == NULL)
17849126SWyllys.Ingersoll@Sun.COM return (CKR_HOST_MEMORY);
1785*10346Swyllys.ingersoll@sun.com
17869126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_OpenSession) {
17879126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_OpenSession(slotID, flags,
17889126SWyllys.Ingersoll@Sun.COM &(apiSessp->RealHandle));
17899126SWyllys.Ingersoll@Sun.COM
17909126SWyllys.Ingersoll@Sun.COM if (rv == CKR_OK) {
17919126SWyllys.Ingersoll@Sun.COM *phSession = (CK_SESSION_HANDLE)apiSessp;
17929126SWyllys.Ingersoll@Sun.COM apiSessp->SltId = slotID;
17939126SWyllys.Ingersoll@Sun.COM
17949126SWyllys.Ingersoll@Sun.COM AddToSessionList(apiSessp);
17959126SWyllys.Ingersoll@Sun.COM } else {
17969126SWyllys.Ingersoll@Sun.COM free(apiSessp);
17979126SWyllys.Ingersoll@Sun.COM }
17989126SWyllys.Ingersoll@Sun.COM } else {
17999126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
18009126SWyllys.Ingersoll@Sun.COM }
18019126SWyllys.Ingersoll@Sun.COM return (rv);
18029126SWyllys.Ingersoll@Sun.COM }
18039126SWyllys.Ingersoll@Sun.COM
18049126SWyllys.Ingersoll@Sun.COM CK_RV
C_SeedRandom(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pSeed,CK_ULONG ulSeedLen)18059126SWyllys.Ingersoll@Sun.COM C_SeedRandom(CK_SESSION_HANDLE hSession,
18069126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSeed,
18079126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSeedLen)
18089126SWyllys.Ingersoll@Sun.COM {
18099126SWyllys.Ingersoll@Sun.COM CK_RV rv;
18109126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
18119126SWyllys.Ingersoll@Sun.COM
18129126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
18139126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
18149126SWyllys.Ingersoll@Sun.COM }
18159126SWyllys.Ingersoll@Sun.COM if (! pSeed && ulSeedLen) {
18169126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
18179126SWyllys.Ingersoll@Sun.COM }
18189126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
18199126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
18209126SWyllys.Ingersoll@Sun.COM }
18219126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SeedRandom) {
18229126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SeedRandom(rSession, pSeed, ulSeedLen);
18239126SWyllys.Ingersoll@Sun.COM } else {
18249126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
18259126SWyllys.Ingersoll@Sun.COM }
18269126SWyllys.Ingersoll@Sun.COM return (rv);
18279126SWyllys.Ingersoll@Sun.COM }
18289126SWyllys.Ingersoll@Sun.COM
18299126SWyllys.Ingersoll@Sun.COM CK_RV
C_SetAttributeValue(CK_SESSION_HANDLE hSession,CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount)18309126SWyllys.Ingersoll@Sun.COM C_SetAttributeValue(CK_SESSION_HANDLE hSession,
18319126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hObject,
18329126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
18339126SWyllys.Ingersoll@Sun.COM CK_ULONG ulCount)
18349126SWyllys.Ingersoll@Sun.COM {
18359126SWyllys.Ingersoll@Sun.COM CK_RV rv;
18369126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
18379126SWyllys.Ingersoll@Sun.COM
18389126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
18399126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
18409126SWyllys.Ingersoll@Sun.COM }
18419126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
18429126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
18439126SWyllys.Ingersoll@Sun.COM }
18449126SWyllys.Ingersoll@Sun.COM if (! pTemplate) {
18459126SWyllys.Ingersoll@Sun.COM return (CKR_TEMPLATE_INCOMPLETE);
18469126SWyllys.Ingersoll@Sun.COM }
18479126SWyllys.Ingersoll@Sun.COM if (! ulCount) {
18489126SWyllys.Ingersoll@Sun.COM return (CKR_TEMPLATE_INCOMPLETE);
18499126SWyllys.Ingersoll@Sun.COM }
18509126SWyllys.Ingersoll@Sun.COM // Get local pointers to session
18519126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SetAttributeValue) {
18529126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SetAttributeValue(rSession, hObject,
18539126SWyllys.Ingersoll@Sun.COM pTemplate, ulCount);
18549126SWyllys.Ingersoll@Sun.COM } else {
18559126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
18569126SWyllys.Ingersoll@Sun.COM }
18579126SWyllys.Ingersoll@Sun.COM return (rv);
18589126SWyllys.Ingersoll@Sun.COM }
18599126SWyllys.Ingersoll@Sun.COM
18609126SWyllys.Ingersoll@Sun.COM CK_RV
C_SetOperationState(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pOperationState,CK_ULONG ulOperationStateLen,CK_OBJECT_HANDLE hEncryptionKey,CK_OBJECT_HANDLE hAuthenticationKey)18619126SWyllys.Ingersoll@Sun.COM C_SetOperationState(CK_SESSION_HANDLE hSession,
18629126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pOperationState,
18639126SWyllys.Ingersoll@Sun.COM CK_ULONG ulOperationStateLen,
18649126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hEncryptionKey,
18659126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hAuthenticationKey)
18669126SWyllys.Ingersoll@Sun.COM {
18679126SWyllys.Ingersoll@Sun.COM CK_RV rv;
18689126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
18699126SWyllys.Ingersoll@Sun.COM
18709126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
18719126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
18729126SWyllys.Ingersoll@Sun.COM }
18739126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
18749126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
18759126SWyllys.Ingersoll@Sun.COM }
18769126SWyllys.Ingersoll@Sun.COM if (! pOperationState || ulOperationStateLen == 0) {
18779126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
18789126SWyllys.Ingersoll@Sun.COM }
18799126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SetOperationState) {
18809126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SetOperationState(rSession, pOperationState,
18819126SWyllys.Ingersoll@Sun.COM ulOperationStateLen, hEncryptionKey, hAuthenticationKey);
18829126SWyllys.Ingersoll@Sun.COM } else {
18839126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
18849126SWyllys.Ingersoll@Sun.COM }
18859126SWyllys.Ingersoll@Sun.COM return (rv);
18869126SWyllys.Ingersoll@Sun.COM }
18879126SWyllys.Ingersoll@Sun.COM
18889126SWyllys.Ingersoll@Sun.COM CK_RV
C_SetPIN(CK_SESSION_HANDLE hSession,CK_CHAR_PTR pOldPin,CK_ULONG ulOldLen,CK_CHAR_PTR pNewPin,CK_ULONG ulNewLen)18899126SWyllys.Ingersoll@Sun.COM C_SetPIN(CK_SESSION_HANDLE hSession,
18909126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pOldPin,
18919126SWyllys.Ingersoll@Sun.COM CK_ULONG ulOldLen,
18929126SWyllys.Ingersoll@Sun.COM CK_CHAR_PTR pNewPin,
18939126SWyllys.Ingersoll@Sun.COM CK_ULONG ulNewLen)
18949126SWyllys.Ingersoll@Sun.COM {
18959126SWyllys.Ingersoll@Sun.COM CK_RV rv;
18969126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
18979126SWyllys.Ingersoll@Sun.COM
18989126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
18999126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
19009126SWyllys.Ingersoll@Sun.COM }
19019126SWyllys.Ingersoll@Sun.COM if (! pOldPin || ! pNewPin)
19029126SWyllys.Ingersoll@Sun.COM return (CKR_PIN_INVALID);
19039126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
19049126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
19059126SWyllys.Ingersoll@Sun.COM }
19069126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SetPIN) {
19079126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SetPIN(rSession, pOldPin, ulOldLen,
19089126SWyllys.Ingersoll@Sun.COM pNewPin, ulNewLen);
19099126SWyllys.Ingersoll@Sun.COM } else {
19109126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
19119126SWyllys.Ingersoll@Sun.COM }
19129126SWyllys.Ingersoll@Sun.COM return (rv);
19139126SWyllys.Ingersoll@Sun.COM }
19149126SWyllys.Ingersoll@Sun.COM
19159126SWyllys.Ingersoll@Sun.COM CK_RV
C_Sign(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pSignature,CK_ULONG_PTR pulSignatureLen)19169126SWyllys.Ingersoll@Sun.COM C_Sign(CK_SESSION_HANDLE hSession,
19179126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
19189126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
19199126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
19209126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSignatureLen)
19219126SWyllys.Ingersoll@Sun.COM {
19229126SWyllys.Ingersoll@Sun.COM CK_RV rv;
19239126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
19249126SWyllys.Ingersoll@Sun.COM
19259126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
19269126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
19279126SWyllys.Ingersoll@Sun.COM }
19289126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
19299126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
19309126SWyllys.Ingersoll@Sun.COM }
19319126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Sign) {
19329126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_Sign(rSession, pData, ulDataLen,
19339126SWyllys.Ingersoll@Sun.COM pSignature, pulSignatureLen);
19349126SWyllys.Ingersoll@Sun.COM } else {
19359126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
19369126SWyllys.Ingersoll@Sun.COM }
19379126SWyllys.Ingersoll@Sun.COM return (rv);
19389126SWyllys.Ingersoll@Sun.COM }
19399126SWyllys.Ingersoll@Sun.COM
19409126SWyllys.Ingersoll@Sun.COM CK_RV
C_SignEncryptUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen,CK_BYTE_PTR pEncryptedPart,CK_ULONG_PTR pulEncryptedPartLen)19419126SWyllys.Ingersoll@Sun.COM C_SignEncryptUpdate(CK_SESSION_HANDLE hSession,
19429126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
19439126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen,
19449126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pEncryptedPart,
19459126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulEncryptedPartLen)
19469126SWyllys.Ingersoll@Sun.COM {
19479126SWyllys.Ingersoll@Sun.COM CK_RV rv;
19489126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
19499126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
19509126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
19519126SWyllys.Ingersoll@Sun.COM }
19529126SWyllys.Ingersoll@Sun.COM if (! pPart || ! pulEncryptedPartLen) {
19539126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
19549126SWyllys.Ingersoll@Sun.COM }
19559126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
19569126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
19579126SWyllys.Ingersoll@Sun.COM }
19589126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SignEncryptUpdate) {
19599126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SignEncryptUpdate(rSession, pPart,
19609126SWyllys.Ingersoll@Sun.COM ulPartLen, pEncryptedPart, pulEncryptedPartLen);
19619126SWyllys.Ingersoll@Sun.COM } else {
19629126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
19639126SWyllys.Ingersoll@Sun.COM }
19649126SWyllys.Ingersoll@Sun.COM return (rv);
19659126SWyllys.Ingersoll@Sun.COM }
19669126SWyllys.Ingersoll@Sun.COM
19679126SWyllys.Ingersoll@Sun.COM CK_RV
C_SignFinal(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pSignature,CK_ULONG_PTR pulSignatureLen)19689126SWyllys.Ingersoll@Sun.COM C_SignFinal(CK_SESSION_HANDLE hSession,
19699126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
19709126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSignatureLen)
19719126SWyllys.Ingersoll@Sun.COM {
19729126SWyllys.Ingersoll@Sun.COM CK_RV rv;
19739126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
19749126SWyllys.Ingersoll@Sun.COM
19759126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
19769126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
19779126SWyllys.Ingersoll@Sun.COM }
19789126SWyllys.Ingersoll@Sun.COM if (! pulSignatureLen) {
19799126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
19809126SWyllys.Ingersoll@Sun.COM }
19819126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
19829126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
19839126SWyllys.Ingersoll@Sun.COM }
19849126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SignFinal) {
19859126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SignFinal(rSession, pSignature,
19869126SWyllys.Ingersoll@Sun.COM pulSignatureLen);
19879126SWyllys.Ingersoll@Sun.COM } else {
19889126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
19899126SWyllys.Ingersoll@Sun.COM }
19909126SWyllys.Ingersoll@Sun.COM return (rv);
19919126SWyllys.Ingersoll@Sun.COM }
19929126SWyllys.Ingersoll@Sun.COM
19939126SWyllys.Ingersoll@Sun.COM CK_RV
C_SignInit(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)19949126SWyllys.Ingersoll@Sun.COM C_SignInit(CK_SESSION_HANDLE hSession,
19959126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
19969126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
19979126SWyllys.Ingersoll@Sun.COM {
19989126SWyllys.Ingersoll@Sun.COM CK_RV rv;
19999126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
20009126SWyllys.Ingersoll@Sun.COM
20019126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
20029126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
20039126SWyllys.Ingersoll@Sun.COM }
20049126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
20059126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
20069126SWyllys.Ingersoll@Sun.COM }
20079126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
20089126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
20099126SWyllys.Ingersoll@Sun.COM }
20109126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SignInit) {
20119126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SignInit(rSession, pMechanism, hKey);
20129126SWyllys.Ingersoll@Sun.COM } else {
20139126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
20149126SWyllys.Ingersoll@Sun.COM }
20159126SWyllys.Ingersoll@Sun.COM return (rv);
20169126SWyllys.Ingersoll@Sun.COM }
20179126SWyllys.Ingersoll@Sun.COM
20189126SWyllys.Ingersoll@Sun.COM CK_RV
C_SignRecover(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pSignature,CK_ULONG_PTR pulSignatureLen)20199126SWyllys.Ingersoll@Sun.COM C_SignRecover(CK_SESSION_HANDLE hSession,
20209126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
20219126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
20229126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
20239126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulSignatureLen)
20249126SWyllys.Ingersoll@Sun.COM {
20259126SWyllys.Ingersoll@Sun.COM CK_RV rv;
20269126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
20279126SWyllys.Ingersoll@Sun.COM
20289126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
20299126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
20309126SWyllys.Ingersoll@Sun.COM }
20319126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
20329126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
20339126SWyllys.Ingersoll@Sun.COM }
20349126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SignRecover) {
20359126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SignRecover(rSession, pData,
20369126SWyllys.Ingersoll@Sun.COM ulDataLen, pSignature, pulSignatureLen);
20379126SWyllys.Ingersoll@Sun.COM } else {
20389126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
20399126SWyllys.Ingersoll@Sun.COM }
20409126SWyllys.Ingersoll@Sun.COM return (rv);
20419126SWyllys.Ingersoll@Sun.COM }
20429126SWyllys.Ingersoll@Sun.COM
20439126SWyllys.Ingersoll@Sun.COM CK_RV
C_SignRecoverInit(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)20449126SWyllys.Ingersoll@Sun.COM C_SignRecoverInit(CK_SESSION_HANDLE hSession,
20459126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
20469126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
20479126SWyllys.Ingersoll@Sun.COM {
20489126SWyllys.Ingersoll@Sun.COM CK_RV rv;
20499126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
20509126SWyllys.Ingersoll@Sun.COM
20519126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
20529126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
20539126SWyllys.Ingersoll@Sun.COM }
20549126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
20559126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
20569126SWyllys.Ingersoll@Sun.COM }
20579126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
20589126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
20599126SWyllys.Ingersoll@Sun.COM }
20609126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SignRecoverInit) {
20619126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SignRecoverInit(rSession, pMechanism, hKey);
20629126SWyllys.Ingersoll@Sun.COM } else {
20639126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
20649126SWyllys.Ingersoll@Sun.COM }
20659126SWyllys.Ingersoll@Sun.COM return (rv);
20669126SWyllys.Ingersoll@Sun.COM }
20679126SWyllys.Ingersoll@Sun.COM
20689126SWyllys.Ingersoll@Sun.COM CK_RV
C_SignUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen)20699126SWyllys.Ingersoll@Sun.COM C_SignUpdate(CK_SESSION_HANDLE hSession,
20709126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
20719126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen)
20729126SWyllys.Ingersoll@Sun.COM {
20739126SWyllys.Ingersoll@Sun.COM CK_RV rv;
20749126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
20759126SWyllys.Ingersoll@Sun.COM
20769126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
20779126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
20789126SWyllys.Ingersoll@Sun.COM }
20799126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
20809126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
20819126SWyllys.Ingersoll@Sun.COM }
20829126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_SignUpdate) {
20839126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_SignUpdate(rSession, pPart, ulPartLen);
20849126SWyllys.Ingersoll@Sun.COM } else {
20859126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
20869126SWyllys.Ingersoll@Sun.COM }
20879126SWyllys.Ingersoll@Sun.COM return (rv);
20889126SWyllys.Ingersoll@Sun.COM }
20899126SWyllys.Ingersoll@Sun.COM
20909126SWyllys.Ingersoll@Sun.COM CK_RV
C_UnwrapKey(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hUnwrappingKey,CK_BYTE_PTR pWrappedKey,CK_ULONG ulWrappedKeyLen,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulAttributeCount,CK_OBJECT_HANDLE_PTR phKey)20919126SWyllys.Ingersoll@Sun.COM C_UnwrapKey(CK_SESSION_HANDLE hSession,
20929126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
20939126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hUnwrappingKey,
20949126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pWrappedKey,
20959126SWyllys.Ingersoll@Sun.COM CK_ULONG ulWrappedKeyLen,
20969126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE_PTR pTemplate,
20979126SWyllys.Ingersoll@Sun.COM CK_ULONG ulAttributeCount,
20989126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE_PTR phKey)
20999126SWyllys.Ingersoll@Sun.COM {
21009126SWyllys.Ingersoll@Sun.COM CK_RV rv;
21019126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
21029126SWyllys.Ingersoll@Sun.COM
21039126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
21049126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
21059126SWyllys.Ingersoll@Sun.COM }
21069453SWyllys.Ingersoll@Sun.COM if (!pMechanism) {
21079126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
21089126SWyllys.Ingersoll@Sun.COM }
21099126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
21109126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
21119126SWyllys.Ingersoll@Sun.COM }
21129126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_UnwrapKey) {
21139126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_UnwrapKey(rSession, pMechanism,
21149126SWyllys.Ingersoll@Sun.COM hUnwrappingKey, pWrappedKey, ulWrappedKeyLen,
21159126SWyllys.Ingersoll@Sun.COM pTemplate, ulAttributeCount, phKey);
21169126SWyllys.Ingersoll@Sun.COM } else {
21179126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
21189126SWyllys.Ingersoll@Sun.COM }
21199126SWyllys.Ingersoll@Sun.COM return (rv);
21209126SWyllys.Ingersoll@Sun.COM }
21219126SWyllys.Ingersoll@Sun.COM
21229126SWyllys.Ingersoll@Sun.COM CK_RV
C_Verify(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pData,CK_ULONG ulDataLen,CK_BYTE_PTR pSignature,CK_ULONG ulSignatureLen)21239126SWyllys.Ingersoll@Sun.COM C_Verify(CK_SESSION_HANDLE hSession,
21249126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
21259126SWyllys.Ingersoll@Sun.COM CK_ULONG ulDataLen,
21269126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
21279126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSignatureLen)
21289126SWyllys.Ingersoll@Sun.COM {
21299126SWyllys.Ingersoll@Sun.COM CK_RV rv;
21309126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
21319126SWyllys.Ingersoll@Sun.COM
21329126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
21339126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
21349126SWyllys.Ingersoll@Sun.COM }
21359126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
21369126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
21379126SWyllys.Ingersoll@Sun.COM }
21389126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_Verify) {
21399126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_Verify(rSession, pData, ulDataLen,
21409126SWyllys.Ingersoll@Sun.COM pSignature, ulSignatureLen);
21419126SWyllys.Ingersoll@Sun.COM } else {
21429126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
21439126SWyllys.Ingersoll@Sun.COM }
21449126SWyllys.Ingersoll@Sun.COM return (rv);
21459126SWyllys.Ingersoll@Sun.COM }
21469126SWyllys.Ingersoll@Sun.COM
21479126SWyllys.Ingersoll@Sun.COM CK_RV
C_VerifyFinal(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pSignature,CK_ULONG ulSignatureLen)21489126SWyllys.Ingersoll@Sun.COM C_VerifyFinal(CK_SESSION_HANDLE hSession,
21499126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
21509126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSignatureLen)
21519126SWyllys.Ingersoll@Sun.COM {
21529126SWyllys.Ingersoll@Sun.COM CK_RV rv;
21539126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
21549126SWyllys.Ingersoll@Sun.COM
21559126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
21569126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
21579126SWyllys.Ingersoll@Sun.COM }
21589126SWyllys.Ingersoll@Sun.COM if (! pSignature) {
21599126SWyllys.Ingersoll@Sun.COM return (CKR_ARGUMENTS_BAD);
21609126SWyllys.Ingersoll@Sun.COM }
21619126SWyllys.Ingersoll@Sun.COM
21629126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
21639126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
21649126SWyllys.Ingersoll@Sun.COM }
21659126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_VerifyFinal) {
21669126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_VerifyFinal(rSession, pSignature,
21679126SWyllys.Ingersoll@Sun.COM ulSignatureLen);
21689126SWyllys.Ingersoll@Sun.COM } else {
21699126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
21709126SWyllys.Ingersoll@Sun.COM }
21719126SWyllys.Ingersoll@Sun.COM return (rv);
21729126SWyllys.Ingersoll@Sun.COM }
21739126SWyllys.Ingersoll@Sun.COM
21749126SWyllys.Ingersoll@Sun.COM CK_RV
C_VerifyInit(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)21759126SWyllys.Ingersoll@Sun.COM C_VerifyInit(CK_SESSION_HANDLE hSession,
21769126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
21779126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
21789126SWyllys.Ingersoll@Sun.COM {
21799126SWyllys.Ingersoll@Sun.COM CK_RV rv;
21809126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
21819126SWyllys.Ingersoll@Sun.COM
21829126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
21839126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
21849126SWyllys.Ingersoll@Sun.COM }
21859126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
21869126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
21879126SWyllys.Ingersoll@Sun.COM }
21889126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
21899126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
21909126SWyllys.Ingersoll@Sun.COM }
21919126SWyllys.Ingersoll@Sun.COM
21929126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_VerifyInit) {
21939126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_VerifyInit(rSession, pMechanism, hKey);
21949126SWyllys.Ingersoll@Sun.COM } else {
21959126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
21969126SWyllys.Ingersoll@Sun.COM }
21979126SWyllys.Ingersoll@Sun.COM return (rv);
21989126SWyllys.Ingersoll@Sun.COM }
21999126SWyllys.Ingersoll@Sun.COM
22009126SWyllys.Ingersoll@Sun.COM CK_RV
C_VerifyRecover(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pSignature,CK_ULONG ulSignatureLen,CK_BYTE_PTR pData,CK_ULONG_PTR pulDataLen)22019126SWyllys.Ingersoll@Sun.COM C_VerifyRecover(CK_SESSION_HANDLE hSession,
22029126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pSignature,
22039126SWyllys.Ingersoll@Sun.COM CK_ULONG ulSignatureLen,
22049126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pData,
22059126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulDataLen)
22069126SWyllys.Ingersoll@Sun.COM {
22079126SWyllys.Ingersoll@Sun.COM CK_RV rv;
22089126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
22099126SWyllys.Ingersoll@Sun.COM
22109126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
22119126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
22129126SWyllys.Ingersoll@Sun.COM }
22139126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
22149126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
22159126SWyllys.Ingersoll@Sun.COM }
22169126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_VerifyRecover) {
22179126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_VerifyRecover(rSession, pSignature,
22189126SWyllys.Ingersoll@Sun.COM ulSignatureLen, pData, pulDataLen);
22199126SWyllys.Ingersoll@Sun.COM } else {
22209126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
22219126SWyllys.Ingersoll@Sun.COM }
22229126SWyllys.Ingersoll@Sun.COM return (rv);
22239126SWyllys.Ingersoll@Sun.COM }
22249126SWyllys.Ingersoll@Sun.COM
22259126SWyllys.Ingersoll@Sun.COM CK_RV
C_VerifyRecoverInit(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey)22269126SWyllys.Ingersoll@Sun.COM C_VerifyRecoverInit(CK_SESSION_HANDLE hSession,
22279126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
22289126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey)
22299126SWyllys.Ingersoll@Sun.COM {
22309126SWyllys.Ingersoll@Sun.COM CK_RV rv;
22319126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
22329126SWyllys.Ingersoll@Sun.COM
22339126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
22349126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
22359126SWyllys.Ingersoll@Sun.COM }
22369126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
22379126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
22389126SWyllys.Ingersoll@Sun.COM }
22399126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
22409126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
22419126SWyllys.Ingersoll@Sun.COM }
22429126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_VerifyRecoverInit) {
22439126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_VerifyRecoverInit(rSession, pMechanism, hKey);
22449126SWyllys.Ingersoll@Sun.COM } else {
22459126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
22469126SWyllys.Ingersoll@Sun.COM }
22479126SWyllys.Ingersoll@Sun.COM return (rv);
22489126SWyllys.Ingersoll@Sun.COM }
22499126SWyllys.Ingersoll@Sun.COM
22509126SWyllys.Ingersoll@Sun.COM CK_RV
C_VerifyUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,CK_ULONG ulPartLen)22519126SWyllys.Ingersoll@Sun.COM C_VerifyUpdate(CK_SESSION_HANDLE hSession,
22529126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pPart,
22539126SWyllys.Ingersoll@Sun.COM CK_ULONG ulPartLen)
22549126SWyllys.Ingersoll@Sun.COM {
22559126SWyllys.Ingersoll@Sun.COM CK_RV rv;
22569126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
22579126SWyllys.Ingersoll@Sun.COM
22589126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
22599126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
22609126SWyllys.Ingersoll@Sun.COM }
22619126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
22629126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
22639126SWyllys.Ingersoll@Sun.COM }
22649126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_VerifyUpdate) {
22659126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_VerifyUpdate(rSession, pPart, ulPartLen);
22669126SWyllys.Ingersoll@Sun.COM } else {
22679126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
22689126SWyllys.Ingersoll@Sun.COM }
22699126SWyllys.Ingersoll@Sun.COM return (rv);
22709126SWyllys.Ingersoll@Sun.COM }
22719126SWyllys.Ingersoll@Sun.COM
22729126SWyllys.Ingersoll@Sun.COM /*ARGSUSED*/
22739126SWyllys.Ingersoll@Sun.COM CK_RV
C_WaitForSlotEvent(CK_FLAGS flags,CK_SLOT_ID_PTR pSlot,CK_VOID_PTR pReserved)22749126SWyllys.Ingersoll@Sun.COM C_WaitForSlotEvent(CK_FLAGS flags,
22759126SWyllys.Ingersoll@Sun.COM CK_SLOT_ID_PTR pSlot,
22769126SWyllys.Ingersoll@Sun.COM CK_VOID_PTR pReserved)
22779126SWyllys.Ingersoll@Sun.COM {
22789126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
22799126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
22809126SWyllys.Ingersoll@Sun.COM }
22819126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_NOT_SUPPORTED);
22829126SWyllys.Ingersoll@Sun.COM }
22839126SWyllys.Ingersoll@Sun.COM
22849126SWyllys.Ingersoll@Sun.COM CK_RV
C_WrapKey(CK_SESSION_HANDLE hSession,CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hWrappingKey,CK_OBJECT_HANDLE hKey,CK_BYTE_PTR pWrappedKey,CK_ULONG_PTR pulWrappedKeyLen)22859126SWyllys.Ingersoll@Sun.COM C_WrapKey(CK_SESSION_HANDLE hSession,
22869126SWyllys.Ingersoll@Sun.COM CK_MECHANISM_PTR pMechanism,
22879126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hWrappingKey,
22889126SWyllys.Ingersoll@Sun.COM CK_OBJECT_HANDLE hKey,
22899126SWyllys.Ingersoll@Sun.COM CK_BYTE_PTR pWrappedKey,
22909126SWyllys.Ingersoll@Sun.COM CK_ULONG_PTR pulWrappedKeyLen)
22919126SWyllys.Ingersoll@Sun.COM {
22929126SWyllys.Ingersoll@Sun.COM CK_RV rv;
22939126SWyllys.Ingersoll@Sun.COM ST_SESSION_T rSession;
22949126SWyllys.Ingersoll@Sun.COM
22959126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == FALSE) {
22969126SWyllys.Ingersoll@Sun.COM return (CKR_CRYPTOKI_NOT_INITIALIZED);
22979126SWyllys.Ingersoll@Sun.COM }
22989126SWyllys.Ingersoll@Sun.COM if (! pMechanism) {
22999126SWyllys.Ingersoll@Sun.COM return (CKR_MECHANISM_INVALID);
23009126SWyllys.Ingersoll@Sun.COM }
23019126SWyllys.Ingersoll@Sun.COM if (! Valid_Session((Session_Struct_t *)hSession, &rSession)) {
23029126SWyllys.Ingersoll@Sun.COM return (CKR_SESSION_HANDLE_INVALID);
23039126SWyllys.Ingersoll@Sun.COM }
23049126SWyllys.Ingersoll@Sun.COM if (FuncList.ST_WrapKey) {
23059126SWyllys.Ingersoll@Sun.COM rv = FuncList.ST_WrapKey(rSession, pMechanism, hWrappingKey,
23069126SWyllys.Ingersoll@Sun.COM hKey, pWrappedKey, pulWrappedKeyLen);
23079126SWyllys.Ingersoll@Sun.COM } else {
23089126SWyllys.Ingersoll@Sun.COM rv = CKR_FUNCTION_NOT_SUPPORTED;
23099126SWyllys.Ingersoll@Sun.COM }
23109126SWyllys.Ingersoll@Sun.COM return (rv);
23119126SWyllys.Ingersoll@Sun.COM }
23129126SWyllys.Ingersoll@Sun.COM
23139126SWyllys.Ingersoll@Sun.COM #pragma init(api_init)
23149126SWyllys.Ingersoll@Sun.COM #pragma fini(api_fini)
23159126SWyllys.Ingersoll@Sun.COM
23169126SWyllys.Ingersoll@Sun.COM static void
api_init(void)23179126SWyllys.Ingersoll@Sun.COM api_init(void)
23189126SWyllys.Ingersoll@Sun.COM {
23199126SWyllys.Ingersoll@Sun.COM loginit();
23209126SWyllys.Ingersoll@Sun.COM if (! Initialized) {
23219453SWyllys.Ingersoll@Sun.COM (void) pthread_atfork(tpmtoken_fork_prepare,
23229453SWyllys.Ingersoll@Sun.COM tpmtoken_fork_parent, tpmtoken_fork_child);
23239126SWyllys.Ingersoll@Sun.COM Initialized = 1;
23249126SWyllys.Ingersoll@Sun.COM }
23259126SWyllys.Ingersoll@Sun.COM }
23269126SWyllys.Ingersoll@Sun.COM
23279126SWyllys.Ingersoll@Sun.COM static void
api_fini()23289126SWyllys.Ingersoll@Sun.COM api_fini()
23299126SWyllys.Ingersoll@Sun.COM {
23309126SWyllys.Ingersoll@Sun.COM logterm();
23319126SWyllys.Ingersoll@Sun.COM if (API_Initialized() == TRUE) {
23329126SWyllys.Ingersoll@Sun.COM (void) do_finalize(NULL);
23339126SWyllys.Ingersoll@Sun.COM }
23349126SWyllys.Ingersoll@Sun.COM }
2335