cryptobyte: fix panic due to malformed ASN.1 inputs on 32-bit archs

When int is 32 bits wide (on 32-bit architectures like 386 and arm), an
overflow could occur, causing a panic, due to malformed ASN.1 being
passed to any of the ASN1 methods of String.

Tested on linux/386 and darwin/amd64.

This fixes CVE-2020-7919 and was found thanks to the Project Wycheproof
test vectors.

Change-Id: I8c9696a8bfad1b40ec877cd740dba3467d66ab54
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/645211
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/216677
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Filippo Valsorda
2020-01-28 17:40:31 +00:00
committed by Katie Hockman
parent 530e935923
commit 69ecbb4d6d
4 changed files with 8 additions and 12 deletions
-4
View File
@@ -17,7 +17,6 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
_ "crypto/sha1"
@@ -34,9 +33,6 @@ func TestMain(m *testing.M) {
log.Printf("skipping test because 'go' command is unavailable: %v", err)
os.Exit(0)
}
if runtime.GOARCH == "386" || runtime.GOARCH == "arm" {
os.Exit(0) // skip tests
}
// Download the JSON test files from github.com/google/wycheproof
// using `go mod download -json` so the cached source of the testdata