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