_curve.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # This file is licensed under the BSD 2-Clause License.
  2. # See https://opensource.org/licenses/BSD-2-Clause for details.
  3. # This is the element of a database of curve parameters. Items are indexed by their
  4. # human-friendly name, such as "P-256". The element has the following fields:
  5. #
  6. # - p the prime number that defines the finite field for all modulo operations
  7. # - b the constant in the Short Weierstrass curve equation (can be None)
  8. # - order the number of elements in the group with the generator below
  9. # - Gx the affine coordinate X of the generator point
  10. # - Gy the affine coordinate Y of the generator point
  11. # - G the generator, as an EccPoint object
  12. # - modulus_bits the minimum number of bits for encoding the modulus p
  13. # - oid an ASCII string with the registered ASN.1 Object ID
  14. # - context a raw pointer to memory holding a context for all curve operations (can be None)
  15. # - canonical the canonical name of the curve
  16. # - openssh the ASCII string used in OpenSSH id files for public keys on this curve
  17. # - rawlib the reference to the dynamic libary with the low-level functions
  18. # - validate a function that raises an exception if the the input point is invalid
  19. class _Curve(object):
  20. def __init__(self, p, b, order, Gx, Gy, G, modulus_bits, oid, context,
  21. canonical, openssh, rawlib, validate=None):
  22. self.p = p
  23. self.b = b
  24. self.order = order
  25. self.Gx = Gx
  26. self.Gy = Gy
  27. self.G = G
  28. self.modulus_bits = modulus_bits
  29. self.oid = oid
  30. self.context = context
  31. self.canonical = canonical
  32. self.openssh = openssh
  33. self.rawlib = rawlib
  34. self.validate = validate