Skip to content

Commit

Permalink
lib: write key usage ext w/ helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpu committed Sep 10, 2023
1 parent 007a2d6 commit 0604d2c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,11 +999,7 @@ impl CertificateParams {

// Write standard key usage
if !self.key_usages.is_empty() {
writer.next().write_sequence(|writer| {
let oid = ObjectIdentifier::from_slice(OID_KEY_USAGE);
writer.next().write_oid(&oid);
writer.next().write_bool(true);

write_x509_extension(writer.next(), OID_KEY_USAGE, true, |writer| {
let mut bits: u16 = 0;

for entry in self.key_usages.iter() {
Expand Down Expand Up @@ -1032,12 +1028,7 @@ impl CertificateParams {
// Finally take only the bytes != 0
let bits = &bits[..nb];

let der = yasna::construct_der(|writer| {
writer.write_bitvec_bytes(&bits, msb as usize)
});

// Write them
writer.next().write_bytes(&der);
writer.write_bitvec_bytes(&bits, msb as usize)
});
}

Expand Down

0 comments on commit 0604d2c

Please sign in to comment.