issuance: Test only, cleanup revokedCertificatesFieldExists (#7510)

Two `//x/crypto/cryptobyte` `ReadASN1Element` calls were unneeded and
are now removed. In the original `//crypto/x509/parser.go` code, those
lines were used to populate fields in a struct, but we're operating on
raw bytes within this lint.
This commit is contained in:
Phil Porada 2024-05-29 16:49:47 -04:00 committed by GitHub
parent 14203c0dcf
commit ebc7dfb973
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 15 deletions

View File

@ -186,6 +186,11 @@ func TestIssueCRL(t *testing.T) {
// //
// https://datatracker.ietf.org/doc/html/rfc5280#appendix-A.1 page 118 // https://datatracker.ietf.org/doc/html/rfc5280#appendix-A.1 page 118
// //
// CertificateList ::= SEQUENCE {
// tbsCertList TBSCertList
// ..
// }
//
// TBSCertList ::= SEQUENCE { // TBSCertList ::= SEQUENCE {
// .. // ..
// revokedCertificates SEQUENCE OF SEQUENCE { // revokedCertificates SEQUENCE OF SEQUENCE {
@ -194,19 +199,16 @@ func TestIssueCRL(t *testing.T) {
// } // }
func revokedCertificatesFieldExists(der []byte) (bool, error) { func revokedCertificatesFieldExists(der []byte) (bool, error) {
input := cryptobyte.String(der) input := cryptobyte.String(der)
if !input.ReadASN1Element(&input, cryptobyte_asn1.SEQUENCE) {
return false, errors.New("x509: malformed crl") // Extract the CertificateList
}
if !input.ReadASN1(&input, cryptobyte_asn1.SEQUENCE) { if !input.ReadASN1(&input, cryptobyte_asn1.SEQUENCE) {
return false, errors.New("x509: malformed crl") return false, errors.New("malformed crl")
} }
var tbs cryptobyte.String var tbs cryptobyte.String
if !input.ReadASN1Element(&tbs, cryptobyte_asn1.SEQUENCE) { // Extract the TBSCertList from the CertificateList
return false, errors.New("x509: malformed tbs crl") if !input.ReadASN1(&tbs, cryptobyte_asn1.SEQUENCE) {
} return false, errors.New("malformed tbs crl")
if !tbs.ReadASN1(&tbs, cryptobyte_asn1.SEQUENCE) {
return false, errors.New("x509: malformed tbs crl")
} }
// Skip optional version // Skip optional version