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>
24 #include <botan/internal/stl_util.h>
27#if defined(BOTAN_HAS_X509_CERTIFICATES)
42std::optional<Botan::GeneralName> extract_general_name_at(
const Botan::AlternativeName& altnames,
size_t index) {
45 std::advance(itr, index);
52 std::advance(itr, index);
59 std::advance(itr, index);
66 std::advance(itr, index);
73 std::advance(itr, index);
80 std::advance(itr, index);
94size_t count_general_names_in(
const Botan::AlternativeName& alt_names) {
130template <std::invocable<
size_t> EnumeratorT>
131int enumerator_count_values(
size_t* count, EnumeratorT fn) {
138 const auto rc = fn(*count);
154std::chrono::system_clock::time_point timepoint_from_timestamp(uint64_t time_since_epoch) {
155 return std::chrono::system_clock::time_point(std::chrono::seconds(time_since_epoch));
158std::string default_from_ptr(
const char* value) {
160 if(value !=
nullptr) {
181#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
184 auto c = std::make_unique<Botan::X509_Certificate>(cert_path);
194 if(cert_obj ==
nullptr) {
198#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
201 auto c = std::make_unique<Botan::X509_Certificate>(
safe_get(cert));
216#if defined(BOTAN_HAS_X509_CERTIFICATES)
219 auto c = std::make_unique<Botan::X509_Certificate>(bits);
231#if defined(BOTAN_HAS_X509_CERTIFICATES)
243 auto view = [=](
const std::string& value) {
return invoke_view_callback(view_fn, ctx, value); };
263 auto view = [=](std::span<const uint8_t> value) {
return invoke_view_callback(view_fn, ctx, value); };
267 return view(
object.tbs_data());
269 return view(
object.signature_algorithm().
BER_encode());
271 return view(
object.signature());
290#if defined(BOTAN_HAS_X509_CERTIFICATES)
296 auto view = [=](std::span<const uint8_t> value) ->
int {
323 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
341#if defined(BOTAN_HAS_X509_CERTIFICATES)
342 return enumerator_count_values(count, [=](
size_t index) {
344 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
357#if defined(BOTAN_HAS_X509_CERTIFICATES)
358 auto enumerate_uris = [view_fn, ctx](
const std::vector<Botan::URI>& values,
size_t idx) ->
int {
359 if(idx >= values.size()) {
375 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
399#if defined(BOTAN_HAS_X509_CERTIFICATES)
400 return enumerator_count_values(count, [=](
size_t index) {
402 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
411#if defined(BOTAN_HAS_X509_CERTIFICATES)
412 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.is_CA_cert() ? 1 : 0; });
420#if defined(BOTAN_HAS_X509_CERTIFICATES)
426 if(
const auto path_len = c.path_length_constraint()) {
427 *path_limit = path_len.value();
446#if defined(BOTAN_HAS_X509_CERTIFICATES)
448 auto public_key =
safe_get(cert).subject_public_key();
458 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
462#if defined(BOTAN_HAS_X509_CERTIFICATES)
464 auto issuer_info = c.issuer_info(key);
465 if(index < issuer_info.size()) {
467 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.issuer_info(key).at(index));
479#if defined(BOTAN_HAS_X509_CERTIFICATES)
485 *count = c.issuer_info(key).size();
495 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
499#if defined(BOTAN_HAS_X509_CERTIFICATES)
501 auto subject_info = c.subject_info(key);
502 if(index < subject_info.size()) {
504 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.subject_info(key).at(index));
516#if defined(BOTAN_HAS_X509_CERTIFICATES)
522 *count = c.subject_info(key).size();
536#if defined(BOTAN_HAS_X509_CERTIFICATES)
545#if defined(BOTAN_HAS_X509_CERTIFICATES)
548 if(c.allowed_usage(k)) {
560#if defined(BOTAN_HAS_X509_CERTIFICATES)
566 return c.has_ex_constraint(oid) ? 1 : 0;
575#if defined(BOTAN_HAS_X509_CERTIFICATES)
576 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) ->
int {
return c.has_ex_constraint(
safe_get(oid)) ? 1 : 0; });
584#if defined(BOTAN_HAS_X509_CERTIFICATES)
593#if defined(BOTAN_HAS_X509_CERTIFICATES)
595 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_before().to_string()); });
603#if defined(BOTAN_HAS_X509_CERTIFICATES)
605 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_after().to_string()); });
613 if(time_since_epoch ==
nullptr) {
616#if defined(BOTAN_HAS_X509_CERTIFICATES)
617 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_before().time_since_epoch(); });
625 if(time_since_epoch ==
nullptr) {
628#if defined(BOTAN_HAS_X509_CERTIFICATES)
629 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_after().time_since_epoch(); });
637#if defined(BOTAN_HAS_X509_CERTIFICATES)
646#if defined(BOTAN_HAS_X509_CERTIFICATES)
653 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
662 if(hash ==
nullptr) {
665#if defined(BOTAN_HAS_X509_CERTIFICATES)
669 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.fingerprint(hash));
678#if defined(BOTAN_HAS_X509_CERTIFICATES)
687#if defined(BOTAN_HAS_X509_CERTIFICATES)
700#if defined(BOTAN_HAS_X509_CERTIFICATES)
710#if defined(BOTAN_HAS_X509_CERTIFICATES)
716 const auto mapped_type = to_botan_x509_general_name_types(n.
type_code());
717 if(!mapped_type.has_value()) {
721 *type = mapped_type.value();
737#if defined(BOTAN_HAS_X509_CERTIFICATES)
739 const auto type = to_botan_x509_general_name_types(n.
type_code());
760#if defined(BOTAN_HAS_X509_CERTIFICATES)
762 const auto type = to_botan_x509_general_name_types(n.
type_code());
780#if defined(BOTAN_HAS_X509_CERTIFICATES)
791#if defined(BOTAN_HAS_X509_CERTIFICATES)
798 if(index >= constraints.size()) {
802 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
811#if defined(BOTAN_HAS_X509_CERTIFICATES)
816 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().permitted().size(); });
826#if defined(BOTAN_HAS_X509_CERTIFICATES)
833 if(index >= constraints.size()) {
837 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
846#if defined(BOTAN_HAS_X509_CERTIFICATES)
851 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().excluded().size(); });
861#if defined(BOTAN_HAS_X509_CERTIFICATES)
872 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(name).value()));
884#if defined(BOTAN_HAS_X509_CERTIFICATES)
900#if defined(BOTAN_HAS_X509_CERTIFICATES)
911 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(name).value()));
923#if defined(BOTAN_HAS_X509_CERTIFICATES)
937 if(hostname ==
nullptr) {
941#if defined(BOTAN_HAS_X509_CERTIFICATES)
942 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.matches_dns_name(hostname) ? 0 : -1; });
952 size_t intermediates_len,
955 const char* trusted_path,
956 size_t required_strength,
957 const char* hostname_cstr,
958 uint64_t reference_time) {
959 if(required_strength == 0) {
960 required_strength = 110;
963#if defined(BOTAN_HAS_X509_CERTIFICATES)
965 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
967 const auto validation_time = reference_time == 0
968 ? std::chrono::system_clock::now()
969 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
971 if(intermediates_len > 0 && intermediates ==
nullptr) {
974 if(trusted_len > 0 && trusted ==
nullptr) {
978 std::vector<Botan::X509_Certificate> end_certs;
979 end_certs.push_back(
safe_get(cert));
980 for(
size_t i = 0; i != intermediates_len; ++i) {
981 end_certs.push_back(
safe_get(intermediates[i]));
984 std::unique_ptr<Botan::Certificate_Store> trusted_from_path;
985 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_extra;
986 std::vector<Botan::Certificate_Store*> trusted_roots;
988 if(trusted_path !=
nullptr && *trusted_path != 0) {
989 trusted_from_path = std::make_unique<Botan::Certificate_Store_In_Memory>(trusted_path);
990 trusted_roots.push_back(trusted_from_path.get());
993 if(trusted_len > 0) {
994 trusted_extra = std::make_unique<Botan::Certificate_Store_In_Memory>();
995 for(
size_t i = 0; i != trusted_len; ++i) {
996 trusted_extra->add_certificate(
safe_get(trusted[i]));
998 trusted_roots.push_back(trusted_extra.get());
1003 auto validation_result =
1006 if(result_code !=
nullptr) {
1007 *result_code =
static_cast<int>(validation_result.result());
1010 if(validation_result.successful_validation()) {
1017 BOTAN_UNUSED(result_code, cert, intermediates, intermediates_len, trusted);
1018 BOTAN_UNUSED(trusted_len, trusted_path, hostname_cstr, reference_time);
1028#if defined(BOTAN_HAS_X509_CERTIFICATES)
1041#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
1044 auto c = std::make_unique<Botan::X509_CRL>(crl_path);
1058#if defined(BOTAN_HAS_X509_CERTIFICATES)
1061 auto c = std::make_unique<Botan::X509_CRL>(bits);
1071#if defined(BOTAN_HAS_X509_CERTIFICATES)
1076 *time_since_epoch = c.this_update().time_since_epoch();
1086#if defined(BOTAN_HAS_X509_CERTIFICATES)
1088 const auto& time = c.next_update();
1089 if(!time.time_is_set()) {
1097 *time_since_epoch = c.next_update().time_since_epoch();
1110 uint64_t issue_time,
1111 uint32_t next_update,
1112 const char* hash_fn,
1113 const char* padding) {
1117#if defined(BOTAN_HAS_X509_CERTIFICATES)
1121 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1122 auto crl = std::make_unique<Botan::X509_CRL>(
1123 ca.new_crl(rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1127 BOTAN_UNUSED(rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update);
1136#if defined(BOTAN_HAS_X509_CERTIFICATES)
1152 uint64_t issue_time,
1153 uint32_t next_update,
1155 size_t new_entries_len,
1156 const char* hash_fn,
1157 const char* padding) {
1164#if defined(BOTAN_HAS_X509_CERTIFICATES)
1168 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1170 std::vector<Botan::CRL_Entry> entries;
1171 entries.reserve(new_entries_len);
1172 for(
size_t i = 0; i < new_entries_len; i++) {
1173 entries.push_back(
safe_get(new_entries[i]));
1176 auto crl = std::make_unique<Botan::X509_CRL>(ca.update_crl(
1177 safe_get(last_crl), entries, rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1182 last_crl, rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update, new_entries, new_entries_len);
1188#if defined(BOTAN_HAS_X509_CERTIFICATES)
1197#if defined(BOTAN_HAS_X509_CERTIFICATES)
1210#if defined(BOTAN_HAS_X509_CERTIFICATES)
1216 auto view = [=](std::span<const uint8_t> value) ->
int {
1225 switch(value_type) {
1229 const size_t view_bytes = std::min<size_t>(crln->bytes(), 4);
1230 return view(crln->serialize<std::vector<uint8_t>>(view_bytes));
1244 return botan_x509_object_view_value(crl, value_type, index, ctx, view_fn);
1259 BOTAN_UNUSED(crl_obj, value_type, index, ctx, view_fn);
1265#if defined(BOTAN_HAS_X509_CERTIFICATES)
1266 return enumerator_count_values(count, [=](
size_t index) {
1268 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1281#if defined(BOTAN_HAS_X509_CERTIFICATES)
1283 switch(value_type) {
1285 return botan_x509_object_view_value(crl, value_type, index, ctx, view);
1312#if defined(BOTAN_HAS_X509_CERTIFICATES)
1313 return enumerator_count_values(count, [=](
size_t index) {
1315 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1324#if defined(BOTAN_HAS_X509_CERTIFICATES)
1334#if defined(BOTAN_HAS_X509_CERTIFICATES)
1337 if(index >= entries.size()) {
1345 return ffi_new_object(entry, std::make_unique<Botan::CRL_Entry>(entries[index]));
1354#if defined(BOTAN_HAS_X509_CERTIFICATES)
1367#if defined(BOTAN_HAS_X509_CERTIFICATES)
1376#if defined(BOTAN_HAS_X509_CERTIFICATES)
1392#if defined(BOTAN_HAS_X509_CERTIFICATES)
1399 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
1408#if defined(BOTAN_HAS_X509_CERTIFICATES)
1418#if defined(BOTAN_HAS_X509_CERTIFICATES)
1436 size_t intermediates_len,
1441 const char* trusted_path,
1442 size_t required_strength,
1443 const char* hostname_cstr,
1444 uint64_t reference_time) {
1445 if(required_strength == 0) {
1446 required_strength = 110;
1449#if defined(BOTAN_HAS_X509_CERTIFICATES)
1451 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
1453 const auto validation_time = reference_time == 0
1454 ? std::chrono::system_clock::now()
1455 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
1457 if(intermediates_len > 0 && intermediates ==
nullptr) {
1460 if(trusted_len > 0 && trusted ==
nullptr) {
1463 if(crls_len > 0 && crls ==
nullptr) {
1467 std::vector<Botan::X509_Certificate> end_certs;
1468 end_certs.push_back(
safe_get(cert));
1469 for(
size_t i = 0; i != intermediates_len; ++i) {
1470 end_certs.push_back(
safe_get(intermediates[i]));
1473 std::unique_ptr<Botan::Certificate_Store> trusted_from_path;
1474 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_extra;
1475 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_crls;
1476 std::vector<Botan::Certificate_Store*> trusted_roots;
1478 if(trusted_path !=
nullptr && *trusted_path != 0) {
1479 trusted_from_path = std::make_unique<Botan::Certificate_Store_In_Memory>(trusted_path);
1480 trusted_roots.push_back(trusted_from_path.get());
1483 if(trusted_len > 0) {
1484 trusted_extra = std::make_unique<Botan::Certificate_Store_In_Memory>();
1485 for(
size_t i = 0; i != trusted_len; ++i) {
1486 trusted_extra->add_certificate(
safe_get(trusted[i]));
1488 trusted_roots.push_back(trusted_extra.get());
1492 trusted_crls = std::make_unique<Botan::Certificate_Store_In_Memory>();
1493 for(
size_t i = 0; i != crls_len; ++i) {
1494 trusted_crls->add_crl(
safe_get(crls[i]));
1496 trusted_roots.push_back(trusted_crls.get());
1501 auto validation_result =
1504 if(result_code !=
nullptr) {
1505 *result_code =
static_cast<int>(validation_result.result());
1508 if(validation_result.successful_validation()) {
1515 BOTAN_UNUSED(result_code, cert, intermediates, intermediates_len, trusted);
1516 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 std::vector< uint8_t > & authority_key_id() const
const X509_DN & issuer_dn() const
const std::optional< BigInt > & crl_number_bigint() 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
const std::vector< uint8_t > & get_bits() 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_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_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)
T & safe_get(botan_struct< T, M > *p)
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)