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/loadstor.h>
25 #include <botan/internal/stl_util.h>
28#if defined(BOTAN_HAS_X509_CERTIFICATES)
43std::optional<Botan::GeneralName> extract_general_name_at(
const Botan::AlternativeName& altnames,
size_t index) {
44 if(index < altnames.
email().size()) {
45 auto itr = altnames.
email().begin();
46 std::advance(itr, index);
49 index -= altnames.
email().size();
51 if(index < altnames.
dns().size()) {
52 auto itr = altnames.
dns().begin();
53 std::advance(itr, index);
56 index -= altnames.
dns().size();
60 std::advance(itr, index);
65 if(index < altnames.
uris().size()) {
66 auto itr = altnames.
uris().begin();
67 std::advance(itr, index);
70 index -= altnames.
uris().size();
74 std::advance(itr, index);
81 std::advance(itr, index);
95size_t count_general_names_in(
const Botan::AlternativeName& alt_names) {
131template <std::invocable<
size_t> EnumeratorT>
132int enumerator_count_values(
size_t* count, EnumeratorT fn) {
139 const auto rc = fn(*count);
155std::chrono::system_clock::time_point timepoint_from_timestamp(uint64_t time_since_epoch) {
156 return std::chrono::system_clock::time_point(std::chrono::seconds(time_since_epoch));
159std::string default_from_ptr(
const char* value) {
161 if(value !=
nullptr) {
178 if(cert_obj ==
nullptr || cert_path ==
nullptr) {
182#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
185 auto c = std::make_unique<Botan::X509_Certificate>(cert_path);
195 if(cert_obj ==
nullptr) {
199#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
202 auto c = std::make_unique<Botan::X509_Certificate>(
safe_get(cert));
213 if(cert_obj ==
nullptr || cert_bits ==
nullptr) {
217#if defined(BOTAN_HAS_X509_CERTIFICATES)
220 auto c = std::make_unique<Botan::X509_Certificate>(bits);
232#if defined(BOTAN_HAS_X509_CERTIFICATES)
244 auto view = [=](
const std::string& value) {
return invoke_view_callback(view_fn, ctx, value); };
264 auto view = [=](std::span<const uint8_t> value) {
return invoke_view_callback(view_fn, ctx, value); };
268 return view(
object.tbs_data());
270 return view(
object.signature_algorithm().
BER_encode());
272 return view(
object.signature());
291#if defined(BOTAN_HAS_X509_CERTIFICATES)
297 auto view = [=](std::span<const uint8_t> value) ->
int {
324 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
342#if defined(BOTAN_HAS_X509_CERTIFICATES)
343 return enumerator_count_values(count, [=](
size_t index) {
345 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
358#if defined(BOTAN_HAS_X509_CERTIFICATES)
359 auto enumerate = [view_fn, ctx](
auto values,
size_t idx) ->
int {
360 if(idx >= values.size()) {
368 const auto* crl_dp_ext =
370 if(crl_dp_ext ==
nullptr) {
375 for(
size_t i = idx;
const auto& dp : dps) {
376 const auto& uris = dp.point().uris();
377 if(i >= uris.size()) {
382 auto itr = uris.begin();
383 std::advance(itr, i);
393 return enumerate_crl_distribution_points(c, index);
395 return enumerate(c.ocsp_responders(), index);
397 return enumerate(c.ca_issuers(), index);
399 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
423#if defined(BOTAN_HAS_X509_CERTIFICATES)
424 return enumerator_count_values(count, [=](
size_t index) {
426 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
435#if defined(BOTAN_HAS_X509_CERTIFICATES)
436 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.is_CA_cert() ? 1 : 0; });
444#if defined(BOTAN_HAS_X509_CERTIFICATES)
450 if(
const auto path_len = c.path_length_constraint()) {
451 *path_limit = path_len.value();
470#if defined(BOTAN_HAS_X509_CERTIFICATES)
472 auto public_key =
safe_get(cert).subject_public_key();
482 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
486#if defined(BOTAN_HAS_X509_CERTIFICATES)
488 auto issuer_info = c.issuer_info(key);
489 if(index < issuer_info.size()) {
491 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.issuer_info(key).at(index));
503#if defined(BOTAN_HAS_X509_CERTIFICATES)
509 *count = c.issuer_info(key).size();
519 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
523#if defined(BOTAN_HAS_X509_CERTIFICATES)
525 auto subject_info = c.subject_info(key);
526 if(index < subject_info.size()) {
528 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.subject_info(key).at(index));
540#if defined(BOTAN_HAS_X509_CERTIFICATES)
546 *count = c.subject_info(key).size();
560#if defined(BOTAN_HAS_X509_CERTIFICATES)
569#if defined(BOTAN_HAS_X509_CERTIFICATES)
572 if(c.allowed_usage(k)) {
584#if defined(BOTAN_HAS_X509_CERTIFICATES)
590 return c.has_ex_constraint(oid) ? 1 : 0;
599#if defined(BOTAN_HAS_X509_CERTIFICATES)
600 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) ->
int {
return c.has_ex_constraint(
safe_get(oid)) ? 1 : 0; });
608#if defined(BOTAN_HAS_X509_CERTIFICATES)
617#if defined(BOTAN_HAS_X509_CERTIFICATES)
619 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_before().to_string()); });
627#if defined(BOTAN_HAS_X509_CERTIFICATES)
629 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_after().to_string()); });
637 if(time_since_epoch ==
nullptr) {
640#if defined(BOTAN_HAS_X509_CERTIFICATES)
641 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_before().time_since_epoch(); });
649 if(time_since_epoch ==
nullptr) {
652#if defined(BOTAN_HAS_X509_CERTIFICATES)
653 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_after().time_since_epoch(); });
661#if defined(BOTAN_HAS_X509_CERTIFICATES)
670#if defined(BOTAN_HAS_X509_CERTIFICATES)
677 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
686 if(hash ==
nullptr) {
689#if defined(BOTAN_HAS_X509_CERTIFICATES)
693 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.fingerprint(hash));
702#if defined(BOTAN_HAS_X509_CERTIFICATES)
711#if defined(BOTAN_HAS_X509_CERTIFICATES)
724#if defined(BOTAN_HAS_X509_CERTIFICATES)
734#if defined(BOTAN_HAS_X509_CERTIFICATES)
740 const auto mapped_type = to_botan_x509_general_name_types(n.
type_code());
741 if(!mapped_type.has_value()) {
745 *type = mapped_type.value();
761#if defined(BOTAN_HAS_X509_CERTIFICATES)
763 const auto type = to_botan_x509_general_name_types(n.
type_code());
784#if defined(BOTAN_HAS_X509_CERTIFICATES)
786 const auto type = to_botan_x509_general_name_types(n.
type_code());
804#if defined(BOTAN_HAS_X509_CERTIFICATES)
815#if defined(BOTAN_HAS_X509_CERTIFICATES)
822 if(index >= constraints.size()) {
826 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
835#if defined(BOTAN_HAS_X509_CERTIFICATES)
840 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().permitted().size(); });
850#if defined(BOTAN_HAS_X509_CERTIFICATES)
857 if(index >= constraints.size()) {
861 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
870#if defined(BOTAN_HAS_X509_CERTIFICATES)
875 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().excluded().size(); });
885#if defined(BOTAN_HAS_X509_CERTIFICATES)
896 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(name).value()));
908#if defined(BOTAN_HAS_X509_CERTIFICATES)
924#if defined(BOTAN_HAS_X509_CERTIFICATES)
935 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(name).value()));
947#if defined(BOTAN_HAS_X509_CERTIFICATES)
961 if(hostname ==
nullptr) {
965#if defined(BOTAN_HAS_X509_CERTIFICATES)
966 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.matches_dns_name(hostname) ? 0 : -1; });
976 size_t intermediates_len,
979 const char* trusted_path,
980 size_t required_strength,
981 const char* hostname_cstr,
982 uint64_t reference_time) {
983 if(required_strength == 0) {
984 required_strength = 110;
987#if defined(BOTAN_HAS_X509_CERTIFICATES)
989 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
991 const auto validation_time = reference_time == 0
992 ? std::chrono::system_clock::now()
993 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
995 std::vector<Botan::X509_Certificate> end_certs;
996 end_certs.push_back(
safe_get(cert));
997 for(
size_t i = 0; i != intermediates_len; ++i) {
998 end_certs.push_back(
safe_get(intermediates[i]));
1001 std::unique_ptr<Botan::Certificate_Store> trusted_from_path;
1002 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_extra;
1003 std::vector<Botan::Certificate_Store*> trusted_roots;
1005 if(trusted_path !=
nullptr && *trusted_path != 0) {
1006 trusted_from_path = std::make_unique<Botan::Certificate_Store_In_Memory>(trusted_path);
1007 trusted_roots.push_back(trusted_from_path.get());
1010 if(trusted_len > 0) {
1011 trusted_extra = std::make_unique<Botan::Certificate_Store_In_Memory>();
1012 for(
size_t i = 0; i != trusted_len; ++i) {
1013 trusted_extra->add_certificate(
safe_get(trusted[i]));
1015 trusted_roots.push_back(trusted_extra.get());
1020 auto validation_result =
1023 if(result_code !=
nullptr) {
1024 *result_code =
static_cast<int>(validation_result.result());
1027 if(validation_result.successful_validation()) {
1034 BOTAN_UNUSED(result_code, cert, intermediates, intermediates_len, trusted);
1035 BOTAN_UNUSED(trusted_len, trusted_path, hostname_cstr, reference_time);
1045#if defined(BOTAN_HAS_X509_CERTIFICATES)
1054 if(crl_obj ==
nullptr || crl_path ==
nullptr) {
1058#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
1061 auto c = std::make_unique<Botan::X509_CRL>(crl_path);
1071 if(crl_obj ==
nullptr || crl_bits ==
nullptr) {
1075#if defined(BOTAN_HAS_X509_CERTIFICATES)
1078 auto c = std::make_unique<Botan::X509_CRL>(bits);
1088#if defined(BOTAN_HAS_X509_CERTIFICATES)
1093 *time_since_epoch = c.this_update().time_since_epoch();
1103#if defined(BOTAN_HAS_X509_CERTIFICATES)
1105 const auto& time = c.next_update();
1106 if(!time.time_is_set()) {
1114 *time_since_epoch = c.next_update().time_since_epoch();
1127 uint64_t issue_time,
1128 uint32_t next_update,
1129 const char* hash_fn,
1130 const char* padding) {
1134#if defined(BOTAN_HAS_X509_CERTIFICATES)
1138 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1139 auto crl = std::make_unique<Botan::X509_CRL>(
1140 ca.new_crl(rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1144 BOTAN_UNUSED(rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update);
1153#if defined(BOTAN_HAS_X509_CERTIFICATES)
1169 uint64_t issue_time,
1170 uint32_t next_update,
1172 size_t new_entries_len,
1173 const char* hash_fn,
1174 const char* padding) {
1181#if defined(BOTAN_HAS_X509_CERTIFICATES)
1185 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1187 std::vector<Botan::CRL_Entry> entries;
1188 entries.reserve(new_entries_len);
1189 for(
size_t i = 0; i < new_entries_len; i++) {
1190 entries.push_back(
safe_get(new_entries[i]));
1193 auto crl = std::make_unique<Botan::X509_CRL>(ca.update_crl(
1194 safe_get(last_crl), entries, rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1199 last_crl, rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update, new_entries, new_entries_len);
1205#if defined(BOTAN_HAS_X509_CERTIFICATES)
1214#if defined(BOTAN_HAS_X509_CERTIFICATES)
1227#if defined(BOTAN_HAS_X509_CERTIFICATES)
1233 auto view = [=](std::span<const uint8_t> value) ->
int {
1242 switch(value_type) {
1254 return botan_x509_object_view_value(crl, value_type, index, ctx, view_fn);
1269 BOTAN_UNUSED(crl_obj, value_type, index, ctx, view_fn);
1275#if defined(BOTAN_HAS_X509_CERTIFICATES)
1276 return enumerator_count_values(count, [=](
size_t index) {
1278 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1291#if defined(BOTAN_HAS_X509_CERTIFICATES)
1293 switch(value_type) {
1295 return botan_x509_object_view_value(crl, value_type, index, ctx, view);
1322#if defined(BOTAN_HAS_X509_CERTIFICATES)
1323 return enumerator_count_values(count, [=](
size_t index) {
1325 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1334#if defined(BOTAN_HAS_X509_CERTIFICATES)
1344#if defined(BOTAN_HAS_X509_CERTIFICATES)
1347 if(index >= entries.size()) {
1355 return ffi_new_object(entry, std::make_unique<Botan::CRL_Entry>(entries[index]));
1364#if defined(BOTAN_HAS_X509_CERTIFICATES)
1377#if defined(BOTAN_HAS_X509_CERTIFICATES)
1386#if defined(BOTAN_HAS_X509_CERTIFICATES)
1402#if defined(BOTAN_HAS_X509_CERTIFICATES)
1409 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
1418#if defined(BOTAN_HAS_X509_CERTIFICATES)
1428#if defined(BOTAN_HAS_X509_CERTIFICATES)
1446 size_t intermediates_len,
1451 const char* trusted_path,
1452 size_t required_strength,
1453 const char* hostname_cstr,
1454 uint64_t reference_time) {
1455 if(required_strength == 0) {
1456 required_strength = 110;
1459#if defined(BOTAN_HAS_X509_CERTIFICATES)
1461 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
1463 const auto validation_time = reference_time == 0
1464 ? std::chrono::system_clock::now()
1465 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
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< X509_DN > & directory_names() const
Return the set of directory names included in this alternative name.
const std::set< uint32_t > & ipv4_address() const
Return the set of IPv4 addresses included in this alternative name.
const std::set< std::string > & uris() const
Return the set of URIs included in this alternative name.
const std::set< std::string > & dns() const
Return the set of DNS names included in this alternative name.
const std::set< IPv6Address > & ipv6_address() const
Return the set of IPv6 addresses included in this alternative name.
const std::set< std::string > & email() const
Return the set of email addresses included in this alternative name.
static BigInt from_bytes(std::span< const uint8_t > bytes)
CRL_Code reason_code() const
const X509_Time & expire_time() const
const std::vector< uint8_t > & serial_number() const
const std::vector< Distribution_Point > & distribution_points() const
bool extension_set(const OID &oid) const
static GeneralName email(std::string_view email)
static GeneralName ipv4_address(uint32_t ipv4)
static GeneralName uri(std::string_view uri)
std::vector< uint8_t > binary_name() const
static GeneralName ipv6_address(const IPv6Address &ipv6)
NameType type_code() const
static GeneralName dns(std::string_view dns)
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
uint32_t crl_number() const
const X509_DN & issuer_dn() const
const NameConstraints & name_constraints() const
const std::vector< uint8_t > & serial_number() 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< 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.
constexpr auto store_be(ParamTs &&... params)
bool any_null_pointers(Ptrs... ptr)