Skip to content

Commit 486fc01

Browse files
aarongablegopherbot
authored andcommitted
crypto/x509: correctly parse CRL entry extensions
When checking to see if a CRL entry has any extensions, attempt to read them from the individual revokedCertificate, rather than from the parent TBSCertList. Additionally, crlEntryExtensions is not an EXPLICIT field (c.f. crlExtension and Certificate extensions), so do not perform an extra layer of unwrapping when parsing the field. The added test case fails without the accompanying changes. Fixes #53592 Change-Id: Icc00e4c911f196aef77e3248117de64ddc5ea27f Reviewed-on: https://go-review.googlesource.com/c/go/+/414877 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent 8ac58de commit 486fc01

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/crypto/x509/parser.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,13 +1106,10 @@ func ParseRevocationList(der []byte) (*RevocationList, error) {
11061106
}
11071107
var extensions cryptobyte.String
11081108
var present bool
1109-
if !tbs.ReadOptionalASN1(&extensions, &present, cryptobyte_asn1.SEQUENCE) {
1109+
if !certSeq.ReadOptionalASN1(&extensions, &present, cryptobyte_asn1.SEQUENCE) {
11101110
return nil, errors.New("x509: malformed extensions")
11111111
}
11121112
if present {
1113-
if !extensions.ReadASN1(&extensions, cryptobyte_asn1.SEQUENCE) {
1114-
return nil, errors.New("x509: malformed extensions")
1115-
}
11161113
for !extensions.Empty() {
11171114
var extension cryptobyte.String
11181115
if !extensions.ReadASN1(&extension, cryptobyte_asn1.SEQUENCE) {

src/crypto/x509/x509_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2524,6 +2524,34 @@ func TestCreateRevocationList(t *testing.T) {
25242524
NextUpdate: time.Time{}.Add(time.Hour * 48),
25252525
},
25262526
},
2527+
{
2528+
name: "valid, extra entry extension",
2529+
key: ec256Priv,
2530+
issuer: &Certificate{
2531+
KeyUsage: KeyUsageCRLSign,
2532+
Subject: pkix.Name{
2533+
CommonName: "testing",
2534+
},
2535+
SubjectKeyId: []byte{1, 2, 3},
2536+
},
2537+
template: &RevocationList{
2538+
RevokedCertificates: []pkix.RevokedCertificate{
2539+
{
2540+
SerialNumber: big.NewInt(2),
2541+
RevocationTime: time.Time{}.Add(time.Hour),
2542+
Extensions: []pkix.Extension{
2543+
{
2544+
Id: []int{2, 5, 29, 99},
2545+
Value: []byte{5, 0},
2546+
},
2547+
},
2548+
},
2549+
},
2550+
Number: big.NewInt(5),
2551+
ThisUpdate: time.Time{}.Add(time.Hour * 24),
2552+
NextUpdate: time.Time{}.Add(time.Hour * 48),
2553+
},
2554+
},
25272555
{
25282556
name: "valid, Ed25519 key",
25292557
key: ed25519Priv,

0 commit comments

Comments
 (0)