Skip to content

Commit 6c1c43a

Browse files
committed
mark supported OpenSSL version range, make CI happy
Signed-off-by: Markus Theil <[email protected]>
1 parent e93ab39 commit 6c1c43a

File tree

6 files changed

+95
-10
lines changed

6 files changed

+95
-10
lines changed

openssl-sys/src/handwritten/x509_sbgp.rs

+40-3
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,111 @@
1+
#[cfg(ossl110)]
12
use super::super::*;
3+
#[cfg(ossl110)]
24
use libc::*;
35

46
#[repr(C)]
7+
#[cfg(ossl110)]
58
pub struct ASRange {
69
pub min: *mut ASN1_INTEGER,
710
pub max: *mut ASN1_INTEGER,
811
}
912

1013
#[repr(C)]
14+
#[cfg(ossl110)]
1115
pub struct ASIdOrRange {
1216
pub type_: c_int,
1317
pub u: ASIdOrRange_st_anon_union,
1418
}
1519

1620
#[repr(C)]
21+
#[cfg(ossl110)]
1722
pub union ASIdOrRange_st_anon_union {
1823
pub id: *mut ASN1_INTEGER,
1924
pub range: *mut ASRange,
2025
}
2126

27+
#[cfg(ossl110)]
2228
stack!(stack_st_ASIdOrRange);
2329

2430
#[repr(C)]
31+
#[cfg(ossl110)]
32+
pub union ASIdentifierChoice_st_anon_union {
33+
pub asIdsOrRanges: *mut stack_st_ASIdOrRange,
34+
}
35+
36+
#[repr(C)]
37+
#[cfg(ossl110)]
2538
pub struct ASIdentifierChoice {
2639
pub type_: c_int,
27-
pub asIdsOrRanges: *mut stack_st_ASIdOrRange,
40+
pub u: ASIdentifierChoice_st_anon_union,
2841
}
2942

3043
#[repr(C)]
44+
#[cfg(ossl110)]
3145
pub struct ASIdentifiers {
3246
pub asnum: *mut ASIdentifierChoice,
3347
pub rdi: *mut ASIdentifierChoice,
3448
}
3549

3650
#[repr(C)]
51+
#[cfg(ossl110)]
3752
pub struct IPAddressRange {
3853
pub min: *mut ASN1_BIT_STRING,
3954
pub max: *mut ASN1_BIT_STRING,
4055
}
4156

4257
#[repr(C)]
58+
#[cfg(ossl110)]
4359
pub struct IPAddressOrRange {
4460
pub type_: c_int,
4561
pub u: IPAddressOrRange_st_anon_union,
4662
}
4763
#[repr(C)]
64+
#[cfg(ossl110)]
4865
pub union IPAddressOrRange_st_anon_union {
4966
pub addressPrefix: *mut ASN1_BIT_STRING,
5067
pub addressRange: *mut IPAddressRange,
5168
}
5269

70+
#[cfg(ossl110)]
5371
stack!(stack_st_IPAddressOrRange);
72+
#[cfg(ossl110)]
5473
type IPAddressOrRanges = stack_st_IPAddressOrRange;
5574

5675
#[repr(C)]
76+
#[cfg(ossl110)]
77+
pub union IPAddressChoice_st_anon_union {
78+
pub addressesOrRanges: *mut IPAddressOrRanges,
79+
}
80+
81+
#[repr(C)]
82+
#[cfg(ossl110)]
5783
pub struct IPAddressChoice {
5884
pub type_: c_int,
59-
pub addressesOrRanges: *mut IPAddressOrRanges,
85+
pub u: IPAddressChoice_st_anon_union,
6086
}
6187

6288
#[repr(C)]
89+
#[cfg(ossl110)]
6390
pub struct IPAddressFamily {
6491
pub addressFamily: *mut ASN1_OCTET_STRING,
6592
pub ipAddressChoice: *mut IPAddressChoice,
6693
}
6794

95+
#[cfg(ossl110)]
6896
stack!(stack_st_IPAddressFamily);
97+
#[cfg(ossl110)]
6998
type IPAddrBlocks = stack_st_IPAddressFamily;
7099

