Skip to content

Commit a7a05dc

Browse files
committed
Add getters for RFC 3779 extensions to FFI
1 parent 70da513 commit a7a05dc

6 files changed

Lines changed: 632 additions & 0 deletions

File tree

src/lib/ffi/ffi.h

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,103 @@ int botan_x509_cert_verify(int* validation_result,
25382538
*/
25392539
BOTAN_FFI_EXPORT(2, 8) const char* botan_x509_cert_validation_status(int code);
25402540

2541+
/*
2542+
* X.509 Extensions
2543+
*/
2544+
2545+
typedef struct botan_x509_ext_ip_addr_blocks_struct* botan_x509_ext_ip_addr_blocks_t;
2546+
2547+
BOTAN_FFI_EXPORT(3, 12)
2548+
int botan_x509_ext_ip_addr_blocks_destroy(botan_x509_ext_ip_addr_blocks_t ip_addr_blocks);
2549+
2550+
/**
2551+
* Get the IP Address Blocks extension from a certificate
2552+
* @returns 0 on success, a negative number on error, e.g. when the certificate does not contain the extension
2553+
*/
2554+
BOTAN_FFI_EXPORT(3, 12)
2555+
int botan_x509_ext_ip_addr_blocks_create_from_cert(botan_x509_ext_ip_addr_blocks_t* ip_addr_blocks,
2556+
botan_x509_cert_t cert);
2557+
2558+
/**
2559+
* Get info about the IP Address Blocks extension
2560+
* @param v4_count is set to the number of v4 families contained in the extension
2561+
* @param v6_count is set to the number of v6 families
2562+
*/
2563+
BOTAN_FFI_EXPORT(3, 12)
2564+
int botan_x509_ext_ip_addr_blocks_get_counts(botan_x509_ext_ip_addr_blocks_t ip_addr_blocks,
2565+
size_t* v4_count,
2566+
size_t* v6_count);
2567+
2568+
/**
2569+
* Get info about a specific family in the extension
2570+
* @param ipv6 must be set to 1 if the family is an IPv6 family, 0 for IPv4 families
2571+
* @param i is the index of the family
2572+
* @param has_safi will be set to one if the family has an associated SAFI
2573+
* @param safi will be set to the families' SAFI, if it has one
2574+
* @param present is set to 1 if the family contains values (ranges), 0 if it is marked as "inherit"
2575+
* @param count is set to the number of values (ranges), if they were present
2576+
* @returns 0 on success, negative number on error,
2577+
*/
2578+
BOTAN_FFI_EXPORT(3, 12)
2579+
int botan_x509_ext_ip_addr_blocks_get_family(botan_x509_ext_ip_addr_blocks_t ip_addr_blocks,
2580+
int ipv6,
2581+
size_t i,
2582+
int* has_safi,
2583+
uint8_t* safi,
2584+
int* present,
2585+
size_t* count);
2586+
2587+
/**
2588+
* Get info about a specific range in the extension
2589+
* @param ipv6 must be set to 1 if the family is an IPv6 family, 0 for IPv4 families
2590+
* @param i is the index of the family
2591+
* @param entry is the index of the range
2592+
* @param min_out is set to the lower address of the range
2593+
* @param max_out is set to the upper address of the range
2594+
* @param out_len is set to the length of the addresses (4 for IPv4, 16 for IPv6)
2595+
*/
2596+
BOTAN_FFI_EXPORT(3, 12)
2597+
int botan_x509_ext_ip_addr_blocks_get_address(botan_x509_ext_ip_addr_blocks_t ip_addr_blocks,
2598+
int ipv6,
2599+
size_t i,
2600+
size_t entry,
2601+
uint8_t min_out[],
2602+
uint8_t max_out[],
2603+
size_t* out_len);
2604+
2605+
typedef struct botan_x509_ext_as_blocks_struct* botan_x509_ext_as_blocks_t;
2606+
2607+
BOTAN_FFI_EXPORT(3, 12)
2608+
int botan_x509_ext_as_blocks_destroy(botan_x509_ext_as_blocks_t as_blocks);
2609+
2610+
/**
2611+
* Get the AS Blocks extension from a certificate
2612+
* @returns 0 on success, a negative number on error, e.g. when the certificate does not contain the extension
2613+
*/
2614+
BOTAN_FFI_EXPORT(3, 12)
2615+
int botan_x509_ext_as_blocks_create_from_cert(botan_x509_ext_as_blocks_t* as_blocks, botan_x509_cert_t cert);
2616+
2617+
/**
2618+
* Get basic info about the AS Blocks extension
2619+
* @param asnum must be set to 1 to get info about AS numbers, 0 for RDIs (the type)
2620+
* @param present is set to 1 if the extension contains entries for the type, 0 if it is marked as "inherit"
2621+
* @param count is set to number of entries for this type, if it was present
2622+
* @returns 0 on success, negative number on error. If the type is not present at all, return `BOTAN_FFI_ERROR_NO_VALUE`.
2623+
*/
2624+
BOTAN_FFI_EXPORT(3, 12)
2625+
int botan_x509_ext_as_blocks_get_info(botan_x509_ext_as_blocks_t as_blocks, int asnum, int* present, size_t* count);
2626+
2627+
/**
2628+
* Get a specific entry from the extension
2629+
* @param asnum Set to 1 to get info about AS numbers, 0 for RDIs (the type)
2630+
* @param i The index of the entry to get
2631+
* @param min is set to the min value of the range
2632+
* @param max is set to the max value of the range
2633+
*/
2634+
BOTAN_FFI_EXPORT(3, 12)
2635+
int botan_x509_ext_as_blocks_get_entry_at(
2636+
botan_x509_ext_as_blocks_t as_blocks, int asnum, size_t i, uint32_t* min, uint32_t* max);
2637+
25412638
/*
25422639
* X.509 CRL
25432640
**************************/

0 commit comments

Comments
 (0)