xref: /titanic_44/usr/src/lib/pkcs11/libpkcs11/common/metaAttrMasters.h (revision e1c679fa4b0ab8c4bcaa6263974ca0c46e5b027f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _META_ATTRMASTERS_H
28 #define	_META_ATTRMASTERS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Master object templates
38  *
39  * [This file should only be included by a single source file. This is a
40  * non-traditional header file in that it simply contains a bunch of large,
41  * preinitialized static const structures. They're stored here to keep them
42  * "out of the way."]
43  *
44  * In PKCS#11, each object is well-defined... Each object type has an exact
45  * set of attributes, and each attribute always has some value. Some
46  * attribute values must be specificed when the object is created, others
47  * are optional (ie, a default value exisits). Thus, the template an
48  * application provides when creating a new object may be a subset of the
49  * allowed attributes. The "master" templates presented here, however,
50  * are complete.
51  */
52 
53 
54 /*
55  * Aliases for some field values in generic_attr_t, so that the initialization
56  * below isn't just a confusing mess of B_TRUE and B_FALSE. Lint
57  * complaints about using "!Foo" in const initializers,
58  * so we #define each value.
59  */
60 
61 #define	unused		0
62 #define	Mallocd		B_TRUE
63 #define	Clone		B_TRUE
64 #define	EmptyValue	B_TRUE
65 #define	NotMallocd	B_FALSE
66 #define	NotClone	B_FALSE
67 #define	NotEmptyValue	B_FALSE
68 #define	EMPTYDATE	' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
69 #define	EMPTY		'\0'
70 
71 /*
72  * A note regarding CKA_CLASS and sub-type (eg CKA_KEY_TYPE)
73  *
74  * These two attributes have been moved to the top of the master template
75  * definitions. All the metaslot code assumes that CKA_CLASS resides in index=0,
76  * and the sub-type resides in index=1.
77  */
78 
79 
80 /*
81  * Common storage object attributes, Table 19 (p81) of PKCS#11 2.11r1 spec.
82  */
83 #define	COMMON_STORAGE_ATTRIBUTES					\
84 	{ { CKA_TOKEN, NULL, sizeof (CK_BBOOL) },			\
85 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
86 		CK_FALSE, unused, { unused } },				\
87 	{ { CKA_PRIVATE, NULL, sizeof (CK_BBOOL) },			\
88 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
89 		CK_FALSE, unused, { unused } },				\
90 	{ { CKA_MODIFIABLE, NULL, sizeof (CK_BBOOL) },			\
91 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
92 		CK_TRUE, unused, { unused } },				\
93 	{ { CKA_LABEL, NULL, 0 },					\
94 		NotMallocd, Clone, EmptyValue, B_FALSE,			\
95 		unused, unused, { EMPTY } }
96 
97 /*
98  * Common certificate attributes, Table 21 (p83) of PKCS#11 2.11r1 spec.
99  * (CKA_CERTIFICATE_TYPE has been moved, to place at top of template)
100  *
101  */
102 #define	COMMON_CERTIFICATE_ATTRIBUTES					\
103 	{ { CKA_TRUSTED, NULL, sizeof (CK_BBOOL) },			\
104 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
105 		CK_FALSE, unused, { unused } }
106 
107 /*
108  * Common key attributes, Table 25 (p89) of PKCS#11 2.11r1 spec.
109  * (CKA_KEY_TYPE has been moved, to place at top of template)
110  *
111  */
112 #define	COMMON_KEY_ATTRIBUTES						\
113 	{ { CKA_ID, NULL, 0 },						\
114 		NotMallocd, Clone, EmptyValue, B_FALSE,			\
115 		unused, unused, { EMPTY } },				\
116 	{ { CKA_START_DATE, NULL, sizeof (CK_DATE) },			\
117 		NotMallocd, Clone, EmptyValue, B_FALSE,			\
118 		unused, unused, { EMPTYDATE } },			\
119 	{ { CKA_END_DATE, NULL, sizeof (CK_DATE) },			\
120 		NotMallocd, Clone, EmptyValue, B_FALSE,			\
121 		unused, unused, { EMPTYDATE } },			\
122 	{ { CKA_DERIVE, NULL, sizeof (CK_BBOOL) },			\
123 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
124 		CK_FALSE, unused, { unused } },				\
125 	{ { CKA_LOCAL, NULL, sizeof (CK_BBOOL) },			\
126 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
127 		CK_FALSE, unused, { unused } },				\
128 	{ { CKA_KEY_GEN_MECHANISM, NULL, sizeof (CK_MECHANISM_TYPE) },	\
129 		NotMallocd, NotClone, EmptyValue, B_FALSE,		\
130 		unused, CK_UNAVAILABLE_INFORMATION, { unused } }
131 
132 /*
133  * Common public-key attributes, Table 26 (p90) of PKCS#11 2.11r1 spec.
134  *
135  * CKA_SUBJECT has the PKCS#11-specified default. The object-usage attributes
136  * are token-specific defaults.
137  *
138  */
139 #define	COMMON_PUBKEY_ATTRIBUTES					\
140 	{ { CKA_SUBJECT, NULL, 0 },					\
141 		NotMallocd, Clone, EmptyValue, B_FALSE,			\
142 		unused, unused, { EMPTY } },				\
143 	{ { CKA_ENCRYPT, NULL, sizeof (CK_BBOOL) },			\
144 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
145 		CK_TRUE, unused, { unused } },				\
146 	{ { CKA_VERIFY, NULL, sizeof (CK_BBOOL) },			\
147 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
148 		CK_TRUE, unused, { unused } },				\
149 	{ { CKA_VERIFY_RECOVER, NULL, sizeof (CK_BBOOL) },		\
150 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
151 		CK_TRUE, unused, { unused } },				\
152 	{ { CKA_WRAP, NULL, sizeof (CK_BBOOL) },			\
153 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
154 		CK_TRUE, unused, { unused } },				\
155 	{ { CKA_TRUSTED, NULL, sizeof (CK_BBOOL) },			\
156 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
157 		CK_FALSE, unused, { unused } }
158 
159 /*
160  * Common private-key attributes, Table 34 (p97) of PKCS#11 2.11r1 spec.
161  */
162 #define	COMMON_PRIVKEY_ATTRIBUTES					\
163 	{ { CKA_SUBJECT, NULL, 0 },					\
164 		NotMallocd, Clone, EmptyValue, B_FALSE,			\
165 		unused, unused, { EMPTY } },				\
166 	{ { CKA_SENSITIVE, NULL, sizeof (CK_BBOOL) },			\
167 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
168 		CK_FALSE, unused, { unused } },				\
169 	{ { CKA_SECONDARY_AUTH, NULL, sizeof (CK_BBOOL) },		\
170 		NotMallocd, Clone, EmptyValue, B_FALSE,			\
171 		CK_FALSE, unused, { unused } },				\
172 	{ { CKA_DECRYPT, NULL, sizeof (CK_BBOOL) },			\
173 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
174 		CK_TRUE, unused, { unused } },				\
175 	{ { CKA_SIGN, NULL, sizeof (CK_BBOOL) },			\
176 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
177 		CK_TRUE, unused, { unused } },				\
178 	{ { CKA_SIGN_RECOVER, NULL, sizeof (CK_BBOOL) },		\
179 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
180 		CK_TRUE, unused, { unused } },				\
181 	{ { CKA_UNWRAP, NULL, sizeof (CK_BBOOL) },			\
182 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
183 		CK_TRUE, unused, { unused } },				\
184 	{ { CKA_EXTRACTABLE, NULL, sizeof (CK_BBOOL) },			\
185 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
186 		CK_TRUE, unused, { unused } },				\
187 	{ { CKA_ALWAYS_SENSITIVE, NULL, sizeof (CK_BBOOL) },		\
188 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
189 		CK_FALSE, unused, { unused } },				\
190 	{ { CKA_NEVER_EXTRACTABLE, NULL, sizeof (CK_BBOOL) },		\
191 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
192 		CK_FALSE, unused, { unused } }
193 
194 
195 /*
196  * Common secret-key attributes, Table 42 (p108) of PKCS#11 2.11r1 spec.
197  */
198 #define	COMMON_SECKEY_ATTRIBUTES					\
199 	{ { CKA_SENSITIVE, NULL, sizeof (CK_BBOOL) },			\
200 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
201 		CK_FALSE, unused, { unused } },				\
202 	{ { CKA_ENCRYPT, NULL, sizeof (CK_BBOOL) },			\
203 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
204 		CK_TRUE, unused, { unused } },				\
205 	{ { CKA_DECRYPT, NULL, sizeof (CK_BBOOL) },			\
206 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
207 		CK_TRUE, unused, { unused } },				\
208 	{ { CKA_SIGN, NULL, sizeof (CK_BBOOL) },			\
209 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
210 		CK_TRUE, unused, { unused } },				\
211 	{ { CKA_VERIFY, NULL, sizeof (CK_BBOOL) },			\
212 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
213 		CK_TRUE, unused, { unused } },				\
214 	{ { CKA_WRAP, NULL, sizeof (CK_BBOOL) },			\
215 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
216 		CK_TRUE, unused, { unused } },				\
217 	{ { CKA_UNWRAP, NULL, sizeof (CK_BBOOL) },			\
218 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
219 		CK_TRUE, unused, { unused } },				\
220 	{ { CKA_EXTRACTABLE, NULL, sizeof (CK_BBOOL) },			\
221 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
222 		CK_TRUE, unused, { unused } },				\
223 	{ { CKA_ALWAYS_SENSITIVE, NULL, sizeof (CK_BBOOL) },		\
224 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
225 		CK_FALSE, unused, { unused } },				\
226 	{ { CKA_NEVER_EXTRACTABLE, NULL, sizeof (CK_BBOOL) },		\
227 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,		\
228 		CK_FALSE, unused, { unused } }
229 
230 /*
231  * Common domain-paramaters attributes, Table 60 (p123) of PKCS#11 2.11r1 spec.
232  * (CKA_KEY_TYPE has been removed, to place elsewhere)
233  */
234 #define	COMMON_DOMAIN_ATTRIBUTES					\
235 	{ { CKA_LOCAL, NULL, sizeof (CK_BBOOL) },			\
236 		NotMallocd, Clone, NotEmptyValue, B_FALSE,		\
237 		CK_FALSE, unused, { unused } }
238 
239 
240 /* ========================= HW Objects ========================= */
241 
242 
243 /*
244  * Master template for: CKO_HW_FEATURE + CKH_CLOCK
245  */
246 static const generic_attr_t OBJ_HW_CLOCK[] =
247 {
248 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
249 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
250 		unused, CKO_HW_FEATURE, { unused } },
251 	{ { CKA_HW_FEATURE_TYPE, NULL, sizeof (CK_HW_FEATURE_TYPE) },
252 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
253 		unused, CKH_CLOCK, { unused } },
254 	{ { CKA_VALUE, NULL, 16 },
255 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
256 		unused, unused, { EMPTYDATE, EMPTYDATE } }
257 };
258 
259 
260 /*
261  * Master template for: CKO_HW_FEATURE + CKH_MONOTONIC_COUNTER
262  *
263  * NOTE: no sub-type for this class!
264  */
265 static const generic_attr_t OBJ_HW_MONOTONIC[] =
266 {
267 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
268 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
269 		unused, CKO_HW_FEATURE, { unused } },
270 	{ { CKA_HW_FEATURE_TYPE, NULL, sizeof (CK_HW_FEATURE_TYPE) },
271 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
272 		unused, CKH_MONOTONIC_COUNTER, { unused } },
273 	{ { CKA_VALUE, NULL, 0 },
274 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
275 		unused, unused, { EMPTY } },
276 	{ { CKA_RESET_ON_INIT, NULL, sizeof (CK_BBOOL) },
277 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
278 		CK_FALSE, unused, { unused } },
279 	{ { CKA_HAS_RESET, NULL, sizeof (CK_BBOOL) },
280 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
281 		CK_FALSE, unused, { unused } }
282 };
283 
284 
285 /* ========================= Data Objects ========================= */
286 
287 
288 /*
289  * Master template for CKO_DATA + (no subtypes for this class)
290  *
291  * Defaults are according to PKCS#11.
292  *
293  * NOTE: no sub-type for this class!
294  */
295 static const generic_attr_t OBJ_DATA[] =
296 {
297 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
298 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
299 		unused, CKO_DATA, { unused } },
300 	COMMON_STORAGE_ATTRIBUTES,
301 	{ { CKA_APPLICATION, NULL, 0 },
302 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
303 		unused, unused, { EMPTY } },
304 	{ { CKA_OBJECT_ID, NULL, 0 },
305 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
306 		unused, unused, { EMPTY } },
307 	{ { CKA_VALUE, NULL, 0 },
308 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
309 		unused, unused, { EMPTY } }
310 };
311 
312 
313 /* ========================= Certificate Objects ========================= */
314 
315 
316 /*
317  * Master template for CKO_CERTIFICATE + CKC_X_509
318  *
319  * Defaults are according to PKCS#11.
320  */
321 static const generic_attr_t OBJ_CERT_X509[] =
322 {
323 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
324 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
325 		unused, CKO_CERTIFICATE, { unused } },
326 	{ { CKA_CERTIFICATE_TYPE, NULL, sizeof (CK_CERTIFICATE_TYPE) },
327 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
328 		unused, CKC_X_509, { unused } },
329 	COMMON_STORAGE_ATTRIBUTES,
330 	COMMON_CERTIFICATE_ATTRIBUTES,
331 	{ { CKA_SUBJECT, NULL, 0 },
332 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
333 		unused, unused, { EMPTY } },
334 	{ { CKA_ID, NULL, 0 },
335 		NotMallocd, Clone, EmptyValue, B_FALSE,
336 		unused, unused, { EMPTY } },
337 	{ { CKA_ISSUER, NULL, 0 },
338 		NotMallocd, Clone, EmptyValue, B_FALSE,
339 		unused, unused, { EMPTY } },
340 	{ { CKA_SERIAL_NUMBER, NULL, 0 },
341 		NotMallocd, Clone, EmptyValue, B_FALSE,
342 		unused, unused, { EMPTY } },
343 	{ { CKA_VALUE, NULL, 0 },
344 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
345 		unused, unused, { EMPTY } }
346 };
347 
348 
349 /*
350  * Master template for CKO_CERTIFICATE + CKC_X_509_ATTR_CERT
351  *
352  * Defaults are according to PKCS#11.
353  */
354 static const generic_attr_t OBJ_CERT_X509ATTR[] =
355 {
356 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
357 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
358 		unused, CKO_CERTIFICATE, { unused } },
359 	{ { CKA_CERTIFICATE_TYPE, NULL, sizeof (CK_CERTIFICATE_TYPE) },
360 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
361 		unused, CKC_X_509_ATTR_CERT, { unused } },
362 	COMMON_STORAGE_ATTRIBUTES,
363 	COMMON_CERTIFICATE_ATTRIBUTES,
364 	{ { CKA_OWNER, NULL, 0 },
365 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
366 		unused, unused, { EMPTY } },
367 	{ { CKA_AC_ISSUER, NULL, 0 },
368 		NotMallocd, Clone, EmptyValue, B_FALSE,
369 		unused, unused, { EMPTY } },
370 	{ { CKA_SERIAL_NUMBER, NULL, 0 },
371 		NotMallocd, Clone, EmptyValue, B_FALSE,
372 		unused, unused, { EMPTY } },
373 	{ { CKA_ATTR_TYPES, NULL, 0 },
374 		NotMallocd, Clone, EmptyValue, B_FALSE,
375 		unused, unused, { EMPTY } },
376 	{ { CKA_VALUE, NULL, 0 },
377 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
378 		unused, unused, { EMPTY } }
379 };
380 
381 
382 /* ========================= Public Keys ========================= */
383 
384 
385 /*
386  * Master template for CKO_PUBLIC_KEY + CKK_RSA
387  */
388 static const generic_attr_t OBJ_PUBKEY_RSA[] =
389 {
390 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
391 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
392 		unused, CKO_PUBLIC_KEY, { unused } },
393 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
394 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
395 		unused, CKK_RSA, { unused } },
396 	COMMON_STORAGE_ATTRIBUTES,
397 	COMMON_KEY_ATTRIBUTES,
398 	COMMON_PUBKEY_ATTRIBUTES,
399 	{ { CKA_MODULUS, NULL, 0 },
400 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
401 		unused, unused, { EMPTY } },
402 	{ { CKA_MODULUS_BITS, NULL, sizeof (CK_ULONG)},
403 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,
404 		unused, 0, { unused } },
405 	{ { CKA_PUBLIC_EXPONENT, NULL, 0 },
406 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
407 		unused, unused, { EMPTY } }
408 };
409 
410 
411 /*
412  * Master template for CKO_PUBLIC_KEY + CKK_DSA
413  *
414  */
415 static const generic_attr_t OBJ_PUBKEY_DSA[] =
416 {
417 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
418 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
419 		unused, CKO_PUBLIC_KEY, { unused } },
420 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
421 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
422 		unused, CKK_DSA, { unused } },
423 	COMMON_STORAGE_ATTRIBUTES,
424 	COMMON_KEY_ATTRIBUTES,
425 	COMMON_PUBKEY_ATTRIBUTES,
426 	{ { CKA_PRIME, NULL, 0 },
427 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
428 		unused, unused, { EMPTY } },
429 	{ { CKA_SUBPRIME, NULL, 0 },
430 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
431 		unused, unused, { EMPTY } },
432 	{ { CKA_BASE, NULL, 0 },
433 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
434 		unused, unused, { EMPTY } },
435 	{ { CKA_VALUE, NULL, 0 },
436 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
437 		unused, unused, { EMPTY } }
438 };
439 
440 
441 /*
442  * Master template for CKO_PUBLIC_KEY + CKK_EC
443  *
444  */
445 static const generic_attr_t OBJ_PUBKEY_EC[] =
446 {
447 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
448 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
449 		unused, CKO_PUBLIC_KEY, { unused } },
450 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
451 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
452 		unused, CKK_EC, { unused } },
453 	COMMON_STORAGE_ATTRIBUTES,
454 	COMMON_KEY_ATTRIBUTES,
455 	COMMON_PUBKEY_ATTRIBUTES,
456 	{ { CKA_EC_PARAMS, NULL, 0 },
457 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
458 		unused, unused, { EMPTY } },
459 	{ { CKA_EC_POINT, NULL, 0 },
460 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
461 		unused, unused, { EMPTY } }
462 };
463 
464 
465 /*
466  * Master template for CKO_PUBLIC_KEY + CKK_DH
467  *
468  */
469 static const generic_attr_t OBJ_PUBKEY_DH[] =
470 {
471 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
472 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
473 		unused, CKO_PUBLIC_KEY, { unused } },
474 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
475 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
476 		unused, CKK_DH, { unused } },
477 	COMMON_STORAGE_ATTRIBUTES,
478 	COMMON_KEY_ATTRIBUTES,
479 	COMMON_PUBKEY_ATTRIBUTES,
480 	{ { CKA_PRIME, NULL, 0 },
481 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
482 		unused, unused, { EMPTY } },
483 	{ { CKA_BASE, NULL, 0 },
484 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
485 		unused, unused, { EMPTY } },
486 	{ { CKA_VALUE, NULL, 0 },
487 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
488 		unused, unused, { EMPTY } }
489 };
490 
491 
492 /*
493  * Master template for CKO_PUBLIC_KEY + CKK_X9_42_DH
494  *
495  */
496 static const generic_attr_t OBJ_PUBKEY_X942DH[] =
497 {
498 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
499 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
500 		unused, CKO_PUBLIC_KEY, { unused } },
501 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
502 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
503 		unused, CKK_X9_42_DH, { unused } },
504 	COMMON_STORAGE_ATTRIBUTES,
505 	COMMON_KEY_ATTRIBUTES,
506 	COMMON_PUBKEY_ATTRIBUTES,
507 	{ { CKA_PRIME, NULL, 0 },
508 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
509 		unused, unused, { EMPTY } },
510 	{ { CKA_BASE, NULL, 0 },
511 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
512 		unused, unused, { EMPTY } },
513 	{ { CKA_SUBPRIME, NULL, 0 },
514 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
515 		unused, unused, { EMPTY } },
516 	{ { CKA_VALUE, NULL, 0 },
517 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
518 		unused, unused, { EMPTY } }
519 };
520 
521 
522 /*
523  * Master template for CKO_PUBLIC_KEY + CKK_KEA
524  *
525  */
526 static const generic_attr_t OBJ_PUBKEY_KEA[] =
527 {
528 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
529 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
530 		unused, CKO_PUBLIC_KEY, { unused } },
531 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
532 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
533 		unused, CKK_KEA, { unused } },
534 	COMMON_STORAGE_ATTRIBUTES,
535 	COMMON_KEY_ATTRIBUTES,
536 	COMMON_PUBKEY_ATTRIBUTES,
537 	{ { CKA_PRIME, NULL, 0 },
538 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
539 		unused, unused, { EMPTY } },
540 	{ { CKA_BASE, NULL, 0 },
541 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
542 		unused, unused, { EMPTY } },
543 	{ { CKA_SUBPRIME, NULL, 0 },
544 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
545 		unused, unused, { EMPTY } },
546 	{ { CKA_VALUE, NULL, 0 },
547 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
548 		unused, unused, { EMPTY } }
549 };
550 
551 
552 /* ========================= Private Keys ========================= */
553 
554 
555 /*
556  * Master template for CKO_PRIVATE_KEY + CKK_RSA
557  *
558  */
559 static const generic_attr_t OBJ_PRIVKEY_RSA[] =
560 {
561 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
562 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
563 		unused, CKO_PRIVATE_KEY, { unused } },
564 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
565 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
566 		unused, CKK_RSA, { unused } },
567 	COMMON_STORAGE_ATTRIBUTES,
568 	COMMON_KEY_ATTRIBUTES,
569 	COMMON_PRIVKEY_ATTRIBUTES,
570 	{ { CKA_MODULUS, NULL, 0 },
571 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
572 		unused, unused, { EMPTY } },
573 	{ { CKA_PRIVATE_EXPONENT, NULL, 0 },
574 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
575 		unused, unused, { EMPTY } },
576 	{ { CKA_PUBLIC_EXPONENT, NULL, 0 },
577 		NotMallocd, Clone, EmptyValue, B_FALSE,
578 		unused, unused, { EMPTY } },
579 	{ { CKA_PRIME_1, NULL, 0 },
580 		NotMallocd, Clone, EmptyValue, B_FALSE,
581 		unused, unused, { EMPTY } },
582 	{ { CKA_PRIME_2, NULL, 0 },
583 		NotMallocd, Clone, EmptyValue, B_FALSE,
584 		unused, unused, { EMPTY } },
585 	{ { CKA_EXPONENT_1, NULL, 0 },
586 		NotMallocd, Clone, EmptyValue, B_FALSE,
587 		unused, unused, { EMPTY } },
588 	{ { CKA_EXPONENT_2, NULL, 0 },
589 		NotMallocd, Clone, EmptyValue, B_FALSE,
590 		unused, unused, { EMPTY } },
591 	{ { CKA_COEFFICIENT, NULL, 0 },
592 		NotMallocd, Clone, EmptyValue, B_FALSE,
593 		unused, unused, { EMPTY } }
594 };
595 
596 
597 /*
598  * Master template for CKO_PRIVATE_KEY + CKK_DSA
599  *
600  */
601 static const generic_attr_t OBJ_PRIVKEY_DSA[] =
602 {
603 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
604 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
605 		unused, CKO_PRIVATE_KEY, { unused } },
606 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
607 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
608 		unused, CKK_DSA, { unused } },
609 	COMMON_STORAGE_ATTRIBUTES,
610 	COMMON_KEY_ATTRIBUTES,
611 	COMMON_PRIVKEY_ATTRIBUTES,
612 	{ { CKA_PRIME, NULL, 0 },
613 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
614 		unused, unused, { EMPTY } },
615 	{ { CKA_SUBPRIME, NULL, 0 },
616 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
617 		unused, unused, { EMPTY } },
618 	{ { CKA_BASE, NULL, 0 },
619 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
620 		unused, unused, { EMPTY } },
621 	{ { CKA_VALUE, NULL, 0 },
622 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
623 		unused, unused, { EMPTY } }
624 };
625 
626 
627 /*
628  * Master template for CKO_PRIVATE_KEY + CKK_EC
629  *
630  */
631 static const generic_attr_t OBJ_PRIVKEY_EC[] =
632 {
633 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
634 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
635 		unused, CKO_PRIVATE_KEY, { unused } },
636 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
637 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
638 		unused, CKK_EC, { unused } },
639 	COMMON_STORAGE_ATTRIBUTES,
640 	COMMON_KEY_ATTRIBUTES,
641 	COMMON_PRIVKEY_ATTRIBUTES,
642 	{ { CKA_EC_PARAMS, NULL, 0 },
643 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
644 		unused, unused, { EMPTY } },
645 	{ { CKA_VALUE, NULL, 0 },
646 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
647 		unused, unused, { EMPTY } }
648 };
649 
650 
651 /*
652  * Master template for CKO_PRIVATE_KEY + CKK_DH
653  */
654 static const generic_attr_t OBJ_PRIVKEY_DH[] =
655 {
656 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
657 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
658 		unused, CKO_PRIVATE_KEY, { unused } },
659 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
660 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
661 		unused, CKK_DH, { unused } },
662 	COMMON_STORAGE_ATTRIBUTES,
663 	COMMON_KEY_ATTRIBUTES,
664 	COMMON_PRIVKEY_ATTRIBUTES,
665 	{ { CKA_PRIME, NULL, 0 },
666 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
667 		unused, unused, { EMPTY } },
668 	{ { CKA_BASE, NULL, 0 },
669 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
670 		unused, unused, { EMPTY } },
671 	{ { CKA_VALUE, NULL, 0 },
672 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
673 		unused, unused, { EMPTY } },
674 	{ { CKA_VALUE_BITS, NULL, sizeof (CK_ULONG) },
675 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,
676 		unused, 0, { unused } }
677 };
678 
679 
680 /*
681  * Master template for CKO_PRIVATE_KEY + CKK_X9_42_DH
682  *
683  */
684 static const generic_attr_t OBJ_PRIVKEY_X942DH[] =
685 {
686 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
687 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
688 		unused, CKO_PRIVATE_KEY, { unused } },
689 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
690 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
691 		unused, CKK_X9_42_DH, { unused } },
692 	COMMON_STORAGE_ATTRIBUTES,
693 	COMMON_KEY_ATTRIBUTES,
694 	COMMON_PRIVKEY_ATTRIBUTES,
695 	{ { CKA_PRIME, NULL, 0 },
696 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
697 		unused, unused, { EMPTY } },
698 	{ { CKA_SUBPRIME, NULL, 0 },
699 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
700 		unused, unused, { EMPTY } },
701 	{ { CKA_BASE, NULL, 0 },
702 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
703 		unused, unused, { EMPTY } },
704 	{ { CKA_VALUE, NULL, 0 },
705 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
706 		unused, unused, { EMPTY } }
707 };
708 
709 
710 /*
711  * Master template for CKO_PRIVATE_KEY + CKK_KEA
712  *
713  */
714 static const generic_attr_t OBJ_PRIVKEY_KEA[] =
715 {
716 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
717 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
718 		unused, CKO_PRIVATE_KEY, { unused } },
719 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
720 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
721 		unused, CKK_KEA, { unused } },
722 	COMMON_STORAGE_ATTRIBUTES,
723 	COMMON_KEY_ATTRIBUTES,
724 	COMMON_PRIVKEY_ATTRIBUTES,
725 	{ { CKA_PRIME, NULL, 0 },
726 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
727 		unused, unused, { EMPTY } },
728 	{ { CKA_BASE, NULL, 0 },
729 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
730 		unused, unused, { EMPTY } },
731 	{ { CKA_SUBPRIME, NULL, 0 },
732 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
733 		unused, unused, { EMPTY } },
734 	{ { CKA_VALUE, NULL, 0 },
735 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
736 		unused, unused, { EMPTY } }
737 };
738 
739 
740 /* ========================= Secret Keys ========================= */
741 
742 
743 /*
744  * Master template for CKO_SECRET_KEY + (fixed-length keytype)
745  */
746 static const generic_attr_t OBJ_SECKEY[] =
747 {
748 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
749 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
750 		unused, CKO_SECRET_KEY, { unused } },
751 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
752 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
753 		unused, CKK_GENERIC_SECRET, { unused } },
754 	COMMON_STORAGE_ATTRIBUTES,
755 	COMMON_KEY_ATTRIBUTES,
756 	COMMON_SECKEY_ATTRIBUTES,
757 	{ { CKA_VALUE, NULL, 0 },
758 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
759 		unused, unused, { EMPTY } }
760 };
761 
762 
763 /*
764  * Master template for CKO_SECRET_KEY + (variable-length keytype)
765  *
766  */
767 static const generic_attr_t OBJ_SECKEY_WITHLEN[] =
768 {
769 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
770 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
771 		unused, CKO_SECRET_KEY, { unused } },
772 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
773 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
774 		unused, CKK_GENERIC_SECRET, { unused } },
775 	COMMON_STORAGE_ATTRIBUTES,
776 	COMMON_KEY_ATTRIBUTES,
777 	COMMON_SECKEY_ATTRIBUTES,
778 	{ { CKA_VALUE, NULL, 0 },
779 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
780 		unused, unused, { EMPTY } },
781 	{ { CKA_VALUE_LEN, NULL, sizeof (CK_ULONG) },
782 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,
783 		unused, 0, { unused } }
784 };
785 
786 
787 /* ========================= Domain Parameters ========================= */
788 
789 
790 /*
791  * Master template for CKO_DOMAIN_PARAMETERS + CKK_DSA
792  *
793  */
794 static const generic_attr_t OBJ_DOM_DSA[] =
795 {
796 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
797 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
798 		unused, CKO_DOMAIN_PARAMETERS, { unused } },
799 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
800 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
801 		unused, CKK_DSA, { unused } },
802 	COMMON_STORAGE_ATTRIBUTES,
803 	COMMON_DOMAIN_ATTRIBUTES,
804 	{ { CKA_PRIME, NULL, 0 },
805 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
806 		unused, unused, { EMPTY } },
807 	{ { CKA_SUBPRIME, NULL, 0 },
808 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
809 		unused, unused, { EMPTY } },
810 	{ { CKA_BASE, NULL, 0 },
811 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
812 		unused, unused, { EMPTY } },
813 	{ { CKA_PRIME_BITS, NULL, sizeof (CK_ULONG) },
814 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,
815 		unused, 0, { unused } }
816 };
817 
818 /*
819  * Master template for CKO_DOMAIN_PARAMETERS + CKK_DH
820  *
821  */
822 static const generic_attr_t OBJ_DOM_DH[] =
823 {
824 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
825 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
826 		unused, CKO_DOMAIN_PARAMETERS, { unused } },
827 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
828 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
829 		unused, CKK_DH, { unused } },
830 	COMMON_STORAGE_ATTRIBUTES,
831 	COMMON_DOMAIN_ATTRIBUTES,
832 	{ { CKA_PRIME, NULL, 0 },
833 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
834 		unused, unused, { EMPTY } },
835 	{ { CKA_BASE, NULL, 0 },
836 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
837 		unused, unused, { EMPTY } },
838 	{ { CKA_PRIME_BITS, NULL, sizeof (CK_ULONG) },
839 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,
840 		unused, 0, { unused } }
841 };
842 
843 /*
844  * Master template for CKO_DOMAIN_PARAMETERS + CKK_X9_42_DH
845  *
846  */
847 static const generic_attr_t OBJ_DOM_X942DH[] =
848 {
849 	{ { CKA_CLASS, NULL, sizeof (CK_OBJECT_CLASS) },
850 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
851 		unused, CKO_DOMAIN_PARAMETERS, { unused } },
852 	{ { CKA_KEY_TYPE, NULL, sizeof (CK_KEY_TYPE) },
853 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
854 		unused, CKK_X9_42_DH, { unused } },
855 	COMMON_STORAGE_ATTRIBUTES,
856 	COMMON_DOMAIN_ATTRIBUTES,
857 	{ { CKA_PRIME, NULL, 0 },
858 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
859 		unused, unused, { EMPTY } },
860 	{ { CKA_BASE, NULL, 0 },
861 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
862 		unused, unused, { EMPTY } },
863 	{ { CKA_SUBPRIME, NULL, 0 },
864 		NotMallocd, Clone, NotEmptyValue, B_FALSE,
865 		unused, unused, { EMPTY } },
866 	{ { CKA_PRIME_BITS, NULL, sizeof (CK_ULONG) },
867 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,
868 		unused, 0, { unused } },
869 	{ { CKA_SUBPRIME_BITS, NULL, sizeof (CK_ULONG) },
870 		NotMallocd, NotClone, NotEmptyValue, B_FALSE,
871 		unused, 0, { unused } }
872 };
873 
874 #ifdef	__cplusplus
875 }
876 #endif
877 
878 #endif /* _META_ATTRMASTERS_H */
879