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.

78 lines
811B

  1. class ::OpenSSL::PKey::EC
  2. def type
  3. :ecc
  4. end
  5. def size
  6. self.group.degree
  7. end
  8. def rsa_equivalent_size
  9. case self.size
  10. when 160 then 1024
  11. when 224 then 2048
  12. when 256 then 3072
  13. when 384 then 7680
  14. when 521 then 15360
  15. end
  16. end
  17. def to_s
  18. "ECC #{self.size} bits"
  19. end
  20. end
  21. class ::OpenSSL::PKey::RSA
  22. def type
  23. :rsa
  24. end
  25. def size
  26. self.n.num_bits
  27. end
  28. def rsa_equivalent_size
  29. self.size
  30. end
  31. def to_s
  32. "RSA #{self.size} bits"
  33. end
  34. end
  35. class ::OpenSSL::PKey::DSA
  36. def type
  37. :dsa
  38. end
  39. def size
  40. self.p.num_bits
  41. end
  42. def rsa_equivalent_size
  43. self.size
  44. end
  45. def to_s
  46. "DSA #{self.size} bits"
  47. end
  48. end
  49. class ::OpenSSL::PKey::DH
  50. def type
  51. :dh
  52. end
  53. def size
  54. self.p.num_bits
  55. end
  56. def rsa_equivalent_size
  57. self.size
  58. end
  59. def to_s
  60. "DH #{self.size} bits"
  61. end
  62. end