2 * Copyright (c) 2011 .SE (The Internet Infrastructure Foundation)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
27 /*****************************************************************************
30 This file contains classes for controlling attributes
31 *****************************************************************************/
33 #ifndef _SOFTHSM_V2_P11ATTRIBUTES_H
34 #define _SOFTHSM_V2_P11ATTRIBUTES_H
39 #include "OSAttributes.h"
41 // The operation types
42 #define OBJECT_OP_NONE 0x0
43 #define OBJECT_OP_COPY 0x1
44 #define OBJECT_OP_CREATE 0x2
45 #define OBJECT_OP_DERIVE 0x3
46 #define OBJECT_OP_GENERATE 0x4
47 #define OBJECT_OP_SET 0x5
48 #define OBJECT_OP_UNWRAP 0x6
54 virtual ~P11Attribute();
56 // Initialize the attribute
59 // Return the attribute type
60 CK_ATTRIBUTE_TYPE getType();
62 // Return the attribute checks
65 // Retrieve the value if allowed
66 CK_RV retrieve(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG_PTR pulValueLen);
68 // Update the value if allowed
69 CK_RV update(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
71 // Checks are determined by footnotes from table 10 under section 4.2 in the PKCS#11 v2.40 spec.
72 // Table 10 contains common footnotes for object attribute tables that determine the checks to perform on attributes.
73 // There are also checks not in table 10 that have been added here to allow enforcing additional contraints.
75 ck1=1, // 1 MUST be specified when object is created with C_CreateObject.
76 ck2=2, // 2 MUST not be specified when object is created with C_CreateObject.
77 ck3=4, // 3 MUST be specified when object is generated with C_GenerateKey or C_GenerateKeyPair.
78 ck4=8, // 4 MUST not be specified when object is generated with C_GenerateKey or C_GenerateKeyPair.
79 ck5=0x10, // 5 MUST be specified when object is unwrapped with C_UnwrapKey.
80 ck6=0x20, // 6 MUST not be specified when object is unwrapped with C_UnwrapKey.
81 ck7=0x40, // 7 Cannot be revealed if object has its CKA_SENSITIVE attribute set to CK_TRUE or
82 // its CKA_EXTRACTABLE attribute set to CK_FALSE.
83 ck8=0x80, // 8 May be modified after object is created with a C_SetAttributeValue call,
84 // or in the process of copying object with a C_CopyObject call.
85 // However, it is possible that a particular token may not permit modification of
86 // the attribute during the course of a C_CopyObject call.
87 ck9=0x100, // 9 Default value is token-specific, and may depend on the values of other attributes.
88 ck10=0x200, // 10 Can only be set to CK_TRUE by the SO user.
89 ck11=0x400, // 11 Attribute cannot be changed once set to CK_TRUE. It becomes a read only attribute.
90 ck12=0x800, // 12 Attribute cannot be changed once set to CK_FALSE. It becomes a read only attribute.
91 ck13=0x1000, // Intentionally not defined
92 ck14=0x2000, // 14 MUST be non-empty if CKA_URL is empty. (CKA_VALUE)
93 ck15=0x4000, // 15 MUST be non-empty if CKA_VALUE is empty. (CKA_URL)
94 ck16=0x8000, // 16 Can only be empty if CKA_URL is empty.
95 ck17=0x10000, // 17 Can be changed in the process of copying the object using C_CopyObject.
106 P11Attribute(OSObject* inobject);
111 // The attribute type
112 CK_ATTRIBUTE_TYPE type;
114 // The checks to perform when the attribute is accessed.
117 // The attribute fixed size contains (CK_ULONG)-1 when size is variable.
120 // Set the default value of the attribute
121 virtual bool setDefault() = 0;
123 // Update the value if allowed
124 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
129 bool isExtractable();
133 /*****************************************
135 *****************************************/
137 class P11AttrClass : public P11Attribute
141 P11AttrClass(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CLASS; size = sizeof(CK_OBJECT_CLASS); checks = ck1; }
144 // Set the default value of the attribute
145 virtual bool setDefault();
147 // Update the value if allowed
148 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
151 /*****************************************
153 *****************************************/
155 class P11AttrKeyType : public P11Attribute
159 P11AttrKeyType(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_KEY_TYPE; size = sizeof(CK_KEY_TYPE); checks = ck1|inchecks; }
162 // Set the default value of the attribute
163 virtual bool setDefault();
165 // Update the value if allowed
166 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
169 /*****************************************
170 * CKA_CERTIFICATE_TYPE
171 *****************************************/
173 class P11AttrCertificateType : public P11Attribute
177 P11AttrCertificateType(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CERTIFICATE_TYPE; size = sizeof(CK_CERTIFICATE_TYPE); checks = ck1; }
180 // Set the default value of the attribute
181 virtual bool setDefault();
183 // Update the value if allowed
184 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
187 /*****************************************
189 *****************************************/
191 class P11AttrToken : public P11Attribute
195 P11AttrToken(OSObject* inobject) : P11Attribute(inobject) { type = CKA_TOKEN; size = sizeof(CK_BBOOL); checks = ck17; }
198 // Set the default value of the attribute
199 virtual bool setDefault();
201 // Update the value if allowed
202 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
205 /*****************************************
207 *****************************************/
209 class P11AttrPrivate : public P11Attribute
213 P11AttrPrivate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIVATE; size = sizeof(CK_BBOOL); checks = ck17; }
216 // Set the default value of the attribute
217 virtual bool setDefault();
219 // Update the value if allowed
220 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
223 /*****************************************
225 *****************************************/
227 class P11AttrModifiable : public P11Attribute
231 P11AttrModifiable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_MODIFIABLE; size = sizeof(CK_BBOOL); checks = ck17; }
234 // Set the default value of the attribute
235 virtual bool setDefault();
237 // Update the value if allowed
238 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
241 /*****************************************
243 *****************************************/
245 class P11AttrLabel : public P11Attribute
249 P11AttrLabel(OSObject* inobject) : P11Attribute(inobject) { type = CKA_LABEL; checks = ck8; }
252 // Set the default value of the attribute
253 virtual bool setDefault();
256 /*****************************************
258 *****************************************/
260 class P11AttrCopyable : public P11Attribute
264 P11AttrCopyable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_COPYABLE; size = sizeof(CK_BBOOL); checks = ck12; }
267 // Set the default value of the attribute
268 virtual bool setDefault();
270 // Update the value if allowed
271 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
274 /*****************************************
276 *****************************************/
278 class P11AttrDestroyable : public P11Attribute
282 P11AttrDestroyable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DESTROYABLE; size = sizeof(CK_BBOOL); checks = ck17; }
285 // Set the default value of the attribute
286 virtual bool setDefault();
288 // Update the value if allowed
289 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
292 /*****************************************
294 *****************************************/
296 class P11AttrApplication : public P11Attribute
300 P11AttrApplication(OSObject* inobject) : P11Attribute(inobject) { type = CKA_APPLICATION; checks = 0; }
303 // Set the default value of the attribute
304 virtual bool setDefault();
307 /*****************************************
309 *****************************************/
311 class P11AttrObjectID : public P11Attribute
315 P11AttrObjectID(OSObject* inobject) : P11Attribute(inobject) { type = CKA_OBJECT_ID; checks = 0; }
318 // Set the default value of the attribute
319 virtual bool setDefault();
322 /*****************************************
324 *****************************************/
326 class P11AttrCheckValue : public P11Attribute
330 P11AttrCheckValue(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_CHECK_VALUE; checks = inchecks; }
333 // Set the default value of the attribute
334 virtual bool setDefault();
337 // Update the value if allowed
338 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
341 /*****************************************
342 * CKA_PUBLIC_KEY_INFO
343 *****************************************/
345 class P11AttrPublicKeyInfo : public P11Attribute
349 P11AttrPublicKeyInfo(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_OBJECT_ID; checks = inchecks; }
352 // Set the default value of the attribute
353 virtual bool setDefault();
356 /*****************************************
358 *****************************************/
360 class P11AttrID : public P11Attribute
364 P11AttrID(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ID; checks = ck8; }
367 // Set the default value of the attribute
368 virtual bool setDefault();
371 /*****************************************
373 *****************************************/
375 class P11AttrValue : public P11Attribute
379 P11AttrValue(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_VALUE; checks = inchecks; }
382 // Set the default value of the attribute
383 virtual bool setDefault();
385 // Update the value if allowed
386 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
389 /*****************************************
391 *****************************************/
393 class P11AttrSubject : public P11Attribute
397 P11AttrSubject(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_SUBJECT; checks = inchecks; }
400 // Set the default value of the attribute
401 virtual bool setDefault();
404 /*****************************************
406 *****************************************/
408 class P11AttrIssuer : public P11Attribute
412 P11AttrIssuer(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ISSUER; checks = ck8; }
415 // Set the default value of the attribute
416 virtual bool setDefault();
419 /*****************************************
421 *****************************************/
423 class P11AttrTrusted : public P11Attribute
427 P11AttrTrusted(OSObject* inobject) : P11Attribute(inobject) { type = CKA_TRUSTED; size = sizeof(CK_BBOOL); checks = ck10; }
430 // Set the default value of the attribute
431 virtual bool setDefault();
433 // Update the value if allowed
434 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
437 /*****************************************
438 * CKA_CERTIFICATE_CATEGORY
439 *****************************************/
441 class P11AttrCertificateCategory : public P11Attribute
445 P11AttrCertificateCategory(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CERTIFICATE_CATEGORY; size = sizeof(CK_ULONG); checks = 0; }
448 // Set the default value of the attribute
449 virtual bool setDefault();
451 // Update the value if allowed
452 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
455 /*****************************************
457 *****************************************/
459 class P11AttrStartDate : public P11Attribute
463 P11AttrStartDate(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_START_DATE; checks = inchecks; }
466 // Set the default value of the attribute
467 virtual bool setDefault();
469 // Update the value if allowed
470 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
473 /*****************************************
475 *****************************************/
477 class P11AttrEndDate : public P11Attribute
481 P11AttrEndDate(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_END_DATE; checks = inchecks; }
484 // Set the default value of the attribute
485 virtual bool setDefault();
487 // Update the value if allowed
488 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
491 /*****************************************
493 *****************************************/
495 class P11AttrSerialNumber : public P11Attribute
499 P11AttrSerialNumber(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SERIAL_NUMBER; checks = ck8; }
502 // Set the default value of the attribute
503 virtual bool setDefault();
506 /*****************************************
508 *****************************************/
510 class P11AttrURL : public P11Attribute
514 P11AttrURL(OSObject* inobject) : P11Attribute(inobject) { type = CKA_URL; checks = ck15; }
517 // Set the default value of the attribute
518 virtual bool setDefault();
521 /*****************************************
522 * CKA_HASH_OF_SUBJECT_PUBLIC_KEY
523 *****************************************/
525 class P11AttrHashOfSubjectPublicKey : public P11Attribute
529 P11AttrHashOfSubjectPublicKey(OSObject* inobject) : P11Attribute(inobject) { type = CKA_HASH_OF_SUBJECT_PUBLIC_KEY; checks = ck16; }
532 // Set the default value of the attribute
533 virtual bool setDefault();
536 /*****************************************
537 * CKA_HASH_OF_ISSUER_PUBLIC_KEY
538 *****************************************/
540 class P11AttrHashOfIssuerPublicKey : public P11Attribute
544 P11AttrHashOfIssuerPublicKey(OSObject* inobject) : P11Attribute(inobject) { type = CKA_HASH_OF_ISSUER_PUBLIC_KEY; checks = ck16; }
547 // Set the default value of the attribute
548 virtual bool setDefault();
551 /*****************************************
552 * CKA_JAVA_MIDP_SECURITY_DOMAIN
553 *****************************************/
555 class P11AttrJavaMidpSecurityDomain : public P11Attribute
559 P11AttrJavaMidpSecurityDomain(OSObject* inobject) : P11Attribute(inobject) { type = CKA_JAVA_MIDP_SECURITY_DOMAIN; size = sizeof(CK_ULONG); checks = 0; }
562 // Set the default value of the attribute
563 virtual bool setDefault();
565 // Update the value if allowed
566 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
569 /*****************************************
570 * CKA_NAME_HASH_ALGORITHM
571 *****************************************/
573 class P11AttrNameHashAlgorithm : public P11Attribute
577 P11AttrNameHashAlgorithm(OSObject* inobject) : P11Attribute(inobject) { type = CKA_NAME_HASH_ALGORITHM; size = sizeof(CK_MECHANISM_TYPE); checks = 0; }
580 // Set the default value of the attribute
581 virtual bool setDefault();
583 // Update the value if allowed
584 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
587 /*****************************************
589 *****************************************/
591 class P11AttrDerive : public P11Attribute
595 P11AttrDerive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DERIVE; size = sizeof(CK_BBOOL); checks = ck8;}
598 // Set the default value of the attribute
599 virtual bool setDefault();
601 // Update the value if allowed
602 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
605 /*****************************************
607 *****************************************/
609 class P11AttrEncrypt : public P11Attribute
613 P11AttrEncrypt(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ENCRYPT; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
616 // Set the default value of the attribute
617 virtual bool setDefault();
619 // Update the value if allowed
620 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
623 /*****************************************
625 *****************************************/
627 class P11AttrVerify : public P11Attribute
631 P11AttrVerify(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VERIFY; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
634 // Set the default value of the attribute
635 virtual bool setDefault();
637 // Update the value if allowed
638 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
641 /*****************************************
643 *****************************************/
645 class P11AttrVerifyRecover : public P11Attribute
649 P11AttrVerifyRecover(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VERIFY_RECOVER; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
652 // Set the default value of the attribute
653 virtual bool setDefault();
655 // Update the value if allowed
656 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
659 /*****************************************
661 *****************************************/
663 class P11AttrWrap : public P11Attribute
667 P11AttrWrap(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
670 // Set the default value of the attribute
671 virtual bool setDefault();
673 // Update the value if allowed
674 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
677 /*****************************************
679 *****************************************/
681 class P11AttrDecrypt : public P11Attribute
685 P11AttrDecrypt(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DECRYPT; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
688 // Set the default value of the attribute
689 virtual bool setDefault();
691 // Update the value if allowed
692 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
695 /*****************************************
697 *****************************************/
699 class P11AttrSign : public P11Attribute
703 P11AttrSign(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SIGN; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
706 // Set the default value of the attribute
707 virtual bool setDefault();
709 // Update the value if allowed
710 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
713 /*****************************************
715 *****************************************/
717 class P11AttrSignRecover : public P11Attribute
721 P11AttrSignRecover(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SIGN_RECOVER; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
724 // Set the default value of the attribute
725 virtual bool setDefault();
727 // Update the value if allowed
728 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
731 /*****************************************
733 *****************************************/
735 class P11AttrUnwrap : public P11Attribute
739 P11AttrUnwrap(OSObject* inobject) : P11Attribute(inobject) { type = CKA_UNWRAP; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
742 // Set the default value of the attribute
743 virtual bool setDefault();
745 // Update the value if allowed
746 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
749 /*****************************************
751 *****************************************/
753 class P11AttrLocal : public P11Attribute
757 P11AttrLocal(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_LOCAL; size = sizeof(CK_BBOOL); checks = ck2|ck4|inchecks; }
760 // Set the default value of the attribute
761 virtual bool setDefault();
763 // Update the value if allowed
764 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
767 /*****************************************
768 * CKA_KEY_GEN_MECHANISM
769 *****************************************/
771 class P11AttrKeyGenMechanism : public P11Attribute
775 P11AttrKeyGenMechanism(OSObject* inobject) : P11Attribute(inobject) { type = CKA_KEY_GEN_MECHANISM; size = sizeof(CK_MECHANISM_TYPE); checks = ck2|ck4|ck6; }
778 // Set the default value of the attribute
779 virtual bool setDefault();
781 // Update the value if allowed
782 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
785 /*****************************************
786 * CKA_ALWAYS_SENSITIVE
787 *****************************************/
789 class P11AttrAlwaysSensitive : public P11Attribute
793 P11AttrAlwaysSensitive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALWAYS_SENSITIVE; size = sizeof(CK_BBOOL); checks = ck2|ck4|ck6; }
796 // Set the default value of the attribute
797 virtual bool setDefault();
799 // Update the value if allowed
800 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
803 /*****************************************
804 * CKA_NEVER_EXTRACTABLE
805 *****************************************/
807 class P11AttrNeverExtractable : public P11Attribute
811 P11AttrNeverExtractable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_NEVER_EXTRACTABLE; size = sizeof(CK_BBOOL); checks = ck2|ck4|ck6; }
814 // Set the default value of the attribute
815 virtual bool setDefault();
817 // Update the value if allowed
818 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
821 /*****************************************
823 *****************************************/
825 class P11AttrSensitive : public P11Attribute
829 P11AttrSensitive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SENSITIVE; size = sizeof(CK_BBOOL); checks = ck8|ck9|ck11; }
832 // Set the default value of the attribute
833 virtual bool setDefault();
835 // Update the value if allowed
836 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
839 /*****************************************
841 *****************************************/
843 class P11AttrExtractable : public P11Attribute
847 P11AttrExtractable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXTRACTABLE; size = sizeof(CK_BBOOL); checks = ck8|ck9|ck12; }
850 // Set the default value of the attribute
851 virtual bool setDefault();
853 // Update the value if allowed
854 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
857 /*****************************************
858 * CKA_WRAP_WITH_TRUSTED
859 *****************************************/
861 class P11AttrWrapWithTrusted : public P11Attribute
865 P11AttrWrapWithTrusted(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP_WITH_TRUSTED; size = sizeof(CK_BBOOL); checks = ck11; }
868 // Set the default value of the attribute
869 virtual bool setDefault();
871 // Update the value if allowed
872 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
875 /*****************************************
876 * CKA_ALWAYS_AUTHENTICATE
877 *****************************************/
879 class P11AttrAlwaysAuthenticate : public P11Attribute
883 P11AttrAlwaysAuthenticate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALWAYS_AUTHENTICATE; size = sizeof(CK_BBOOL); checks = 0; }
886 // Set the default value of the attribute
887 virtual bool setDefault();
889 // Update the value if allowed
890 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
893 /*****************************************
895 *****************************************/
897 class P11AttrModulus : public P11Attribute
901 P11AttrModulus(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_MODULUS; checks = ck1|ck4|inchecks; }
904 // Set the default value of the attribute
905 virtual bool setDefault();
907 // Update the value if allowed
908 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
911 /*****************************************
912 * CKA_PUBLIC_EXPONENT
913 *****************************************/
915 class P11AttrPublicExponent : public P11Attribute
919 P11AttrPublicExponent(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_PUBLIC_EXPONENT; checks = inchecks; }
922 // Set the default value of the attribute
923 virtual bool setDefault();
926 /*****************************************
927 * CKA_PRIVATE_EXPONENT
928 *****************************************/
930 class P11AttrPrivateExponent : public P11Attribute
934 P11AttrPrivateExponent(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIVATE_EXPONENT; checks = ck1|ck4|ck6|ck7; }
937 // Set the default value of the attribute
938 virtual bool setDefault();
941 /*****************************************
943 *****************************************/
945 class P11AttrPrime1 : public P11Attribute
949 P11AttrPrime1(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_1; checks = ck4|ck6|ck7; }
952 // Set the default value of the attribute
953 virtual bool setDefault();
956 /*****************************************
958 *****************************************/
960 class P11AttrPrime2 : public P11Attribute
964 P11AttrPrime2(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_2; checks = ck4|ck6|ck7; }
967 // Set the default value of the attribute
968 virtual bool setDefault();
971 /*****************************************
973 *****************************************/
975 class P11AttrExponent1 : public P11Attribute
979 P11AttrExponent1(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXPONENT_1; checks = ck4|ck6|ck7; }
982 // Set the default value of the attribute
983 virtual bool setDefault();
986 /*****************************************
988 *****************************************/
990 class P11AttrExponent2 : public P11Attribute
994 P11AttrExponent2(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXPONENT_2; checks = ck4|ck6|ck7; }
997 // Set the default value of the attribute
998 virtual bool setDefault();
1001 /*****************************************
1003 *****************************************/
1005 class P11AttrCoefficient : public P11Attribute
1009 P11AttrCoefficient(OSObject* inobject) : P11Attribute(inobject) { type = CKA_COEFFICIENT; checks = ck4|ck6|ck7; }
1012 // Set the default value of the attribute
1013 virtual bool setDefault();
1016 /*****************************************
1018 *****************************************/
1020 class P11AttrModulusBits : public P11Attribute
1024 P11AttrModulusBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_MODULUS_BITS; size = sizeof(CK_ULONG); checks = ck2|ck3;}
1027 // Set the default value of the attribute
1028 virtual bool setDefault();
1030 // Update the value if allowed
1031 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1034 /*****************************************
1036 *****************************************/
1038 class P11AttrPrime : public P11Attribute
1042 P11AttrPrime(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_PRIME; checks = ck1|inchecks; }
1045 // Set the default value of the attribute
1046 virtual bool setDefault();
1048 // Update the value if allowed
1049 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1052 /*****************************************
1054 *****************************************/
1056 class P11AttrSubPrime : public P11Attribute
1060 P11AttrSubPrime(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_SUBPRIME; checks = ck1|inchecks; }
1063 // Set the default value of the attribute
1064 virtual bool setDefault();
1067 /*****************************************
1069 *****************************************/
1071 class P11AttrBase : public P11Attribute
1075 P11AttrBase(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_BASE; checks = ck1|inchecks; }
1078 // Set the default value of the attribute
1079 virtual bool setDefault();
1082 /*****************************************
1084 *****************************************/
1086 class P11AttrPrimeBits : public P11Attribute
1090 P11AttrPrimeBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_BITS; size = sizeof(CK_ULONG); checks = ck2|ck3;}
1093 // Set the default value of the attribute
1094 virtual bool setDefault();
1096 // Update the value if allowed
1097 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1100 /*****************************************
1102 *****************************************/
1104 class P11AttrValueBits : public P11Attribute
1108 P11AttrValueBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VALUE_BITS; size = sizeof(CK_ULONG); checks = ck2|ck6;}
1111 // Set the default value of the attribute
1112 virtual bool setDefault();
1114 // Update the value if allowed
1115 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1118 /*****************************************
1120 *****************************************/
1122 class P11AttrEcParams : public P11Attribute
1126 P11AttrEcParams(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_EC_PARAMS; checks = ck1|inchecks; }
1129 // Set the default value of the attribute
1130 virtual bool setDefault();
1133 /*****************************************
1135 *****************************************/
1137 class P11AttrEcPoint : public P11Attribute
1141 P11AttrEcPoint(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EC_POINT; checks = ck1|ck4; }
1144 // Set the default value of the attribute
1145 virtual bool setDefault();
1148 /*****************************************
1149 * CKA_GOSTR3410_PARAMS
1150 *****************************************/
1152 class P11AttrGostR3410Params : public P11Attribute
1156 P11AttrGostR3410Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOSTR3410_PARAMS; checks = ck1|inchecks; }
1159 // Set the default value of the attribute
1160 virtual bool setDefault();
1163 /*****************************************
1164 * CKA_GOSTR3411_PARAMS
1165 *****************************************/
1167 class P11AttrGostR3411Params : public P11Attribute
1171 P11AttrGostR3411Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOSTR3411_PARAMS; checks = ck1|ck8|inchecks; }
1174 // Set the default value of the attribute
1175 virtual bool setDefault();
1178 /*****************************************
1179 * CKA_GOST28147_PARAMS
1180 *****************************************/
1182 class P11AttrGost28147Params : public P11Attribute
1186 P11AttrGost28147Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOST28147_PARAMS; checks = inchecks; }
1189 // Set the default value of the attribute
1190 virtual bool setDefault();
1193 /*****************************************
1195 *****************************************/
1197 class P11AttrValueLen : public P11Attribute
1201 P11AttrValueLen(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_VALUE_LEN; size = sizeof(CK_ULONG); checks = ck2|ck3|inchecks; }
1204 // Set the default value of the attribute
1205 virtual bool setDefault();
1207 // Update the value if allowed
1208 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1211 /*****************************************
1213 *****************************************/
1215 class P11AttrWrapTemplate : public P11Attribute
1219 P11AttrWrapTemplate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP_TEMPLATE; checks = 0; }
1222 // Set the default value of the attribute
1223 virtual bool setDefault();
1225 // Update the value if allowed
1226 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1229 /*****************************************
1230 * CKA_UNWRAP_TEMPLATE
1231 *****************************************/
1233 class P11AttrUnwrapTemplate : public P11Attribute
1237 P11AttrUnwrapTemplate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_UNWRAP_TEMPLATE; checks = 0; }
1240 // Set the default value of the attribute
1241 virtual bool setDefault();
1243 // Update the value if allowed
1244 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1247 /*****************************************
1248 * CKA_ALLOWED_MECHANISMS
1249 *****************************************/
1251 class P11AttrAllowedMechanisms : public P11Attribute
1255 P11AttrAllowedMechanisms(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALLOWED_MECHANISMS; checks = 0; }
1258 // Set the default value of the attribute
1259 virtual bool setDefault();
1261 // Update the value if allowed
1262 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1265 /*****************************************
1267 *****************************************/
1269 class P11AttrPrivateHandle : public P11Attribute
1273 P11AttrPrivateHandle(OSObject* inobject) : P11Attribute(inobject) { type = CKA_OS_PRIVATE_HANDLE; checks = 0; }
1276 // Set the default value of the attribute
1277 virtual bool setDefault();
1278 // Update the value if allowed
1279 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1283 #endif // !_SOFTHSM_V2_P11ATTRIBUTES_H