Botan  2.4.0
Crypto and TLS for C++11
pkcs10.h
Go to the documentation of this file.
1 /*
2 * PKCS #10
3 * (C) 1999-2007 Jack Lloyd
4 * (C) 2016 RenĂ© Korthaus, Rohde & Schwarz Cybersecurity
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8 
9 #ifndef BOTAN_PKCS10_H_
10 #define BOTAN_PKCS10_H_
11 
12 #include <botan/x509_obj.h>
13 #include <botan/x509_dn.h>
14 #include <botan/key_constraint.h>
15 #include <botan/asn1_attribute.h>
16 #include <botan/asn1_alt_name.h>
17 #include <vector>
18 
19 namespace Botan {
20 
21 class Extensions;
22 struct PKCS10_Data;
23 
24 /**
25 * PKCS #10 Certificate Request.
26 */
27 class BOTAN_PUBLIC_API(2,0) PKCS10_Request final : public X509_Object
28  {
29  public:
30  /**
31  * Get the subject public key.
32  * @return subject public key
33  */
34  Public_Key* subject_public_key() const;
35 
36  /**
37  * Get the raw DER encoded public key.
38  * @return raw DER encoded public key
39  */
40  const std::vector<uint8_t>& raw_public_key() const;
41 
42  /**
43  * Get the subject DN.
44  * @return subject DN
45  */
46  const X509_DN& subject_dn() const;
47 
48  /**
49  * Get the subject alternative name.
50  * @return subject alternative name.
51  */
52  const AlternativeName& subject_alt_name() const;
53 
54  /**
55  * Get the key constraints for the key associated with this
56  * PKCS#10 object.
57  * @return key constraints
58  */
59  Key_Constraints constraints() const;
60 
61  /**
62  * Get the extendend key constraints (if any).
63  * @return extended key constraints
64  */
65  std::vector<OID> ex_constraints() const;
66 
67  /**
68  * Find out whether this is a CA request.
69  * @result true if it is a CA request, false otherwise.
70  */
71  bool is_CA() const;
72 
73  /**
74  * Return the constraint on the path length defined
75  * in the BasicConstraints extension.
76  * @return path limit
77  */
78  size_t path_limit() const;
79 
80  /**
81  * Get the challenge password for this request
82  * @return challenge password for this request
83  */
84  std::string challenge_password() const;
85 
86  /**
87  * Get the X509v3 extensions.
88  * @return X509v3 extensions
89  */
90  const Extensions& extensions() const;
91 
92  /**
93  * Create a PKCS#10 Request from a data source.
94  * @param source the data source providing the DER encoded request
95  */
96  explicit PKCS10_Request(DataSource& source);
97 
98 #if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
99  /**
100  * Create a PKCS#10 Request from a file.
101  * @param filename the name of the file containing the DER or PEM
102  * encoded request file
103  */
104  explicit PKCS10_Request(const std::string& filename);
105 #endif
106 
107  /**
108  * Create a PKCS#10 Request from binary data.
109  * @param vec a std::vector containing the DER value
110  */
111  explicit PKCS10_Request(const std::vector<uint8_t>& vec);
112  private:
113  std::string PEM_label() const override;
114 
115  std::vector<std::string> alternate_PEM_labels() const override;
116 
117  void force_decode() override;
118 
119  const PKCS10_Data& data() const;
120 
121  std::shared_ptr<PKCS10_Data> m_data;
122  };
123 
124 }
125 
126 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Definition: alg_id.cpp:13