Skip to content

Commit

Permalink
mark supported OpenSSL version range
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Theil <theil.markus@gmail.com>
  • Loading branch information
thillux committed Oct 12, 2023
1 parent cc555a8 commit 3bf5d75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion openssl/src/x509/sbgp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::mem::MaybeUninit;

#[cfg(ossl110)]
use ffi::{
ASIdOrRange_id, ASIdOrRange_range, ASIdentifierChoice_asIdsOrRanges,
ASIdentifierChoice_inherit, IPAddressChoice_addressesOrRanges, X509v3_addr_get_afi,
Expand All @@ -15,6 +16,7 @@ use crate::{

use super::X509;

#[cfg(ossl110)]
foreign_type_and_impl_send_sync! {
type CType = ffi::ASIdOrRange;
fn drop = ffi::ASIdOrRange_free;
Expand All @@ -24,11 +26,12 @@ foreign_type_and_impl_send_sync! {
/// Reference to `ASIdOrRange`.
pub struct ASIdOrRangeRef;
}

#[cfg(ossl110)]
impl Stackable for ASIdOrRange {
type StackType = ffi::stack_st_ASIdOrRange;
}

#[cfg(ossl110)]
foreign_type_and_impl_send_sync! {
type CType = ffi::ASIdentifiers;
fn drop = ffi::ASIdentifiers_free;
Expand All @@ -39,6 +42,7 @@ foreign_type_and_impl_send_sync! {
pub struct ASIdentifiersRef;
}

#[cfg(ossl110)]
impl ASIdentifiers {
pub fn inherited(&self) -> bool {
unsafe {
Expand Down Expand Up @@ -109,6 +113,7 @@ foreign_type_and_impl_send_sync! {
pub struct IPAddressFamilyRef;
}

#[cfg(ossl110)]
impl Stackable for IPAddressFamily {
type StackType = ffi::stack_st_IPAddressFamily;
}
Expand All @@ -119,6 +124,7 @@ pub enum IPVersion {
V6,
}

#[cfg(ossl110)]
impl IPAddressFamily {
pub fn fam(&self) -> Option<IPVersion> {
let ptr = self.0;
Expand Down Expand Up @@ -180,11 +186,13 @@ impl IPAddressFamily {
}
}

#[cfg(ossl110)]
pub trait ExtractSBGPInfo {
fn asn(&self) -> Option<ASIdentifiers>;
fn ip_addresses(&self) -> Option<Stack<IPAddressFamily>>;
}

#[cfg(ossl110)]
impl ExtractSBGPInfo for X509 {
fn asn(&self) -> Option<ASIdentifiers> {
unsafe {
Expand Down
3 changes: 3 additions & 0 deletions openssl/src/x509/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::x509::extension::{
AuthorityKeyIdentifier, BasicConstraints, ExtendedKeyUsage, KeyUsage, SbgpAsIdentifier,
SbgpIpAddressIdentifier, SubjectAlternativeName, SubjectKeyIdentifier,
};
#[cfg(ossl110)]
use crate::x509::sbgp::ExtractSBGPInfo;
#[cfg(not(boringssl))]
use crate::x509::store::X509Lookup;
Expand Down Expand Up @@ -1182,6 +1183,7 @@ fn test_dist_point_null() {
}

#[test]
#[cfg(ossl110)]
fn test_sbgp_extensions_parsing() {
let cert = include_bytes!("../../test/rfc3779.pem");
let cert = X509::from_pem(cert).unwrap();
Expand Down Expand Up @@ -1210,6 +1212,7 @@ fn test_sbgp_extensions_parsing() {
}

#[test]
#[cfg(ossl110)]
fn test_sbgp_extensions_builder() {
let mut builder = X509Builder::new().unwrap();
let asn_ext = SbgpAsIdentifier::new()
Expand Down

0 comments on commit 3bf5d75

Please sign in to comment.