]> Cypherpunks repositories - gostls13.git/commit
crypto/ecdh,crypto/internal/nistec: enable pruning of unused curves
authorFilippo Valsorda <filippo@golang.org>
Wed, 20 Apr 2022 17:12:18 +0000 (13:12 -0400)
committerFilippo Valsorda <filippo@golang.org>
Fri, 12 Aug 2022 00:04:29 +0000 (00:04 +0000)
commita5cd894318677359f6d07ee74f9004d28b4d164c
tree4a203aa807ce4e9e7943d1bfc0e4f251c0a74f04
parentd88d91e32e1440307369d50ba17ce622399a8bc1
crypto/ecdh,crypto/internal/nistec: enable pruning of unused curves

If a program only uses ecdh.P256(), the implementation of the other
curves shouldn't end up in the binary. This mostly required moving some
operations from init() time. Small performance hit in uncompressed
Bytes/SetBytes, but not big enough to show up in higher-level
benchmarks. If it becomes a problem, we can fix it by pregenerating the
p-1 bytes representation in generate.go.

For #52182
Updates #52221

Change-Id: I64460973b59ee3df787d7e967a6c2bcbc114ba65
Reviewed-on: https://go-review.googlesource.com/c/go/+/402555
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Fernando Lobato Meeser <felobato@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
18 files changed:
src/crypto/ecdh/ecdh_test.go
src/crypto/internal/nistec/fiat/generate.go
src/crypto/internal/nistec/fiat/p224.go
src/crypto/internal/nistec/fiat/p224_invert.go
src/crypto/internal/nistec/fiat/p256.go
src/crypto/internal/nistec/fiat/p384.go
src/crypto/internal/nistec/fiat/p384_invert.go
src/crypto/internal/nistec/fiat/p521.go
src/crypto/internal/nistec/fiat/p521_invert.go
src/crypto/internal/nistec/generate.go
src/crypto/internal/nistec/nistec_test.go
src/crypto/internal/nistec/p224.go
src/crypto/internal/nistec/p224_sqrt.go
src/crypto/internal/nistec/p256.go
src/crypto/internal/nistec/p256_asm.go
src/crypto/internal/nistec/p256_asm_table_test.go
src/crypto/internal/nistec/p384.go
src/crypto/internal/nistec/p521.go