Skip to content

Commit

Permalink
Merge pull request #12 from kedars/feature/txt-fields-dn
Browse files Browse the repository at this point in the history
Certs: Include support for text fields in Distinguished Names
  • Loading branch information
kedars authored Jan 28, 2023
2 parents 690e396 + cf72862 commit d77871e
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 54 deletions.
11 changes: 8 additions & 3 deletions matter/src/cert/asn1_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,18 @@ impl<'a> CertConsumer for ASN1Writer<'a> {
self.write_str(0x02, i)
}

fn printstr(&mut self, _tag: &str, s: &str) -> Result<(), Error> {
// Note: ASN1 has multiple strings, this is PrintableString
self.write_str(0x13, s.as_bytes())
}

fn utf8str(&mut self, _tag: &str, s: &str) -> Result<(), Error> {
// Note: ASN1 has 3 string, this is UTF8String
// Note: ASN1 has multiple strings, this is UTF8String
self.write_str(0x0c, s.as_bytes())
}

fn bitstr(&mut self, _tag: &str, truncate: bool, s: &[u8]) -> Result<(), Error> {
// Note: ASN1 has 3 string, this is BIT String
// Note: ASN1 has multiple strings, this is BIT String

// Strip off the end zeroes
let mut last_byte = s.len() - 1;
Expand All @@ -208,7 +213,7 @@ impl<'a> CertConsumer for ASN1Writer<'a> {
}

fn ostr(&mut self, _tag: &str, s: &[u8]) -> Result<(), Error> {
// Note: ASN1 has 3 string, this is Octet String
// Note: ASN1 has multiple strings, this is Octet String
self.write_str(0x04, s)
}

Expand Down
Loading

0 comments on commit d77871e

Please sign in to comment.