9#include <botan/assert.h>
10#include <botan/internal/ffi_cert.h>
11#include <botan/internal/ffi_pkey.h>
12#include <botan/internal/ffi_rng.h>
13#include <botan/internal/ffi_util.h>
16#if defined(BOTAN_HAS_X509_CERTIFICATES)
17 #include <botan/data_src.h>
18 #include <botan/x509_crl.h>
19 #include <botan/x509_ext.h>
20 #include <botan/x509cert.h>
21 #include <botan/x509path.h>
22 #include <botan/internal/ffi_mp.h>
23 #include <botan/internal/ffi_oid.h>
26#if defined(BOTAN_HAS_X509_CERTIFICATES)
41std::optional<Botan::GeneralName> extract_general_name_at(
const Botan::AlternativeName& altnames,
size_t index) {
44 std::advance(itr, index);
51 std::advance(itr, index);
58 std::advance(itr, index);
65 std::advance(itr, index);
72 std::advance(itr, index);
79 std::advance(itr, index);
93size_t count_general_names_in(
const Botan::AlternativeName& alt_names) {
129template <std::invocable<
size_t> EnumeratorT>
130int enumerator_count_values(
size_t* count, EnumeratorT fn) {
137 const auto rc = fn(*count);
153std::chrono::system_clock::time_point timepoint_from_timestamp(uint64_t time_since_epoch) {
154 return std::chrono::system_clock::time_point(std::chrono::seconds(time_since_epoch));
157std::string default_from_ptr(
const char* value) {
159 if(value !=
nullptr) {
180#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
183 auto c = std::make_unique<Botan::X509_Certificate>(cert_path);
193 if(cert_obj ==
nullptr) {
197#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
200 auto c = std::make_unique<Botan::X509_Certificate>(
safe_get(cert));
215#if defined(BOTAN_HAS_X509_CERTIFICATES)
218 auto c = std::make_unique<Botan::X509_Certificate>(bits);
230#if defined(BOTAN_HAS_X509_CERTIFICATES)
242 const auto view = [=](
const std::string& value) {
return invoke_view_callback(view_fn, ctx, value); };
261 const auto view = [=](std::span<const uint8_t> value) {
return invoke_view_callback(view_fn, ctx, value); };
265 return view(
object.tbs_data());
267 return view(
object.signature_algorithm().
BER_encode());
269 return view(
object.signature());
288#if defined(BOTAN_HAS_X509_CERTIFICATES)
294 const auto view = [=](std::span<const uint8_t> value) ->
int {
321 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
339#if defined(BOTAN_HAS_X509_CERTIFICATES)
340 return enumerator_count_values(count, [=](
size_t index) {
342 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
355#if defined(BOTAN_HAS_X509_CERTIFICATES)
356 const auto enumerate_uris = [view_fn, ctx](
const std::vector<Botan::URI>& values,
size_t idx) ->
int {
357 if(idx >= values.size()) {
373 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
397#if defined(BOTAN_HAS_X509_CERTIFICATES)
398 return enumerator_count_values(count, [=](
size_t index) {
400 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
409#if defined(BOTAN_HAS_X509_CERTIFICATES)
410 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.is_CA_cert() ? 1 : 0; });
418#if defined(BOTAN_HAS_X509_CERTIFICATES)
424 if(
const auto path_len = c.path_length_constraint()) {
425 *path_limit = path_len.value();
444#if defined(BOTAN_HAS_X509_CERTIFICATES)
446 auto public_key =
safe_get(cert).subject_public_key();
456 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
460#if defined(BOTAN_HAS_X509_CERTIFICATES)
462 const auto issuer_info = c.issuer_info(key);
463 if(index < issuer_info.size()) {
465 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.issuer_info(key).at(index));
477#if defined(BOTAN_HAS_X509_CERTIFICATES)
483 *count = c.issuer_info(key).size();
493 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
497#if defined(BOTAN_HAS_X509_CERTIFICATES)
499 const auto subject_info = c.subject_info(key);
500 if(index < subject_info.size()) {
502 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.subject_info(key).at(index));
514#if defined(BOTAN_HAS_X509_CERTIFICATES)
520 *count = c.subject_info(key).size();
534#if defined(BOTAN_HAS_X509_CERTIFICATES)
543#if defined(BOTAN_HAS_X509_CERTIFICATES)
546 if(c.allowed_usage(k)) {
558#if defined(BOTAN_HAS_X509_CERTIFICATES)
564 return c.has_ex_constraint(oid) ? 1 : 0;
573#if defined(BOTAN_HAS_X509_CERTIFICATES)
574 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) ->
int {
return c.has_ex_constraint(
safe_get(oid)) ? 1 : 0; });
582#if defined(BOTAN_HAS_X509_CERTIFICATES)
591#if defined(BOTAN_HAS_X509_CERTIFICATES)
593 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_before().to_string()); });
601#if defined(BOTAN_HAS_X509_CERTIFICATES)
603 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_after().to_string()); });
611 if(time_since_epoch ==
nullptr) {
614#if defined(BOTAN_HAS_X509_CERTIFICATES)
615 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_before().time_since_epoch(); });
623 if(time_since_epoch ==
nullptr) {
626#if defined(BOTAN_HAS_X509_CERTIFICATES)
627 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_after().time_since_epoch(); });
635#if defined(BOTAN_HAS_X509_CERTIFICATES)
644#if defined(BOTAN_HAS_X509_CERTIFICATES)
651 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
660 if(hash ==
nullptr) {
663#if defined(BOTAN_HAS_X509_CERTIFICATES)
667 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.fingerprint(hash));
676#if defined(BOTAN_HAS_X509_CERTIFICATES)
685#if defined(BOTAN_HAS_X509_CERTIFICATES)
698#if defined(BOTAN_HAS_X509_CERTIFICATES)
708#if defined(BOTAN_HAS_X509_CERTIFICATES)
714 const auto mapped_type = to_botan_x509_general_name_types(n.
type_code());
715 if(!mapped_type.has_value()) {
719 *type = mapped_type.value();
735#if defined(BOTAN_HAS_X509_CERTIFICATES)
737 const auto type = to_botan_x509_general_name_types(n.
type_code());
758#if defined(BOTAN_HAS_X509_CERTIFICATES)
760 const auto type = to_botan_x509_general_name_types(n.
type_code());
778#if defined(BOTAN_HAS_X509_CERTIFICATES)
789#if defined(BOTAN_HAS_X509_CERTIFICATES)
796 if(index >= constraints.size()) {
800 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
809#if defined(BOTAN_HAS_X509_CERTIFICATES)
814 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().permitted().size(); });
824#if defined(BOTAN_HAS_X509_CERTIFICATES)
831 if(index >= constraints.size()) {
835 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
844#if defined(BOTAN_HAS_X509_CERTIFICATES)
849 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().excluded().size(); });
859#if defined(BOTAN_HAS_X509_CERTIFICATES)
870 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(
name).value()));
882#if defined(BOTAN_HAS_X509_CERTIFICATES)
898#if defined(BOTAN_HAS_X509_CERTIFICATES)
909 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(
name).value()));
921#if defined(BOTAN_HAS_X509_CERTIFICATES)
935 if(hostname ==
nullptr) {
939#if defined(BOTAN_HAS_X509_CERTIFICATES)
940 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.matches_dns_name(hostname) ? 0 : -1; });
950 size_t intermediates_len,
953 const char* trusted_path,
954 size_t required_strength,
955 const char* hostname_cstr,
956 uint64_t reference_time) {
957 if(required_strength == 0) {
958 required_strength = 110;
961#if defined(BOTAN_HAS_X509_CERTIFICATES)
963 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
965 const auto validation_time = reference_time == 0
966 ? std::chrono::system_clock::now()
967 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
969 if(intermediates_len > 0 && intermediates ==
nullptr) {
972 if(trusted_len > 0 && trusted ==
nullptr) {
976 std::vector<Botan::X509_Certificate> end_certs;
977 end_certs.push_back(
safe_get(cert));
978 for(
size_t i = 0; i != intermediates_len; ++i) {
979 end_certs.push_back(
safe_get(intermediates[i]));
982 std::unique_ptr<Botan::Certificate_Store> trusted_from_path;
983 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_extra;
984 std::vector<Botan::Certificate_Store*> trusted_roots;
986 if(trusted_path !=
nullptr && *trusted_path != 0) {
987 trusted_from_path = std::make_unique<Botan::Certificate_Store_In_Memory>(trusted_path);
988 trusted_roots.push_back(trusted_from_path.get());
991 if(trusted_len > 0) {
992 trusted_extra = std::make_unique<Botan::Certificate_Store_In_Memory>();
993 for(
size_t i = 0; i != trusted_len; ++i) {
994 trusted_extra->add_certificate(
safe_get(trusted[i]));
996 trusted_roots.push_back(trusted_extra.get());
1001 const auto validation_result =
1004 if(result_code !=
nullptr) {
1005 *result_code =
static_cast<int>(validation_result.result());
1008 if(validation_result.successful_validation()) {
1015 BOTAN_UNUSED(result_code, cert, intermediates, intermediates_len, trusted);
1016 BOTAN_UNUSED(trusted_len, trusted_path, hostname_cstr, reference_time);
1026#if defined(BOTAN_HAS_X509_CERTIFICATES)
1039#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
1042 auto c = std::make_unique<Botan::X509_CRL>(crl_path);
1056#if defined(BOTAN_HAS_X509_CERTIFICATES)
1059 auto c = std::make_unique<Botan::X509_CRL>(bits);
1069#if defined(BOTAN_HAS_X509_CERTIFICATES)
1074 *time_since_epoch = c.this_update().time_since_epoch();
1084#if defined(BOTAN_HAS_X509_CERTIFICATES)
1086 const auto& time = c.next_update();
1087 if(!time.time_is_set()) {
1095 *time_since_epoch = c.next_update().time_since_epoch();
1108 uint64_t issue_time,
1109 uint32_t next_update,
1110 const char* hash_fn,
1111 const char* padding) {
1115#if defined(BOTAN_HAS_X509_CERTIFICATES)
1119 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1120 auto crl = std::make_unique<Botan::X509_CRL>(
1121 ca.new_crl(rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1125 BOTAN_UNUSED(rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update);
1134#if defined(BOTAN_HAS_X509_CERTIFICATES)
1150 uint64_t issue_time,
1151 uint32_t next_update,
1153 size_t new_entries_len,
1154 const char* hash_fn,
1155 const char* padding) {
1162#if defined(BOTAN_HAS_X509_CERTIFICATES)
1166 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1168 std::vector<Botan::CRL_Entry> entries;
1169 entries.reserve(new_entries_len);
1170 for(
size_t i = 0; i < new_entries_len; i++) {
1171 entries.push_back(
safe_get(new_entries[i]));
1174 auto crl = std::make_unique<Botan::X509_CRL>(ca.update_crl(
1175 safe_get(last_crl), entries, rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1180 last_crl, rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update, new_entries, new_entries_len);
1186#if defined(BOTAN_HAS_X509_CERTIFICATES)
1195#if defined(BOTAN_HAS_X509_CERTIFICATES)
1208#if defined(BOTAN_HAS_X509_CERTIFICATES)
1214 const auto view = [=](std::span<const uint8_t> value) ->
int {
1223 switch(value_type) {
1225 if(
const auto& crln =
crl.crl_number_bigint()) {
1227 const size_t view_bytes = std::min<size_t>(crln->bytes(), 4);
1228 return view(crln->serialize<std::vector<uint8_t>>(view_bytes));
1236 return view(
crl.authority_key_id());
1242 return botan_x509_object_view_value(
crl, value_type, index, ctx, view_fn);
1257 BOTAN_UNUSED(crl_obj, value_type, index, ctx, view_fn);
1263#if defined(BOTAN_HAS_X509_CERTIFICATES)
1264 return enumerator_count_values(count, [=](
size_t index) {
1266 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1279#if defined(BOTAN_HAS_X509_CERTIFICATES)
1281 switch(value_type) {
1283 return botan_x509_object_view_value(
crl, value_type, index, ctx, view);
1310#if defined(BOTAN_HAS_X509_CERTIFICATES)
1311 return enumerator_count_values(count, [=](
size_t index) {
1313 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1326#if defined(BOTAN_HAS_X509_CERTIFICATES)
1328 const auto& dn = c.issuer_dn();
1329 const auto& issuer_info = dn.get_attribute(key);
1330 if(index < issuer_info.size()) {
1346#if defined(BOTAN_HAS_X509_CERTIFICATES)
1348 const auto& dn = c.issuer_dn();
1349 *count = dn.get_attribute(key).size();
1360#if defined(BOTAN_HAS_X509_CERTIFICATES)
1370#if defined(BOTAN_HAS_X509_CERTIFICATES)
1373 if(index >= entries.size()) {
1381 return ffi_new_object(entry, std::make_unique<Botan::CRL_Entry>(entries[index]));
1390#if defined(BOTAN_HAS_X509_CERTIFICATES)
1403#if defined(BOTAN_HAS_X509_CERTIFICATES)
1412#if defined(BOTAN_HAS_X509_CERTIFICATES)
1428#if defined(BOTAN_HAS_X509_CERTIFICATES)
1435 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
1444#if defined(BOTAN_HAS_X509_CERTIFICATES)
1454#if defined(BOTAN_HAS_X509_CERTIFICATES)
1472 size_t intermediates_len,
1477 const char* trusted_path,
1478 size_t required_strength,
1479 const char* hostname_cstr,
1480 uint64_t reference_time) {
1481 if(required_strength == 0) {
1482 required_strength = 110;
1485#if defined(BOTAN_HAS_X509_CERTIFICATES)
1487 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
1489 const auto validation_time = reference_time == 0
1490 ? std::chrono::system_clock::now()
1491 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
1493 if(intermediates_len > 0 && intermediates ==
nullptr) {
1496 if(trusted_len > 0 && trusted ==
nullptr) {
1499 if(crls_len > 0 && crls ==
nullptr) {
1503 std::vector<Botan::X509_Certificate> end_certs;
1504 end_certs.push_back(
safe_get(cert));
1505 for(
size_t i = 0; i != intermediates_len; ++i) {
1506 end_certs.push_back(
safe_get(intermediates[i]));
1509 std::unique_ptr<Botan::Certificate_Store> trusted_from_path;
1510 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_extra;
1511 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_crls;
1512 std::vector<Botan::Certificate_Store*> trusted_roots;
1514 if(trusted_path !=
nullptr && *trusted_path != 0) {
1515 trusted_from_path = std::make_unique<Botan::Certificate_Store_In_Memory>(trusted_path);
1516 trusted_roots.push_back(trusted_from_path.get());
1519 if(trusted_len > 0) {
1520 trusted_extra = std::make_unique<Botan::Certificate_Store_In_Memory>();
1521 for(
size_t i = 0; i != trusted_len; ++i) {
1522 trusted_extra->add_certificate(
safe_get(trusted[i]));
1524 trusted_roots.push_back(trusted_extra.get());
1528 trusted_crls = std::make_unique<Botan::Certificate_Store_In_Memory>();
1529 for(
size_t i = 0; i != crls_len; ++i) {
1530 trusted_crls->add_crl(
safe_get(crls[i]));
1532 trusted_roots.push_back(trusted_crls.get());
1537 const auto validation_result =
1540 if(result_code !=
nullptr) {
1541 *result_code =
static_cast<int>(validation_result.result());
1544 if(validation_result.successful_validation()) {
1551 BOTAN_UNUSED(result_code, cert, intermediates, intermediates_len, trusted);
1552 BOTAN_UNUSED(trusted_len, trusted_path, hostname_cstr, reference_time, crls, crls_len);
#define BOTAN_ASSERT_UNREACHABLE()
uint64_t time_since_epoch() const
Return time since epoch.
const std::set< IPv6Address > & ipv6_addresses() const
Return the set of IPv6 addresses included in this alternative name.
const std::set< DNSName > & dns_names() const
Return the set of DNS names included in this alternative name.
const std::set< X509_DN > & directory_names() const
Return the set of directory names included in this alternative name.
const std::set< EmailAddress > & email_addresses() const
Return the set of email addresses included in this alternative name.
const std::set< IPv4Address > & ipv4_addresses() const
Return the set of IPv4 addresses included in this alternative name.
const std::set< URI > & uri_names() const
Return the set of URIs included in this alternative name.
CRL_Code reason_code() const
const X509_Serial_Number & serial() const
const X509_Time & expire_time() const
const std::vector< uint8_t > & serial_number() const
bool extension_set(const OID &oid) const
static GeneralName email(std::string_view email)
static GeneralName ipv4_address(uint32_t ipv4)
static GeneralName _dns_san_value(std::string_view dns)
std::vector< uint8_t > binary_name() const
static GeneralName ipv6_address(const IPv6Address &ipv6)
NameType type_code() const
static GeneralName _uri_san_value(std::string_view full_uri)
static GeneralName directory_name(Botan::X509_DN dn)
const std::vector< GeneralSubtree > & permitted() const
const std::vector< GeneralSubtree > & excluded() const
static OID from_string(std::string_view str)
const std::vector< CRL_Entry > & get_revoked() const
const NameConstraints & name_constraints() const
const std::vector< uint8_t > & serial_number() const
const std::vector< URI > & ocsp_responder_uris() const
const X509_Serial_Number & serial() const
const std::vector< uint8_t > & authority_key_id() const
const AlternativeName & issuer_alt_name() const
const std::vector< uint8_t > & raw_subject_dn() const
const std::vector< uint8_t > & subject_key_id() const
const Extensions & v3_extensions() const
const std::vector< URI > & crl_distribution_point_uris() const
const std::vector< URI > & ca_issuer_uris() const
const std::vector< uint8_t > & raw_issuer_dn() const
const AlternativeName & subject_alt_name() const
const std::vector< uint8_t > & subject_public_key_info() const
struct botan_pubkey_struct * botan_pubkey_t
struct botan_asn1_oid_struct * botan_asn1_oid_t
struct botan_privkey_struct * botan_privkey_t
struct botan_x509_crl_entry_struct * botan_x509_crl_entry_t
struct botan_x509_crl_struct * botan_x509_crl_t
struct botan_x509_general_name_struct * botan_x509_general_name_t
int botan_x509_cert_view_as_string(botan_x509_cert_t cert, botan_view_ctx ctx, botan_view_str_fn view)
int(* botan_view_bin_fn)(botan_view_ctx view_ctx, const uint8_t *data, size_t len)
struct botan_x509_cert_struct * botan_x509_cert_t
@ BOTAN_X509_DIRECTORY_NAME
@ BOTAN_X509_EMAIL_ADDRESS
struct botan_mp_struct * botan_mp_t
struct botan_rng_struct * botan_rng_t
@ BOTAN_FFI_ERROR_NOT_IMPLEMENTED
@ BOTAN_FFI_ERROR_OUT_OF_RANGE
@ BOTAN_FFI_ERROR_NULL_POINTER
@ BOTAN_FFI_ERROR_NO_VALUE
@ BOTAN_FFI_ERROR_INVALID_OBJECT_STATE
@ BOTAN_FFI_ERROR_BAD_PARAMETER
int botan_x509_cert_view_public_key_bits(botan_x509_cert_t cert, botan_view_ctx ctx, botan_view_bin_fn view)
int(* botan_view_str_fn)(botan_view_ctx view_ctx, const char *str, size_t len)
@ BOTAN_X509_AUTHORITY_KEY_IDENTIFIER
@ BOTAN_X509_SUBJECT_KEY_IDENTIFIER
@ BOTAN_X509_TBS_DATA_BITS
@ BOTAN_X509_SIGNATURE_BITS
@ BOTAN_X509_PUBLIC_KEY_PKCS8_BITS
@ BOTAN_X509_DER_ENCODING
@ BOTAN_X509_PEM_ENCODING
@ BOTAN_X509_OCSP_RESPONDER_URLS
@ BOTAN_X509_SIGNATURE_SCHEME_BITS
@ BOTAN_X509_SUBJECT_DN_BITS
@ BOTAN_X509_CRL_DISTRIBUTION_URLS
@ BOTAN_X509_SERIAL_NUMBER
@ BOTAN_X509_ISSUER_DN_BITS
@ BOTAN_X509_CA_ISSUERS_URLS
int botan_x509_cert_get_subject_dn_count(botan_x509_cert_t cert, const char *key, size_t *count)
int botan_x509_is_revoked(botan_x509_crl_t crl, botan_x509_cert_t cert)
int botan_x509_crl_destroy(botan_x509_crl_t crl)
int botan_x509_cert_destroy(botan_x509_cert_t cert)
int botan_x509_cert_load_file(botan_x509_cert_t *cert_obj, const char *cert_path)
int botan_x509_crl_entry_serial_number(botan_x509_crl_entry_t entry, botan_mp_t *serial_number)
int botan_x509_general_name_destroy(botan_x509_general_name_t name)
int botan_x509_cert_dup(botan_x509_cert_t *cert_obj, botan_x509_cert_t cert)
int botan_x509_crl_next_update(botan_x509_crl_t crl, uint64_t *time_since_epoch)
int botan_x509_cert_get_issuer_dn_count(botan_x509_cert_t cert, const char *key, size_t *count)
int botan_x509_crl_entry_destroy(botan_x509_crl_entry_t entry)
int botan_x509_cert_issuer_alternative_names_count(botan_x509_cert_t cert, size_t *count)
int botan_x509_cert_verify_with_crl(int *result_code, botan_x509_cert_t cert, const botan_x509_cert_t *intermediates, size_t intermediates_len, const botan_x509_cert_t *trusted, size_t trusted_len, const botan_x509_crl_t *crls, size_t crls_len, const char *trusted_path, size_t required_strength, const char *hostname_cstr, uint64_t reference_time)
int botan_x509_crl_view_binary_values_count(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t *count)
int botan_x509_general_name_view_binary_value(botan_x509_general_name_t name, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_x509_crl_this_update(botan_x509_crl_t crl, uint64_t *time_since_epoch)
int botan_x509_cert_view_binary_values_count(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t *count)
int botan_x509_crl_view_issuer_dn_count(botan_x509_crl_t crl, const char *key, size_t *count)
int botan_x509_crl_view_binary_values(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_bin_fn view_fn)
int botan_x509_cert_get_public_key(botan_x509_cert_t cert, botan_pubkey_t *key)
int botan_x509_cert_allowed_extended_usage_oid(botan_x509_cert_t cert, botan_asn1_oid_t oid)
int botan_x509_cert_view_binary_values(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_bin_fn view_fn)
const char * botan_x509_cert_validation_status(int code)
int botan_x509_crl_update(botan_x509_crl_t *crl_obj, botan_x509_crl_t last_crl, botan_rng_t rng, botan_x509_cert_t ca_cert, botan_privkey_t ca_key, uint64_t issue_time, uint32_t next_update, const botan_x509_crl_entry_t *new_entries, size_t new_entries_len, const char *hash_fn, const char *padding)
int botan_x509_cert_get_authority_key_id(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
int botan_x509_cert_get_issuer_dn(botan_x509_cert_t cert, const char *key, size_t index, uint8_t out[], size_t *out_len)
int botan_x509_cert_subject_alternative_names_count(botan_x509_cert_t cert, size_t *count)
int botan_x509_cert_excluded_name_constraints(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *constraint)
int botan_x509_crl_entries_count(botan_x509_crl_t crl, size_t *count)
int botan_x509_crl_entries(botan_x509_crl_t crl, size_t index, botan_x509_crl_entry_t *entry)
int botan_x509_cert_subject_alternative_names(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *alt_name)
int botan_x509_crl_entry_revocation_date(botan_x509_crl_entry_t entry, uint64_t *time_since_epoch)
int botan_x509_cert_issuer_alternative_names(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *alt_name)
int botan_x509_cert_serial_number(botan_x509_cert_t cert, botan_mp_t *serial_number)
int botan_x509_cert_get_time_expires(botan_x509_cert_t cert, char out[], size_t *out_len)
int botan_x509_cert_permitted_name_constraints(botan_x509_cert_t cert, size_t index, botan_x509_general_name_t *constraint)
int botan_x509_crl_view_issuer_dn(botan_x509_crl_t crl, const char *key, size_t index, botan_view_ctx ctx, botan_view_str_fn view)
int botan_x509_cert_view_as_string(botan_x509_cert_t cert, botan_view_ctx ctx, botan_view_str_fn view)
int botan_x509_cert_get_time_starts(botan_x509_cert_t cert, char out[], size_t *out_len)
int botan_x509_cert_load(botan_x509_cert_t *cert_obj, const uint8_t cert_bits[], size_t cert_bits_len)
int botan_x509_crl_load(botan_x509_crl_t *crl_obj, const uint8_t crl_bits[], size_t crl_bits_len)
int botan_x509_cert_get_subject_dn(botan_x509_cert_t cert, const char *key, size_t index, uint8_t out[], size_t *out_len)
int botan_x509_cert_not_before(botan_x509_cert_t cert, uint64_t *time_since_epoch)
int botan_x509_crl_entry_view_serial_number(botan_x509_crl_entry_t entry, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_x509_cert_verify(int *result_code, botan_x509_cert_t cert, const botan_x509_cert_t *intermediates, size_t intermediates_len, const botan_x509_cert_t *trusted, size_t trusted_len, const char *trusted_path, size_t required_strength, const char *hostname_cstr, uint64_t reference_time)
int botan_x509_cert_excluded_name_constraints_count(botan_x509_cert_t cert, size_t *count)
int botan_x509_cert_is_ca(botan_x509_cert_t cert)
int botan_x509_cert_hostname_match(botan_x509_cert_t cert, const char *hostname)
int botan_x509_crl_entry_create(botan_x509_crl_entry_t *entry, botan_x509_cert_t cert, int reason_code)
int botan_x509_cert_get_serial_number(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
int botan_x509_cert_get_subject_key_id(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
int botan_x509_crl_create(botan_x509_crl_t *crl_obj, botan_rng_t rng, botan_x509_cert_t ca_cert, botan_privkey_t ca_key, uint64_t issue_time, uint32_t next_update, const char *hash_fn, const char *padding)
int botan_x509_cert_allowed_extended_usage_str(botan_x509_cert_t cert, const char *oid)
int botan_x509_cert_view_public_key_bits(botan_x509_cert_t cert, botan_view_ctx ctx, botan_view_bin_fn view)
int botan_x509_crl_view_string_values(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_str_fn view)
int botan_x509_crl_verify_signature(botan_x509_crl_t crl, botan_pubkey_t key)
int botan_x509_crl_load_file(botan_x509_crl_t *crl_obj, const char *crl_path)
int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage)
int botan_x509_cert_view_string_values_count(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t *count)
int botan_x509_cert_not_after(botan_x509_cert_t cert, uint64_t *time_since_epoch)
int botan_x509_general_name_view_string_value(botan_x509_general_name_t name, botan_view_ctx ctx, botan_view_str_fn view)
int botan_x509_crl_entry_reason(botan_x509_crl_entry_t entry, int *reason_code)
int botan_x509_cert_get_public_key_bits(botan_x509_cert_t cert, uint8_t out[], size_t *out_len)
int botan_x509_cert_get_fingerprint(botan_x509_cert_t cert, const char *hash, uint8_t out[], size_t *out_len)
int botan_x509_cert_get_path_length_constraint(botan_x509_cert_t cert, size_t *path_limit)
int botan_x509_cert_to_string(botan_x509_cert_t cert, char out[], size_t *out_len)
int botan_x509_crl_view_string_values_count(botan_x509_crl_t crl_obj, botan_x509_value_type value_type, size_t *count)
int botan_x509_general_name_get_type(botan_x509_general_name_t name, unsigned int *type)
int botan_x509_cert_permitted_name_constraints_count(botan_x509_cert_t cert, size_t *count)
int botan_x509_cert_view_string_values(botan_x509_cert_t cert, botan_x509_value_type value_type, size_t index, botan_view_ctx ctx, botan_view_str_fn view_fn)
#define BOTAN_FFI_VISIT(obj, lambda)
#define BOTAN_FFI_CHECKED_DELETE(o)
std::vector< uint8_t > put_in_sequence(const std::vector< uint8_t > &contents)
std::vector< uint8_t > BER_encode(const Private_Key &key, RandomNumberGenerator &rng, std::string_view pass, std::chrono::milliseconds msec, std::string_view pbe_algo)
std::string PEM_encode(const Private_Key &key)
int invoke_view_callback(botan_view_bin_fn view, botan_view_ctx ctx, std::span< const uint8_t > buf)
int copy_view_bin(uint8_t out[], size_t *out_len, Fn fn, Args... args)
auto safe_get(T *p) -> typename T::element_type &
BOTAN_FFI_ERROR ffi_new_object(T *obj, Args &&... args)
int copy_view_str(uint8_t out[], size_t *out_len, Fn fn, Args... args)
int ffi_guard_thunk(const char *func_name, T thunk)
int write_vec_output(uint8_t out[], size_t *out_len, std::span< const uint8_t > buf)
int write_str_output(char out[], size_t *out_len, const std::string &str)
Path_Validation_Result x509_path_validate(const std::vector< X509_Certificate > &end_certs, const Path_Validation_Restrictions &restrictions, const std::vector< Certificate_Store * > &trusted_roots, std::string_view hostname, Usage_Type usage, std::chrono::system_clock::time_point ref_time, std::chrono::milliseconds ocsp_timeout, const std::vector< std::optional< OCSP::Response > > &ocsp_resp)
std::string to_string(ErrorType type)
Convert an ErrorType to string.
bool any_null_pointers(Ptrs... ptr)