8 #include <botan/pkcs10.h>
9 #include <botan/x509_ext.h>
10 #include <botan/x509cert.h>
11 #include <botan/der_enc.h>
12 #include <botan/ber_dec.h>
13 #include <botan/parsing.h>
14 #include <botan/oids.h>
15 #include <botan/pem.h>
23 X509_Object(in,
"CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
32 X509_Object(in,
"CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
41 X509_Object(in,
"CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
49 void PKCS10_Request::force_decode()
54 cert_req_info.decode(version);
56 throw Decoding_Error(
"Unknown version code in PKCS #10 request: " +
60 cert_req_info.decode(dn_subject);
64 BER_Object public_key = cert_req_info.get_next_object();
66 throw BER_Bad_Tag(
"PKCS10_Request: Unexpected tag for public key",
69 info.
add(
"X509.Certificate.public_key",
76 BER_Object attr_bits = cert_req_info.get_next_object();
82 while(attributes.more_items())
85 attributes.decode(attr);
86 handle_attribute(attr);
88 attributes.verify_end();
91 throw BER_Bad_Tag(
"PKCS10_Request: Unexpected tag for attributes",
94 cert_req_info.verify_end();
97 throw Decoding_Error(
"PKCS #10 request: Bad signature detected");
103 void PKCS10_Request::handle_attribute(
const Attribute& attr)
105 BER_Decoder value(attr.parameters);
111 info.
add(
"RFC822", email.value());
113 else if(attr.oid ==
OIDS::lookup(
"PKCS9.ChallengePassword"))
116 value.decode(challenge_password);
117 info.
add(
"PKCS9.ChallengePassword", challenge_password.value());
119 else if(attr.oid ==
OIDS::lookup(
"PKCS9.ExtensionRequest"))
121 Extensions extensions;
122 value.decode(extensions).verify_end();
124 Data_Store issuer_info;
125 extensions.contents_to(info, issuer_info);
134 return info.
get1(
"PKCS9.ChallengePassword");
184 std::vector<std::string> oids = info.
get(
"X509v3.ExtendedKeyUsage");
186 std::vector<OID> result;
187 for(
size_t i = 0; i != oids.size(); ++i)
188 result.push_back(
OID(oids[i]));
197 return (info.
get1_u32bit(
"X509v3.BasicConstraints.is_ca") > 0);
205 return info.
get1_u32bit(
"X509v3.BasicConstraints.path_constraint", 0);