Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

p11_object.h
Go to the documentation of this file.
1 /*
2 * PKCS#11 Object
3 * (C) 2016 Daniel Neus, Sirrix AG
4 * (C) 2016 Philipp Weber, Sirrix AG
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9 #ifndef BOTAN_P11_OBJECT_H__
10 #define BOTAN_P11_OBJECT_H__
11
12 #include <botan/p11.h>
13 #include <botan/p11_session.h>
14 #include <botan/secmem.h>
15
16 #include <vector>
17 #include <string>
18 #include <type_traits>
19 #include <list>
20 #include <functional>
21
22 namespace Botan {
23 namespace PKCS11 {
24
25 class Module;
26
27 /// Helper class to build the Attribute / CK_ATTRIBUTE structures
28 class BOTAN_DLL AttributeContainer
29 {
30 public:
31 AttributeContainer() = default;
32
33 /// @param object_class the class type of this container
34 AttributeContainer(ObjectClass object_class);
35
36 virtual ~AttributeContainer() = default;
37
38 /* Microsoft Visual Studio <= 2013 does not support default generated move special member functions.
39 Everything else we target should support it */
40 #if !defined( _MSC_VER ) || ( _MSC_VER >= 1900 )
41 AttributeContainer(AttributeContainer&& other) = default;
42 AttributeContainer& operator=(AttributeContainer&& other) = default;
43 #endif
44
45 // Warning when implementing copy/assignment: m_attributes contains pointers to the other members which must be updated after a copy
46 AttributeContainer(const AttributeContainer& other) = delete;
47 AttributeContainer& operator=(const AttributeContainer& other) = delete;
48
49 /// @return the attributes this container contains
50 inline const std::vector<Attribute>& attributes() const
51 {
52 return m_attributes;
53 }
54
55 /// @return raw attribute data
56 inline Attribute* data() const
57 {
58 return const_cast< Attribute* >(m_attributes.data());
59 }
60
61 /// @return the number of attributes in this container
62 inline size_t count() const
63 {
64 return m_attributes.size();
65 }
66
67 /**
68 * Add a class attribute (CKA_CLASS / AttributeType::Class).
69 * @param object_class class attribute to add
70 */
71 void add_class(ObjectClass object_class);
72
73 /**
74 * Add a string attribute (e.g. CKA_LABEL / AttributeType::Label).
75 * @param attribute attribute type
76 * @param value string value to add
77 */
78 void add_string(AttributeType attribute, const std::string& value);
79
80 /**
81 * Add a binary attribute (e.g. CKA_ID / AttributeType::Id).
82 * @param attribute attribute type
83 * @param value binary attribute value to add
84 * @param length size of the binary attribute value in bytes
85 */
86 void add_binary(AttributeType attribute, const uint8_t* value, size_t length);
87
88 /**
89 * Add a binary attribute (e.g. CKA_ID / AttributeType::Id).
90 * @param attribute attribute type
91 * @param binary binary attribute value to add
92 */
93 template<typename TAlloc>
94 void add_binary(AttributeType attribute, const std::vector<uint8_t, TAlloc>& binary)
95 {
96 add_binary(attribute, binary.data(), binary.size());
97 }
98
99 /**
100 * Add a bool attribute (e.g. CKA_SENSITIVE / AttributeType::Sensitive).
101 * @param attribute attribute type
102 * @param value boolean value to add
103 */
104 void add_bool(AttributeType attribute, bool value);
105
106 /**
107 * Add a numeric attribute (e.g. CKA_MODULUS_BITS / AttributeType::ModulusBits).
108 * @param attribute attribute type
109 * @param value numeric value to add
110 */
111 template<typename T>
112 void add_numeric(AttributeType attribute, T value)
113 {
114 static_assert(std::is_integral<T>::value, "Numeric value required.");
115 m_numerics.push_back(static_cast< uint64_t >(value));
116 add_attribute(attribute, reinterpret_cast< uint8_t* >(&m_numerics.back()), sizeof(T));
117 }
118
119 protected:
120 /// Add an attribute with the given value and size to the attribute collection `m_attributes`
121 void add_attribute(AttributeType attribute, const uint8_t* value, uint32_t size);
122
123 private:
124 std::vector<Attribute> m_attributes;
125 std::list<uint64_t> m_numerics;
126 std::list<std::string> m_strings;
127 std::list<secure_vector<uint8_t>> m_vectors;
128 };
129
130 /// Manages calls to C_FindObjects* functions (C_FindObjectsInit -> C_FindObjects -> C_FindObjectsFinal)
131 class BOTAN_DLL ObjectFinder final
132 {
133 public:
134 /**
135 * Initializes a search for token and session objects that match a template (calls C_FindObjectsInit)
136 * @param session the session to use for the search
137 * @param search_template the search_template as a vector of `Attribute`
138 */
139 ObjectFinder(Session& session, const std::vector<Attribute>& search_template);
140
141 ObjectFinder(const ObjectFinder& other) = default;
142 ObjectFinder& operator=(const ObjectFinder& other) = default;
143
144 /* Microsoft Visual Studio <= 2013 does not support default generated move special member functions.
145 Everything else we target should support it */
146 #if !defined( _MSC_VER ) || ( _MSC_VER >= 1900 )
147 ObjectFinder(ObjectFinder&& other) = default;
148 ObjectFinder& operator=(ObjectFinder&& other) = default;
149 #endif
150
151 /// Terminates a search for token and session objects (calls C_FindObjectsFinal)
152 ~ObjectFinder() BOTAN_NOEXCEPT;
153
154 /**
155 * Starts or continues a search for token and session objects that match a template, obtaining additional object handles (calls C_FindObjects)
156 * @param max_count maximum amount of object handles to retrieve. Default = 100
157 * @return the result of the search as a vector of `ObjectHandle`
158 */
159 std::vector<ObjectHandle> find(std::uint32_t max_count = 100) const;
160
161 /// Finishes the search operation manually to allow a new ObjectFinder to exist
162 void finish();
163
164 /// @return the module this `ObjectFinder` belongs to
165 inline Module& module() const
166 {
167 return m_session.get().module();
168 }
169
170 private:
171 const std::reference_wrapper<Session> m_session;
172 bool m_search_terminated;
173 };
174
175 /// Common attributes of all objects
176 class BOTAN_DLL ObjectProperties : public AttributeContainer
177 {
178 public:
179 /// @param object_class the object class of the object
180 ObjectProperties(ObjectClass object_class);
181
182 /// @return the object class of this object
183 inline ObjectClass object_class() const
184 {
185 return m_object_class;
186 }
187
188 private:
189 const ObjectClass m_object_class;
190 };
191
192 /// Common attributes of all storage objects
193 class BOTAN_DLL StorageObjectProperties : public ObjectProperties
194 {
195 public:
196 /// @param object_class the CK_OBJECT_CLASS this storage object belongs to
197 StorageObjectProperties(ObjectClass object_class);
198
199 /// @param label description of the object (RFC2279 string)
200 inline void set_label(const std::string& label)
201 {
202 add_string(AttributeType::Label, label);
203 }
204
205 /// @param value if true the object is a token object; otherwise the object is a session object
206 inline void set_token(bool value)
207 {
208 add_bool(AttributeType::Token, value);
209 }
210
211 /**
212 * @param value if true the object is a private object; otherwise the object is a public object
213 * When private, a user may not access the object until the user has been authenticated to the token
214 */
215 inline void set_private(bool value)
216 {
217 add_bool(AttributeType::Private, value);
218 }
219
220 /// @param value if true the object can be modified, otherwise it is read-only
221 void set_modifiable(bool value)
222 {
223 add_bool(AttributeType::Modifiable, value);
224 }
225
226 /// @param value if true the object can be copied using C_CopyObject
227 void set_copyable(bool value)
228 {
229 add_bool(AttributeType::Copyable, value);
230 }
231
232 /// @param value if true the object can be destroyed using C_DestroyObject
233 void set_destroyable(bool value)
234 {
235 add_bool(AttributeType::Destroyable, value);
236 }
237 };
238
239 /// Common attributes of all data objects
240 class BOTAN_DLL DataObjectProperties : public StorageObjectProperties
241 {
242 public:
243 DataObjectProperties();
244
245 /// @param value description of the application that manages the object (RFC2279 string)
246 inline void set_application(const std::string& value)
247 {
248 add_string(AttributeType::Application, value);
249 }
250
251 /// @param object_id DER-encoding of the object identifier indicating the data object type
252 inline void set_object_id(const std::vector<uint8_t>& object_id)
253 {
254 add_binary(AttributeType::ObjectId, object_id);
255 }
256
257 /// @param value value of the object
258 inline void set_value(const secure_vector<uint8_t>& value)
259 {
260 add_binary(AttributeType::Value, value);
261 }
262 };
263
264 /// Common attributes of all certificate objects
265 class BOTAN_DLL CertificateProperties : public StorageObjectProperties
266 {
267 public:
268 /// @param cert_type type of certificate
269 CertificateProperties(CertificateType cert_type);
270
271 /// @param value the certificate can be trusted for the application that it was created (can only be set to true by SO user)
272 inline void set_trusted(bool value)
273 {
274 add_bool(AttributeType::Trusted, value);
275 }
276
277 /// @param category one of `CertificateCategory`
278 inline void set_category(CertificateCategory category)
279 {
280 add_numeric(AttributeType::CertificateCategory, static_cast< CK_CERTIFICATE_CATEGORY >(category));
281 }
282
283 /**
284 * @param checksum the value of this attribute is derived from the certificate by taking the
285 * first three bytes of the SHA - 1 hash of the certificate object's `CKA_VALUE` attribute
286 */
287 inline void set_check_value(const std::vector<uint8_t>& checksum)
288 {
289 add_binary(AttributeType::CheckValue, checksum);
290 }
291
292 /// @param date start date for the certificate
293 inline void set_start_date(Date date)
294 {
295 add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
296 }
297
298 /// @param date end date for the certificate
299 inline void set_end_date(Date date)
300 {
301 add_binary(AttributeType::EndDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
302 }
303
304 /// @param pubkey_info DER-encoding of the SubjectPublicKeyInfo for the public key contained in this certificate
305 inline void set_public_key_info(const std::vector<uint8_t>& pubkey_info)
306 {
307 add_binary(AttributeType::PublicKeyInfo, pubkey_info);
308 }
309
310 /// @return the certificate type of this certificate object
311 inline CertificateType cert_type() const
312 {
313 return m_cert_type;
314 }
315
316 private:
317 const CertificateType m_cert_type;
318 };
319
320 /// Common attributes of all key objects
321 class BOTAN_DLL KeyProperties : public StorageObjectProperties
322 {
323 public:
324 /**
325 * @param object_class the `CK_OBJECT_CLASS` this key object belongs to
326 * @param key_type type of key
327 */
328 KeyProperties(ObjectClass object_class, KeyType key_type);
329
330 /// @param id key identifier for key
331 inline void set_id(const std::vector<uint8_t>& id)
332 {
333 add_binary(AttributeType::Id, id);
334 }
335
336 /// @param date start date for the key
337 inline void set_start_date(Date date)
338 {
339 add_binary(AttributeType::StartDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
340 }
341
342 /// @param date end date for the key
343 inline void set_end_date(Date date)
344 {
345 add_binary(AttributeType::EndDate, reinterpret_cast<uint8_t*>(&date), sizeof(Date));
346 }
347
348 /// @param value true if key supports key derivation (i.e., if other keys can be derived from this one)
349 inline void set_derive(bool value)
350 {
351 add_bool(AttributeType::Derive, value);
352 }
353
354 /**
355 * Sets a list of mechanisms allowed to be used with this key
356 * Not implemented
357 */
358 inline void set_allowed_mechanisms(const std::vector<MechanismType>&)
359 {
360 throw Exception("Not implemented (KeyProperties::set_allowed_mechanisms)");
361 }
362
363 /// @return the key type of this key object
364 inline KeyType key_type() const
365 {
366 return m_key_type;
367 }
368
369 private:
370 const KeyType m_key_type;
371 };
372
373 /// Common attributes of all public key objects
374 class BOTAN_DLL PublicKeyProperties : public KeyProperties
375 {
376 public:
377 /// @param key_type type of key
378 PublicKeyProperties(KeyType key_type);
379
380 /// @param subject DER-encoding of the key subject name
381 inline void set_subject(const std::vector<uint8_t>& subject)
382 {
383 add_binary(AttributeType::Subject, subject);
384 }
385
386 /// @param value true if the key supports encryption
387 inline void set_encrypt(bool value)
388 {
389 add_bool(AttributeType::Encrypt, value);
390 }
391
392 /// @param value true if the key supports verification where the signature is an appendix to the data
393 inline void set_verify(bool value)
394 {
395 add_bool(AttributeType::Verify, value);
396 }
397
398 /// @param value true if the key supports verification where the data is recovered from the signature
399 inline void set_verify_recover(bool value)
400 {
401 add_bool(AttributeType::VerifyRecover, value);
402 }
403
404 /// @param value true if the key supports wrapping (i.e., can be used to wrap other keys)
405 inline void set_wrap(bool value)
406 {
407 add_bool(AttributeType::Wrap, value);
408 }
409
410 /**
411 * @param value true if the key can be trusted for the application that it was created.
412 * The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`
413 */
414 inline void set_trusted(bool value)
415 {
416 add_bool(AttributeType::Trusted, value);
417 }
418
419 /**
420 * For wrapping keys
421 * The attribute template to match against any keys wrapped using this wrapping key.
422 * Keys that do not match cannot be wrapped
423 * Not implemented
424 */
425 inline void set_wrap_template(const AttributeContainer&)
426 {
427 throw Exception("Not implemented (PublicKeyProperties::set_wrap_template)");
428 }
429
430 /// @param pubkey_info DER-encoding of the SubjectPublicKeyInfo for this public key
431 inline void set_public_key_info(const std::vector<uint8_t>& pubkey_info)
432 {
433 add_binary(AttributeType::PublicKeyInfo, pubkey_info);
434 }
435 };
436
437 /// Common attributes of all private keys
438 class BOTAN_DLL PrivateKeyProperties : public KeyProperties
439 {
440 public:
441 /// @param key_type type of key
442 PrivateKeyProperties(KeyType key_type);
443
444 /// @param subject DER-encoding of the key subject name
445 inline void set_subject(const std::vector<uint8_t>& subject)
446 {
447 add_binary(AttributeType::Subject, subject);
448 }
449
450 /// @param value true if the key is sensitive
451 inline void set_sensitive(bool value)
452 {
453 add_bool(AttributeType::Sensitive, value);
454 }
455
456 /// @param value true if the key supports decryption
457 inline void set_decrypt(bool value)
458 {
459 add_bool(AttributeType::Decrypt, value);
460 }
461
462 /// @param value true if the key supports signatures where the signature is an appendix to the data
463 inline void set_sign(bool value)
464 {
465 add_bool(AttributeType::Sign, value);
466 }
467
468 /// @param value true if the key supports signatures where the data can be recovered from the signature
469 inline void set_sign_recover(bool value)
470 {
471 add_bool(AttributeType::SignRecover, value);
472 }
473
474 /// @param value true if the key supports unwrapping (i.e., can be used to unwrap other keys)
475 inline void set_unwrap(bool value)
476 {
477 add_bool(AttributeType::Unwrap, value);
478 }
479
480 /// @param value true if the key is extractable and can be wrapped
481 inline void set_extractable(bool value)
482 {
483 add_bool(AttributeType::Extractable, value);
484 }
485
486 /// @param value true if the key can only be wrapped with a wrapping key that has `CKA_TRUSTED` set to `CK_TRUE`
487 inline void set_wrap_with_trusted(bool value)
488 {
489 add_bool(AttributeType::WrapWithTrusted, value);
490 }
491
492 /// @param value If true, the user has to supply the PIN for each use (sign or decrypt) with the key
493 inline void set_always_authenticate(bool value)
494 {
495 add_bool(AttributeType::AlwaysAuthenticate, value);
496 }
497
498 /**
499 * For wrapping keys
500 * The attribute template to apply to any keys unwrapped using this wrapping key.
501 * Any user supplied template is applied after this template as if the object has already been created
502 * Not implemented
503 */
504 inline void set_unwrap_template(const AttributeContainer&)
505 {
506 throw Exception("Not implemented (PrivateKeyProperties::set_unwrap_template)");
507 }
508
509 /// @param pubkey_info DER-encoding of the SubjectPublicKeyInfo for this public key
510 inline void set_public_key_info(const std::vector<uint8_t>& pubkey_info)
511 {
512 add_binary(AttributeType::PublicKeyInfo, pubkey_info);
513 }
514 };
515
516 /// Common attributes of all secret (symmetric) keys
517 class BOTAN_DLL SecretKeyProperties : public KeyProperties
518 {
519 public:
520 /// @param key_type type of key
521 SecretKeyProperties(KeyType key_type);
522
523 /// @param value true if the key is sensitive
524 inline void set_sensitive(bool value)
525 {
526 add_bool(AttributeType::Sensitive, value);
527 }
528
529 /// @param value true if the key supports encryption
530 inline void set_encrypt(bool value)
531 {
532 add_bool(AttributeType::Encrypt, value);
533 }
534
535 /// @param value true if the key supports decryption
536 inline void set_decrypt(bool value)
537 {
538 add_bool(AttributeType::Decrypt, value);
539 }
540
541 /// @param value true if the key supports signatures where the signature is an appendix to the data
542 inline void set_sign(bool value)
543 {
544 add_bool(AttributeType::Sign, value);
545 }
546
547 /// @param value true if the key supports verification where the signature is an appendix to the data
548 inline void set_verify(bool value)
549 {
550 add_bool(AttributeType::Verify, value);
551 }
552
553 /// @param value true if the key supports unwrapping (i.e., can be used to unwrap other keys)
554 inline void set_unwrap(bool value)
555 {
556 add_bool(AttributeType::Unwrap, value);
557 }
558
559 /// @param value true if the key is extractable and can be wrapped
560 inline void set_extractable(bool value)
561 {
562 add_bool(AttributeType::Extractable, value);
563 }
564
565 /// @param value true if the key can only be wrapped with a wrapping key that has `CKA_TRUSTED` set to `CK_TRUE`
566 inline void set_wrap_with_trusted(bool value)
567 {
568 add_bool(AttributeType::WrapWithTrusted, value);
569 }
570
571 /// @param value if true, the user has to supply the PIN for each use (sign or decrypt) with the key
572 inline void set_always_authenticate(bool value)
573 {
574 add_bool(AttributeType::AlwaysAuthenticate, value);
575 }
576
577 /// @param value true if the key supports wrapping (i.e., can be used to wrap other keys)
578 inline void set_wrap(bool value)
579 {
580 add_bool(AttributeType::Wrap, value);
581 }
582
583 /**
584 * @param value the key can be trusted for the application that it was created.
585 * The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`
586 */
587 inline void set_trusted(bool value)
588 {
589 add_bool(AttributeType::Trusted, value);
590 }
591
592 /// @param checksum the key check value of this key
593 inline void set_check_value(const std::vector<uint8_t>& checksum)
594 {
595 add_binary(AttributeType::CheckValue, checksum);
596 }
597
598 /**
599 * For wrapping keys
600 * The attribute template to match against any keys wrapped using this wrapping key.
601 * Keys that do not match cannot be wrapped
602 * Not implemented
603 */
604 inline void set_wrap_template(const AttributeContainer&)
605 {
606 throw Exception("Not implemented (SecretKeyProperties::set_wrap_template)");
607 }
608
609 /**
610 * For wrapping keys
611 * The attribute template to apply to any keys unwrapped using this wrapping key
612 * Any user supplied template is applied after this template as if the object has already been created
613 * Not Implemented
614 */
615 inline void set_unwrap_template(const AttributeContainer&)
616 {
617 throw Exception("Not implemented (SecretKeyProperties::set_unwrap_template)");
618 }
619 };
620
621 /// Common attributes of domain parameter
622 class BOTAN_DLL DomainParameterProperties : public StorageObjectProperties
623 {
624 public:
625 /// @param key_type type of key the domain parameters can be used to generate
626 DomainParameterProperties(KeyType key_type);
627
628 /// @return the key type
629 inline KeyType key_type() const
630 {
631 return m_key_type;
632 }
633
634 private:
635 const KeyType m_key_type;
636 };
637
638 /**
639 * Represents a PKCS#11 object.
640 */
641 class BOTAN_DLL Object
642 {
643 public:
644 /**
645 * Creates an `Object` from an existing PKCS#11 object
646 * @param session the session the object belongs to
647 * @param handle handle of the object
648 */
649
650 Object(Session& session, ObjectHandle handle);
651
652 /**
653 * Creates the object
654 * @param session the session in which the object should be created
655 * @param obj_props properties of this object
656 */
657 Object(Session& session, const ObjectProperties& obj_props);
658
659 Object(const Object&) = default;
660 Object& operator=(const Object&) = default;
661 virtual ~Object() = default;
662
663 /// Searches for all objects of the given type that match `search_template`
664 template<typename T>
665 static std::vector<T> search(Session& session, const std::vector<Attribute>& search_template);
666
667 /// Searches for all objects of the given type using the label (`CKA_LABEL`)
668 template<typename T>
669 static std::vector<T> search(Session& session, const std::string& label);
670
671 /// Searches for all objects of the given type using the id (`CKA_ID`)
672 template<typename T>
673 static std::vector<T> search(Session& session, const std::vector<uint8_t>& id);
674
675 /// Searches for all objects of the given type using the label (`CKA_LABEL`) and id (`CKA_ID`)
676 template<typename T>
677 static std::vector<T> search(Session& session, const std::string& label, const std::vector<uint8_t>& id);
678
679 /// Searches for all objects of the given type
680 template<typename T>
681 static std::vector<T> search(Session& session);
682
683 /// @returns the value of the given attribute (using `C_GetAttributeValue`)
684 secure_vector<uint8_t> get_attribute_value(AttributeType attribute) const;
685
686 /// Sets the given value for the attribute (using `C_SetAttributeValue`)
687 void set_attribute_value(AttributeType attribute, const secure_vector<uint8_t>& value) const;
688
689 /// Destroys the object
690 void destroy() const;
691
692 /**
693 * Copies the object
694 * @param modified_attributes the attributes of the copied object
695 */
696 ObjectHandle copy(const AttributeContainer& modified_attributes) const;
697
698 /// @return the handle of this object.
699 inline ObjectHandle handle() const
700 {
701 return m_handle;
702 }
703
704 /// @return the session this objects belongs to
705 inline Session& session() const
706 {
707 return m_session;
708 }
709
710 /// @return the module this object belongs to
711 inline Module& module() const
712 {
713 return m_session.get().module();
714 }
715 protected:
716 Object(Session& session)
717 : m_session(session)
718 {}
719
720 const std::reference_wrapper<Session> m_session;
721 ObjectHandle m_handle = CK_INVALID_HANDLE;
722 };
723
724 template<typename T>
725 std::vector<T> Object::search(Session& session, const std::vector<Attribute>& search_template)
726 {
727 ObjectFinder finder(session, search_template);
728 std::vector<ObjectHandle> handles = finder.find();
729 std::vector<T> result;
730 result.reserve(handles.size());
731 for(const auto& handle : handles)
732 {
733 result.emplace_back(T(session, handle));
734 }
735 return result;
736 }
737
738 template<typename T>
739 std::vector<T> Object::search(Session& session, const std::string& label)
740 {
741 AttributeContainer search_template(T::Class);
742 search_template.add_string(AttributeType::Label, label);
743 return search<T>(session, search_template.attributes());
744 }
745
746 template<typename T>
747 std::vector<T> Object::search(Session& session, const std::vector<uint8_t>& id)
748 {
749 AttributeContainer search_template(T::Class);
750 search_template.add_binary(AttributeType::Id, id);
751 return search<T>(session, search_template.attributes());
752 }
753
754 template<typename T>
755 std::vector<T> Object::search(Session& session, const std::string& label, const std::vector<uint8_t>& id)
756 {
757 AttributeContainer search_template(T::Class);
758 search_template.add_string(AttributeType::Label, label);
759 search_template.add_binary(AttributeType::Id, id);
760 return search<T>(session, search_template.attributes());
761 }
762
763 template<typename T>
764 std::vector<T> Object::search(Session& session)
765 {
766 return search<T>(session, AttributeContainer(T::Class).attributes());
767 }
768
769 }
770
771 }
772
773 #endif
Botan::PKCS11::SecretKeyProperties::set_unwrap_template
void set_unwrap_template(const AttributeContainer &)
Definition: p11_object.h:615
Botan::PKCS11::PublicKeyProperties::set_public_key_info
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
Definition: p11_object.h:431
Botan::PKCS11::ObjectProperties
Common attributes of all objects.
Definition: p11_object.h:176
Botan::PKCS11::DataObjectProperties::set_application
void set_application(const std::string &value)
Definition: p11_object.h:246
Botan::PKCS11::CertificateProperties::set_end_date
void set_end_date(Date date)
Definition: p11_object.h:299
Botan::PKCS11::SecretKeyProperties::set_verify
void set_verify(bool value)
Definition: p11_object.h:548
Botan::PKCS11::CertificateProperties::set_check_value
void set_check_value(const std::vector< uint8_t > &checksum)
Definition: p11_object.h:287
Botan::PKCS11::DataObjectProperties::set_object_id
void set_object_id(const std::vector< uint8_t > &object_id)
Definition: p11_object.h:252
CK_INVALID_HANDLE
#define CK_INVALID_HANDLE
Definition: pkcs11t.h:75
Botan::PKCS11::AttributeType::Sign
Botan::PKCS11::PrivateKeyProperties::set_sign
void set_sign(bool value)
Definition: p11_object.h:463
Botan::PKCS11::KeyProperties::set_end_date
void set_end_date(Date date)
Definition: p11_object.h:343
Botan::PKCS11::AttributeType::Application
Botan::PKCS11::ObjectFinder::module
Module & module() const
Definition: p11_object.h:165
Botan::Exception
Definition: exceptn.h:21
Botan::PKCS11::PrivateKeyProperties
Common attributes of all private keys.
Definition: p11_object.h:438
Botan::PKCS11::AttributeType::Subject
Botan::PKCS11::CertificateProperties::set_start_date
void set_start_date(Date date)
Definition: p11_object.h:293
Botan::PKCS11::CertificateType
CertificateType
Definition: p11.h:175
Botan::PKCS11::KeyProperties::set_id
void set_id(const std::vector< uint8_t > &id)
Definition: p11_object.h:331
Botan::PKCS11::PrivateKeyProperties::set_unwrap_template
void set_unwrap_template(const AttributeContainer &)
Definition: p11_object.h:504
Botan::PKCS11::AttributeType
AttributeType
Definition: p11.h:63
Botan::PKCS11::PrivateKeyProperties::set_always_authenticate
void set_always_authenticate(bool value)
Definition: p11_object.h:493
Botan::PKCS11::AttributeType::Wrap
Botan::PKCS11::AttributeType::Decrypt
Botan::PKCS11::AttributeType::Token
Botan::PKCS11::AttributeType::PublicKeyInfo
Botan::PKCS11::StorageObjectProperties::set_copyable
void set_copyable(bool value)
Definition: p11_object.h:227
Botan::PKCS11::PublicKeyProperties::set_wrap_template
void set_wrap_template(const AttributeContainer &)
Definition: p11_object.h:425
Botan::PKCS11::SecretKeyProperties::set_wrap_template
void set_wrap_template(const AttributeContainer &)
Definition: p11_object.h:604
Botan::PKCS11::StorageObjectProperties::set_modifiable
void set_modifiable(bool value)
Definition: p11_object.h:221
Botan::PKCS11::SecretKeyProperties
Common attributes of all secret (symmetric) keys.
Definition: p11_object.h:517
Botan::PKCS11::ObjectClass
ObjectClass
Definition: p11.h:678
Botan::PKCS11::Module
Definition: p11_module.h:25
Botan::PKCS11::StorageObjectProperties::set_token
void set_token(bool value)
Definition: p11_object.h:206
m_handle
HCRYPTPROV m_handle
Definition: es_capi.cpp:45
Botan::PKCS11::SecretKeyProperties::set_trusted
void set_trusted(bool value)
Definition: p11_object.h:587
Botan::PKCS11::DataObjectProperties::set_value
void set_value(const secure_vector< uint8_t > &value)
Definition: p11_object.h:258
Botan::PKCS11::AttributeType::WrapWithTrusted
BOTAN_NOEXCEPT
#define BOTAN_NOEXCEPT
Definition: compiler.h:116
Botan::PKCS11::PrivateKeyProperties::set_public_key_info
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
Definition: p11_object.h:510
Botan::PKCS11::AttributeType::Verify
Botan::PKCS11::PrivateKeyProperties::set_extractable
void set_extractable(bool value)
Definition: p11_object.h:481
Botan::PKCS11::Object::search
static std::vector< T > search(Session &session, const std::vector< Attribute > &search_template)
Searches for all objects of the given type that match search_template
Definition: p11_object.h:725
Botan::PKCS11::CertificateProperties::set_public_key_info
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
Definition: p11_object.h:305
Botan::PKCS11::DomainParameterProperties::key_type
KeyType key_type() const
Definition: p11_object.h:629
Botan::PKCS11::AttributeType::AlwaysAuthenticate
Botan::PKCS11::CertificateProperties::set_category
void set_category(CertificateCategory category)
Definition: p11_object.h:278
Botan::PKCS11::AttributeType::Derive
Botan::PKCS11::SecretKeyProperties::set_unwrap
void set_unwrap(bool value)
Definition: p11_object.h:554
Botan::PKCS11::AttributeType::Private
Botan::PKCS11::PublicKeyProperties::set_trusted
void set_trusted(bool value)
Definition: p11_object.h:414
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34
Botan::PKCS11::StorageObjectProperties::set_destroyable
void set_destroyable(bool value)
Definition: p11_object.h:233
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan::PKCS11::PublicKeyProperties::set_verify
void set_verify(bool value)
Definition: p11_object.h:393
Botan::PKCS11::AttributeType::Class
Botan::PKCS11::AttributeType::EndDate
Botan::PKCS11::AttributeType::CheckValue
Botan::PKCS11::KeyProperties::set_allowed_mechanisms
void set_allowed_mechanisms(const std::vector< MechanismType > &)
Definition: p11_object.h:358
Botan::PKCS11::AttributeType::VerifyRecover
Botan::PKCS11::AttributeType::Sensitive
Botan::PKCS11::AttributeType::Extractable
Botan::PKCS11::SecretKeyProperties::set_sign
void set_sign(bool value)
Definition: p11_object.h:542
Botan::PKCS11::DomainParameterProperties
Common attributes of domain parameter.
Definition: p11_object.h:622
Botan::PKCS11::Object::m_session
const std::reference_wrapper< Session > m_session
Definition: p11_object.h:720
Botan::PKCS11::Object::handle
ObjectHandle handle() const
Definition: p11_object.h:699
Botan::PKCS11::AttributeType::Value
Botan::PKCS11::AttributeType::Destroyable
Botan::PKCS11::AttributeType::CertificateCategory
Botan::PKCS11::SecretKeyProperties::set_encrypt
void set_encrypt(bool value)
Definition: p11_object.h:530
Botan::PKCS11::PrivateKeyProperties::set_decrypt
void set_decrypt(bool value)
Definition: p11_object.h:457
Botan::PKCS11::StorageObjectProperties::set_label
void set_label(const std::string &label)
Definition: p11_object.h:200
Botan::PKCS11::Object::session
Session & session() const
Definition: p11_object.h:705
Botan
Definition: alg_id.cpp:13
Botan::PKCS11::ObjectHandle
CK_OBJECT_HANDLE ObjectHandle
Definition: p11.h:846
Botan::PKCS11::AttributeContainer::data
Attribute * data() const
Definition: p11_object.h:56
Botan::PKCS11::Object
Definition: p11_object.h:641
Botan::PKCS11::AttributeType::ObjectId
Botan::PKCS11::StorageObjectProperties
Common attributes of all storage objects.
Definition: p11_object.h:193
Botan::PKCS11::Object::Object
Object(Session &session)
Definition: p11_object.h:716
Botan::PKCS11::PublicKeyProperties::set_subject
void set_subject(const std::vector< uint8_t > &subject)
Definition: p11_object.h:381
Botan::PKCS11::PublicKeyProperties
Common attributes of all public key objects.
Definition: p11_object.h:374
Botan::PKCS11::AttributeContainer::count
size_t count() const
Definition: p11_object.h:62
Botan::PKCS11::AttributeType::SignRecover
Botan::PKCS11::DataObjectProperties
Common attributes of all data objects.
Definition: p11_object.h:240
Botan::PKCS11::KeyProperties::key_type
KeyType key_type() const
Definition: p11_object.h:364
Botan::PKCS11::KeyProperties::set_start_date
void set_start_date(Date date)
Definition: p11_object.h:337
Botan::PKCS11::CertificateProperties
Common attributes of all certificate objects.
Definition: p11_object.h:265
Botan::PKCS11::Object::module
Module & module() const
Definition: p11_object.h:711
Botan::PKCS11::SecretKeyProperties::set_check_value
void set_check_value(const std::vector< uint8_t > &checksum)
Definition: p11_object.h:593
Botan::PKCS11::SecretKeyProperties::set_sensitive
void set_sensitive(bool value)
Definition: p11_object.h:524
Botan::PKCS11::AttributeType::Modifiable
Botan::PKCS11::AttributeType::Trusted
Botan::PKCS11::AttributeType::Encrypt
Botan::PKCS11::PrivateKeyProperties::set_sensitive
void set_sensitive(bool value)
Definition: p11_object.h:451
Botan::PKCS11::AttributeContainer::add_binary
void add_binary(AttributeType attribute, const std::vector< uint8_t, TAlloc > &binary)
Definition: p11_object.h:94
Botan::PKCS11::AttributeContainer::add_numeric
void add_numeric(AttributeType attribute, T value)
Definition: p11_object.h:112
Botan::PKCS11::KeyProperties
Common attributes of all key objects.
Definition: p11_object.h:321
Botan::PKCS11::SecretKeyProperties::set_extractable
void set_extractable(bool value)
Definition: p11_object.h:560
Botan::PKCS11::AttributeContainer
Helper class to build the Attribute / CK_ATTRIBUTE structures.
Definition: p11_object.h:28
Botan::PKCS11::SecretKeyProperties::set_wrap
void set_wrap(bool value)
Definition: p11_object.h:578
Botan::PKCS11::PrivateKeyProperties::set_sign_recover
void set_sign_recover(bool value)
Definition: p11_object.h:469
Botan::PKCS11::AttributeContainer::attributes
const std::vector< Attribute > & attributes() const
Definition: p11_object.h:50
Botan::PKCS11::AttributeType::Label
Botan::PKCS11::PublicKeyProperties::set_wrap
void set_wrap(bool value)
Definition: p11_object.h:405
Botan::PKCS11::CertificateProperties::set_trusted
void set_trusted(bool value)
Definition: p11_object.h:272
Botan::PKCS11::AttributeType::Unwrap
Botan::PKCS11::AttributeType::Copyable
Botan::PKCS11::KeyType
KeyType
Definition: p11.h:287
Botan::PKCS11::PrivateKeyProperties::set_subject
void set_subject(const std::vector< uint8_t > &subject)
Definition: p11_object.h:445
Botan::PKCS11::AttributeContainer::add_string
void add_string(AttributeType attribute, const std::string &value)
Definition: p11_object.cpp:28
Botan::PKCS11::SecretKeyProperties::set_always_authenticate
void set_always_authenticate(bool value)
Definition: p11_object.h:572
Botan::PKCS11::ObjectFinder::find
std::vector< ObjectHandle > find(std::uint32_t max_count=100) const
Definition: p11_object.cpp:108
Botan::PKCS11::Session
Represents a PKCS#11 session.
Definition: p11_session.h:22
Botan::PKCS11::CertificateProperties::cert_type
CertificateType cert_type() const
Definition: p11_object.h:311
Botan::PKCS11::ObjectProperties::object_class
ObjectClass object_class() const
Definition: p11_object.h:183
Botan::PKCS11::SecretKeyProperties::set_decrypt
void set_decrypt(bool value)
Definition: p11_object.h:536
Botan::PKCS11::SecretKeyProperties::set_wrap_with_trusted
void set_wrap_with_trusted(bool value)
Definition: p11_object.h:566
Botan::PKCS11::PublicKeyProperties::set_verify_recover
void set_verify_recover(bool value)
Definition: p11_object.h:399
Botan::PKCS11::PrivateKeyProperties::set_wrap_with_trusted
void set_wrap_with_trusted(bool value)
Definition: p11_object.h:487
Botan::PKCS11::CertificateCategory
CertificateCategory
Definition: p11.h:185
CK_DATE
Definition: pkcs11t.h:573
Botan::PKCS11::AttributeType::Id
Botan::PKCS11::AttributeType::StartDate
CK_ATTRIBUTE
Definition: pkcs11t.h:564
Botan::PKCS11::KeyProperties::set_derive
void set_derive(bool value)
Definition: p11_object.h:349
Botan::PKCS11::PublicKeyProperties::set_encrypt
void set_encrypt(bool value)
Definition: p11_object.h:387
Botan::PKCS11::PrivateKeyProperties::set_unwrap
void set_unwrap(bool value)
Definition: p11_object.h:475
Botan::PKCS11::ObjectFinder
Manages calls to C_FindObjects* functions (C_FindObjectsInit -> C_FindObjects -> C_FindObjectsFinal) ...
Definition: p11_object.h:131
Botan::PKCS11::StorageObjectProperties::set_private
void set_private(bool value)
Definition: p11_object.h:215