Botan  2.6.0
Crypto and TLS for C++11
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
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)
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)
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
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
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
241  {
242  public:
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
266  {
267  public:
268  /// @param cert_type type of certificate
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
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
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  */
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
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  */
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
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  */
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  */
616  {
617  throw Exception("Not implemented (SecretKeyProperties::set_unwrap_template)");
618  }
619  };
620 
621 /// Common attributes of domain parameter
623  {
624  public:
625  /// @param key_type type of key the domain parameters can be used to generate
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 */
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 
721  {
722  if(m_handle != CK_INVALID_HANDLE)
723  throw Invalid_Argument("Cannot reset handle on already valid PKCS11 object");
724  m_handle = handle;
725  }
726 
727  private:
728  const std::reference_wrapper<Session> m_session;
729  ObjectHandle m_handle = CK_INVALID_HANDLE;
730  };
731 
732 template<typename T>
733 std::vector<T> Object::search(Session& session, const std::vector<Attribute>& search_template)
734  {
735  ObjectFinder finder(session, search_template);
736  std::vector<ObjectHandle> handles = finder.find();
737  std::vector<T> result;
738  result.reserve(handles.size());
739  for(const auto& handle : handles)
740  {
741  result.emplace_back(T(session, handle));
742  }
743  return result;
744  }
745 
746 template<typename T>
747 std::vector<T> Object::search(Session& session, const std::string& label)
748  {
749  AttributeContainer search_template(T::Class);
750  search_template.add_string(AttributeType::Label, label);
751  return search<T>(session, search_template.attributes());
752  }
753 
754 template<typename T>
755 std::vector<T> Object::search(Session& session, const std::vector<uint8_t>& id)
756  {
757  AttributeContainer search_template(T::Class);
758  search_template.add_binary(AttributeType::Id, id);
759  return search<T>(session, search_template.attributes());
760  }
761 
762 template<typename T>
763 std::vector<T> Object::search(Session& session, const std::string& label, const std::vector<uint8_t>& id)
764  {
765  AttributeContainer search_template(T::Class);
766  search_template.add_string(AttributeType::Label, label);
767  search_template.add_binary(AttributeType::Id, id);
768  return search<T>(session, search_template.attributes());
769  }
770 
771 template<typename T>
772 std::vector<T> Object::search(Session& session)
773  {
774  return search<T>(session, AttributeContainer(T::Class).attributes());
775  }
776 
777 }
778 
779 }
780 
781 #endif
void set_unwrap_template(const AttributeContainer &)
Definition: p11_object.h:615
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
Definition: p11_object.h:431
Common attributes of all objects.
Definition: p11_object.h:176
ObjectHandle handle() const
Definition: p11_object.h:699
void set_application(const std::string &value)
Definition: p11_object.h:246
void set_check_value(const std::vector< uint8_t > &checksum)
Definition: p11_object.h:287
void set_object_id(const std::vector< uint8_t > &object_id)
Definition: p11_object.h:252
#define CK_INVALID_HANDLE
Definition: pkcs11t.h:75
void set_end_date(Date date)
Definition: p11_object.h:343
Common attributes of all private keys.
Definition: p11_object.h:438
CertificateType
Definition: p11.h:175
void set_id(const std::vector< uint8_t > &id)
Definition: p11_object.h:331
void set_unwrap_template(const AttributeContainer &)
Definition: p11_object.h:504
AttributeType
Definition: p11.h:63
void set_always_authenticate(bool value)
Definition: p11_object.h:493
void reset_handle(ObjectHandle handle)
Definition: p11_object.h:720
Session & session() const
Definition: p11_object.h:705
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
void set_wrap_template(const AttributeContainer &)
Definition: p11_object.h:425
CertificateType cert_type() const
Definition: p11_object.h:311
void set_wrap_template(const AttributeContainer &)
Definition: p11_object.h:604
Common attributes of all secret (symmetric) keys.
Definition: p11_object.h:517
void set_value(const secure_vector< uint8_t > &value)
Definition: p11_object.h:258
#define BOTAN_NOEXCEPT
Definition: compiler.h:154
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
Definition: p11_object.h:510
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:733
void set_public_key_info(const std::vector< uint8_t > &pubkey_info)
Definition: p11_object.h:305
void set_category(CertificateCategory category)
Definition: p11_object.h:278
Module & module() const
Definition: p11_object.h:711
void add_binary(AttributeType attribute, const uint8_t *value, size_t length)
Definition: p11_object.cpp:34
ObjectClass object_class() const
Definition: p11_object.h:183
void set_allowed_mechanisms(const std::vector< MechanismType > &)
Definition: p11_object.h:358
Common attributes of domain parameter.
Definition: p11_object.h:622
void set_label(const std::string &label)
Definition: p11_object.h:200
Definition: alg_id.cpp:13
CK_OBJECT_HANDLE ObjectHandle
Definition: p11.h:846
Common attributes of all storage objects.
Definition: p11_object.h:193
Object(Session &session)
Definition: p11_object.h:716
void set_subject(const std::vector< uint8_t > &subject)
Definition: p11_object.h:381
Common attributes of all public key objects.
Definition: p11_object.h:374
Common attributes of all data objects.
Definition: p11_object.h:240
Attribute * data() const
Definition: p11_object.h:56
void set_start_date(Date date)
Definition: p11_object.h:337
Common attributes of all certificate objects.
Definition: p11_object.h:265
std::vector< ObjectHandle > find(std::uint32_t max_count=100) const
Definition: p11_object.cpp:108
const std::vector< Attribute > & attributes() const
Definition: p11_object.h:50
void set_check_value(const std::vector< uint8_t > &checksum)
Definition: p11_object.h:593
KeyType key_type() const
Definition: p11_object.h:364
void add_binary(AttributeType attribute, const std::vector< uint8_t, TAlloc > &binary)
Definition: p11_object.h:94
void add_numeric(AttributeType attribute, T value)
Definition: p11_object.h:112
Common attributes of all key objects.
Definition: p11_object.h:321
Helper class to build the Attribute / CK_ATTRIBUTE structures.
Definition: p11_object.h:28
fe T
Definition: ge.cpp:37
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88
void set_subject(const std::vector< uint8_t > &subject)
Definition: p11_object.h:445
void add_string(AttributeType attribute, const std::string &value)
Definition: p11_object.cpp:28
void set_always_authenticate(bool value)
Definition: p11_object.h:572
Represents a PKCS#11 session.
Definition: p11_session.h:21
void set_wrap_with_trusted(bool value)
Definition: p11_object.h:566
void set_verify_recover(bool value)
Definition: p11_object.h:399
void set_wrap_with_trusted(bool value)
Definition: p11_object.h:487
CertificateCategory
Definition: p11.h:185
void set_derive(bool value)
Definition: p11_object.h:349
Module & module() const
Definition: p11_object.h:165
Manages calls to C_FindObjects* functions (C_FindObjectsInit -> C_FindObjects -> C_FindObjectsFinal) ...
Definition: p11_object.h:131