nlnetlabs / bcder Goto Github PK
View Code? Open in Web Editor NEWHandling of BER, CER, and DER encoded data in Rust.
License: BSD 3-Clause "New" or "Revised" License
Handling of BER, CER, and DER encoded data in Rust.
License: BSD 3-Clause "New" or "Revised" License
I have a use case where the application tag for implicit sequence go up to 120.
Why the limitation of up to 30 (seen here https://docs.rs/bcder/0.4.0/src/bcder/tag.rs.html#189)?
#[test]
pub fn test_oid_format(){
let oid= Oid(&[85, 29, 19]);
assert_eq!("2.5.29.19",format!("{}",oid).as_str()); //never finished per infinite loop in fmt implemntation
}
as far bytes recently released 1.0.0, please upgrade bdder
This would result in a cleaner top-level hierarchy: encode
, decode
, types
or somesuch.
::bstring::BitString
is currently limited to the primitive encoding.
In BER mode, OCTET STRINGs can be encoded in a nested fashion. Currently, you can blow up the stack with a well-crafted structure. Either find a way to parse them without recursion or limit the recursion depth and bail out.
In https://github.com/NLnetLabs/bcder/blob/master/src/int.rs#L244 there is a check to ensure that an integer is encoded in the smallest possible octets number.
The problem is that under BER it is valid to have an integer that is encoded in the most efficient way, and sadly it happens a lot in the type of packets that I'm decoding...
For example, the following code
use bcder::Mode;
fn main() {
let u16_1: &[u8] = b"\x02\x03\x00\xff\xf8";
let u16_2: &[u8] = b"\x02\x02\xff\xff";
let decode = |val| {
Mode::Ber.decode(val, |cons| cons.take_u16())
};
println!("{:?}", decode(u16_1));
println!("{:?}", decode(u16_2));
}
will print
Ok(65528)
Err(Malformed)
Even though the second slice is also a valid ASN.1 integer (0..max).
I'm currently in the process of updating packaged crates for futures 0.3/tokio 0.2 compatibility in Debian, which also entails updating to bytes 0.5.
Unfortunately bytes 0.4->0.5 does entail some breaking changes, and bcder's Captured/CapturedWriter are affected as well:
call in Captured::extend
error[E0599]: no method named `extend_from_slice` found for type `&'a mut bytes::bytes::Bytes` in the current scope
--> src/captured.rs:197:16
|
197 | self.0.extend_from_slice(buf);
| ^^^^^^^^^^^^^^^^^ help: there is a method with a similar name: `clone_from_slice`
I am not sure whether this means that Captured needs to switch over to BytesMut or whether there is a simpler solution. tokio-rs/bytes#368 and tokio-rs/bytes#350 might also be related.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.