Debian Codegraph @

src/lib/P11Attributes.h

raw
1 /*
2 * Copyright (c) 2011 .SE (The Internet Infrastructure Foundation)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 /*****************************************************************************
28 P11Attributes.h
29
30 This file contains classes for controlling attributes
31 *****************************************************************************/
32
33 #ifndef _SOFTHSM_V2_P11ATTRIBUTES_H
34 #define _SOFTHSM_V2_P11ATTRIBUTES_H
35
36 #include "cryptoki.h"
37 #include "OSObject.h"
38 #include "Token.h"
39
40 // The operation types
41 #define OBJECT_OP_NONE 0x0
42 #define OBJECT_OP_COPY 0x1
43 #define OBJECT_OP_CREATE 0x2
44 #define OBJECT_OP_DERIVE 0x3
45 #define OBJECT_OP_GENERATE 0x4
46 #define OBJECT_OP_SET 0x5
47 #define OBJECT_OP_UNWRAP 0x6
48
49 class P11Attribute
50 {
51 public:
52 // Destructor
53 virtual ~P11Attribute();
54
55 // Initialize the attribute
56 bool init();
57
58 // Return the attribute type
59 CK_ATTRIBUTE_TYPE getType();
60
61 // Return the attribute checks
62 CK_ULONG getChecks();
63
64 // Retrieve the value if allowed
65 CK_RV retrieve(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG_PTR pulValueLen);
66
67 // Update the value if allowed
68 CK_RV update(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
69
70 // Checks are determined by footnotes from table 10 under section 4.2 in the PKCS#11 v2.40 spec.
71 // Table 10 contains common footnotes for object attribute tables that determine the checks to perform on attributes.
72 // There are also checks not in table 10 that have been added here to allow enforcing additional contraints.
73 enum {
74 ck1=1, // 1 MUST be specified when object is created with C_CreateObject.
75 ck2=2, // 2 MUST not be specified when object is created with C_CreateObject.
76 ck3=4, // 3 MUST be specified when object is generated with C_GenerateKey or C_GenerateKeyPair.
77 ck4=8, // 4 MUST not be specified when object is generated with C_GenerateKey or C_GenerateKeyPair.
78 ck5=0x10, // 5 MUST be specified when object is unwrapped with C_UnwrapKey.
79 ck6=0x20, // 6 MUST not be specified when object is unwrapped with C_UnwrapKey.
80 ck7=0x40, // 7 Cannot be revealed if object has its CKA_SENSITIVE attribute set to CK_TRUE or
81 // its CKA_EXTRACTABLE attribute set to CK_FALSE.
82 ck8=0x80, // 8 May be modified after object is created with a C_SetAttributeValue call,
83 // or in the process of copying object with a C_CopyObject call.
84 // However, it is possible that a particular token may not permit modification of
85 // the attribute during the course of a C_CopyObject call.
86 ck9=0x100, // 9 Default value is token-specific, and may depend on the values of other attributes.
87 ck10=0x200, // 10 Can only be set to CK_TRUE by the SO user.
88 ck11=0x400, // 11 Attribute cannot be changed once set to CK_TRUE. It becomes a read only attribute.
89 ck12=0x800, // 12 Attribute cannot be changed once set to CK_FALSE. It becomes a read only attribute.
90 ck13=0x1000, // Intentionally not defined
91 ck14=0x2000, // 14 MUST be non-empty if CKA_URL is empty. (CKA_VALUE)
92 ck15=0x4000, // 15 MUST be non-empty if CKA_VALUE is empty. (CKA_URL)
93 ck16=0x8000, // 16 Can only be empty if CKA_URL is empty.
94 ck17=0x10000, // 17 Can be changed in the process of copying the object using C_CopyObject.
95 ck18=0x20000,
96 ck19=0x40000,
97 ck20=0x80000,
98 ck21=0x100000,
99 ck22=0x200000,
100 ck23=0x400000,
101 ck24=0x800000
102 };
103 protected:
104 // Constructor
105 P11Attribute(OSObject* inobject);
106
107 // The object
108 OSObject* osobject;
109
110 // The attribute type
111 CK_ATTRIBUTE_TYPE type;
112
113 // The checks to perform when the attribute is accessed.
114 CK_ULONG checks;
115
116 // The attribute fixed size contains (CK_ULONG)-1 when size is variable.
117 CK_ULONG size;
118
119 // Set the default value of the attribute
120 virtual bool setDefault() = 0;
121
122 // Update the value if allowed
123 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
124
125 // Helper functions
126 bool isModifiable();
127 bool isSensitive();
128 bool isExtractable();
129 bool isTrusted();
130 };
131
132 /*****************************************
133 * CKA_CLASS
134 *****************************************/
135
136 class P11AttrClass : public P11Attribute
137 {
138 public:
139 // Constructor
140 P11AttrClass(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CLASS; size = sizeof(CK_OBJECT_CLASS); checks = ck1; }
141
142 protected:
143 // Set the default value of the attribute
144 virtual bool setDefault();
145
146 // Update the value if allowed
147 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
148 };
149
150 /*****************************************
151 * CKA_KEY_TYPE
152 *****************************************/
153
154 class P11AttrKeyType : public P11Attribute
155 {
156 public:
157 // Constructor
158 P11AttrKeyType(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_KEY_TYPE; size = sizeof(CK_KEY_TYPE); checks = ck1|inchecks; }
159
160 protected:
161 // Set the default value of the attribute
162 virtual bool setDefault();
163
164 // Update the value if allowed
165 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
166 };
167
168 /*****************************************
169 * CKA_CERTIFICATE_TYPE
170 *****************************************/
171
172 class P11AttrCertificateType : public P11Attribute
173 {
174 public:
175 // Constructor
176 P11AttrCertificateType(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CERTIFICATE_TYPE; size = sizeof(CK_CERTIFICATE_TYPE); checks = ck1; }
177
178 protected:
179 // Set the default value of the attribute
180 virtual bool setDefault();
181
182 // Update the value if allowed
183 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
184 };
185
186 /*****************************************
187 * CKA_TOKEN
188 *****************************************/
189
190 class P11AttrToken : public P11Attribute
191 {
192 public:
193 // Constructor
194 P11AttrToken(OSObject* inobject) : P11Attribute(inobject) { type = CKA_TOKEN; size = sizeof(CK_BBOOL); checks = ck17; }
195
196 protected:
197 // Set the default value of the attribute
198 virtual bool setDefault();
199
200 // Update the value if allowed
201 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
202 };
203
204 /*****************************************
205 * CKA_PRIVATE
206 *****************************************/
207
208 class P11AttrPrivate : public P11Attribute
209 {
210 public:
211 // Constructor
212 P11AttrPrivate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIVATE; size = sizeof(CK_BBOOL); checks = ck17; }
213
214 protected:
215 // Set the default value of the attribute
216 virtual bool setDefault();
217
218 // Update the value if allowed
219 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
220 };
221
222 /*****************************************
223 * CKA_MODIFIABLE
224 *****************************************/
225
226 class P11AttrModifiable : public P11Attribute
227 {
228 public:
229 // Constructor
230 P11AttrModifiable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_MODIFIABLE; size = sizeof(CK_BBOOL); checks = ck17; }
231
232 protected:
233 // Set the default value of the attribute
234 virtual bool setDefault();
235
236 // Update the value if allowed
237 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
238 };
239
240 /*****************************************
241 * CKA_LABEL
242 *****************************************/
243
244 class P11AttrLabel : public P11Attribute
245 {
246 public:
247 // Constructor
248 P11AttrLabel(OSObject* inobject) : P11Attribute(inobject) { type = CKA_LABEL; checks = ck8; }
249
250 protected:
251 // Set the default value of the attribute
252 virtual bool setDefault();
253 };
254
255 /*****************************************
256 * CKA_COPYABLE
257 *****************************************/
258
259 class P11AttrCopyable : public P11Attribute
260 {
261 public:
262 // Constructor
263 P11AttrCopyable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_COPYABLE; size = sizeof(CK_BBOOL); checks = ck12; }
264
265 protected:
266 // Set the default value of the attribute
267 virtual bool setDefault();
268
269 // Update the value if allowed
270 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
271 };
272
273 /*****************************************
274 * CKA_DESTROYABLE
275 *****************************************/
276
277 class P11AttrDestroyable : public P11Attribute
278 {
279 public:
280 // Constructor
281 P11AttrDestroyable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DESTROYABLE; size = sizeof(CK_BBOOL); checks = ck17; }
282
283 protected:
284 // Set the default value of the attribute
285 virtual bool setDefault();
286
287 // Update the value if allowed
288 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
289 };
290
291 /*****************************************
292 * CKA_APPLICATION
293 *****************************************/
294
295 class P11AttrApplication : public P11Attribute
296 {
297 public:
298 // Constructor
299 P11AttrApplication(OSObject* inobject) : P11Attribute(inobject) { type = CKA_APPLICATION; checks = 0; }
300
301 protected:
302 // Set the default value of the attribute
303 virtual bool setDefault();
304 };
305
306 /*****************************************
307 * CKA_OBJECT_ID
308 *****************************************/
309
310 class P11AttrObjectID : public P11Attribute
311 {
312 public:
313 // Constructor
314 P11AttrObjectID(OSObject* inobject) : P11Attribute(inobject) { type = CKA_OBJECT_ID; checks = 0; }
315
316 protected:
317 // Set the default value of the attribute
318 virtual bool setDefault();
319 };
320
321 /*****************************************
322 * CKA_CHECK_VALUE
323 *****************************************/
324
325 class P11AttrCheckValue : public P11Attribute
326 {
327 public:
328 // Constructor
329 P11AttrCheckValue(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_CHECK_VALUE; checks = inchecks; }
330
331 protected:
332 // Set the default value of the attribute
333 virtual bool setDefault();
334
335
336 // Update the value if allowed
337 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
338 };
339
340 /*****************************************
341 * CKA_PUBLIC_KEY_INFO
342 *****************************************/
343
344 class P11AttrPublicKeyInfo : public P11Attribute
345 {
346 public:
347 // Constructor
348 P11AttrPublicKeyInfo(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_PUBLIC_KEY_INFO; checks = inchecks; }
349
350 protected:
351 // Set the default value of the attribute
352 virtual bool setDefault();
353 };
354
355 /*****************************************
356 * CKA_ID
357 *****************************************/
358
359 class P11AttrID : public P11Attribute
360 {
361 public:
362 // Constructor
363 P11AttrID(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ID; checks = ck8; }
364
365 protected:
366 // Set the default value of the attribute
367 virtual bool setDefault();
368 };
369
370 /*****************************************
371 * CKA_VALUE
372 *****************************************/
373
374 class P11AttrValue : public P11Attribute
375 {
376 public:
377 // Constructor
378 P11AttrValue(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_VALUE; checks = inchecks; }
379
380 protected:
381 // Set the default value of the attribute
382 virtual bool setDefault();
383
384 // Update the value if allowed
385 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
386 };
387
388 /*****************************************
389 * CKA_SUBJECT
390 *****************************************/
391
392 class P11AttrSubject : public P11Attribute
393 {
394 public:
395 // Constructor
396 P11AttrSubject(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_SUBJECT; checks = inchecks; }
397
398 protected:
399 // Set the default value of the attribute
400 virtual bool setDefault();
401 };
402
403 /*****************************************
404 * CKA_ISSUER
405 *****************************************/
406
407 class P11AttrIssuer : public P11Attribute
408 {
409 public:
410 // Constructor
411 P11AttrIssuer(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ISSUER; checks = ck8; }
412
413 protected:
414 // Set the default value of the attribute
415 virtual bool setDefault();
416 };
417
418 /*****************************************
419 * CKA_TRUSTED
420 *****************************************/
421
422 class P11AttrTrusted : public P11Attribute
423 {
424 public:
425 // Constructor
426 P11AttrTrusted(OSObject* inobject) : P11Attribute(inobject) { type = CKA_TRUSTED; size = sizeof(CK_BBOOL); checks = ck10; }
427
428 protected:
429 // Set the default value of the attribute
430 virtual bool setDefault();
431
432 // Update the value if allowed
433 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
434 };
435
436 /*****************************************
437 * CKA_CERTIFICATE_CATEGORY
438 *****************************************/
439
440 class P11AttrCertificateCategory : public P11Attribute
441 {
442 public:
443 // Constructor
444 P11AttrCertificateCategory(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CERTIFICATE_CATEGORY; size = sizeof(CK_ULONG); checks = 0; }
445
446 protected:
447 // Set the default value of the attribute
448 virtual bool setDefault();
449
450 // Update the value if allowed
451 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
452 };
453
454 /*****************************************
455 * CKA_START_DATE
456 *****************************************/
457
458 class P11AttrStartDate : public P11Attribute
459 {
460 public:
461 // Constructor
462 P11AttrStartDate(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_START_DATE; checks = inchecks; }
463
464 protected:
465 // Set the default value of the attribute
466 virtual bool setDefault();
467
468 // Update the value if allowed
469 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
470 };
471
472 /*****************************************
473 * CKA_END_DATE
474 *****************************************/
475
476 class P11AttrEndDate : public P11Attribute
477 {
478 public:
479 // Constructor
480 P11AttrEndDate(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_END_DATE; checks = inchecks; }
481
482 protected:
483 // Set the default value of the attribute
484 virtual bool setDefault();
485
486 // Update the value if allowed
487 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
488 };
489
490 /*****************************************
491 * CKA_SERIAL_NUMBER
492 *****************************************/
493
494 class P11AttrSerialNumber : public P11Attribute
495 {
496 public:
497 // Constructor
498 P11AttrSerialNumber(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SERIAL_NUMBER; checks = ck8; }
499
500 protected:
501 // Set the default value of the attribute
502 virtual bool setDefault();
503 };
504
505 /*****************************************
506 * CKA_URL
507 *****************************************/
508
509 class P11AttrURL : public P11Attribute
510 {
511 public:
512 // Constructor
513 P11AttrURL(OSObject* inobject) : P11Attribute(inobject) { type = CKA_URL; checks = ck15; }
514
515 protected:
516 // Set the default value of the attribute
517 virtual bool setDefault();
518 };
519
520 /*****************************************
521 * CKA_HASH_OF_SUBJECT_PUBLIC_KEY
522 *****************************************/
523
524 class P11AttrHashOfSubjectPublicKey : public P11Attribute
525 {
526 public:
527 // Constructor
528 P11AttrHashOfSubjectPublicKey(OSObject* inobject) : P11Attribute(inobject) { type = CKA_HASH_OF_SUBJECT_PUBLIC_KEY; checks = ck16; }
529
530 protected:
531 // Set the default value of the attribute
532 virtual bool setDefault();
533 };
534
535 /*****************************************
536 * CKA_HASH_OF_ISSUER_PUBLIC_KEY
537 *****************************************/
538
539 class P11AttrHashOfIssuerPublicKey : public P11Attribute
540 {
541 public:
542 // Constructor
543 P11AttrHashOfIssuerPublicKey(OSObject* inobject) : P11Attribute(inobject) { type = CKA_HASH_OF_ISSUER_PUBLIC_KEY; checks = ck16; }
544
545 protected:
546 // Set the default value of the attribute
547 virtual bool setDefault();
548 };
549
550 /*****************************************
551 * CKA_JAVA_MIDP_SECURITY_DOMAIN
552 *****************************************/
553
554 class P11AttrJavaMidpSecurityDomain : public P11Attribute
555 {
556 public:
557 // Constructor
558 P11AttrJavaMidpSecurityDomain(OSObject* inobject) : P11Attribute(inobject) { type = CKA_JAVA_MIDP_SECURITY_DOMAIN; size = sizeof(CK_ULONG); checks = 0; }
559
560 protected:
561 // Set the default value of the attribute
562 virtual bool setDefault();
563
564 // Update the value if allowed
565 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
566 };
567
568 /*****************************************
569 * CKA_NAME_HASH_ALGORITHM
570 *****************************************/
571
572 class P11AttrNameHashAlgorithm : public P11Attribute
573 {
574 public:
575 // Constructor
576 P11AttrNameHashAlgorithm(OSObject* inobject) : P11Attribute(inobject) { type = CKA_NAME_HASH_ALGORITHM; size = sizeof(CK_MECHANISM_TYPE); checks = 0; }
577
578 protected:
579 // Set the default value of the attribute
580 virtual bool setDefault();
581
582 // Update the value if allowed
583 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
584 };
585
586 /*****************************************
587 * CKA_DERIVE
588 *****************************************/
589
590 class P11AttrDerive : public P11Attribute
591 {
592 public:
593 // Constructor
594 P11AttrDerive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DERIVE; size = sizeof(CK_BBOOL); checks = ck8;}
595
596 protected:
597 // Set the default value of the attribute
598 virtual bool setDefault();
599
600 // Update the value if allowed
601 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
602 };
603
604 /*****************************************
605 * CKA_ENCRYPT
606 *****************************************/
607
608 class P11AttrEncrypt : public P11Attribute
609 {
610 public:
611 // Constructor
612 P11AttrEncrypt(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ENCRYPT; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
613
614 protected:
615 // Set the default value of the attribute
616 virtual bool setDefault();
617
618 // Update the value if allowed
619 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
620 };
621
622 /*****************************************
623 * CKA_VERIFY
624 *****************************************/
625
626 class P11AttrVerify : public P11Attribute
627 {
628 public:
629 // Constructor
630 P11AttrVerify(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VERIFY; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
631
632 protected:
633 // Set the default value of the attribute
634 virtual bool setDefault();
635
636 // Update the value if allowed
637 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
638 };
639
640 /*****************************************
641 * CKA_VERIFY_RECOVER
642 *****************************************/
643
644 class P11AttrVerifyRecover : public P11Attribute
645 {
646 public:
647 // Constructor
648 P11AttrVerifyRecover(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VERIFY_RECOVER; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
649
650 protected:
651 // Set the default value of the attribute
652 virtual bool setDefault();
653
654 // Update the value if allowed
655 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
656 };
657
658 /*****************************************
659 * CKA_WRAP
660 *****************************************/
661
662 class P11AttrWrap : public P11Attribute
663 {
664 public:
665 // Constructor
666 P11AttrWrap(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
667
668 protected:
669 // Set the default value of the attribute
670 virtual bool setDefault();
671
672 // Update the value if allowed
673 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
674 };
675
676 /*****************************************
677 * CKA_DECRYPT
678 *****************************************/
679
680 class P11AttrDecrypt : public P11Attribute
681 {
682 public:
683 // Constructor
684 P11AttrDecrypt(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DECRYPT; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
685
686 protected:
687 // Set the default value of the attribute
688 virtual bool setDefault();
689
690 // Update the value if allowed
691 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
692 };
693
694 /*****************************************
695 * CKA_SIGN
696 *****************************************/
697
698 class P11AttrSign : public P11Attribute
699 {
700 public:
701 // Constructor
702 P11AttrSign(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SIGN; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
703
704 protected:
705 // Set the default value of the attribute
706 virtual bool setDefault();
707
708 // Update the value if allowed
709 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
710 };
711
712 /*****************************************
713 * CKA_SIGN_RECOVER
714 *****************************************/
715
716 class P11AttrSignRecover : public P11Attribute
717 {
718 public:
719 // Constructor
720 P11AttrSignRecover(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SIGN_RECOVER; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
721
722 protected:
723 // Set the default value of the attribute
724 virtual bool setDefault();
725
726 // Update the value if allowed
727 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
728 };
729
730 /*****************************************
731 * CKA_UNWRAP
732 *****************************************/
733
734 class P11AttrUnwrap : public P11Attribute
735 {
736 public:
737 // Constructor
738 P11AttrUnwrap(OSObject* inobject) : P11Attribute(inobject) { type = CKA_UNWRAP; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
739
740 protected:
741 // Set the default value of the attribute
742 virtual bool setDefault();
743
744 // Update the value if allowed
745 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
746 };
747
748 /*****************************************
749 * CKA_LOCAL
750 *****************************************/
751
752 class P11AttrLocal : public P11Attribute
753 {
754 public:
755 // Constructor
756 P11AttrLocal(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_LOCAL; size = sizeof(CK_BBOOL); checks = ck2|ck4|inchecks; }
757
758 protected:
759 // Set the default value of the attribute
760 virtual bool setDefault();
761
762 // Update the value if allowed
763 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
764 };
765
766 /*****************************************
767 * CKA_KEY_GEN_MECHANISM
768 *****************************************/
769
770 class P11AttrKeyGenMechanism : public P11Attribute
771 {
772 public:
773 // Constructor
774 P11AttrKeyGenMechanism(OSObject* inobject) : P11Attribute(inobject) { type = CKA_KEY_GEN_MECHANISM; size = sizeof(CK_MECHANISM_TYPE); checks = ck2|ck4|ck6; }
775
776 protected:
777 // Set the default value of the attribute
778 virtual bool setDefault();
779
780 // Update the value if allowed
781 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
782 };
783
784 /*****************************************
785 * CKA_ALWAYS_SENSITIVE
786 *****************************************/
787
788 class P11AttrAlwaysSensitive : public P11Attribute
789 {
790 public:
791 // Constructor
792 P11AttrAlwaysSensitive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALWAYS_SENSITIVE; size = sizeof(CK_BBOOL); checks = ck2|ck4|ck6; }
793
794 protected:
795 // Set the default value of the attribute
796 virtual bool setDefault();
797
798 // Update the value if allowed
799 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
800 };
801
802 /*****************************************
803 * CKA_NEVER_EXTRACTABLE
804 *****************************************/
805
806 class P11AttrNeverExtractable : public P11Attribute
807 {
808 public:
809 // Constructor
810 P11AttrNeverExtractable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_NEVER_EXTRACTABLE; size = sizeof(CK_BBOOL); checks = ck2|ck4|ck6; }
811
812 protected:
813 // Set the default value of the attribute
814 virtual bool setDefault();
815
816 // Update the value if allowed
817 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
818 };
819
820 /*****************************************
821 * CKA_SENSITIVE
822 *****************************************/
823
824 class P11AttrSensitive : public P11Attribute
825 {
826 public:
827 // Constructor
828 P11AttrSensitive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SENSITIVE; size = sizeof(CK_BBOOL); checks = ck8|ck9|ck11; }
829
830 protected:
831 // Set the default value of the attribute
832 virtual bool setDefault();
833
834 // Update the value if allowed
835 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
836 };
837
838 /*****************************************
839 * CKA_EXTRACTABLE
840 *****************************************/
841
842 class P11AttrExtractable : public P11Attribute
843 {
844 public:
845 // Constructor
846 P11AttrExtractable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXTRACTABLE; size = sizeof(CK_BBOOL); checks = ck8|ck9|ck12; }
847
848 protected:
849 // Set the default value of the attribute
850 virtual bool setDefault();
851
852 // Update the value if allowed
853 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
854 };
855
856 /*****************************************
857 * CKA_WRAP_WITH_TRUSTED
858 *****************************************/
859
860 class P11AttrWrapWithTrusted : public P11Attribute
861 {
862 public:
863 // Constructor
864 P11AttrWrapWithTrusted(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP_WITH_TRUSTED; size = sizeof(CK_BBOOL); checks = ck11; }
865
866 protected:
867 // Set the default value of the attribute
868 virtual bool setDefault();
869
870 // Update the value if allowed
871 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
872 };
873
874 /*****************************************
875 * CKA_ALWAYS_AUTHENTICATE
876 *****************************************/
877
878 class P11AttrAlwaysAuthenticate : public P11Attribute
879 {
880 public:
881 // Constructor
882 P11AttrAlwaysAuthenticate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALWAYS_AUTHENTICATE; size = sizeof(CK_BBOOL); checks = 0; }
883
884 protected:
885 // Set the default value of the attribute
886 virtual bool setDefault();
887
888 // Update the value if allowed
889 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
890 };
891
892 /*****************************************
893 * CKA_MODULUS
894 *****************************************/
895
896 class P11AttrModulus : public P11Attribute
897 {
898 public:
899 // Constructor
900 P11AttrModulus(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_MODULUS; checks = ck1|ck4|inchecks; }
901
902 protected:
903 // Set the default value of the attribute
904 virtual bool setDefault();
905
906 // Update the value if allowed
907 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
908 };
909
910 /*****************************************
911 * CKA_PUBLIC_EXPONENT
912 *****************************************/
913
914 class P11AttrPublicExponent : public P11Attribute
915 {
916 public:
917 // Constructor
918 P11AttrPublicExponent(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_PUBLIC_EXPONENT; checks = inchecks; }
919
920 protected:
921 // Set the default value of the attribute
922 virtual bool setDefault();
923 };
924
925 /*****************************************
926 * CKA_PRIVATE_EXPONENT
927 *****************************************/
928
929 class P11AttrPrivateExponent : public P11Attribute
930 {
931 public:
932 // Constructor
933 P11AttrPrivateExponent(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIVATE_EXPONENT; checks = ck1|ck4|ck6|ck7; }
934
935 protected:
936 // Set the default value of the attribute
937 virtual bool setDefault();
938 };
939
940 /*****************************************
941 * CKA_PRIME_1
942 *****************************************/
943
944 class P11AttrPrime1 : public P11Attribute
945 {
946 public:
947 // Constructor
948 P11AttrPrime1(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_1; checks = ck4|ck6|ck7; }
949
950 protected:
951 // Set the default value of the attribute
952 virtual bool setDefault();
953 };
954
955 /*****************************************
956 * CKA_PRIME_2
957 *****************************************/
958
959 class P11AttrPrime2 : public P11Attribute
960 {
961 public:
962 // Constructor
963 P11AttrPrime2(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_2; checks = ck4|ck6|ck7; }
964
965 protected:
966 // Set the default value of the attribute
967 virtual bool setDefault();
968 };
969
970 /*****************************************
971 * CKA_EXPONENT_1
972 *****************************************/
973
974 class P11AttrExponent1 : public P11Attribute
975 {
976 public:
977 // Constructor
978 P11AttrExponent1(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXPONENT_1; checks = ck4|ck6|ck7; }
979
980 protected:
981 // Set the default value of the attribute
982 virtual bool setDefault();
983 };
984
985 /*****************************************
986 * CKA_EXPONENT_2
987 *****************************************/
988
989 class P11AttrExponent2 : public P11Attribute
990 {
991 public:
992 // Constructor
993 P11AttrExponent2(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXPONENT_2; checks = ck4|ck6|ck7; }
994
995 protected:
996 // Set the default value of the attribute
997 virtual bool setDefault();
998 };
999
1000 /*****************************************
1001 * CKA_COEFFICIENT
1002 *****************************************/
1003
1004 class P11AttrCoefficient : public P11Attribute
1005 {
1006 public:
1007 // Constructor
1008 P11AttrCoefficient(OSObject* inobject) : P11Attribute(inobject) { type = CKA_COEFFICIENT; checks = ck4|ck6|ck7; }
1009
1010 protected:
1011 // Set the default value of the attribute
1012 virtual bool setDefault();
1013 };
1014
1015 /*****************************************
1016 * CKA_MODULUS_BITS
1017 *****************************************/
1018
1019 class P11AttrModulusBits : public P11Attribute
1020 {
1021 public:
1022 // Constructor
1023 P11AttrModulusBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_MODULUS_BITS; size = sizeof(CK_ULONG); checks = ck2|ck3;}
1024
1025 protected:
1026 // Set the default value of the attribute
1027 virtual bool setDefault();
1028
1029 // Update the value if allowed
1030 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1031 };
1032
1033 /*****************************************
1034 * CKA_PRIME
1035 *****************************************/
1036
1037 class P11AttrPrime : public P11Attribute
1038 {
1039 public:
1040 // Constructor
1041 P11AttrPrime(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_PRIME; checks = ck1|inchecks; }
1042
1043 protected:
1044 // Set the default value of the attribute
1045 virtual bool setDefault();
1046
1047 // Update the value if allowed
1048 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1049 };
1050
1051 /*****************************************
1052 * CKA_SUBPRIME
1053 *****************************************/
1054
1055 class P11AttrSubPrime : public P11Attribute
1056 {
1057 public:
1058 // Constructor
1059 P11AttrSubPrime(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_SUBPRIME; checks = ck1|inchecks; }
1060
1061 protected:
1062 // Set the default value of the attribute
1063 virtual bool setDefault();
1064 };
1065
1066 /*****************************************
1067 * CKA_BASE
1068 *****************************************/
1069
1070 class P11AttrBase : public P11Attribute
1071 {
1072 public:
1073 // Constructor
1074 P11AttrBase(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_BASE; checks = ck1|inchecks; }
1075
1076 protected:
1077 // Set the default value of the attribute
1078 virtual bool setDefault();
1079 };
1080
1081 /*****************************************
1082 * CKA_PRIME_BITS
1083 *****************************************/
1084
1085 class P11AttrPrimeBits : public P11Attribute
1086 {
1087 public:
1088 // Constructor
1089 P11AttrPrimeBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_BITS; size = sizeof(CK_ULONG); checks = ck2|ck3;}
1090
1091 protected:
1092 // Set the default value of the attribute
1093 virtual bool setDefault();
1094
1095 // Update the value if allowed
1096 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1097 };
1098
1099 /*****************************************
1100 * CKA_VALUE_BITS
1101 *****************************************/
1102
1103 class P11AttrValueBits : public P11Attribute
1104 {
1105 public:
1106 // Constructor
1107 P11AttrValueBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VALUE_BITS; size = sizeof(CK_ULONG); checks = ck2|ck6;}
1108
1109 protected:
1110 // Set the default value of the attribute
1111 virtual bool setDefault();
1112
1113 // Update the value if allowed
1114 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1115 };
1116
1117 /*****************************************
1118 * CKA_EC_PARAMS
1119 *****************************************/
1120
1121 class P11AttrEcParams : public P11Attribute
1122 {
1123 public:
1124 // Constructor
1125 P11AttrEcParams(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_EC_PARAMS; checks = ck1|inchecks; }
1126
1127 protected:
1128 // Set the default value of the attribute
1129 virtual bool setDefault();
1130 };
1131
1132 /*****************************************
1133 * CKA_EC_POINT
1134 *****************************************/
1135
1136 class P11AttrEcPoint : public P11Attribute
1137 {
1138 public:
1139 // Constructor
1140 P11AttrEcPoint(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EC_POINT; checks = ck1|ck4; }
1141
1142 protected:
1143 // Set the default value of the attribute
1144 virtual bool setDefault();
1145 };
1146
1147 /*****************************************
1148 * CKA_GOSTR3410_PARAMS
1149 *****************************************/
1150
1151 class P11AttrGostR3410Params : public P11Attribute
1152 {
1153 public:
1154 // Constructor
1155 P11AttrGostR3410Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOSTR3410_PARAMS; checks = ck1|inchecks; }
1156
1157 protected:
1158 // Set the default value of the attribute
1159 virtual bool setDefault();
1160 };
1161
1162 /*****************************************
1163 * CKA_GOSTR3411_PARAMS
1164 *****************************************/
1165
1166 class P11AttrGostR3411Params : public P11Attribute
1167 {
1168 public:
1169 // Constructor
1170 P11AttrGostR3411Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOSTR3411_PARAMS; checks = ck1|ck8|inchecks; }
1171
1172 protected:
1173 // Set the default value of the attribute
1174 virtual bool setDefault();
1175 };
1176
1177 /*****************************************
1178 * CKA_GOST28147_PARAMS
1179 *****************************************/
1180
1181 class P11AttrGost28147Params : public P11Attribute
1182 {
1183 public:
1184 // Constructor
1185 P11AttrGost28147Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOST28147_PARAMS; checks = inchecks; }
1186
1187 protected:
1188 // Set the default value of the attribute
1189 virtual bool setDefault();
1190 };
1191
1192 /*****************************************
1193 * CKA_VALUE_LEN
1194 *****************************************/
1195
1196 class P11AttrValueLen : public P11Attribute
1197 {
1198 public:
1199 // Constructor
1200 P11AttrValueLen(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_VALUE_LEN; size = sizeof(CK_ULONG); checks = ck2|ck3|inchecks; }
1201
1202 protected:
1203 // Set the default value of the attribute
1204 virtual bool setDefault();
1205
1206 // Update the value if allowed
1207 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1208 };
1209
1210 /*****************************************
1211 * CKA_WRAP_TEMPLATE
1212 *****************************************/
1213
1214 class P11AttrWrapTemplate : public P11Attribute
1215 {
1216 public:
1217 // Constructor
1218 P11AttrWrapTemplate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP_TEMPLATE; checks = 0; }
1219
1220 protected:
1221 // Set the default value of the attribute
1222 virtual bool setDefault();
1223
1224 // Update the value if allowed
1225 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1226 };
1227
1228 /*****************************************
1229 * CKA_UNWRAP_TEMPLATE
1230 *****************************************/
1231
1232 class P11AttrUnwrapTemplate : public P11Attribute
1233 {
1234 public:
1235 // Constructor
1236 P11AttrUnwrapTemplate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_UNWRAP_TEMPLATE; checks = 0; }
1237
1238 protected:
1239 // Set the default value of the attribute
1240 virtual bool setDefault();
1241
1242 // Update the value if allowed
1243 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1244 };
1245
1246 /*****************************************
1247 * CKA_ALLOWED_MECHANISMS
1248 *****************************************/
1249
1250 class P11AttrAllowedMechanisms : public P11Attribute
1251 {
1252 public:
1253 // Constructor
1254 P11AttrAllowedMechanisms(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALLOWED_MECHANISMS; checks = 0; }
1255
1256 protected:
1257 // Set the default value of the attribute
1258 virtual bool setDefault();
1259
1260 // Update the value if allowed
1261 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1262 };
1263
1264 #endif // !_SOFTHSM_V2_P11ATTRIBUTES_H