Botan  2.1.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/x509_ext.h>
15 #include <botan/datastor.h>
16 #include <botan/key_constraint.h>
17 #include <botan/asn1_attribute.h>
18 #include <botan/asn1_alt_name.h>
19 #include <vector>
20 
21 namespace Botan {
22 
23 /**
24 * PKCS #10 Certificate Request.
25 */
26 class BOTAN_DLL PKCS10_Request final : public X509_Object
27  {
28  public:
29  /**
30  * Get the subject public key.
31  * @return subject public key
32  */
33  Public_Key* subject_public_key() const;
34 
35  /**
36  * Get the raw DER encoded public key.
37  * @return raw DER encoded public key
38  */
39  std::vector<uint8_t> raw_public_key() const;
40 
41  /**
42  * Get the subject DN.
43  * @return subject DN
44  */
45  X509_DN subject_dn() const;
46 
47  /**
48  * Get the subject alternative name.
49  * @return subject alternative name.
50  */
51  AlternativeName subject_alt_name() const;
52 
53  /**
54  * Get the key constraints for the key associated with this
55  * PKCS#10 object.
56  * @return key constraints
57  */
58  Key_Constraints constraints() const;
59 
60  /**
61  * Get the extendend key constraints (if any).
62  * @return extended key constraints
63  */
64  std::vector<OID> ex_constraints() const;
65 
66  /**
67  * Find out whether this is a CA request.
68  * @result true if it is a CA request, false otherwise.
69  */
70  bool is_CA() const;
71 
72  /**
73  * Return the constraint on the path length defined
74  * in the BasicConstraints extension.
75  * @return path limit
76  */
77  size_t path_limit() const;
78 
79  /**
80  * Get the challenge password for this request
81  * @return challenge password for this request
82  */
83  std::string challenge_password() const;
84 
85  /**
86  * Get the X509v3 extensions.
87  * @return X509v3 extensions
88  */
89  Extensions extensions() const;
90 
91  /**
92  * Create a PKCS#10 Request from a data source.
93  * @param source the data source providing the DER encoded request
94  */
95  explicit PKCS10_Request(DataSource& source);
96 
97 #if defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
98  /**
99  * Create a PKCS#10 Request from a file.
100  * @param filename the name of the file containing the DER or PEM
101  * encoded request file
102  */
103  explicit PKCS10_Request(const std::string& filename);
104 #endif
105 
106  /**
107  * Create a PKCS#10 Request from binary data.
108  * @param vec a std::vector containing the DER value
109  */
110  explicit PKCS10_Request(const std::vector<uint8_t>& vec);
111  private:
112  void force_decode() override;
113  void handle_attribute(const Attribute&);
114 
115  Data_Store m_info;
116  Extensions m_extensions;
117  };
118 
119 }
120 
121 #endif
Definition: alg_id.cpp:13