Skip to content

Commit

Permalink
crypto/elliptic: document the Name and names of each curve
Browse files Browse the repository at this point in the history
See https://tools.ietf.org/html/rfc8422#appendix-A for a helpful table.

Also, commit to keeping them singletons, as that assumption is already
made all over the place in the ecosystem.

Fixes golang#34193

Change-Id: I2ec50fa18bb80e11d6101f2562df60b5e27d4f66
Reviewed-on: https://go-review.googlesource.com/c/go/+/218921
Run-TryBot: Filippo Valsorda <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
FiloSottile committed Feb 11, 2020
1 parent ab5d9f5 commit 25da21d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/crypto/elliptic/elliptic.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,23 +372,36 @@ func initP521() {
p521.BitSize = 521
}

// P256 returns a Curve which implements P-256 (see FIPS 186-3, section D.2.3)
// P256 returns a Curve which implements NIST P-256 (FIPS 186-3, section D.2.3),
// also known as secp256r1 or prime256v1. The CurveParams.Name of this Curve is
// "P-256".
//
// Multiple invocations of this function will return the same value, so it can
// be used for equality checks and switch statements.
//
// The cryptographic operations are implemented using constant-time algorithms.
func P256() Curve {
initonce.Do(initAll)
return p256
}

// P384 returns a Curve which implements P-384 (see FIPS 186-3, section D.2.4)
// P384 returns a Curve which implements NIST P-384 (FIPS 186-3, section D.2.4),
// also known as secp384r1. The CurveParams.Name of this Curve is "P-384".
//
// Multiple invocations of this function will return the same value, so it can
// be used for equality checks and switch statements.
//
// The cryptographic operations do not use constant-time algorithms.
func P384() Curve {
initonce.Do(initAll)
return p384
}

// P521 returns a Curve which implements P-521 (see FIPS 186-3, section D.2.5)
// P521 returns a Curve which implements NIST P-521 (FIPS 186-3, section D.2.5),
// also known as secp521r1. The CurveParams.Name of this Curve is "P-521".
//
// Multiple invocations of this function will return the same value, so it can
// be used for equality checks and switch statements.
//
// The cryptographic operations do not use constant-time algorithms.
func P521() Curve {
Expand Down

0 comments on commit 25da21d

Please sign in to comment.