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
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
53 virtual ~P11Attribute();
55 // Initialize the attribute
58 // Return the attribute type
59 CK_ATTRIBUTE_TYPE getType();
61 // Return the attribute checks
64 // Retrieve the value if allowed
65 CK_RV retrieve(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG_PTR pulValueLen);
67 // Update the value if allowed
68 CK_RV update(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
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.
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.
105 P11Attribute(OSObject* inobject);
110 // The attribute type
111 CK_ATTRIBUTE_TYPE type;
113 // The checks to perform when the attribute is accessed.
116 // The attribute fixed size contains (CK_ULONG)-1 when size is variable.
119 // Set the default value of the attribute
120 virtual bool setDefault() = 0;
122 // Update the value if allowed
123 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
128 bool isExtractable();
132 /*****************************************
134 *****************************************/
136 class P11AttrClass : public P11Attribute
140 P11AttrClass(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CLASS; size = sizeof(CK_OBJECT_CLASS); checks = ck1; }
143 // Set the default value of the attribute
144 virtual bool setDefault();
146 // Update the value if allowed
147 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
150 /*****************************************
152 *****************************************/
154 class P11AttrKeyType : public P11Attribute
158 P11AttrKeyType(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_KEY_TYPE; size = sizeof(CK_KEY_TYPE); checks = ck1|inchecks; }
161 // Set the default value of the attribute
162 virtual bool setDefault();
164 // Update the value if allowed
165 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
168 /*****************************************
169 * CKA_CERTIFICATE_TYPE
170 *****************************************/
172 class P11AttrCertificateType : public P11Attribute
176 P11AttrCertificateType(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CERTIFICATE_TYPE; size = sizeof(CK_CERTIFICATE_TYPE); checks = ck1; }
179 // Set the default value of the attribute
180 virtual bool setDefault();
182 // Update the value if allowed
183 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
186 /*****************************************
188 *****************************************/
190 class P11AttrToken : public P11Attribute
194 P11AttrToken(OSObject* inobject) : P11Attribute(inobject) { type = CKA_TOKEN; size = sizeof(CK_BBOOL); checks = ck17; }
197 // Set the default value of the attribute
198 virtual bool setDefault();
200 // Update the value if allowed
201 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
204 /*****************************************
206 *****************************************/
208 class P11AttrPrivate : public P11Attribute
212 P11AttrPrivate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIVATE; size = sizeof(CK_BBOOL); checks = ck17; }
215 // Set the default value of the attribute
216 virtual bool setDefault();
218 // Update the value if allowed
219 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
222 /*****************************************
224 *****************************************/
226 class P11AttrModifiable : public P11Attribute
230 P11AttrModifiable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_MODIFIABLE; size = sizeof(CK_BBOOL); checks = ck17; }
233 // Set the default value of the attribute
234 virtual bool setDefault();
236 // Update the value if allowed
237 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
240 /*****************************************
242 *****************************************/
244 class P11AttrLabel : public P11Attribute
248 P11AttrLabel(OSObject* inobject) : P11Attribute(inobject) { type = CKA_LABEL; checks = ck8; }
251 // Set the default value of the attribute
252 virtual bool setDefault();
255 /*****************************************
257 *****************************************/
259 class P11AttrCopyable : public P11Attribute
263 P11AttrCopyable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_COPYABLE; size = sizeof(CK_BBOOL); checks = ck12; }
266 // Set the default value of the attribute
267 virtual bool setDefault();
269 // Update the value if allowed
270 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
273 /*****************************************
275 *****************************************/
277 class P11AttrDestroyable : public P11Attribute
281 P11AttrDestroyable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DESTROYABLE; size = sizeof(CK_BBOOL); checks = ck17; }
284 // Set the default value of the attribute
285 virtual bool setDefault();
287 // Update the value if allowed
288 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
291 /*****************************************
293 *****************************************/
295 class P11AttrApplication : public P11Attribute
299 P11AttrApplication(OSObject* inobject) : P11Attribute(inobject) { type = CKA_APPLICATION; checks = 0; }
302 // Set the default value of the attribute
303 virtual bool setDefault();
306 /*****************************************
308 *****************************************/
310 class P11AttrObjectID : public P11Attribute
314 P11AttrObjectID(OSObject* inobject) : P11Attribute(inobject) { type = CKA_OBJECT_ID; checks = 0; }
317 // Set the default value of the attribute
318 virtual bool setDefault();
321 /*****************************************
323 *****************************************/
325 class P11AttrCheckValue : public P11Attribute
329 P11AttrCheckValue(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_CHECK_VALUE; checks = inchecks; }
332 // Set the default value of the attribute
333 virtual bool setDefault();
336 // Update the value if allowed
337 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
340 /*****************************************
341 * CKA_PUBLIC_KEY_INFO
342 *****************************************/
344 class P11AttrPublicKeyInfo : public P11Attribute
348 P11AttrPublicKeyInfo(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_OBJECT_ID; checks = inchecks; }
351 // Set the default value of the attribute
352 virtual bool setDefault();
355 /*****************************************
357 *****************************************/
359 class P11AttrID : public P11Attribute
363 P11AttrID(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ID; checks = ck8; }
366 // Set the default value of the attribute
367 virtual bool setDefault();
370 /*****************************************
372 *****************************************/
374 class P11AttrValue : public P11Attribute
378 P11AttrValue(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_VALUE; checks = inchecks; }
381 // Set the default value of the attribute
382 virtual bool setDefault();
384 // Update the value if allowed
385 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
388 /*****************************************
390 *****************************************/
392 class P11AttrSubject : public P11Attribute
396 P11AttrSubject(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_SUBJECT; checks = inchecks; }
399 // Set the default value of the attribute
400 virtual bool setDefault();
403 /*****************************************
405 *****************************************/
407 class P11AttrIssuer : public P11Attribute
411 P11AttrIssuer(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ISSUER; checks = ck8; }
414 // Set the default value of the attribute
415 virtual bool setDefault();
418 /*****************************************
420 *****************************************/
422 class P11AttrTrusted : public P11Attribute
426 P11AttrTrusted(OSObject* inobject) : P11Attribute(inobject) { type = CKA_TRUSTED; size = sizeof(CK_BBOOL); checks = ck10; }
429 // Set the default value of the attribute
430 virtual bool setDefault();
432 // Update the value if allowed
433 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
436 /*****************************************
437 * CKA_CERTIFICATE_CATEGORY
438 *****************************************/
440 class P11AttrCertificateCategory : public P11Attribute
444 P11AttrCertificateCategory(OSObject* inobject) : P11Attribute(inobject) { type = CKA_CERTIFICATE_CATEGORY; size = sizeof(CK_ULONG); checks = 0; }
447 // Set the default value of the attribute
448 virtual bool setDefault();
450 // Update the value if allowed
451 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
454 /*****************************************
456 *****************************************/
458 class P11AttrStartDate : public P11Attribute
462 P11AttrStartDate(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_START_DATE; checks = inchecks; }
465 // Set the default value of the attribute
466 virtual bool setDefault();
468 // Update the value if allowed
469 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
472 /*****************************************
474 *****************************************/
476 class P11AttrEndDate : public P11Attribute
480 P11AttrEndDate(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_END_DATE; checks = inchecks; }
483 // Set the default value of the attribute
484 virtual bool setDefault();
486 // Update the value if allowed
487 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
490 /*****************************************
492 *****************************************/
494 class P11AttrSerialNumber : public P11Attribute
498 P11AttrSerialNumber(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SERIAL_NUMBER; checks = ck8; }
501 // Set the default value of the attribute
502 virtual bool setDefault();
505 /*****************************************
507 *****************************************/
509 class P11AttrURL : public P11Attribute
513 P11AttrURL(OSObject* inobject) : P11Attribute(inobject) { type = CKA_URL; checks = ck15; }
516 // Set the default value of the attribute
517 virtual bool setDefault();
520 /*****************************************
521 * CKA_HASH_OF_SUBJECT_PUBLIC_KEY
522 *****************************************/
524 class P11AttrHashOfSubjectPublicKey : public P11Attribute
528 P11AttrHashOfSubjectPublicKey(OSObject* inobject) : P11Attribute(inobject) { type = CKA_HASH_OF_SUBJECT_PUBLIC_KEY; checks = ck16; }
531 // Set the default value of the attribute
532 virtual bool setDefault();
535 /*****************************************
536 * CKA_HASH_OF_ISSUER_PUBLIC_KEY
537 *****************************************/
539 class P11AttrHashOfIssuerPublicKey : public P11Attribute
543 P11AttrHashOfIssuerPublicKey(OSObject* inobject) : P11Attribute(inobject) { type = CKA_HASH_OF_ISSUER_PUBLIC_KEY; checks = ck16; }
546 // Set the default value of the attribute
547 virtual bool setDefault();
550 /*****************************************
551 * CKA_JAVA_MIDP_SECURITY_DOMAIN
552 *****************************************/
554 class P11AttrJavaMidpSecurityDomain : public P11Attribute
558 P11AttrJavaMidpSecurityDomain(OSObject* inobject) : P11Attribute(inobject) { type = CKA_JAVA_MIDP_SECURITY_DOMAIN; size = sizeof(CK_ULONG); checks = 0; }
561 // Set the default value of the attribute
562 virtual bool setDefault();
564 // Update the value if allowed
565 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
568 /*****************************************
569 * CKA_NAME_HASH_ALGORITHM
570 *****************************************/
572 class P11AttrNameHashAlgorithm : public P11Attribute
576 P11AttrNameHashAlgorithm(OSObject* inobject) : P11Attribute(inobject) { type = CKA_NAME_HASH_ALGORITHM; size = sizeof(CK_MECHANISM_TYPE); checks = 0; }
579 // Set the default value of the attribute
580 virtual bool setDefault();
582 // Update the value if allowed
583 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
586 /*****************************************
588 *****************************************/
590 class P11AttrDerive : public P11Attribute
594 P11AttrDerive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DERIVE; size = sizeof(CK_BBOOL); checks = ck8;}
597 // Set the default value of the attribute
598 virtual bool setDefault();
600 // Update the value if allowed
601 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
604 /*****************************************
606 *****************************************/
608 class P11AttrEncrypt : public P11Attribute
612 P11AttrEncrypt(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ENCRYPT; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
615 // Set the default value of the attribute
616 virtual bool setDefault();
618 // Update the value if allowed
619 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
622 /*****************************************
624 *****************************************/
626 class P11AttrVerify : public P11Attribute
630 P11AttrVerify(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VERIFY; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
633 // Set the default value of the attribute
634 virtual bool setDefault();
636 // Update the value if allowed
637 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
640 /*****************************************
642 *****************************************/
644 class P11AttrVerifyRecover : public P11Attribute
648 P11AttrVerifyRecover(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VERIFY_RECOVER; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
651 // Set the default value of the attribute
652 virtual bool setDefault();
654 // Update the value if allowed
655 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
658 /*****************************************
660 *****************************************/
662 class P11AttrWrap : public P11Attribute
666 P11AttrWrap(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
669 // Set the default value of the attribute
670 virtual bool setDefault();
672 // Update the value if allowed
673 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
676 /*****************************************
678 *****************************************/
680 class P11AttrDecrypt : public P11Attribute
684 P11AttrDecrypt(OSObject* inobject) : P11Attribute(inobject) { type = CKA_DECRYPT; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
687 // Set the default value of the attribute
688 virtual bool setDefault();
690 // Update the value if allowed
691 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
694 /*****************************************
696 *****************************************/
698 class P11AttrSign : public P11Attribute
702 P11AttrSign(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SIGN; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
705 // Set the default value of the attribute
706 virtual bool setDefault();
708 // Update the value if allowed
709 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
712 /*****************************************
714 *****************************************/
716 class P11AttrSignRecover : public P11Attribute
720 P11AttrSignRecover(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SIGN_RECOVER; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
723 // Set the default value of the attribute
724 virtual bool setDefault();
726 // Update the value if allowed
727 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
730 /*****************************************
732 *****************************************/
734 class P11AttrUnwrap : public P11Attribute
738 P11AttrUnwrap(OSObject* inobject) : P11Attribute(inobject) { type = CKA_UNWRAP; size = sizeof(CK_BBOOL); checks = ck8|ck9; }
741 // Set the default value of the attribute
742 virtual bool setDefault();
744 // Update the value if allowed
745 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
748 /*****************************************
750 *****************************************/
752 class P11AttrLocal : public P11Attribute
756 P11AttrLocal(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_LOCAL; size = sizeof(CK_BBOOL); checks = ck2|ck4|inchecks; }
759 // Set the default value of the attribute
760 virtual bool setDefault();
762 // Update the value if allowed
763 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
766 /*****************************************
767 * CKA_KEY_GEN_MECHANISM
768 *****************************************/
770 class P11AttrKeyGenMechanism : public P11Attribute
774 P11AttrKeyGenMechanism(OSObject* inobject) : P11Attribute(inobject) { type = CKA_KEY_GEN_MECHANISM; size = sizeof(CK_MECHANISM_TYPE); checks = ck2|ck4|ck6; }
777 // Set the default value of the attribute
778 virtual bool setDefault();
780 // Update the value if allowed
781 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
784 /*****************************************
785 * CKA_ALWAYS_SENSITIVE
786 *****************************************/
788 class P11AttrAlwaysSensitive : public P11Attribute
792 P11AttrAlwaysSensitive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALWAYS_SENSITIVE; size = sizeof(CK_BBOOL); checks = ck2|ck4|ck6; }
795 // Set the default value of the attribute
796 virtual bool setDefault();
798 // Update the value if allowed
799 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
802 /*****************************************
803 * CKA_NEVER_EXTRACTABLE
804 *****************************************/
806 class P11AttrNeverExtractable : public P11Attribute
810 P11AttrNeverExtractable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_NEVER_EXTRACTABLE; size = sizeof(CK_BBOOL); checks = ck2|ck4|ck6; }
813 // Set the default value of the attribute
814 virtual bool setDefault();
816 // Update the value if allowed
817 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
820 /*****************************************
822 *****************************************/
824 class P11AttrSensitive : public P11Attribute
828 P11AttrSensitive(OSObject* inobject) : P11Attribute(inobject) { type = CKA_SENSITIVE; size = sizeof(CK_BBOOL); checks = ck8|ck9|ck11; }
831 // Set the default value of the attribute
832 virtual bool setDefault();
834 // Update the value if allowed
835 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
838 /*****************************************
840 *****************************************/
842 class P11AttrExtractable : public P11Attribute
846 P11AttrExtractable(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXTRACTABLE; size = sizeof(CK_BBOOL); checks = ck8|ck9|ck12; }
849 // Set the default value of the attribute
850 virtual bool setDefault();
852 // Update the value if allowed
853 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
856 /*****************************************
857 * CKA_WRAP_WITH_TRUSTED
858 *****************************************/
860 class P11AttrWrapWithTrusted : public P11Attribute
864 P11AttrWrapWithTrusted(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP_WITH_TRUSTED; size = sizeof(CK_BBOOL); checks = ck11; }
867 // Set the default value of the attribute
868 virtual bool setDefault();
870 // Update the value if allowed
871 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
874 /*****************************************
875 * CKA_ALWAYS_AUTHENTICATE
876 *****************************************/
878 class P11AttrAlwaysAuthenticate : public P11Attribute
882 P11AttrAlwaysAuthenticate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALWAYS_AUTHENTICATE; size = sizeof(CK_BBOOL); checks = 0; }
885 // Set the default value of the attribute
886 virtual bool setDefault();
888 // Update the value if allowed
889 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
892 /*****************************************
894 *****************************************/
896 class P11AttrModulus : public P11Attribute
900 P11AttrModulus(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_MODULUS; checks = ck1|ck4|inchecks; }
903 // Set the default value of the attribute
904 virtual bool setDefault();
906 // Update the value if allowed
907 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
910 /*****************************************
911 * CKA_PUBLIC_EXPONENT
912 *****************************************/
914 class P11AttrPublicExponent : public P11Attribute
918 P11AttrPublicExponent(OSObject* inobject, CK_ULONG inchecks) : P11Attribute(inobject) { type = CKA_PUBLIC_EXPONENT; checks = inchecks; }
921 // Set the default value of the attribute
922 virtual bool setDefault();
925 /*****************************************
926 * CKA_PRIVATE_EXPONENT
927 *****************************************/
929 class P11AttrPrivateExponent : public P11Attribute
933 P11AttrPrivateExponent(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIVATE_EXPONENT; checks = ck1|ck4|ck6|ck7; }
936 // Set the default value of the attribute
937 virtual bool setDefault();
940 /*****************************************
942 *****************************************/
944 class P11AttrPrime1 : public P11Attribute
948 P11AttrPrime1(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_1; checks = ck4|ck6|ck7; }
951 // Set the default value of the attribute
952 virtual bool setDefault();
955 /*****************************************
957 *****************************************/
959 class P11AttrPrime2 : public P11Attribute
963 P11AttrPrime2(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_2; checks = ck4|ck6|ck7; }
966 // Set the default value of the attribute
967 virtual bool setDefault();
970 /*****************************************
972 *****************************************/
974 class P11AttrExponent1 : public P11Attribute
978 P11AttrExponent1(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXPONENT_1; checks = ck4|ck6|ck7; }
981 // Set the default value of the attribute
982 virtual bool setDefault();
985 /*****************************************
987 *****************************************/
989 class P11AttrExponent2 : public P11Attribute
993 P11AttrExponent2(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EXPONENT_2; checks = ck4|ck6|ck7; }
996 // Set the default value of the attribute
997 virtual bool setDefault();
1000 /*****************************************
1002 *****************************************/
1004 class P11AttrCoefficient : public P11Attribute
1008 P11AttrCoefficient(OSObject* inobject) : P11Attribute(inobject) { type = CKA_COEFFICIENT; checks = ck4|ck6|ck7; }
1011 // Set the default value of the attribute
1012 virtual bool setDefault();
1015 /*****************************************
1017 *****************************************/
1019 class P11AttrModulusBits : public P11Attribute
1023 P11AttrModulusBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_MODULUS_BITS; size = sizeof(CK_ULONG); checks = ck2|ck3;}
1026 // Set the default value of the attribute
1027 virtual bool setDefault();
1029 // Update the value if allowed
1030 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1033 /*****************************************
1035 *****************************************/
1037 class P11AttrPrime : public P11Attribute
1041 P11AttrPrime(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_PRIME; checks = ck1|inchecks; }
1044 // Set the default value of the attribute
1045 virtual bool setDefault();
1047 // Update the value if allowed
1048 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1051 /*****************************************
1053 *****************************************/
1055 class P11AttrSubPrime : public P11Attribute
1059 P11AttrSubPrime(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_SUBPRIME; checks = ck1|inchecks; }
1062 // Set the default value of the attribute
1063 virtual bool setDefault();
1066 /*****************************************
1068 *****************************************/
1070 class P11AttrBase : public P11Attribute
1074 P11AttrBase(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_BASE; checks = ck1|inchecks; }
1077 // Set the default value of the attribute
1078 virtual bool setDefault();
1081 /*****************************************
1083 *****************************************/
1085 class P11AttrPrimeBits : public P11Attribute
1089 P11AttrPrimeBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_PRIME_BITS; size = sizeof(CK_ULONG); checks = ck2|ck3;}
1092 // Set the default value of the attribute
1093 virtual bool setDefault();
1095 // Update the value if allowed
1096 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1099 /*****************************************
1101 *****************************************/
1103 class P11AttrValueBits : public P11Attribute
1107 P11AttrValueBits(OSObject* inobject) : P11Attribute(inobject) { type = CKA_VALUE_BITS; size = sizeof(CK_ULONG); checks = ck2|ck6;}
1110 // Set the default value of the attribute
1111 virtual bool setDefault();
1113 // Update the value if allowed
1114 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1117 /*****************************************
1119 *****************************************/
1121 class P11AttrEcParams : public P11Attribute
1125 P11AttrEcParams(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_EC_PARAMS; checks = ck1|inchecks; }
1128 // Set the default value of the attribute
1129 virtual bool setDefault();
1132 /*****************************************
1134 *****************************************/
1136 class P11AttrEcPoint : public P11Attribute
1140 P11AttrEcPoint(OSObject* inobject) : P11Attribute(inobject) { type = CKA_EC_POINT; checks = ck1|ck4; }
1143 // Set the default value of the attribute
1144 virtual bool setDefault();
1147 /*****************************************
1148 * CKA_GOSTR3410_PARAMS
1149 *****************************************/
1151 class P11AttrGostR3410Params : public P11Attribute
1155 P11AttrGostR3410Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOSTR3410_PARAMS; checks = ck1|inchecks; }
1158 // Set the default value of the attribute
1159 virtual bool setDefault();
1162 /*****************************************
1163 * CKA_GOSTR3411_PARAMS
1164 *****************************************/
1166 class P11AttrGostR3411Params : public P11Attribute
1170 P11AttrGostR3411Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOSTR3411_PARAMS; checks = ck1|ck8|inchecks; }
1173 // Set the default value of the attribute
1174 virtual bool setDefault();
1177 /*****************************************
1178 * CKA_GOST28147_PARAMS
1179 *****************************************/
1181 class P11AttrGost28147Params : public P11Attribute
1185 P11AttrGost28147Params(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_GOST28147_PARAMS; checks = inchecks; }
1188 // Set the default value of the attribute
1189 virtual bool setDefault();
1192 /*****************************************
1194 *****************************************/
1196 class P11AttrValueLen : public P11Attribute
1200 P11AttrValueLen(OSObject* inobject, CK_ULONG inchecks = 0) : P11Attribute(inobject) { type = CKA_VALUE_LEN; size = sizeof(CK_ULONG); checks = ck2|ck3|inchecks; }
1203 // Set the default value of the attribute
1204 virtual bool setDefault();
1206 // Update the value if allowed
1207 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1210 /*****************************************
1212 *****************************************/
1214 class P11AttrWrapTemplate : public P11Attribute
1218 P11AttrWrapTemplate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_WRAP_TEMPLATE; checks = 0; }
1221 // Set the default value of the attribute
1222 virtual bool setDefault();
1224 // Update the value if allowed
1225 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1228 /*****************************************
1229 * CKA_UNWRAP_TEMPLATE
1230 *****************************************/
1232 class P11AttrUnwrapTemplate : public P11Attribute
1236 P11AttrUnwrapTemplate(OSObject* inobject) : P11Attribute(inobject) { type = CKA_UNWRAP_TEMPLATE; checks = 0; }
1239 // Set the default value of the attribute
1240 virtual bool setDefault();
1242 // Update the value if allowed
1243 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1246 /*****************************************
1247 * CKA_ALLOWED_MECHANISMS
1248 *****************************************/
1250 class P11AttrAllowedMechanisms : public P11Attribute
1254 P11AttrAllowedMechanisms(OSObject* inobject) : P11Attribute(inobject) { type = CKA_ALLOWED_MECHANISMS; checks = 0; }
1257 // Set the default value of the attribute
1258 virtual bool setDefault();
1260 // Update the value if allowed
1261 virtual CK_RV updateAttr(Token *token, bool isPrivate, CK_VOID_PTR pValue, CK_ULONG ulValueLen, int op);
1264 #endif // !_SOFTHSM_V2_P11ATTRIBUTES_H