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>
23 X509_Object(in,
"CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
32 X509_Object(in,
"CERTIFICATE REQUEST/NEW CERTIFICATE REQUEST")
40void PKCS10_Request::force_decode()
45 cert_req_info.decode(version);
47 throw Decoding_Error(
"Unknown version code in PKCS #10 request: " +
51 cert_req_info.decode(dn_subject);
55 BER_Object public_key = cert_req_info.get_next_object();
57 throw BER_Bad_Tag(
"PKCS10_Request: Unexpected tag for public key",
60 info.
add(
"X509.Certificate.public_key",
67 BER_Object attr_bits = cert_req_info.get_next_object();
73 while(attributes.more_items())
76 attributes.decode(attr);
77 handle_attribute(attr);
79 attributes.verify_end();
82 throw BER_Bad_Tag(
"PKCS10_Request: Unexpected tag for attributes",
85 cert_req_info.verify_end();
94void PKCS10_Request::handle_attribute(
const Attribute& attr)
96 BER_Decoder value(attr.parameters);
102 info.add(
"RFC822", email.value());
104 else if(attr.oid ==
OIDS::lookup(
"PKCS9.ChallengePassword"))
110 else if(attr.oid ==
OIDS::lookup(
"PKCS9.ExtensionRequest"))
112 Extensions extensions;
113 value.decode(extensions).verify_end();
115 Data_Store issuer_info;
116 extensions.contents_to(info, issuer_info);
125 return info.get1(
"PKCS9.ChallengePassword");
175 std::vector<std::string> oids = info.get(
"X509v3.ExtendedKeyUsage");
177 std::vector<OID> result;
178 for(
size_t i = 0; i != oids.size(); ++i)
179 result.push_back(
OID(oids[i]));
188 return (info.get1_u32bit(
"X509v3.BasicConstraints.is_ca") > 0);
196 return info.get1_u32bit(
"X509v3.BasicConstraints.path_constraint", 0);
SecureVector< byte > value
void add(const std::multimap< std::string, std::string > &)
AlternativeName subject_alt_name() const
PKCS10_Request(DataSource &source)
MemoryVector< byte > raw_public_key() const
Public_Key * subject_public_key() const
X509_DN subject_dn() const
std::vector< OID > ex_constraints() const
Key_Constraints constraints() const
u32bit path_limit() const
std::string challenge_password() const
std::multimap< std::string, std::string > contents() const
bool check_signature(class Public_Key &key) const
X509_Object(DataSource &src, const std::string &pem_labels)
MemoryVector< byte > tbs_bits
SecureVector< byte > put_in_sequence(const MemoryRegion< byte > &contents)
std::string lookup(const OID &oid)
std::string encode(const byte der[], size_t length, const std::string &label, size_t width)
SecureVector< byte > decode_check_label(DataSource &source, const std::string &label_want)
Public_Key * load_key(DataSource &source)
std::string to_string(u64bit n, size_t min_len)
X509_DN create_dn(const Data_Store &info)
AlternativeName create_alt_name(const Data_Store &info)
BER_Bad_Tag(const std::string &msg, ASN1_Tag tag)
Decoding_Error(const std::string &name)