Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions doc/api_ref/ffi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,79 @@ X.509 Certificates
Return a (statically allocated) string associated with the verification
result, or NULL if the code is not known.

.. cpp:function:: int botan_x509_ext_ip_addr_blocks_get_counts(botan_x509_cert_t cert, \
size_t* v4_count, \
size_t* v6_count)

Get info about the IP Address Blocks extension from `RFC 3779 <https://www.rfc-editor.org/rfc/rfc3779>`_.
``v4_count`` is set to the number of v4 families contained in the extension,
``v6_count`` to the number of v6 families. If the extension is not present, :cpp:enumerator:`BOTAN_FFI_ERROR_NO_VALUE` is returned.

If the extension is not present or an error occurs, ``v4_count`` and ``v6_count`` are not modified.

.. cpp:function:: int botan_x509_ext_ip_addr_blocks_get_family(botan_x509_cert_t cert, \
int ipv6, \
size_t i, \
int* has_safi, \
uint8_t* safi, \
int* present, \
size_t* count)

Get info about a specific family in the extension.
``ipv6`` should be set to 0 for v4 families, 1 for v6 families.
``i`` is the local index for each family type, the first v4 family is at (``i = 0``, ``ipv6 = 0``), the first v6 family is at (``i = 0``, ``ipv6 = 1``).
The number of v4 / v6 families corresponds to the ``v4_count`` / ``v6_count`` values obtained from :cpp:func:`botan_x509_ext_ip_addr_blocks_get_counts`.
``has_safi`` is set to 1 if the family has an associated SAFI, else 0.
``safi`` contains the SAFI if the family has one, otherwise its value is not modified.
``present`` is set to 1 if the family has range values, 0 if it is marked as "inherit".
``count`` is set to the number of ranges contained if any, otherwise its value is not modified.

The output parameters ``has_safi``, ``safi``, ``present`` and ``count`` may be modified even if the extension is not present or some other error occurs.
In this event, the value of each output parameter after the call returns is undefined.

.. cpp:function:: int botan_x509_ext_ip_addr_blocks_get_address(botan_x509_cert_t cert, \
int ipv6, \
size_t i, \
size_t entry, \
uint8_t min_out[], \
uint8_t max_out[], \
size_t* out_len)

Get info about a specific range in the extension.
``ipv6`` and ``i`` behave as in :cpp:func:`botan_x509_ext_ip_addr_blocks_get_family`.
``entry`` is the index to the range in the family, between 0 and (not including) ``count``.
``min_out`` and ``max_out`` are set to the min and max addresses of the range respectively.
``out_len`` should be set to 4 for v4 families, 16 for v6 families, the two arrays must also be that size.

The output parameters ``min_out``, ``max_out`` and ``out_len`` may be modified even if the extension is not present or some other error occurs.
In this event, the value of each output parameter after the call returns is undefined.

.. cpp:function:: int botan_x509_ext_as_blocks_get_info(botan_x509_cert_t cert, \
int asnum, \
int* present, \
size_t* count)

Get info about the AS Blocks extension from `RFC 3779 <https://www.rfc-editor.org/rfc/rfc3779>`_.
``asnum`` should be set to 1 to get info about the ASNUM part of the extension, 0 for RDI.
``present`` is set to 1 if a value is contained, 0 if that part of the extension is marked as "inherit".
If the part is not present at all, :cpp:enumerator:`BOTAN_FFI_ERROR_NO_VALUE` will be returned.
``count`` is set to the number of entries for that part if any, otherwise its value is not modified.

If the extension is not present or an error occurs, ``present`` and ``count`` are not modified.

.. cpp:function:: int botan_x509_ext_as_blocks_get_entry_at(botan_x509_cert_t cert, \
int asnum, \
size_t i, \
uint32_t* min, \
uint32_t* max)

Get info about a specific entry from the extension.
``asnum`` behaves as in :cpp:func:`botan_x509_ext_as_blocks_get_info`, ``i`` is the index for that part,
between 0 and (not including) ``count``.
``min`` and ``max`` will be set to the minimum and maximum AS numbers of the range respectively.

If the extension is not present or an error occurs, ``min`` and ``max`` are not modified.

X.509 Certificate Revocation Lists
----------------------------------------

