You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.2KB

  1. module CryptCheck
  2. module Tls
  3. class Curve
  4. attr_reader :name
  5. def initialize(name)
  6. name = name.to_sym if name.is_a? String
  7. @name = name
  8. end
  9. # SUPPORTED = %i(sect163k1 sect163r1 sect163r2 sect193r1
  10. # sect193r2 sect233k1 sect233r1 sect239k1 sect283k1 sect283r1
  11. # sect409k1 sect409r1 sect571k1 sect571r1 secp160k1 secp160r1
  12. # secp160r2 secp192k1 secp192r1 secp224k1 secp224r1 secp256k1
  13. # secp256r1 secp384r1 secp521r1
  14. # prime256v1
  15. # brainpoolP256r1 brainpoolP384r1 brainpoolP512r1)
  16. SUPPORTED = %i(secp256k1 sect283k1 sect283r1 secp384r1
  17. sect409k1 sect409r1 secp521r1 sect571k1 sect571r1
  18. prime192v1 prime256v1
  19. brainpoolP256r1 brainpoolP384r1 brainpoolP512r1).collect { |c| self.new c }.freeze
  20. extend Enumerable
  21. def self.each(&block)
  22. SUPPORTED.each &block
  23. end
  24. def to_s
  25. @name
  26. end
  27. def to_h
  28. { name: @name, states: self.states }
  29. end
  30. def ==(other)
  31. case other
  32. when String
  33. @name == other.to_sym
  34. when Symbol
  35. @name == other
  36. else
  37. @name == other.name
  38. end
  39. end
  40. protected
  41. include State
  42. CHECKS = [].freeze
  43. protected
  44. def available_checks
  45. CHECKS
  46. end
  47. end
  48. end
  49. end