1*9126SWyllys.Ingersoll@Sun.COM /*
2*9126SWyllys.Ingersoll@Sun.COM * Common Public License Version 0.5
3*9126SWyllys.Ingersoll@Sun.COM *
4*9126SWyllys.Ingersoll@Sun.COM * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF
5*9126SWyllys.Ingersoll@Sun.COM * THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE,
6*9126SWyllys.Ingersoll@Sun.COM * REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
7*9126SWyllys.Ingersoll@Sun.COM * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
8*9126SWyllys.Ingersoll@Sun.COM *
9*9126SWyllys.Ingersoll@Sun.COM * 1. DEFINITIONS
10*9126SWyllys.Ingersoll@Sun.COM *
11*9126SWyllys.Ingersoll@Sun.COM * "Contribution" means:
12*9126SWyllys.Ingersoll@Sun.COM * a) in the case of the initial Contributor, the
13*9126SWyllys.Ingersoll@Sun.COM * initial code and documentation distributed under
14*9126SWyllys.Ingersoll@Sun.COM * this Agreement, and
15*9126SWyllys.Ingersoll@Sun.COM *
16*9126SWyllys.Ingersoll@Sun.COM * b) in the case of each subsequent Contributor:
17*9126SWyllys.Ingersoll@Sun.COM * i) changes to the Program, and
18*9126SWyllys.Ingersoll@Sun.COM * ii) additions to the Program;
19*9126SWyllys.Ingersoll@Sun.COM *
20*9126SWyllys.Ingersoll@Sun.COM * where such changes and/or additions to the Program
21*9126SWyllys.Ingersoll@Sun.COM * originate from and are distributed by that
22*9126SWyllys.Ingersoll@Sun.COM * particular Contributor. A Contribution 'originates'
23*9126SWyllys.Ingersoll@Sun.COM * from a Contributor if it was added to the Program
24*9126SWyllys.Ingersoll@Sun.COM * by such Contributor itself or anyone acting on such
25*9126SWyllys.Ingersoll@Sun.COM * Contributor's behalf. Contributions do not include
26*9126SWyllys.Ingersoll@Sun.COM * additions to the Program which: (i) are separate
27*9126SWyllys.Ingersoll@Sun.COM * modules of software distributed in conjunction with
28*9126SWyllys.Ingersoll@Sun.COM * the Program under their own license agreement, and
29*9126SWyllys.Ingersoll@Sun.COM * (ii) are not derivative works of the Program.
30*9126SWyllys.Ingersoll@Sun.COM *
31*9126SWyllys.Ingersoll@Sun.COM *
32*9126SWyllys.Ingersoll@Sun.COM * "Contributor" means any person or entity that distributes
33*9126SWyllys.Ingersoll@Sun.COM * the Program.
34*9126SWyllys.Ingersoll@Sun.COM *
35*9126SWyllys.Ingersoll@Sun.COM * "Licensed Patents " mean patent claims licensable by a
36*9126SWyllys.Ingersoll@Sun.COM * Contributor which are necessarily infringed by the use or
37*9126SWyllys.Ingersoll@Sun.COM * sale of its Contribution alone or when combined with the
38*9126SWyllys.Ingersoll@Sun.COM * Program.
39*9126SWyllys.Ingersoll@Sun.COM *
40*9126SWyllys.Ingersoll@Sun.COM * "Program" means the Contributions distributed in
41*9126SWyllys.Ingersoll@Sun.COM * accordance with this Agreement.
42*9126SWyllys.Ingersoll@Sun.COM *
43*9126SWyllys.Ingersoll@Sun.COM * "Recipient" means anyone who receives the Program under
44*9126SWyllys.Ingersoll@Sun.COM * this Agreement, including all Contributors.
45*9126SWyllys.Ingersoll@Sun.COM *
46*9126SWyllys.Ingersoll@Sun.COM * 2. GRANT OF RIGHTS
47*9126SWyllys.Ingersoll@Sun.COM *
48*9126SWyllys.Ingersoll@Sun.COM * a) Subject to the terms of this Agreement, each
49*9126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a
50*9126SWyllys.Ingersoll@Sun.COM * non-exclusive, worldwide, royalty-free copyright
51*9126SWyllys.Ingersoll@Sun.COM * license to reproduce, prepare derivative works of,
52*9126SWyllys.Ingersoll@Sun.COM * publicly display, publicly perform, distribute and
53*9126SWyllys.Ingersoll@Sun.COM * sublicense the Contribution of such Contributor, if
54*9126SWyllys.Ingersoll@Sun.COM * any, and such derivative works, in source code and
55*9126SWyllys.Ingersoll@Sun.COM * object code form.
56*9126SWyllys.Ingersoll@Sun.COM *
57*9126SWyllys.Ingersoll@Sun.COM * b) Subject to the terms of this Agreement, each
58*9126SWyllys.Ingersoll@Sun.COM * Contributor hereby grants Recipient a
59*9126SWyllys.Ingersoll@Sun.COM * non-exclusive, worldwide, royalty-free patent
60*9126SWyllys.Ingersoll@Sun.COM * license under Licensed Patents to make, use, sell,
61*9126SWyllys.Ingersoll@Sun.COM * offer to sell, import and otherwise transfer the
62*9126SWyllys.Ingersoll@Sun.COM * Contribution of such Contributor, if any, in source
63*9126SWyllys.Ingersoll@Sun.COM * code and object code form. This patent license
64*9126SWyllys.Ingersoll@Sun.COM * shall apply to the combination of the Contribution
65*9126SWyllys.Ingersoll@Sun.COM * and the Program if, at the time the Contribution is
66*9126SWyllys.Ingersoll@Sun.COM * added by the Contributor, such addition of the
67*9126SWyllys.Ingersoll@Sun.COM * Contribution causes such combination to be covered
68*9126SWyllys.Ingersoll@Sun.COM * by the Licensed Patents. The patent license shall
69*9126SWyllys.Ingersoll@Sun.COM * not apply to any other combinations which include
70*9126SWyllys.Ingersoll@Sun.COM * the Contribution. No hardware per se is licensed
71*9126SWyllys.Ingersoll@Sun.COM * hereunder.
72*9126SWyllys.Ingersoll@Sun.COM *
73*9126SWyllys.Ingersoll@Sun.COM * c) Recipient understands that although each
74*9126SWyllys.Ingersoll@Sun.COM * Contributor grants the licenses to its
75*9126SWyllys.Ingersoll@Sun.COM * Contributions set forth herein, no assurances are
76*9126SWyllys.Ingersoll@Sun.COM * provided by any Contributor that the Program does
77*9126SWyllys.Ingersoll@Sun.COM * not infringe the patent or other intellectual
78*9126SWyllys.Ingersoll@Sun.COM * property rights of any other entity. Each
79*9126SWyllys.Ingersoll@Sun.COM * Contributor disclaims any liability to Recipient
80*9126SWyllys.Ingersoll@Sun.COM * for claims brought by any other entity based on
81*9126SWyllys.Ingersoll@Sun.COM * infringement of intellectual property rights or
82*9126SWyllys.Ingersoll@Sun.COM * otherwise. As a condition to exercising the rights
83*9126SWyllys.Ingersoll@Sun.COM * and licenses granted hereunder, each Recipient
84*9126SWyllys.Ingersoll@Sun.COM * hereby assumes sole responsibility to secure any
85*9126SWyllys.Ingersoll@Sun.COM * other intellectual property rights needed, if any.
86*9126SWyllys.Ingersoll@Sun.COM *
87*9126SWyllys.Ingersoll@Sun.COM * For example, if a third party patent license is
88*9126SWyllys.Ingersoll@Sun.COM * required to allow Recipient to distribute the
89*9126SWyllys.Ingersoll@Sun.COM * Program, it is Recipient's responsibility to
90*9126SWyllys.Ingersoll@Sun.COM * acquire that license before distributing the
91*9126SWyllys.Ingersoll@Sun.COM * Program.
92*9126SWyllys.Ingersoll@Sun.COM *
93*9126SWyllys.Ingersoll@Sun.COM * d) Each Contributor represents that to its
94*9126SWyllys.Ingersoll@Sun.COM * knowledge it has sufficient copyright rights in its
95*9126SWyllys.Ingersoll@Sun.COM * Contribution, if any, to grant the copyright
96*9126SWyllys.Ingersoll@Sun.COM * license set forth in this Agreement.
97*9126SWyllys.Ingersoll@Sun.COM *
98*9126SWyllys.Ingersoll@Sun.COM * 3. REQUIREMENTS
99*9126SWyllys.Ingersoll@Sun.COM *
100*9126SWyllys.Ingersoll@Sun.COM * A Contributor may choose to distribute the Program in
101*9126SWyllys.Ingersoll@Sun.COM * object code form under its own license agreement, provided
102*9126SWyllys.Ingersoll@Sun.COM * that:
103*9126SWyllys.Ingersoll@Sun.COM * a) it complies with the terms and conditions of
104*9126SWyllys.Ingersoll@Sun.COM * this Agreement; and
105*9126SWyllys.Ingersoll@Sun.COM *
106*9126SWyllys.Ingersoll@Sun.COM * b) its license agreement:
107*9126SWyllys.Ingersoll@Sun.COM * i) effectively disclaims on behalf of all
108*9126SWyllys.Ingersoll@Sun.COM * Contributors all warranties and conditions, express
109*9126SWyllys.Ingersoll@Sun.COM * and implied, including warranties or conditions of
110*9126SWyllys.Ingersoll@Sun.COM * title and non-infringement, and implied warranties
111*9126SWyllys.Ingersoll@Sun.COM * or conditions of merchantability and fitness for a
112*9126SWyllys.Ingersoll@Sun.COM * particular purpose;
113*9126SWyllys.Ingersoll@Sun.COM *
114*9126SWyllys.Ingersoll@Sun.COM * ii) effectively excludes on behalf of all
115*9126SWyllys.Ingersoll@Sun.COM * Contributors all liability for damages, including
116*9126SWyllys.Ingersoll@Sun.COM * direct, indirect, special, incidental and
117*9126SWyllys.Ingersoll@Sun.COM * consequential damages, such as lost profits;
118*9126SWyllys.Ingersoll@Sun.COM *
119*9126SWyllys.Ingersoll@Sun.COM * iii) states that any provisions which differ from
120*9126SWyllys.Ingersoll@Sun.COM * this Agreement are offered by that Contributor
121*9126SWyllys.Ingersoll@Sun.COM * alone and not by any other party; and
122*9126SWyllys.Ingersoll@Sun.COM *
123*9126SWyllys.Ingersoll@Sun.COM * iv) states that source code for the Program is
124*9126SWyllys.Ingersoll@Sun.COM * available from such Contributor, and informs
125*9126SWyllys.Ingersoll@Sun.COM * licensees how to obtain it in a reasonable manner
126*9126SWyllys.Ingersoll@Sun.COM * on or through a medium customarily used for
127*9126SWyllys.Ingersoll@Sun.COM * software exchange.
128*9126SWyllys.Ingersoll@Sun.COM *
129*9126SWyllys.Ingersoll@Sun.COM * When the Program is made available in source code form:
130*9126SWyllys.Ingersoll@Sun.COM * a) it must be made available under this Agreement;
131*9126SWyllys.Ingersoll@Sun.COM * and
132*9126SWyllys.Ingersoll@Sun.COM * b) a copy of this Agreement must be included with
133*9126SWyllys.Ingersoll@Sun.COM * each copy of the Program.
134*9126SWyllys.Ingersoll@Sun.COM *
135*9126SWyllys.Ingersoll@Sun.COM * Contributors may not remove or alter any copyright notices
136*9126SWyllys.Ingersoll@Sun.COM * contained within the Program.
137*9126SWyllys.Ingersoll@Sun.COM *
138*9126SWyllys.Ingersoll@Sun.COM * Each Contributor must identify itself as the originator of
139*9126SWyllys.Ingersoll@Sun.COM * its Contribution, if any, in a manner that reasonably
140*9126SWyllys.Ingersoll@Sun.COM * allows subsequent Recipients to identify the originator of
141*9126SWyllys.Ingersoll@Sun.COM * the Contribution.
142*9126SWyllys.Ingersoll@Sun.COM *
143*9126SWyllys.Ingersoll@Sun.COM *
144*9126SWyllys.Ingersoll@Sun.COM * 4. COMMERCIAL DISTRIBUTION
145*9126SWyllys.Ingersoll@Sun.COM *
146*9126SWyllys.Ingersoll@Sun.COM * Commercial distributors of software may accept certain
147*9126SWyllys.Ingersoll@Sun.COM * responsibilities with respect to end users, business
148*9126SWyllys.Ingersoll@Sun.COM * partners and the like. While this license is intended to
149*9126SWyllys.Ingersoll@Sun.COM * facilitate the commercial use of the Program, the
150*9126SWyllys.Ingersoll@Sun.COM * Contributor who includes the Program in a commercial
151*9126SWyllys.Ingersoll@Sun.COM * product offering should do so in a manner which does not
152*9126SWyllys.Ingersoll@Sun.COM * create potential liability for other Contributors.
153*9126SWyllys.Ingersoll@Sun.COM * Therefore, if a Contributor includes the Program in a
154*9126SWyllys.Ingersoll@Sun.COM * commercial product offering, such Contributor ("Commercial
155*9126SWyllys.Ingersoll@Sun.COM * Contributor") hereby agrees to defend and indemnify every
156*9126SWyllys.Ingersoll@Sun.COM * other Contributor ("Indemnified Contributor") against any
157*9126SWyllys.Ingersoll@Sun.COM * losses, damages and costs (collectively "Losses") arising
158*9126SWyllys.Ingersoll@Sun.COM * from claims, lawsuits and other legal actions brought by a
159*9126SWyllys.Ingersoll@Sun.COM * third party against the Indemnified Contributor to the
160*9126SWyllys.Ingersoll@Sun.COM * extent caused by the acts or omissions of such Commercial
161*9126SWyllys.Ingersoll@Sun.COM * Contributor in connection with its distribution of the
162*9126SWyllys.Ingersoll@Sun.COM * Program in a commercial product offering. The obligations
163*9126SWyllys.Ingersoll@Sun.COM * in this section do not apply to any claims or Losses
164*9126SWyllys.Ingersoll@Sun.COM * relating to any actual or alleged intellectual property
165*9126SWyllys.Ingersoll@Sun.COM * infringement. In order to qualify, an Indemnified
166*9126SWyllys.Ingersoll@Sun.COM * Contributor must: a) promptly notify the Commercial
167*9126SWyllys.Ingersoll@Sun.COM * Contributor in writing of such claim, and b) allow the
168*9126SWyllys.Ingersoll@Sun.COM * Commercial Contributor to control, and cooperate with the
169*9126SWyllys.Ingersoll@Sun.COM * Commercial Contributor in, the defense and any related
170*9126SWyllys.Ingersoll@Sun.COM * settlement negotiations. The Indemnified Contributor may
171*9126SWyllys.Ingersoll@Sun.COM * participate in any such claim at its own expense.
172*9126SWyllys.Ingersoll@Sun.COM *
173*9126SWyllys.Ingersoll@Sun.COM *
174*9126SWyllys.Ingersoll@Sun.COM * For example, a Contributor might include the Program in a
175*9126SWyllys.Ingersoll@Sun.COM * commercial product offering, Product X. That Contributor
176*9126SWyllys.Ingersoll@Sun.COM * is then a Commercial Contributor. If that Commercial
177*9126SWyllys.Ingersoll@Sun.COM * Contributor then makes performance claims, or offers
178*9126SWyllys.Ingersoll@Sun.COM * warranties related to Product X, those performance claims
179*9126SWyllys.Ingersoll@Sun.COM * and warranties are such Commercial Contributor's
180*9126SWyllys.Ingersoll@Sun.COM * responsibility alone. Under this section, the Commercial
181*9126SWyllys.Ingersoll@Sun.COM * Contributor would have to defend claims against the other
182*9126SWyllys.Ingersoll@Sun.COM * Contributors related to those performance claims and
183*9126SWyllys.Ingersoll@Sun.COM * warranties, and if a court requires any other Contributor
184*9126SWyllys.Ingersoll@Sun.COM * to pay any damages as a result, the Commercial Contributor
185*9126SWyllys.Ingersoll@Sun.COM * must pay those damages.
186*9126SWyllys.Ingersoll@Sun.COM *
187*9126SWyllys.Ingersoll@Sun.COM *
188*9126SWyllys.Ingersoll@Sun.COM * 5. NO WARRANTY
189*9126SWyllys.Ingersoll@Sun.COM *
190*9126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE
191*9126SWyllys.Ingersoll@Sun.COM * PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
192*9126SWyllys.Ingersoll@Sun.COM * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
193*9126SWyllys.Ingersoll@Sun.COM * IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR
194*9126SWyllys.Ingersoll@Sun.COM * CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
195*9126SWyllys.Ingersoll@Sun.COM * FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
196*9126SWyllys.Ingersoll@Sun.COM * responsible for determining the appropriateness of using
197*9126SWyllys.Ingersoll@Sun.COM * and distributing the Program and assumes all risks
198*9126SWyllys.Ingersoll@Sun.COM * associated with its exercise of rights under this
199*9126SWyllys.Ingersoll@Sun.COM * Agreement, including but not limited to the risks and
200*9126SWyllys.Ingersoll@Sun.COM * costs of program errors, compliance with applicable laws,
201*9126SWyllys.Ingersoll@Sun.COM * damage to or loss of data, programs or equipment, and
202*9126SWyllys.Ingersoll@Sun.COM * unavailability or interruption of operations.
203*9126SWyllys.Ingersoll@Sun.COM *
204*9126SWyllys.Ingersoll@Sun.COM * 6. DISCLAIMER OF LIABILITY
205*9126SWyllys.Ingersoll@Sun.COM * EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER
206*9126SWyllys.Ingersoll@Sun.COM * RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY
207*9126SWyllys.Ingersoll@Sun.COM * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
208*9126SWyllys.Ingersoll@Sun.COM * OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
209*9126SWyllys.Ingersoll@Sun.COM * LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
210*9126SWyllys.Ingersoll@Sun.COM * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
211*9126SWyllys.Ingersoll@Sun.COM * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
212*9126SWyllys.Ingersoll@Sun.COM * OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE
213*9126SWyllys.Ingersoll@Sun.COM * OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
214*9126SWyllys.Ingersoll@Sun.COM * POSSIBILITY OF SUCH DAMAGES.
215*9126SWyllys.Ingersoll@Sun.COM *
216*9126SWyllys.Ingersoll@Sun.COM * 7. GENERAL
217*9126SWyllys.Ingersoll@Sun.COM *
218*9126SWyllys.Ingersoll@Sun.COM * If any provision of this Agreement is invalid or
219*9126SWyllys.Ingersoll@Sun.COM * unenforceable under applicable law, it shall not affect
220*9126SWyllys.Ingersoll@Sun.COM * the validity or enforceability of the remainder of the
221*9126SWyllys.Ingersoll@Sun.COM * terms of this Agreement, and without further action by the
222*9126SWyllys.Ingersoll@Sun.COM * parties hereto, such provision shall be reformed to the
223*9126SWyllys.Ingersoll@Sun.COM * minimum extent necessary to make such provision valid and
224*9126SWyllys.Ingersoll@Sun.COM * enforceable.
225*9126SWyllys.Ingersoll@Sun.COM *
226*9126SWyllys.Ingersoll@Sun.COM *
227*9126SWyllys.Ingersoll@Sun.COM * If Recipient institutes patent litigation against a
228*9126SWyllys.Ingersoll@Sun.COM * Contributor with respect to a patent applicable to
229*9126SWyllys.Ingersoll@Sun.COM * software (including a cross-claim or counterclaim in a
230*9126SWyllys.Ingersoll@Sun.COM * lawsuit), then any patent licenses granted by that
231*9126SWyllys.Ingersoll@Sun.COM * Contributor to such Recipient under this Agreement shall
232*9126SWyllys.Ingersoll@Sun.COM * terminate as of the date such litigation is filed. In
233*9126SWyllys.Ingersoll@Sun.COM * addition, If Recipient institutes patent litigation
234*9126SWyllys.Ingersoll@Sun.COM * against any entity (including a cross-claim or
235*9126SWyllys.Ingersoll@Sun.COM * counterclaim in a lawsuit) alleging that the Program
236*9126SWyllys.Ingersoll@Sun.COM * itself (excluding combinations of the Program with other
237*9126SWyllys.Ingersoll@Sun.COM * software or hardware) infringes such Recipient's
238*9126SWyllys.Ingersoll@Sun.COM * patent(s), then such Recipient's rights granted under
239*9126SWyllys.Ingersoll@Sun.COM * Section 2(b) shall terminate as of the date such
240*9126SWyllys.Ingersoll@Sun.COM * litigation is filed.
241*9126SWyllys.Ingersoll@Sun.COM *
242*9126SWyllys.Ingersoll@Sun.COM * All Recipient's rights under this Agreement shall
243*9126SWyllys.Ingersoll@Sun.COM * terminate if it fails to comply with any of the material
244*9126SWyllys.Ingersoll@Sun.COM * terms or conditions of this Agreement and does not cure
245*9126SWyllys.Ingersoll@Sun.COM * such failure in a reasonable period of time after becoming
246*9126SWyllys.Ingersoll@Sun.COM * aware of such noncompliance. If all Recipient's rights
247*9126SWyllys.Ingersoll@Sun.COM * under this Agreement terminate, Recipient agrees to cease
248*9126SWyllys.Ingersoll@Sun.COM * use and distribution of the Program as soon as reasonably
249*9126SWyllys.Ingersoll@Sun.COM * practicable. However, Recipient's obligations under this
250*9126SWyllys.Ingersoll@Sun.COM * Agreement and any licenses granted by Recipient relating
251*9126SWyllys.Ingersoll@Sun.COM * to the Program shall continue and survive.
252*9126SWyllys.Ingersoll@Sun.COM *
253*9126SWyllys.Ingersoll@Sun.COM * Everyone is permitted to copy and distribute copies of
254*9126SWyllys.Ingersoll@Sun.COM * this Agreement, but in order to avoid inconsistency the
255*9126SWyllys.Ingersoll@Sun.COM * Agreement is copyrighted and may only be modified in the
256*9126SWyllys.Ingersoll@Sun.COM * following manner. The Agreement Steward reserves the right
257*9126SWyllys.Ingersoll@Sun.COM * to publish new versions (including revisions) of this
258*9126SWyllys.Ingersoll@Sun.COM * Agreement from time to time. No one other than the
259*9126SWyllys.Ingersoll@Sun.COM * Agreement Steward has the right to modify this Agreement.
260*9126SWyllys.Ingersoll@Sun.COM *
261*9126SWyllys.Ingersoll@Sun.COM * IBM is the initial Agreement Steward. IBM may assign the
262*9126SWyllys.Ingersoll@Sun.COM * responsibility to serve as the Agreement Steward to a
263*9126SWyllys.Ingersoll@Sun.COM * suitable separate entity. Each new version of the
264*9126SWyllys.Ingersoll@Sun.COM * Agreement will be given a distinguishing version number.
265*9126SWyllys.Ingersoll@Sun.COM * The Program (including Contributions) may always be
266*9126SWyllys.Ingersoll@Sun.COM * distributed subject to the version of the Agreement under
267*9126SWyllys.Ingersoll@Sun.COM * which it was received. In addition, after a new version of
268*9126SWyllys.Ingersoll@Sun.COM * the Agreement is published, Contributor may elect to
269*9126SWyllys.Ingersoll@Sun.COM * distribute the Program (including its Contributions) under
270*9126SWyllys.Ingersoll@Sun.COM * the new version. Except as expressly stated in Sections
271*9126SWyllys.Ingersoll@Sun.COM * 2(a) and 2(b) above, Recipient receives no rights or
272*9126SWyllys.Ingersoll@Sun.COM * licenses to the intellectual property of any Contributor
273*9126SWyllys.Ingersoll@Sun.COM * under this Agreement, whether expressly, by implication,
274*9126SWyllys.Ingersoll@Sun.COM * estoppel or otherwise. All rights in the Program not
275*9126SWyllys.Ingersoll@Sun.COM * expressly granted under this Agreement are reserved.
276*9126SWyllys.Ingersoll@Sun.COM *
277*9126SWyllys.Ingersoll@Sun.COM *
278*9126SWyllys.Ingersoll@Sun.COM * This Agreement is governed by the laws of the State of New
279*9126SWyllys.Ingersoll@Sun.COM * York and the intellectual property laws of the United
280*9126SWyllys.Ingersoll@Sun.COM * States of America. No party to this Agreement will bring a
281*9126SWyllys.Ingersoll@Sun.COM * legal action under this Agreement more than one year after
282*9126SWyllys.Ingersoll@Sun.COM * the cause of action arose. Each party waives its rights to
283*9126SWyllys.Ingersoll@Sun.COM * a jury trial in any resulting litigation.
284*9126SWyllys.Ingersoll@Sun.COM *
285*9126SWyllys.Ingersoll@Sun.COM *
286*9126SWyllys.Ingersoll@Sun.COM *
287*9126SWyllys.Ingersoll@Sun.COM * (C) COPYRIGHT International Business Machines Corp. 2001,2002
288*9126SWyllys.Ingersoll@Sun.COM */
289*9126SWyllys.Ingersoll@Sun.COM /*
290*9126SWyllys.Ingersoll@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
291*9126SWyllys.Ingersoll@Sun.COM * Use is subject to license terms.
292*9126SWyllys.Ingersoll@Sun.COM */
293*9126SWyllys.Ingersoll@Sun.COM
294*9126SWyllys.Ingersoll@Sun.COM #include "tpmtok_int.h"
295*9126SWyllys.Ingersoll@Sun.COM
296*9126SWyllys.Ingersoll@Sun.COM CK_RV
md5_hash(SESSION * sess,CK_BBOOL length_only,DIGEST_CONTEXT * ctx,CK_BYTE * in_data,CK_ULONG in_data_len,CK_BYTE * out_data,CK_ULONG * out_data_len)297*9126SWyllys.Ingersoll@Sun.COM md5_hash(SESSION *sess,
298*9126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only,
299*9126SWyllys.Ingersoll@Sun.COM DIGEST_CONTEXT *ctx,
300*9126SWyllys.Ingersoll@Sun.COM CK_BYTE *in_data,
301*9126SWyllys.Ingersoll@Sun.COM CK_ULONG in_data_len,
302*9126SWyllys.Ingersoll@Sun.COM CK_BYTE *out_data,
303*9126SWyllys.Ingersoll@Sun.COM CK_ULONG *out_data_len)
304*9126SWyllys.Ingersoll@Sun.COM {
305*9126SWyllys.Ingersoll@Sun.COM if (! sess || ! ctx || ! out_data_len) {
306*9126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
307*9126SWyllys.Ingersoll@Sun.COM }
308*9126SWyllys.Ingersoll@Sun.COM
309*9126SWyllys.Ingersoll@Sun.COM *out_data_len = MD5_DIGEST_LENGTH;
310*9126SWyllys.Ingersoll@Sun.COM if (length_only == TRUE) {
311*9126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
312*9126SWyllys.Ingersoll@Sun.COM }
313*9126SWyllys.Ingersoll@Sun.COM
314*9126SWyllys.Ingersoll@Sun.COM MD5Update(ctx->context.md5ctx, in_data, in_data_len);
315*9126SWyllys.Ingersoll@Sun.COM MD5Final(out_data, ctx->context.md5ctx);
316*9126SWyllys.Ingersoll@Sun.COM
317*9126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
318*9126SWyllys.Ingersoll@Sun.COM }
319*9126SWyllys.Ingersoll@Sun.COM
320*9126SWyllys.Ingersoll@Sun.COM CK_RV
md5_hmac_sign(SESSION * sess,CK_BBOOL length_only,SIGN_VERIFY_CONTEXT * ctx,CK_BYTE * in_data,CK_ULONG in_data_len,CK_BYTE * out_data,CK_ULONG * out_data_len)321*9126SWyllys.Ingersoll@Sun.COM md5_hmac_sign(SESSION * sess,
322*9126SWyllys.Ingersoll@Sun.COM CK_BBOOL length_only,
323*9126SWyllys.Ingersoll@Sun.COM SIGN_VERIFY_CONTEXT * ctx,
324*9126SWyllys.Ingersoll@Sun.COM CK_BYTE * in_data,
325*9126SWyllys.Ingersoll@Sun.COM CK_ULONG in_data_len,
326*9126SWyllys.Ingersoll@Sun.COM CK_BYTE * out_data,
327*9126SWyllys.Ingersoll@Sun.COM CK_ULONG * out_data_len)
328*9126SWyllys.Ingersoll@Sun.COM {
329*9126SWyllys.Ingersoll@Sun.COM OBJECT * key_obj = NULL;
330*9126SWyllys.Ingersoll@Sun.COM CK_ATTRIBUTE * attr = NULL;
331*9126SWyllys.Ingersoll@Sun.COM CK_BYTE hash[MD5_DIGEST_LENGTH];
332*9126SWyllys.Ingersoll@Sun.COM DIGEST_CONTEXT digest_ctx;
333*9126SWyllys.Ingersoll@Sun.COM CK_MECHANISM digest_mech;
334*9126SWyllys.Ingersoll@Sun.COM CK_BYTE k_ipad[MD5_BLOCK_SIZE];
335*9126SWyllys.Ingersoll@Sun.COM CK_BYTE k_opad[MD5_BLOCK_SIZE];
336*9126SWyllys.Ingersoll@Sun.COM CK_ULONG key_bytes, hash_len, hmac_len;
337*9126SWyllys.Ingersoll@Sun.COM CK_ULONG i;
338*9126SWyllys.Ingersoll@Sun.COM CK_RV rc;
339*9126SWyllys.Ingersoll@Sun.COM
340*9126SWyllys.Ingersoll@Sun.COM if (! sess || ! ctx || ! out_data_len) {
341*9126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
342*9126SWyllys.Ingersoll@Sun.COM }
343*9126SWyllys.Ingersoll@Sun.COM
344*9126SWyllys.Ingersoll@Sun.COM if (ctx->mech.mechanism == CKM_MD5_HMAC_GENERAL) {
345*9126SWyllys.Ingersoll@Sun.COM hmac_len = *(CK_ULONG *)ctx->mech.pParameter;
346*9126SWyllys.Ingersoll@Sun.COM
347*9126SWyllys.Ingersoll@Sun.COM if (hmac_len == 0) {
348*9126SWyllys.Ingersoll@Sun.COM *out_data_len = 0;
349*9126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
350*9126SWyllys.Ingersoll@Sun.COM }
351*9126SWyllys.Ingersoll@Sun.COM }
352*9126SWyllys.Ingersoll@Sun.COM else
353*9126SWyllys.Ingersoll@Sun.COM hmac_len = MD5_DIGEST_LENGTH;
354*9126SWyllys.Ingersoll@Sun.COM
355*9126SWyllys.Ingersoll@Sun.COM
356*9126SWyllys.Ingersoll@Sun.COM *out_data_len = hmac_len;
357*9126SWyllys.Ingersoll@Sun.COM if (length_only == TRUE) {
358*9126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
359*9126SWyllys.Ingersoll@Sun.COM }
360*9126SWyllys.Ingersoll@Sun.COM
361*9126SWyllys.Ingersoll@Sun.COM (void) memset(&digest_ctx, 0x0, sizeof (DIGEST_CONTEXT));
362*9126SWyllys.Ingersoll@Sun.COM
363*9126SWyllys.Ingersoll@Sun.COM rc = object_mgr_find_in_map1(sess->hContext, ctx->key, &key_obj);
364*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK)
365*9126SWyllys.Ingersoll@Sun.COM return (rc);
366*9126SWyllys.Ingersoll@Sun.COM rc = template_attribute_find(key_obj->template, CKA_VALUE, &attr);
367*9126SWyllys.Ingersoll@Sun.COM if (rc == FALSE) {
368*9126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
369*9126SWyllys.Ingersoll@Sun.COM }
370*9126SWyllys.Ingersoll@Sun.COM else
371*9126SWyllys.Ingersoll@Sun.COM key_bytes = attr->ulValueLen;
372*9126SWyllys.Ingersoll@Sun.COM
373*9126SWyllys.Ingersoll@Sun.COM // build (K XOR ipad), (K XOR opad)
374*9126SWyllys.Ingersoll@Sun.COM //
375*9126SWyllys.Ingersoll@Sun.COM if (key_bytes > MD5_BLOCK_SIZE) {
376*9126SWyllys.Ingersoll@Sun.COM digest_mech.mechanism = CKM_MD5;
377*9126SWyllys.Ingersoll@Sun.COM digest_mech.ulParameterLen = 0;
378*9126SWyllys.Ingersoll@Sun.COM digest_mech.pParameter = NULL;
379*9126SWyllys.Ingersoll@Sun.COM
380*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_init(sess, &digest_ctx, &digest_mech);
381*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
382*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
383*9126SWyllys.Ingersoll@Sun.COM return (rc);
384*9126SWyllys.Ingersoll@Sun.COM }
385*9126SWyllys.Ingersoll@Sun.COM
386*9126SWyllys.Ingersoll@Sun.COM hash_len = *out_data_len;
387*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest(sess, FALSE, &digest_ctx,
388*9126SWyllys.Ingersoll@Sun.COM attr->pValue, attr->ulValueLen,
389*9126SWyllys.Ingersoll@Sun.COM hash, &hash_len);
390*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
391*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
392*9126SWyllys.Ingersoll@Sun.COM return (rc);
393*9126SWyllys.Ingersoll@Sun.COM }
394*9126SWyllys.Ingersoll@Sun.COM
395*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
396*9126SWyllys.Ingersoll@Sun.COM (void) memset(&digest_ctx, 0x0, sizeof (DIGEST_CONTEXT));
397*9126SWyllys.Ingersoll@Sun.COM
398*9126SWyllys.Ingersoll@Sun.COM for (i = 0; i < hash_len; i++) {
399*9126SWyllys.Ingersoll@Sun.COM k_ipad[i] = hash[i] ^ 0x36;
400*9126SWyllys.Ingersoll@Sun.COM k_opad[i] = hash[i] ^ 0x5C;
401*9126SWyllys.Ingersoll@Sun.COM }
402*9126SWyllys.Ingersoll@Sun.COM
403*9126SWyllys.Ingersoll@Sun.COM (void) memset(&k_ipad[i], 0x36, MD5_BLOCK_SIZE - i);
404*9126SWyllys.Ingersoll@Sun.COM (void) memset(&k_opad[i], 0x5C, MD5_BLOCK_SIZE - i);
405*9126SWyllys.Ingersoll@Sun.COM } else {
406*9126SWyllys.Ingersoll@Sun.COM CK_BYTE *key = attr->pValue;
407*9126SWyllys.Ingersoll@Sun.COM
408*9126SWyllys.Ingersoll@Sun.COM for (i = 0; i < key_bytes; i++) {
409*9126SWyllys.Ingersoll@Sun.COM k_ipad[i] = key[i] ^ 0x36;
410*9126SWyllys.Ingersoll@Sun.COM k_opad[i] = key[i] ^ 0x5C;
411*9126SWyllys.Ingersoll@Sun.COM }
412*9126SWyllys.Ingersoll@Sun.COM
413*9126SWyllys.Ingersoll@Sun.COM (void) memset(&k_ipad[i], 0x36, MD5_BLOCK_SIZE - key_bytes);
414*9126SWyllys.Ingersoll@Sun.COM (void) memset(&k_opad[i], 0x5C, MD5_BLOCK_SIZE - key_bytes);
415*9126SWyllys.Ingersoll@Sun.COM }
416*9126SWyllys.Ingersoll@Sun.COM
417*9126SWyllys.Ingersoll@Sun.COM digest_mech.mechanism = CKM_MD5;
418*9126SWyllys.Ingersoll@Sun.COM digest_mech.ulParameterLen = 0;
419*9126SWyllys.Ingersoll@Sun.COM digest_mech.pParameter = NULL;
420*9126SWyllys.Ingersoll@Sun.COM
421*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_init(sess, &digest_ctx, &digest_mech);
422*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
423*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
424*9126SWyllys.Ingersoll@Sun.COM return (rc);
425*9126SWyllys.Ingersoll@Sun.COM }
426*9126SWyllys.Ingersoll@Sun.COM
427*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_update(sess, &digest_ctx,
428*9126SWyllys.Ingersoll@Sun.COM k_ipad, MD5_BLOCK_SIZE);
429*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
430*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
431*9126SWyllys.Ingersoll@Sun.COM return (rc);
432*9126SWyllys.Ingersoll@Sun.COM }
433*9126SWyllys.Ingersoll@Sun.COM
434*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_update(sess, &digest_ctx,
435*9126SWyllys.Ingersoll@Sun.COM in_data, in_data_len);
436*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
437*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
438*9126SWyllys.Ingersoll@Sun.COM return (rc);
439*9126SWyllys.Ingersoll@Sun.COM }
440*9126SWyllys.Ingersoll@Sun.COM
441*9126SWyllys.Ingersoll@Sun.COM hash_len = sizeof (hash);
442*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_final(sess, &digest_ctx, hash, &hash_len);
443*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
444*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
445*9126SWyllys.Ingersoll@Sun.COM return (rc);
446*9126SWyllys.Ingersoll@Sun.COM }
447*9126SWyllys.Ingersoll@Sun.COM
448*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
449*9126SWyllys.Ingersoll@Sun.COM (void) memset(&digest_ctx, 0x0, sizeof (DIGEST_CONTEXT));
450*9126SWyllys.Ingersoll@Sun.COM
451*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_init(sess, &digest_ctx, &digest_mech);
452*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
453*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
454*9126SWyllys.Ingersoll@Sun.COM return (rc);
455*9126SWyllys.Ingersoll@Sun.COM }
456*9126SWyllys.Ingersoll@Sun.COM
457*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_update(sess, &digest_ctx,
458*9126SWyllys.Ingersoll@Sun.COM k_opad, MD5_BLOCK_SIZE);
459*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
460*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
461*9126SWyllys.Ingersoll@Sun.COM return (rc);
462*9126SWyllys.Ingersoll@Sun.COM }
463*9126SWyllys.Ingersoll@Sun.COM
464*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_update(sess, &digest_ctx, hash, hash_len);
465*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
466*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
467*9126SWyllys.Ingersoll@Sun.COM return (rc);
468*9126SWyllys.Ingersoll@Sun.COM }
469*9126SWyllys.Ingersoll@Sun.COM
470*9126SWyllys.Ingersoll@Sun.COM hash_len = sizeof (hash);
471*9126SWyllys.Ingersoll@Sun.COM rc = digest_mgr_digest_final(sess, &digest_ctx, hash, &hash_len);
472*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
473*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
474*9126SWyllys.Ingersoll@Sun.COM return (rc);
475*9126SWyllys.Ingersoll@Sun.COM }
476*9126SWyllys.Ingersoll@Sun.COM
477*9126SWyllys.Ingersoll@Sun.COM (void) memcpy(out_data, hash, hmac_len);
478*9126SWyllys.Ingersoll@Sun.COM *out_data_len = hmac_len;
479*9126SWyllys.Ingersoll@Sun.COM
480*9126SWyllys.Ingersoll@Sun.COM (void) digest_mgr_cleanup(&digest_ctx);
481*9126SWyllys.Ingersoll@Sun.COM return (CKR_OK);
482*9126SWyllys.Ingersoll@Sun.COM }
483*9126SWyllys.Ingersoll@Sun.COM
484*9126SWyllys.Ingersoll@Sun.COM CK_RV
md5_hmac_verify(SESSION * sess,SIGN_VERIFY_CONTEXT * ctx,CK_BYTE * in_data,CK_ULONG in_data_len,CK_BYTE * signature,CK_ULONG sig_len)485*9126SWyllys.Ingersoll@Sun.COM md5_hmac_verify(SESSION * sess,
486*9126SWyllys.Ingersoll@Sun.COM SIGN_VERIFY_CONTEXT * ctx,
487*9126SWyllys.Ingersoll@Sun.COM CK_BYTE * in_data,
488*9126SWyllys.Ingersoll@Sun.COM CK_ULONG in_data_len,
489*9126SWyllys.Ingersoll@Sun.COM CK_BYTE * signature,
490*9126SWyllys.Ingersoll@Sun.COM CK_ULONG sig_len)
491*9126SWyllys.Ingersoll@Sun.COM {
492*9126SWyllys.Ingersoll@Sun.COM CK_BYTE hmac[MD5_DIGEST_LENGTH];
493*9126SWyllys.Ingersoll@Sun.COM SIGN_VERIFY_CONTEXT hmac_ctx;
494*9126SWyllys.Ingersoll@Sun.COM CK_ULONG hmac_len, len;
495*9126SWyllys.Ingersoll@Sun.COM CK_RV rc;
496*9126SWyllys.Ingersoll@Sun.COM
497*9126SWyllys.Ingersoll@Sun.COM if (! sess || ! ctx || ! in_data || ! signature) {
498*9126SWyllys.Ingersoll@Sun.COM return (CKR_FUNCTION_FAILED);
499*9126SWyllys.Ingersoll@Sun.COM }
500*9126SWyllys.Ingersoll@Sun.COM if (ctx->mech.mechanism == CKM_MD5_HMAC_GENERAL)
501*9126SWyllys.Ingersoll@Sun.COM hmac_len = *(CK_ULONG *)ctx->mech.pParameter;
502*9126SWyllys.Ingersoll@Sun.COM else
503*9126SWyllys.Ingersoll@Sun.COM hmac_len = MD5_DIGEST_LENGTH;
504*9126SWyllys.Ingersoll@Sun.COM
505*9126SWyllys.Ingersoll@Sun.COM (void) memset(&hmac_ctx, 0, sizeof (SIGN_VERIFY_CONTEXT));
506*9126SWyllys.Ingersoll@Sun.COM
507*9126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_init(sess, &hmac_ctx, &ctx->mech, FALSE, ctx->key);
508*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
509*9126SWyllys.Ingersoll@Sun.COM (void) sign_mgr_cleanup(&hmac_ctx);
510*9126SWyllys.Ingersoll@Sun.COM return (rc);
511*9126SWyllys.Ingersoll@Sun.COM }
512*9126SWyllys.Ingersoll@Sun.COM
513*9126SWyllys.Ingersoll@Sun.COM len = sizeof (hmac);
514*9126SWyllys.Ingersoll@Sun.COM rc = sign_mgr_sign(sess, FALSE, &hmac_ctx,
515*9126SWyllys.Ingersoll@Sun.COM in_data, in_data_len, hmac, &len);
516*9126SWyllys.Ingersoll@Sun.COM if (rc != CKR_OK) {
517*9126SWyllys.Ingersoll@Sun.COM (void) sign_mgr_cleanup(&hmac_ctx);
518*9126SWyllys.Ingersoll@Sun.COM return (rc);
519*9126SWyllys.Ingersoll@Sun.COM }
520*9126SWyllys.Ingersoll@Sun.COM
521*9126SWyllys.Ingersoll@Sun.COM if ((len != hmac_len) || (len != sig_len)) {
522*9126SWyllys.Ingersoll@Sun.COM return (CKR_SIGNATURE_LEN_RANGE);
523*9126SWyllys.Ingersoll@Sun.COM }
524*9126SWyllys.Ingersoll@Sun.COM if (memcmp(hmac, signature, hmac_len) != 0) {
525*9126SWyllys.Ingersoll@Sun.COM rc = CKR_SIGNATURE_INVALID;
526*9126SWyllys.Ingersoll@Sun.COM }
527*9126SWyllys.Ingersoll@Sun.COM (void) sign_mgr_cleanup(&hmac_ctx);
528*9126SWyllys.Ingersoll@Sun.COM return (rc);
529*9126SWyllys.Ingersoll@Sun.COM }
530