Skip to content

Commit

Permalink
Cleanup some unnecessary allocations (#849)
Browse files Browse the repository at this point in the history
Co-authored-by: Christopher Henderson <chris@chenderson.org>
  • Loading branch information
pgporada and christopher-henderson authored Jun 9, 2024
1 parent 26ca0f3 commit bf3764c
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions v3/lints/rfc/lint_crl_revoked_certificates_field_empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,14 @@ func (l *revokedCertificates) Execute(c *x509.RevocationList) *lint.LintResult {
// or confirmed to be missing from the ASN.1 data structure.
input := cryptobyte.String(c.Raw)

// From crypto/x509/parser.go: we read the SEQUENCE including length and tag
// bytes so that we can populate RevocationList.Raw, before unwrapping the
// SEQUENCE so it can be operated on
if !input.ReadASN1Element(&input, cryptobyte_asn1.SEQUENCE) {
return &lint.LintResult{Status: lint.Fatal, Details: "malformed CRL"}
}
// Extract the CertificateList
if !input.ReadASN1(&input, cryptobyte_asn1.SEQUENCE) {
return &lint.LintResult{Status: lint.Fatal, Details: "malformed CRL"}
}

var tbs cryptobyte.String
// From crypto/x509/parser.go: do the same trick again as above to extract
// the raw bytes for Certificate.RawTBSCertificate
if !input.ReadASN1Element(&tbs, cryptobyte_asn1.SEQUENCE) {
return &lint.LintResult{Status: lint.Fatal, Details: "malformed TBS CRL"}
}
if !tbs.ReadASN1(&tbs, cryptobyte_asn1.SEQUENCE) {
// Extract the TBSCertList from the CertificateList
if !input.ReadASN1(&tbs, cryptobyte_asn1.SEQUENCE) {
return &lint.LintResult{Status: lint.Fatal, Details: "malformed TBS CRL"}
}

Expand Down

0 comments on commit bf3764c

Please sign in to comment.