curves.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package x509
  5. import (
  6. "crypto/elliptic"
  7. "math/big"
  8. "sync"
  9. )
  10. // This file holds ECC curves that are not supported by the main Go crypto/elliptic
  11. // library, but which have been observed in certificates in the wild.
  12. var initonce sync.Once
  13. var p192r1 *elliptic.CurveParams
  14. func initAllCurves() {
  15. initSECP192R1()
  16. }
  17. func initSECP192R1() {
  18. // See SEC-2, section 2.2.2
  19. p192r1 = &elliptic.CurveParams{Name: "P-192"}
  20. p192r1.P, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF", 16)
  21. p192r1.N, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831", 16)
  22. p192r1.B, _ = new(big.Int).SetString("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1", 16)
  23. p192r1.Gx, _ = new(big.Int).SetString("188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012", 16)
  24. p192r1.Gy, _ = new(big.Int).SetString("07192B95FFC8DA78631011ED6B24CDD573F977A11E794811", 16)
  25. p192r1.BitSize = 192
  26. }
  27. func secp192r1() elliptic.Curve {
  28. initonce.Do(initAllCurves)
  29. return p192r1
  30. }