From 62adc274e022ffdf1b47dd52a6371d6f975103f3 Mon Sep 17 00:00:00 2001 From: Pierre Chifflier Date: Thu, 22 Feb 2024 16:21:06 +0100 Subject: [PATCH] examples: drop circular dependency caused by oid-registry --- Cargo.toml | 1 - examples/dump-der.rs | 28 ++++++++++++---------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9c76f12..84a5aa3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,6 +61,5 @@ time = { version="0.3", features=["macros", "parsing", "formatting"], optional=t [dev-dependencies] colored = "2.0" hex-literal = "0.4" -oid-registry = { version="0.6", features=["crypto","x509"] } pem = "3.0" trybuild = "1.0" diff --git a/examples/dump-der.rs b/examples/dump-der.rs index 359fd83..98fbc17 100644 --- a/examples/dump-der.rs +++ b/examples/dump-der.rs @@ -1,23 +1,23 @@ use asn1_rs::{Any, Class, FromDer, Length, Result, Tag}; use colored::*; use nom::HexDisplay; -use oid_registry::{format_oid, Oid as DerOid, OidRegistry}; +// use oid_registry::{format_oid, Oid as DerOid, OidRegistry}; use std::cmp::min; use std::error::Error; use std::marker::PhantomData; use std::{env, fs}; struct Context<'a> { - oid_registry: OidRegistry<'a>, + // oid_registry: OidRegistry<'a>, hex_max: usize, t: PhantomData<&'a ()>, } impl<'a> Default for Context<'a> { fn default() -> Self { - let oid_registry = OidRegistry::default().with_all_crypto().with_x509(); + // let oid_registry = OidRegistry::default().with_all_crypto().with_x509(); Context { - oid_registry, + // oid_registry, hex_max: 64, t: PhantomData, } @@ -191,12 +191,10 @@ fn print_der_any(any: Any, depth: usize, ctx: &Context) { } Tag::Oid => { let oid = any.oid().unwrap(); - let der_oid = DerOid::new(oid.as_bytes().into()); - indent_println!( - depth + 1, - "OID: {}", - format_oid(&der_oid, &ctx.oid_registry).cyan() - ); + // let der_oid = DerOid::new(oid.as_bytes().into()); + // let s = format_oid(&der_oid, &ctx.oid_registry).cyan(); + let s = oid.to_string().cyan(); + indent_println!(depth + 1, "OID: {}", s); } Tag::PrintableString => { let s = any.printablestring().unwrap(); @@ -204,12 +202,10 @@ fn print_der_any(any: Any, depth: usize, ctx: &Context) { } Tag::RelativeOid => { let oid = any.oid().unwrap(); - let der_oid = DerOid::new(oid.as_bytes().into()); - indent_println!( - depth + 1, - "RELATIVE-OID: {}", - format_oid(&der_oid, &ctx.oid_registry).cyan() - ); + // let der_oid = DerOid::new(oid.as_bytes().into()); + // let s = format_oid(&der_oid, &ctx.oid_registry).cyan(); + let s = oid.to_string().cyan(); + indent_println!(depth + 1, "RELATIVE-OID: {}", s); } Tag::Set => { let seq = any.set().unwrap();