Skip to content

Commit cf72862

Browse files
committed
tlv_tool: Make provision to dump ASN1 representation of certificates
1 parent e6709aa commit cf72862

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tools/tlv_tool/src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ fn main() {
4747
.arg(
4848
Arg::with_name("cert")
4949
.long("cert")
50-
.help("The input is a Matter-encoded Certificate"),
50+
.help("Decode a Matter-encoded Certificate"),
51+
)
52+
.arg(
53+
Arg::with_name("as-asn1")
54+
.long("as-asn1")
55+
.help("Decode a Matter-encoded Certificate and encode as ASN1"),
5156
)
5257
.arg(Arg::with_name("tlvs").help("List of TLVs").required(true))
5358
.get_matches();
@@ -88,6 +93,11 @@ fn main() {
8893
if m.is_present("cert") {
8994
let cert = cert::Cert::new(&tlv_list[..index]).unwrap();
9095
println!("{}", cert);
96+
} else if m.is_present("as-asn1") {
97+
let mut asn1_cert = [0_u8; 1024];
98+
let cert = cert::Cert::new(&tlv_list[..index]).unwrap();
99+
let len = cert.as_asn1(&mut asn1_cert).unwrap();
100+
println!("{:02x?}", &asn1_cert[..len]);
91101
} else {
92102
tlv::print_tlv_list(&tlv_list[..index]);
93103
}

0 commit comments

Comments
 (0)