Skip to content

Commit d77871e

Browse files
authored
Merge pull request #12 from kedars/feature/txt-fields-dn
Certs: Include support for text fields in Distinguished Names
2 parents 690e396 + cf72862 commit d77871e

File tree

5 files changed

+278
-54
lines changed

5 files changed

+278
-54
lines changed

matter/src/cert/asn1_writer.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,18 @@ impl<'a> CertConsumer for ASN1Writer<'a> {
180180
self.write_str(0x02, i)
181181
}
182182

183+
fn printstr(&mut self, _tag: &str, s: &str) -> Result<(), Error> {
184+
// Note: ASN1 has multiple strings, this is PrintableString
185+
self.write_str(0x13, s.as_bytes())
186+
}
187+
183188
fn utf8str(&mut self, _tag: &str, s: &str) -> Result<(), Error> {
184-
// Note: ASN1 has 3 string, this is UTF8String
189+
// Note: ASN1 has multiple strings, this is UTF8String
185190
self.write_str(0x0c, s.as_bytes())
186191
}
187192

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

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

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

0 commit comments

Comments
 (0)