100+
#[cfg(ossl110)]
71101
extern "C" {
72102
pub fn ASIdentifiers_free(asi: *mut ASIdentifiers);
73103
pub fn ASIdOrRange_free(asi: *mut ASIdOrRange);
74104
pub fn IPAddressFamily_free(asi: *mut IPAddressFamily);
75105
pub fn IPAddressOrRange_free(asi: *mut IPAddressOrRange);
76106
}
77107

108+
#[cfg(ossl110)]
78109
pub unsafe fn X509v3_addr_get_afi(f: *mut IPAddressFamily) -> c_int {
79110
if f.is_null() {
80111
0
@@ -84,11 +115,12 @@ pub unsafe fn X509v3_addr_get_afi(f: *mut IPAddressFamily) -> c_int {
84115
0
85116
} else {
86117
let raw = ASN1_STRING_get0_data(d);
87-
((*raw.offset(0) as i32) << 8) | *raw.offset(1) as i32
118+
((*raw.offset(0) as c_int) << 8) | *raw.offset(1) as c_int
88119
}
89120
}
90121
}
91122

123+
#[cfg(ossl110)]
92124
fn length_from_afi(afi: c_int) -> isize {
93125
match afi {
94126
IANA_AFI_IPV4 => 4,
@@ -97,6 +129,7 @@ fn length_from_afi(afi: c_int) -> isize {
97129
}
98130
}
99131

132+
#[cfg(ossl110)]
100133
struct ASN1_STRING_internal {
101134
length: c_int,
102135
type_: c_int,
@@ -108,10 +141,12 @@ struct ASN1_STRING_internal {
108141
*/
109142
flags: c_int,
110143
}
144+
111145
/*
112146
* Expand the bitstring form of an address into a raw byte array.
113147
* At the moment this is coded for simplicity, not speed.
114148
*/
149+
#[cfg(ossl110)]
115150
fn addr_expand(addr: *mut u8, bs: *const ASN1_BIT_STRING, length: isize, fill: u8) -> bool {
116151
unsafe {
117152
let str = bs as *mut ASN1_STRING;
@@ -151,6 +186,7 @@ fn addr_expand(addr: *mut u8, bs: *const ASN1_BIT_STRING, length: isize, fill: u
151186
/*
152187
* Extract min and max values from an IPAddressOrRange.
153188
*/
189+
#[cfg(ossl110)]
154190
fn extract_min_max(aor: *mut IPAddressOrRange, min: *mut u8, max: *mut u8, length: isize) -> bool {
155191
unsafe {
156192
match (*aor).type_ {
@@ -167,6 +203,7 @@ fn extract_min_max(aor: *mut IPAddressOrRange, min: *mut u8, max: *mut u8, lengt
167203
}
168204
}
169205

206+
#[cfg(ossl110)]
170207
pub fn X509v3_addr_get_range(
171208
aor: *mut IPAddressOrRange,
172209
afi: c_int,

openssl-sys/src/x509_sbgp.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1+
#[cfg(ossl110)]
12
use libc::*;
23

4+
#[cfg(ossl110)]
35
use super::*;
46

7+
#[cfg(ossl110)]
58
pub const ASIdOrRange_id: c_int = 0;
9+
#[cfg(ossl110)]
610
pub const ASIdOrRange_range: c_int = 1;
711

12+
#[cfg(ossl110)]
813
pub const ASIdentifierChoice_inherit: c_int = 0;
14+
#[cfg(ossl110)]
915
pub const ASIdentifierChoice_asIdsOrRanges: c_int = 1;
1016

17+
#[cfg(ossl110)]
1118
pub const IPAddressOrRange_addressPrefix: c_int = 0;
19+
#[cfg(ossl110)]
1220
pub const IPAddressOrRange_addressRange: c_int = 1;
1321

22+
#[cfg(ossl110)]
1423
pub const IPAddressChoice_inherit: c_int = 0;
24+
#[cfg(ossl110)]
1525
pub const IPAddressChoice_addressesOrRanges: c_int = 1;
1626

27+
#[cfg(ossl110)]
1728
pub const IANA_AFI_IPV4: c_int = 1;
29+
#[cfg(ossl110)]
1830
pub const IANA_AFI_IPV6: c_int = 2;

openssl/src/x509/extension.rs

+6
Original file line numberDiff line numberDiff line change
@@ -428,17 +428,20 @@ impl AuthorityKeyIdentifier {
428428
}
429429
}
430430

431+
#[cfg(ossl110)]
431432
pub struct SbgpAsIdentifier {
432433
critical: bool,
433434
asn: Vec<(u32, u32)>,
434435
}
435436

437+
#[cfg(ossl110)]
436438
impl Default for SbgpAsIdentifier {
437439
fn default() -> SbgpAsIdentifier {
438440
SbgpAsIdentifier::new()
439441
}
440442
}
441443

444+
#[cfg(ossl110)]
442445
impl SbgpAsIdentifier {
443446
/// Construct a new `SbgpAsIdentifier` extension.
444447
pub fn new() -> SbgpAsIdentifier {
@@ -484,17 +487,20 @@ impl SbgpAsIdentifier {
484487
}
485488
}
486489

490+
#[cfg(ossl110)]
487491
pub struct SbgpIpAddressIdentifier {
488492
critical: bool,
489493
ip_ranges: Vec<(std::net::IpAddr, std::net::IpAddr)>,
490494
}
491495

496+
#[cfg(ossl110)]
492497
impl Default for SbgpIpAddressIdentifier {
493498
fn default() -> SbgpIpAddressIdentifier {
494499
SbgpIpAddressIdentifier::new()
495500
}
496501
}
497502

503+
#[cfg(ossl110)]
498504
impl SbgpIpAddressIdentifier {
499505
/// Construct a new `SbgpIpAddressIdentifier` extension.
500506
pub fn new() -> SbgpIpAddressIdentifier {

openssl/src/x509/sbgp.rs

+26-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1+
#[cfg(ossl110)]
2+
use std::convert::TryInto;
3+
#[cfg(ossl110)]
14
use std::mem::MaybeUninit;
25

6+
#[cfg(ossl110)]
37
use ffi::{
48
ASIdOrRange_id, ASIdOrRange_range, ASIdentifierChoice_asIdsOrRanges,
59
ASIdentifierChoice_inherit, IPAddressChoice_addressesOrRanges, X509v3_addr_get_afi,
610
X509v3_addr_get_range, ASN1_INTEGER, IANA_AFI_IPV4, IANA_AFI_IPV6,
711
};
12+
#[cfg(ossl110)]
813
use foreign_types::{ForeignType, ForeignTypeRef};
914

15+
#[cfg(ossl110)]
1016
use crate::{
1117
asn1::Asn1IntegerRef,
1218
stack::{Stack, StackRef, Stackable},
1319
util::{ForeignTypeExt, ForeignTypeRefExt},
1420
};
1521

22+
#[cfg(ossl110)]
1623
use super::X509;
1724

25+
#[cfg(ossl110)]
1826
foreign_type_and_impl_send_sync! {
1927
type CType = ffi::ASIdOrRange;
2028
fn drop = ffi::ASIdOrRange_free;
@@ -24,11 +32,12 @@ foreign_type_and_impl_send_sync! {
2432
/// Reference to `ASIdOrRange`.
2533
pub struct ASIdOrRangeRef;
2634
}
27-
35+
#[cfg(ossl110)]
2836
impl Stackable for ASIdOrRange {
2937
type StackType = ffi::stack_st_ASIdOrRange;
3038
}
3139

40+
#[cfg(ossl110)]
3241
foreign_type_and_impl_send_sync! {
3342
type CType = ffi::ASIdentifiers;
3443
fn drop = ffi::ASIdentifiers_free;
@@ -39,6 +48,7 @@ foreign_type_and_impl_send_sync! {
3948
pub struct ASIdentifiersRef;
4049
}
4150

51+
#[cfg(ossl110)]
4252
impl ASIdentifiers {
4353
pub fn inherited(&self) -> bool {
4454
unsafe {
@@ -56,7 +66,7 @@ impl ASIdentifiers {
5666
if (*asnum).type_ != ASIdentifierChoice_asIdsOrRanges {
5767
return None;
5868
}
59-
if let Some(s) = StackRef::<ASIdOrRange>::from_const_ptr_opt((*asnum).asIdsOrRanges) {
69+
if let Some(s) = StackRef::<ASIdOrRange>::from_const_ptr_opt((*asnum).u.asIdsOrRanges) {
6070
for a_ptr in s {
6171
let a = a_ptr.as_ptr();
6272
if (*a).type_ == ASIdOrRange_id {
@@ -85,6 +95,7 @@ impl ASIdentifiers {
8595
}
8696
}
8797

98+
#[cfg(ossl110)]
8899
foreign_type_and_impl_send_sync! {
89100
type CType = ffi::IPAddressOrRange;
90101
fn drop = ffi::IPAddressOrRange_free;
@@ -95,10 +106,12 @@ foreign_type_and_impl_send_sync! {
95106
pub struct IPAddressOrRangeRef;
96107
}
97108

109+
#[cfg(ossl110)]
98110
impl Stackable for IPAddressOrRange {
99111
type StackType = ffi::stack_st_IPAddressOrRange;
100112
}
101113

114+
#[cfg(ossl110)]
102115
foreign_type_and_impl_send_sync! {
103116
type CType = ffi::IPAddressFamily;
104117
fn drop = ffi::IPAddressFamily_free;
@@ -109,21 +122,24 @@ foreign_type_and_impl_send_sync! {
109122
pub struct IPAddressFamilyRef;
110123
}
111124

125+
#[cfg(ossl110)]
112126
impl Stackable for IPAddressFamily {
113127
type StackType = ffi::stack_st_IPAddressFamily;
114128
}
115129

116130
#[derive(PartialEq, Eq, Debug)]
131+
#[cfg(ossl110)]
117132
pub enum IPVersion {
118133
V4,
119134
V6,
120135
}
121136

137+
#[cfg(ossl110)]
122138
impl IPAddressFamily {
123139
pub fn fam(&self) -> Option<IPVersion> {
124140
let ptr = self.0;
125141
unsafe {
126-
match X509v3_addr_get_afi(ptr) {
142+
match X509v3_addr_get_afi(ptr) as libc::c_int {
127143
IANA_AFI_IPV4 => Some(IPVersion::V4),
128144
IANA_AFI_IPV6 => Some(IPVersion::V6),
129145
_ => None,
@@ -140,7 +156,7 @@ impl IPAddressFamily {
140156
return None;
141157
}
142158
let stack =
143-
StackRef::<IPAddressOrRange>::from_const_ptr_opt((*choice).addressesOrRanges)?;
159+
StackRef::<IPAddressOrRange>::from_const_ptr_opt((*choice).u.addressesOrRanges)?;
144160
for e in stack {
145161
let mut min = MaybeUninit::<[u8; 16]>::uninit();
146162
let mut max = MaybeUninit::<[u8; 16]>::uninit();
@@ -152,8 +168,10 @@ impl IPAddressFamily {
152168
16,
153169
);
154170
r.push((
155-
Self::data_to_ip_addr(min.assume_init(), size)?,
156-
Self::data_to_ip_addr(max.assume_init(), size)?,
171+
#[allow(clippy::useless_conversion)]
172+
Self::data_to_ip_addr(min.assume_init(), size.try_into().unwrap())?,
173+
#[allow(clippy::useless_conversion)]
174+
Self::data_to_ip_addr(max.assume_init(), size.try_into().unwrap())?,
157175
))
158176
}
159177
}
@@ -180,11 +198,13 @@ impl IPAddressFamily {
180198
}
181199
}
182200

201+
#[cfg(ossl110)]
183202
pub trait ExtractSBGPInfo {
184203
fn asn(&self) -> Option<ASIdentifiers>;
185204
fn ip_addresses(&self) -> Option<Stack<IPAddressFamily>>;
186205
}
187206

207+
#[cfg(ossl110)]
188208
impl ExtractSBGPInfo for X509 {
189209
fn asn(&self) -> Option<ASIdentifiers> {
190210
unsafe {

0 commit comments

Comments
 (0)