Skip to content

Commit b819013

Browse files
committed
Removed faulty native signed integer implementation
1 parent f69d4b8 commit b819013

File tree

4 files changed

+2
-38
lines changed

4 files changed

+2
-38
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "asn1_der"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
edition = "2018"
55
authors = ["KizzyCode Software Labs./Keziah Biermann <[email protected]>"]
66
keywords = ["asn1", "asn1-der", "serialize", "deserialize", "no_panic"]

src/typed/integer.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,6 @@ impl<'a> DerEncodable for Integer<'a> {
124124

125125
/// Implements `DerCodable`
126126
macro_rules! impl_dercodable {
127-
(signed: $num:ty) => {
128-
impl<'a> DerDecodable<'a> for $num {
129-
#[cfg_attr(feature = "no_panic", no_panic::no_panic)]
130-
fn load(object: DerObject<'a>) -> Result<Self, Asn1DerError> {
131-
// Load integer
132-
let integer = Integer::load(object).propagate(e!("Failed to load integer"))?;
133-
let buf = integer.copy_numbytes([0; mem::size_of::<Self>()])
134-
.propagate(e!("The numeric value is too large"))?;
135-
136-
// Validate the integer
137-
match Self::from_be_bytes(buf) {
138-
num if num.is_negative() && !integer.is_negative() =>
139-
Err(eunsupported!("The numeric value is too large")),
140-
num => Ok(num)
141-
}
142-
}
143-
}
144-
impl DerEncodable for $num {
145-
#[cfg_attr(feature = "no_panic", no_panic::no_panic)]
146-
fn encode<S: Sink>(&self, sink: &mut S) -> Result<(), Asn1DerError> {
147-
Integer::write(&self.to_be_bytes(), self.is_negative(), sink)
148-
}
149-
}
150-
};
151127
(unsigned: $num:ty) => {
152128
impl<'a> DerDecodable<'a> for $num {
153129
#[cfg_attr(feature = "no_panic", no_panic::no_panic)]
@@ -172,8 +148,6 @@ macro_rules! impl_dercodable {
172148
}
173149
}
174150
};
175-
(signed: $($num:ty),+) => ($( impl_dercodable!(signed: $num); )+);
176151
(unsigned: $($num:ty),+) => ($( impl_dercodable!(unsigned: $num); )+);
177152
}
178-
impl_dercodable!(unsigned: u8, u16, u32, u64, u128, usize);
179-
impl_dercodable!(signed: i8, i16, i32, i64, i128, isize);
153+
impl_dercodable!(unsigned: u8, u16, u32, u64, u128, usize);

tests/ok.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,6 @@
250250
"tag": 2,
251251
"value": [0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255],
252252
"uint": 340282366920938463463374607431768211455
253-
},
254-
255-
{
256-
"name": "Integer (-169099404967786586218975441646099483807)",
257-
"bytes": [2,16,128,200,163,165,50,73,204,242,115,179,233,77,225,182,51,97],
258-
"tag": 2,
259-
"value": [128,200,163,165,50,73,204,242,115,179,233,77,225,182,51,97],
260-
"int": -169099404967786586218975441646099483807
261253
}
262254
],
263255
"null": [

tests/ok_typed.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ fn integer() {
7474
}
7575
};
7676
(unsigned: $( $num:ty ),+) => ($( native!($num, uint, |_| false); )+);
77-
(signed: $( $num:ty ),+) => ($( native!($num, int, |n: $num| n.is_negative()); )+);
7877
}
7978
native!(unsigned: u8, u16, u32, u64, u128, usize);
80-
native!(signed: i8, i16, i32, i64, i128, isize);
8179
}
8280
}
8381

0 commit comments

Comments
 (0)