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);
88size_t count_general_names_in(
const Botan::AlternativeName& alt_names) {
123template <std::invocable<
size_t> EnumeratorT>
124int enumerator_count_values(
size_t* count, EnumeratorT fn) {
131 const auto rc = fn(*count);
147std::chrono::system_clock::time_point timepoint_from_timestamp(uint64_t time_since_epoch) {
148 return std::chrono::system_clock::time_point(std::chrono::seconds(time_since_epoch));
151std::string default_from_ptr(
const char* value) {
153 if(value !=
nullptr) {
170 if(cert_obj ==
nullptr || cert_path ==
nullptr) {
174#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
177 auto c = std::make_unique<Botan::X509_Certificate>(cert_path);
187 if(cert_obj ==
nullptr) {
191#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
194 auto c = std::make_unique<Botan::X509_Certificate>(
safe_get(cert));
205 if(cert_obj ==
nullptr || cert_bits ==
nullptr) {
209#if defined(BOTAN_HAS_X509_CERTIFICATES)
212 auto c = std::make_unique<Botan::X509_Certificate>(bits);
224#if defined(BOTAN_HAS_X509_CERTIFICATES)
236 auto view = [=](
const std::string& value) {
return invoke_view_callback(view_fn, ctx, value); };
256 auto view = [=](std::span<const uint8_t> value) {
return invoke_view_callback(view_fn, ctx, value); };
260 return view(
object.tbs_data());
262 return view(
object.signature_algorithm().
BER_encode());
264 return view(
object.signature());
283#if defined(BOTAN_HAS_X509_CERTIFICATES)
289 auto view = [=](std::span<const uint8_t> value) ->
int {
316 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
334#if defined(BOTAN_HAS_X509_CERTIFICATES)
335 return enumerator_count_values(count, [=](
size_t index) {
337 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
350#if defined(BOTAN_HAS_X509_CERTIFICATES)
351 auto enumerate = [view_fn, ctx](
auto values,
size_t idx) ->
int {
352 if(idx >= values.size()) {
360 const auto* crl_dp_ext =
362 if(crl_dp_ext ==
nullptr) {
367 for(
size_t i = idx;
const auto& dp : dps) {
368 const auto& uris = dp.point().uris();
369 if(i >= uris.size()) {
374 auto itr = uris.begin();
375 std::advance(itr, i);
385 return enumerate_crl_distribution_points(c, index);
387 return enumerate(c.ocsp_responders(), index);
389 return enumerate(c.ca_issuers(), index);
391 return botan_x509_object_view_value(c, value_type, index, ctx, view_fn);
415#if defined(BOTAN_HAS_X509_CERTIFICATES)
416 return enumerator_count_values(count, [=](
size_t index) {
418 cert, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
427#if defined(BOTAN_HAS_X509_CERTIFICATES)
428 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.is_CA_cert() ? 1 : 0; });
436#if defined(BOTAN_HAS_X509_CERTIFICATES)
442 if(
const auto path_len = c.path_length_constraint()) {
443 *path_limit = path_len.value();
462#if defined(BOTAN_HAS_X509_CERTIFICATES)
464 auto public_key =
safe_get(cert).subject_public_key();
474 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
475#if defined(BOTAN_HAS_X509_CERTIFICATES)
477 auto issuer_info = c.issuer_info(key);
478 if(index < issuer_info.size()) {
480 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.issuer_info(key).at(index));
492#if defined(BOTAN_HAS_X509_CERTIFICATES)
498 *count = c.issuer_info(key).size();
508 botan_x509_cert_t cert,
const char* key,
size_t index, uint8_t out[],
size_t* out_len) {
509#if defined(BOTAN_HAS_X509_CERTIFICATES)
511 auto subject_info = c.subject_info(key);
512 if(index < subject_info.size()) {
514 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.subject_info(key).at(index));
526#if defined(BOTAN_HAS_X509_CERTIFICATES)
532 *count = c.subject_info(key).size();
546#if defined(BOTAN_HAS_X509_CERTIFICATES)
555#if defined(BOTAN_HAS_X509_CERTIFICATES)
558 if(c.allowed_usage(k)) {
570#if defined(BOTAN_HAS_X509_CERTIFICATES)
576 return c.has_ex_constraint(oid) ? 1 : 0;
585#if defined(BOTAN_HAS_X509_CERTIFICATES)
586 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) ->
int {
return c.has_ex_constraint(
safe_get(oid)) ? 1 : 0; });
594#if defined(BOTAN_HAS_X509_CERTIFICATES)
603#if defined(BOTAN_HAS_X509_CERTIFICATES)
605 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_before().to_string()); });
613#if defined(BOTAN_HAS_X509_CERTIFICATES)
615 [=](
const auto& c) {
return write_str_output(out, out_len, c.not_after().to_string()); });
623#if defined(BOTAN_HAS_X509_CERTIFICATES)
624 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_before().time_since_epoch(); });
632#if defined(BOTAN_HAS_X509_CERTIFICATES)
633 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *time_since_epoch = c.not_after().time_since_epoch(); });
641#if defined(BOTAN_HAS_X509_CERTIFICATES)
650#if defined(BOTAN_HAS_X509_CERTIFICATES)
657 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
666#if defined(BOTAN_HAS_X509_CERTIFICATES)
670 return write_str_output(
reinterpret_cast<char*
>(out), out_len, c.fingerprint(hash));
679#if defined(BOTAN_HAS_X509_CERTIFICATES)
688#if defined(BOTAN_HAS_X509_CERTIFICATES)
701#if defined(BOTAN_HAS_X509_CERTIFICATES)
711#if defined(BOTAN_HAS_X509_CERTIFICATES)
717 const auto mapped_type = to_botan_x509_general_name_types(n.
type_code());
718 if(!mapped_type.has_value()) {
722 *type = mapped_type.value();
738#if defined(BOTAN_HAS_X509_CERTIFICATES)
740 const auto type = to_botan_x509_general_name_types(n.
type_code());
761#if defined(BOTAN_HAS_X509_CERTIFICATES)
763 const auto type = to_botan_x509_general_name_types(n.
type_code());
781#if defined(BOTAN_HAS_X509_CERTIFICATES)
792#if defined(BOTAN_HAS_X509_CERTIFICATES)
799 if(index >= constraints.size()) {
803 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
812#if defined(BOTAN_HAS_X509_CERTIFICATES)
817 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().permitted().size(); });
827#if defined(BOTAN_HAS_X509_CERTIFICATES)
834 if(index >= constraints.size()) {
838 return ffi_new_object(constraint, std::make_unique<Botan::GeneralName>(constraints[index].base()));
847#if defined(BOTAN_HAS_X509_CERTIFICATES)
852 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) { *count = c.name_constraints().excluded().size(); });
862#if defined(BOTAN_HAS_X509_CERTIFICATES)
873 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(name).value()));
885#if defined(BOTAN_HAS_X509_CERTIFICATES)
901#if defined(BOTAN_HAS_X509_CERTIFICATES)
912 return ffi_new_object(alt_name, std::make_unique<Botan::GeneralName>(std::move(name).value()));
924#if defined(BOTAN_HAS_X509_CERTIFICATES)
938 if(hostname ==
nullptr) {
942#if defined(BOTAN_HAS_X509_CERTIFICATES)
943 return BOTAN_FFI_VISIT(cert, [=](
const auto& c) {
return c.matches_dns_name(hostname) ? 0 : -1; });
953 size_t intermediates_len,
956 const char* trusted_path,
957 size_t required_strength,
958 const char* hostname_cstr,
959 uint64_t reference_time) {
960 if(required_strength == 0) {
961 required_strength = 110;
964#if defined(BOTAN_HAS_X509_CERTIFICATES)
966 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
968 const auto validation_time = reference_time == 0
969 ? std::chrono::system_clock::now()
970 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
972 std::vector<Botan::X509_Certificate> end_certs;
973 end_certs.push_back(
safe_get(cert));
974 for(
size_t i = 0; i != intermediates_len; ++i) {
975 end_certs.push_back(
safe_get(intermediates[i]));
978 std::unique_ptr<Botan::Certificate_Store> trusted_from_path;
979 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_extra;
980 std::vector<Botan::Certificate_Store*> trusted_roots;
982 if(trusted_path !=
nullptr && *trusted_path != 0) {
983 trusted_from_path = std::make_unique<Botan::Certificate_Store_In_Memory>(trusted_path);
984 trusted_roots.push_back(trusted_from_path.get());
987 if(trusted_len > 0) {
988 trusted_extra = std::make_unique<Botan::Certificate_Store_In_Memory>();
989 for(
size_t i = 0; i != trusted_len; ++i) {
990 trusted_extra->add_certificate(
safe_get(trusted[i]));
992 trusted_roots.push_back(trusted_extra.get());
997 auto validation_result =
1000 if(result_code !=
nullptr) {
1001 *result_code =
static_cast<int>(validation_result.result());
1004 if(validation_result.successful_validation()) {
1011 BOTAN_UNUSED(result_code, cert, intermediates, intermediates_len, trusted);
1012 BOTAN_UNUSED(trusted_len, trusted_path, hostname_cstr, reference_time);
1022#if defined(BOTAN_HAS_X509_CERTIFICATES)
1031 if(crl_obj ==
nullptr || crl_path ==
nullptr) {
1035#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
1038 auto c = std::make_unique<Botan::X509_CRL>(crl_path);
1048 if(crl_obj ==
nullptr || crl_bits ==
nullptr) {
1052#if defined(BOTAN_HAS_X509_CERTIFICATES)
1055 auto c = std::make_unique<Botan::X509_CRL>(bits);
1065#if defined(BOTAN_HAS_X509_CERTIFICATES)
1070 *time_since_epoch = c.this_update().time_since_epoch();
1080#if defined(BOTAN_HAS_X509_CERTIFICATES)
1082 const auto& time = c.next_update();
1083 if(!time.time_is_set()) {
1091 *time_since_epoch = c.next_update().time_since_epoch();
1104 uint64_t issue_time,
1105 uint32_t next_update,
1106 const char* hash_fn,
1107 const char* padding) {
1111#if defined(BOTAN_HAS_X509_CERTIFICATES)
1115 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1116 auto crl = std::make_unique<Botan::X509_CRL>(
1117 ca.new_crl(rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1121 BOTAN_UNUSED(rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update);
1130#if defined(BOTAN_HAS_X509_CERTIFICATES)
1146 uint64_t issue_time,
1147 uint32_t next_update,
1149 size_t new_entries_len,
1150 const char* hash_fn,
1151 const char* padding) {
1158#if defined(BOTAN_HAS_X509_CERTIFICATES)
1162 safe_get(ca_cert),
safe_get(ca_key), default_from_ptr(hash_fn), default_from_ptr(padding), rng_);
1164 std::vector<Botan::CRL_Entry> entries;
1165 entries.reserve(new_entries_len);
1166 for(
size_t i = 0; i < new_entries_len; i++) {
1167 entries.push_back(
safe_get(new_entries[i]));
1170 auto crl = std::make_unique<Botan::X509_CRL>(ca.update_crl(
1171 safe_get(last_crl), entries, rng_, timepoint_from_timestamp(issue_time), std::chrono::seconds(next_update)));
1176 last_crl, rng, ca_cert, ca_key, hash_fn, padding, issue_time, next_update, new_entries, new_entries_len);
1182#if defined(BOTAN_HAS_X509_CERTIFICATES)
1191#if defined(BOTAN_HAS_X509_CERTIFICATES)
1204#if defined(BOTAN_HAS_X509_CERTIFICATES)
1210 auto view = [=](std::span<const uint8_t> value) ->
int {
1219 switch(value_type) {
1231 return botan_x509_object_view_value(crl, value_type, index, ctx, view_fn);
1246 BOTAN_UNUSED(crl_obj, value_type, index, ctx, view_fn);
1252#if defined(BOTAN_HAS_X509_CERTIFICATES)
1253 return enumerator_count_values(count, [=](
size_t index) {
1255 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1268#if defined(BOTAN_HAS_X509_CERTIFICATES)
1270 switch(value_type) {
1272 return botan_x509_object_view_value(crl, value_type, index, ctx, view);
1299#if defined(BOTAN_HAS_X509_CERTIFICATES)
1300 return enumerator_count_values(count, [=](
size_t index) {
1302 crl_obj, value_type, index,
nullptr, [](
auto,
auto,
auto) ->
int {
return BOTAN_FFI_SUCCESS; });
1311#if defined(BOTAN_HAS_X509_CERTIFICATES)
1321#if defined(BOTAN_HAS_X509_CERTIFICATES)
1324 if(index >= entries.size()) {
1332 return ffi_new_object(entry, std::make_unique<Botan::CRL_Entry>(entries[index]));
1341#if defined(BOTAN_HAS_X509_CERTIFICATES)
1354#if defined(BOTAN_HAS_X509_CERTIFICATES)
1363#if defined(BOTAN_HAS_X509_CERTIFICATES)
1379#if defined(BOTAN_HAS_X509_CERTIFICATES)
1386 return ffi_new_object(serial_number, std::make_unique<Botan::BigInt>(std::move(serial_bn)));
1395#if defined(BOTAN_HAS_X509_CERTIFICATES)
1405#if defined(BOTAN_HAS_X509_CERTIFICATES)
1423 size_t intermediates_len,
1428 const char* trusted_path,
1429 size_t required_strength,
1430 const char* hostname_cstr,
1431 uint64_t reference_time) {
1432 if(required_strength == 0) {
1433 required_strength = 110;
1436#if defined(BOTAN_HAS_X509_CERTIFICATES)
1438 const std::string hostname((hostname_cstr ==
nullptr) ?
"" : hostname_cstr);
1440 const auto validation_time = reference_time == 0
1441 ? std::chrono::system_clock::now()
1442 : std::chrono::system_clock::from_time_t(
static_cast<time_t
>(reference_time));
1444 std::vector<Botan::X509_Certificate> end_certs;
1445 end_certs.push_back(
safe_get(cert));
1446 for(
size_t i = 0; i != intermediates_len; ++i) {
1447 end_certs.push_back(
safe_get(intermediates[i]));
1450 std::unique_ptr<Botan::Certificate_Store> trusted_from_path;
1451 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_extra;
1452 std::unique_ptr<Botan::Certificate_Store_In_Memory> trusted_crls;
1453 std::vector<Botan::Certificate_Store*> trusted_roots;
1455 if(trusted_path !=
nullptr && *trusted_path != 0) {
1456 trusted_from_path = std::make_unique<Botan::Certificate_Store_In_Memory>(trusted_path);
1457 trusted_roots.push_back(trusted_from_path.get());
1460 if(trusted_len > 0) {
1461 trusted_extra = std::make_unique<Botan::Certificate_Store_In_Memory>();
1462 for(
size_t i = 0; i != trusted_len; ++i) {
1463 trusted_extra->add_certificate(
safe_get(trusted[i]));
1465 trusted_roots.push_back(trusted_extra.get());
1469 trusted_crls = std::make_unique<Botan::Certificate_Store_In_Memory>();
1470 for(
size_t i = 0; i != crls_len; ++i) {
1471 trusted_crls->add_crl(
safe_get(crls[i]));
1473 trusted_roots.push_back(trusted_crls.get());
1478 auto validation_result =
1481 if(result_code !=
nullptr) {
1482 *result_code =
static_cast<int>(validation_result.result());
1485 if(validation_result.successful_validation()) {
1492 BOTAN_UNUSED(result_code, cert, intermediates, intermediates_len, trusted);
1493 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< 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
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)