Expand Down
74 changes: 74 additions & 0 deletions src/lib/ffi/ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2704,6 +2704,80 @@ int botan_x509_cert_verify(int* validation_result,
*/
BOTAN_FFI_EXPORT(2, 8) const char* botan_x509_cert_validation_status(int code);

/*
* X.509 Extensions
*/

/**
* Get info about the IP Address Blocks extension from RFC 3779
* @param v4_count is set to the number of v4 families contained in the extension
* @param v6_count is set to the number of v6 families
* @returns 0 on success, negative number on error
*
* If the extension is not present or an error occurs, `v4_count` and `v6_count` are not modified
*/
BOTAN_FFI_EXPORT(3, 13)
int botan_x509_ext_ip_addr_blocks_get_counts(botan_x509_cert_t cert, size_t* v4_count, size_t* v6_count);

/**
* Get info about a specific family in the IP Address Blocks extension from RFC 3779
* @param ipv6 must be set to 1 if the family is an IPv6 family, 0 for IPv4 families
* @param i is the (local) index for this family kind (the first v4 family is at i = 0, ipv6 = 0; the first v6 family is at i = 0, ipv6 = 1)
* @param has_safi will be set to 1 if the family has an associated SAFI
* @param safi will be set to the families' SAFI, if it has one, otherwise `safi` is not modified
* @param present is set to 1 if the family contains values (ranges), 0 if it is marked as "inherit"
* @param count is set to the number of values (ranges), if they were present, otherwise `count` is not modified
* @returns 0 on success, negative number on error
*
* The output parameters `has_safi`, `safi`, `present` and `count` may be modified even if the extension is not present or some other error occurs.
* In this event, the value of each output parameter after the call returns is undefined.
*/
BOTAN_FFI_EXPORT(3, 13)
int botan_x509_ext_ip_addr_blocks_get_family(
botan_x509_cert_t cert, int ipv6, size_t i, int* has_safi, uint8_t* safi, int* present, size_t* count);

/**
* Get info about a specific range in the IP Address Blocks extension from RFC 3779
* @param ipv6 must be set to 1 if the family is an IPv6 family, 0 for IPv4 families
* @param i is the (local) index of the family, see `botan_x509_ext_ip_addr_blocks_get_family`
* @param entry is the index of the range
* @param min_out is set to the lower address of the range
* @param max_out is set to the upper address of the range
* @param out_len is set to the length of the addresses (4 for IPv4, 16 for IPv6)
* @returns 0 on success, negative number on error
*
* The output parameters `min_out`, `max_out` and `out_len` may be modified even if the extension is not present or some other error occurs.
* In this event, the value of each output parameter after the call returns is undefined.
*/
BOTAN_FFI_EXPORT(3, 13)
int botan_x509_ext_ip_addr_blocks_get_address(
botan_x509_cert_t cert, int ipv6, size_t i, size_t entry, uint8_t min_out[], uint8_t max_out[], size_t* out_len);

/**
* Get basic info about the AS Blocks extension from RFC 3779
* @param asnum must be set to 1 to get info about AS numbers, 0 for RDIs (the type)
* @param present is set to 1 if the extension contains entries for the type, 0 if it is marked as "inherit"
Comment thread
arckoor marked this conversation as resolved.
* @param count is set to number of entries for this type, if it was present, otherwise `count` is not modified
* @returns 0 on success, negative number on error
*
* If the extension is not present or an error occurs, `present` and `count` are not modified
*/
BOTAN_FFI_EXPORT(3, 13)
int botan_x509_ext_as_blocks_get_info(botan_x509_cert_t cert, int asnum, int* present, size_t* count);

/**
* Get a specific entry in the AS Blocks extension from RFC 3779
* @param asnum Set to 1 to get info about AS numbers, 0 for RDIs (the type)
* @param i The index of the entry to get
* @param min is set to the min value of the range
* @param max is set to the max value of the range
* @returns 0 on success, negative number on error
*
* If the extension is not present or an error occurs, `min` and `max` are not modified
*/
BOTAN_FFI_EXPORT(3, 13)
int botan_x509_ext_as_blocks_get_entry_at(botan_x509_cert_t cert, int asnum, size_t i, uint32_t* min, uint32_t* max);

/*
* X.509 CRL
**************************/
Expand Down
Loading
Loading