mirror of
https://github.com/golang/go
synced 2024-11-18 04:24:47 -07:00
crypto/elliptic: add Name field to CurveParams struct
And add names for the curve implemented in crypto/elliptic. This permits a safer alternative to switching on BitSize for code that implements curve-dependent cryptosystems. (E.g., ECDSA on P-xxx curves with the matched SHA-2 instances.) Change-Id: I653c8f47506648028a99a96ebdff8389b2a95fc1 Reviewed-on: https://go-review.googlesource.com/2133 Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
parent
1cd347b18b
commit
081bc6b226
@ -45,6 +45,7 @@ type CurveParams struct {
|
||||
B *big.Int // the constant of the curve equation
|
||||
Gx, Gy *big.Int // (x,y) of the base point
|
||||
BitSize int // the size of the underlying field
|
||||
Name string // the canonical name of the curve
|
||||
}
|
||||
|
||||
func (curve *CurveParams) Params() *CurveParams {
|
||||
@ -334,7 +335,7 @@ func initAll() {
|
||||
|
||||
func initP384() {
|
||||
// See FIPS 186-3, section D.2.4
|
||||
p384 = new(CurveParams)
|
||||
p384 = &CurveParams{Name: "P-384"}
|
||||
p384.P, _ = new(big.Int).SetString("39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112319", 10)
|
||||
p384.N, _ = new(big.Int).SetString("39402006196394479212279040100143613805079739270465446667946905279627659399113263569398956308152294913554433653942643", 10)
|
||||
p384.B, _ = new(big.Int).SetString("b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef", 16)
|
||||
@ -345,7 +346,7 @@ func initP384() {
|
||||
|
||||
func initP521() {
|
||||
// See FIPS 186-3, section D.2.5
|
||||
p521 = new(CurveParams)
|
||||
p521 = &CurveParams{Name: "P-521"}
|
||||
p521.P, _ = new(big.Int).SetString("6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151", 10)
|
||||
p521.N, _ = new(big.Int).SetString("6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449", 10)
|
||||
p521.B, _ = new(big.Int).SetString("051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00", 16)
|
||||
|
@ -22,7 +22,7 @@ type p224Curve struct {
|
||||
|
||||
func initP224() {
|
||||
// See FIPS 186-3, section D.2.2
|
||||
p224.CurveParams = new(CurveParams)
|
||||
p224.CurveParams = &CurveParams{Name: "P-224"}
|
||||
p224.P, _ = new(big.Int).SetString("26959946667150639794667015087019630673557916260026308143510066298881", 10)
|
||||
p224.N, _ = new(big.Int).SetString("26959946667150639794667015087019625940457807714424391721682722368061", 10)
|
||||
p224.B, _ = new(big.Int).SetString("b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4", 16)
|
||||
|
@ -23,7 +23,7 @@ var (
|
||||
|
||||
func initP256() {
|
||||
// See FIPS 186-3, section D.2.3
|
||||
p256.CurveParams = new(CurveParams)
|
||||
p256.CurveParams = &CurveParams{Name: "P-256"}
|
||||
p256.P, _ = new(big.Int).SetString("115792089210356248762697446949407573530086143415290314195533631308867097853951", 10)
|
||||
p256.N, _ = new(big.Int).SetString("115792089210356248762697446949407573529996955224135760342422259061068512044369", 10)
|
||||
p256.B, _ = new(big.Int).SetString("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16)
|
||||
|
Loading…
Reference in New Issue
Block a user