Botan 3.5.0
Crypto and TLS for C&
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/pkix_enums.h>
13#include <botan/x509_obj.h>
14#include <vector>
15
16namespace Botan {
17
18struct PKCS10_Data;
19
20class Private_Key;
21class Extensions;
22class X509_DN;
23class AlternativeName;
24
25/**
26* PKCS #10 Certificate Request.
27*/
29 public:
30 /**
31 * Get the subject public key.
32 * @return subject public key
33 */
34 std::unique_ptr<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(std::string_view 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
113 /**
114 * Create a new PKCS10 certificate request
115 * @param key the key that will be included in the certificate request
116 * @param subject_dn the DN to be placed in the request
117 * @param extensions extensions to include in the request
118 * @param hash_fn the hash function to use to create the signature
119 * @param rng a random number generator
120 * @param padding_scheme if set specifies the padding scheme, otherwise an
121 * algorithm-specific default is used.
122 * @param challenge a challenge string to be included in the PKCS10 request,
123 * sometimes used for revocation purposes.
124 */
125 static PKCS10_Request create(const Private_Key& key,
126 const X509_DN& subject_dn,
127 const Extensions& extensions,
128 std::string_view hash_fn,
130 std::string_view padding_scheme = "",
131 std::string_view challenge = "");
132
133 private:
134 std::string PEM_label() const override;
135
136 std::vector<std::string> alternate_PEM_labels() const override;
137
138 void force_decode() override;
139
140 const PKCS10_Data& data() const;
141
142 std::shared_ptr<PKCS10_Data> m_data;
143};
144
145} // namespace Botan
146
147#endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31