Skip to content

Commit

Permalink
examples: drop circular dependency caused by oid-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
chifflier committed Feb 22, 2024
1 parent bc9b098 commit 62adc27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
28 changes: 12 additions & 16 deletions examples/dump-der.rs
Original file line number Diff line number Diff line change
@@ -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,
}
Expand Down Expand Up @@ -191,25 +191,21 @@ 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();
indent_println!(depth + 1, "PrintableString: {}", s.as_ref());
}
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();
Expand Down

0 comments on commit 62adc27

Please sign in to comment.