diff --git a/Cargo.lock b/Cargo.lock index 3d9d200f..a01cc320 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,6 +122,7 @@ dependencies = [ "prop-strategies", "proptest", "tracing", + "tracing-subscriber", ] [[package]] @@ -2490,7 +2491,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", - "itoa", "js-sys", "libc", "num-conv", @@ -2498,7 +2498,6 @@ dependencies = [ "powerfmt", "serde", "time-core", - "time-macros", ] [[package]] @@ -2507,16 +2506,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" -[[package]] -name = "time-macros" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tokio" version = "1.39.3" @@ -2598,7 +2587,6 @@ dependencies = [ "regex", "sharded-slab", "thread_local", - "time", "tracing", "tracing-core", ] diff --git a/Cargo.toml b/Cargo.toml index c66be02a..f8a9bb99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ web-sys = { version = "0.3", features = ["Window"] } # logging tracing-web = "0.1" -tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "fmt", "time", "ansi", "env-filter"] } +tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "fmt", "ansi", "env-filter"] } tracing = "0.1" # utils diff --git a/crates/asn1-parser/Cargo.toml b/crates/asn1-parser/Cargo.toml index 40d31bca..64bc29e7 100644 --- a/crates/asn1-parser/Cargo.toml +++ b/crates/asn1-parser/Cargo.toml @@ -13,6 +13,7 @@ default-fearures = [] std = [] [dev-dependencies] +tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "fmt", "ansi"] } env_logger = "0.11.3" prop-strategies = { path = "../prop-strategies" } proptest = "1.2.0" diff --git a/crates/asn1-parser/src/tlv.rs b/crates/asn1-parser/src/tlv.rs index e9d15678..7665cd90 100644 --- a/crates/asn1-parser/src/tlv.rs +++ b/crates/asn1-parser/src/tlv.rs @@ -1,4 +1,5 @@ use alloc::borrow::Cow; +use alloc::fmt::Debug; use crate::length::read_len; use crate::reader::{read_data, Reader}; @@ -56,11 +57,12 @@ impl Asn1Entity for Tlv<'_, A> { } } -impl<'data, A: Asn1ValueDecoder<'data>> Asn1Decoder<'data> for Tlv<'data, A> { +impl<'data, A: Asn1ValueDecoder<'data> + Debug> Asn1Decoder<'data> for Tlv<'data, A> { fn compare_tags(tag: Tag) -> bool { A::compare_tags(tag) } + #[instrument(level = "debug", ret)] fn decode(reader: &mut Reader<'data>) -> Asn1Result { let tag_position = reader.full_offset(); let data_start = reader.position(); diff --git a/crates/asn1-parser/tests/decode_encode.rs b/crates/asn1-parser/tests/decode_encode.rs index c1b4f2d4..2d7b7b48 100644 --- a/crates/asn1-parser/tests/decode_encode.rs +++ b/crates/asn1-parser/tests/decode_encode.rs @@ -133,3 +133,29 @@ fn decode_utc() { let mut encoded = vec![0; asn1.needed_buf_size()]; asn1.encode_buff(&mut encoded).expect("ASN1 encoding should not fail"); } + +fn init_logging() { + use std::io; + + use tracing_subscriber::prelude::*; + use tracing_subscriber::filter::LevelFilter; + + let fmt_layer = tracing_subscriber::fmt::layer() + .pretty() + .with_writer(io::stdout) + .with_filter(LevelFilter::TRACE); + + tracing_subscriber::registry() + .with(fmt_layer) + .init(); +} + +#[test] +fn issue_68() { + init_logging(); + + let raw = &[161, 130, 5, 56, 48, 130, 5, 52, 160, 3, 10, 1, 1, 162, 130, 5, 43, 4, 130, 5, 39, 96, 130, 5, 35, 6, 10, 42, 134, 72, 134, 247, 18, 1, 2, 2, 3, 1, 0, 110, 130, 5, 17, 48, 130, 5, 13, 160, 3, 2, 1, 5, 161, 3, 2, 1, 14, 162, 7, 3, 5, 0, 96, 0, 0, 0, 163, 130, 4, 42, 97, 130, 4, 38, 48, 130, 4, 34, 160, 3, 2, 1, 5, 161, 9, 27, 7, 84, 66, 84, 46, 67, 79, 77, 162, 45, 48, 43, 160, 3, 2, 1, 2, 161, 36, 48, 34, 27, 7, 84, 69, 82, 77, 83, 82, 86, 27, 23, 68, 69, 83, 75, 84, 79, 80, 45, 56, 70, 51, 51, 82, 70, 72, 46, 116, 98, 116, 46, 99, 111, 109, 163, 130, 3, 223, 48, 130, 3, 219, 160, 3, 2, 1, 18, 162, 130, 3, 210, 4, 130, 3, 206, 158, 158, 244, 176, 66, 8, 178, 207, 41, 230, 24, 88, 30, 16, 83, 38, 203, 59, 153, 73, 96, 76, 210, 66, 72, 97, 246, 44, 194, 42, 204, 55, 162, 231, 206, 155, 158, 112, 244, 74, 96, 81, 82, 185, 79, 236, 126, 64, 3, 130, 228, 86, 107, 174, 41, 64, 249, 79, 171, 3, 58, 48, 178, 141, 44, 191, 136, 148, 30, 3, 241, 140, 238, 211, 156, 166, 83, 67, 138, 179, 162, 13, 70, 5, 226, 122, 60, 114, 26, 98, 207, 242, 51, 89, 105, 145, 167, 66, 105, 240, 105, 4, 134, 16, 201, 21, 136, 181, 72, 79, 217, 15, 35, 219, 71, 22, 26, 127, 134, 86, 115, 107, 93, 180, 120, 147, 222, 177, 159, 8, 35, 153, 83, 75, 149, 196, 219, 161, 253, 107, 9, 96, 103, 200, 221, 147, 75, 130, 119, 161, 20, 250, 232, 217, 143, 248, 91, 167, 35, 27, 247, 131, 64, 41, 105, 222, 101, 187, 95, 229, 226, 99, 128, 204, 165, 113, 2, 116, 159, 199, 165, 212, 38, 40, 97, 31, 62, 144, 62, 0, 151, 103, 3, 206, 81, 230, 10, 144, 110, 113, 250, 247, 95, 127, 114, 131, 167, 5, 189, 201, 42, 95, 8, 209, 85, 145, 163, 132, 178, 198, 222, 196, 196, 26, 64, 97, 91, 70, 69, 110, 201, 113, 177, 27, 26, 173, 142, 49, 30, 3, 121, 252, 90, 71, 236, 24, 137, 72, 97, 48, 194, 234, 6, 38, 5, 152, 126, 238, 244, 219, 198, 148, 239, 27, 230, 234, 41, 28, 200, 162, 226, 69, 21, 234, 209, 19, 103, 82, 6, 74, 45, 100, 175, 183, 104, 186, 18, 76, 12, 250, 198, 43, 30, 180, 119, 133, 202, 147, 123, 20, 192, 85, 99, 223, 226, 183, 2, 208, 163, 154, 146, 60, 246, 249, 53, 112, 38, 30, 75, 214, 187, 30, 193, 254, 132, 232, 91, 222, 189, 189, 185, 89, 156, 207, 53, 10, 108, 92, 87, 194, 129, 130, 140, 44, 85, 93, 7, 19, 150, 127, 231, 52, 134, 173, 232, 151, 215, 71, 59, 244, 236, 122, 88, 117, 110, 20, 148, 234, 34, 44, 131, 128, 117, 230, 181, 110, 226, 33, 160, 218, 181, 95, 75, 77, 159, 21, 14, 249, 228, 85, 85, 8, 100, 0, 89, 15, 132, 166, 171, 206, 22, 176, 38, 20, 0, 67, 76, 99, 22, 215, 98, 72, 43, 226, 152, 52, 121, 128, 49, 68, 250, 247, 66, 185, 34, 102, 111, 247, 13, 177, 15, 37, 101, 226, 216, 51, 14, 30, 90, 222, 85, 208, 28, 116, 56, 158, 35, 154, 32, 253, 211, 101, 13, 207, 233, 53, 211, 193, 79, 171, 174, 56, 210, 142, 84, 55, 4, 231, 118, 149, 175, 51, 229, 7, 161, 250, 56, 92, 222, 67, 35, 139, 150, 162, 214, 1, 110, 127, 113, 162, 11, 110, 6, 87, 75, 204, 234, 101, 205, 194, 208, 45, 197, 223, 89, 33, 228, 165, 65, 95, 178, 154, 187, 5, 98, 110, 163, 90, 241, 165, 60, 215, 0, 196, 183, 207, 108, 136, 35, 225, 187, 188, 133, 13, 253, 223, 34, 25, 85, 192, 255, 150, 168, 188, 188, 108, 9, 92, 145, 204, 170, 111, 79, 89, 193, 224, 224, 115, 71, 38, 171, 245, 137, 147, 35, 73, 174, 252, 106, 107, 7, 139, 78, 131, 173, 209, 6, 159, 239, 229, 104, 18, 77, 68, 132, 162, 170, 31, 151, 14, 58, 4, 107, 221, 46, 120, 123, 102, 247, 95, 129, 31, 253, 194, 15, 93, 205, 9, 42, 110, 44, 126, 132, 214, 24, 54, 125, 226, 21, 32, 63, 69, 175, 3, 160, 105, 251, 200, 87, 121, 94, 162, 159, 212, 153, 2, 141, 193, 255, 199, 45, 246, 190, 239, 72, 162, 193, 92, 92, 225, 57, 107, 192, 196, 233, 185, 164, 78, 230, 10, 183, 185, 14, 75, 163, 16, 72, 203, 242, 123, 14, 149, 180, 227, 23, 238, 148, 247, 117, 39, 168, 240, 129, 193, 86, 59, 205, 214, 139, 98, 20, 254, 19, 173, 210, 60, 65, 82, 126, 221, 190, 43, 57, 220, 102, 253, 136, 87, 107, 16, 196, 192, 241, 176, 188, 254, 199, 190, 22, 224, 23, 254, 236, 8, 234, 169, 217, 109, 238, 97, 7, 121, 253, 129, 255, 148, 35, 71, 114, 36, 7, 240, 118, 28, 235, 64, 70, 110, 172, 47, 1, 64, 53, 187, 188, 222, 48, 119, 36, 111, 64, 23, 85, 119, 59, 50, 89, 10, 80, 43, 47, 27, 241, 59, 143, 217, 230, 202, 73, 202, 21, 124, 207, 134, 35, 246, 172, 216, 149, 223, 125, 101, 124, 76, 112, 85, 64, 118, 143, 36, 118, 223, 186, 219, 197, 232, 247, 16, 59, 181, 111, 103, 52, 195, 128, 234, 111, 159, 37, 117, 37, 115, 21, 102, 173, 197, 175, 169, 138, 237, 185, 44, 165, 155, 49, 22, 83, 138, 57, 47, 156, 35, 222, 65, 205, 27, 158, 16, 100, 126, 255, 227, 56, 11, 41, 125, 129, 207, 246, 83, 20, 127, 0, 49, 74, 183, 243, 64, 63, 86, 206, 56, 37, 194, 20, 231, 223, 136, 204, 54, 97, 197, 31, 103, 74, 35, 104, 13, 67, 23, 43, 148, 43, 136, 230, 122, 239, 63, 34, 114, 45, 167, 145, 33, 56, 164, 184, 106, 198, 96, 7, 13, 220, 177, 243, 222, 27, 249, 252, 121, 66, 168, 205, 31, 44, 176, 94, 100, 45, 104, 103, 176, 233, 50, 49, 191, 55, 244, 107, 64, 153, 29, 181, 213, 1, 201, 142, 246, 181, 114, 93, 141, 30, 143, 40, 30, 163, 60, 12, 169, 53, 89, 131, 254, 62, 4, 161, 161, 73, 62, 133, 75, 63, 37, 164, 129, 201, 48, 129, 198, 160, 3, 2, 1, 18, 162, 129, 190, 4, 129, 187, 86, 189, 100, 52, 67, 93, 247, 236, 239, 108, 242, 195, 180, 144, 1, 161, 13, 24, 16, 244, 175, 190, 119, 19, 7, 90, 1, 39, 243, 220, 245, 18, 38, 242, 80, 81, 174, 62, 28, 90, 136, 13, 8, 37, 240, 80, 120, 192, 158, 132, 242, 107, 249, 63, 131, 88, 221, 76, 62, 185, 214, 174, 251, 14, 72, 157, 184, 142, 4, 150, 128, 40, 74, 58, 6, 202, 78, 162, 183, 19, 28, 192, 212, 202, 10, 85, 102, 219, 201, 73, 104, 18, 229, 16, 25, 94, 74, 149, 74, 184, 235, 199, 151, 5, 240, 30, 83, 110, 69, 216, 47, 177, 38, 199, 63, 145, 0, 135, 51, 8, 43, 196, 235, 140, 114, 71, 37, 89, 220, 122, 14, 120, 85, 183, 6, 150, 243, 147, 20, 45, 201, 54, 127, 76, 215, 79, 79, 94, 166, 237, 1, 141, 68, 201, 203, 211, 73, 21, 67, 121, 15, 86, 218, 109, 224, 120, 170, 147, 159, 68, 74, 172, 80, 38, 14, 173, 236, 149, 60, 97, 13, 39, 194, 59, 114, 52, 36]; + + let asn1 = Asn1::decode_buff(raw).unwrap(); + println!("{:?}", asn1); +}