Skip to content

crypto/tls: Unnecessary check whether a point is on a curve  #20496

Description

@aead

What version of Go are you using (go version)?

go version go1.8.1 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/andreas/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build282450971=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

I looked at processServerKeyExchange and processClientKeyExchange while investigating #20482.

It's actually not necessary to check explicitly whether the (x,y) coordinate is on the curve because the Unmarshal function does this anyway and the returned error (on failure) is the same.

Of course it's valid to check this again and maybe it's worth to do so for explicitness.
On the other side omitting the (unnecessary) IsOnCurve check would speed-up client/server key-exchange processing. A comment could make it clear that Unmarshal checks the point anyway - maybe @agl should decide about this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions