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.

fixture.rb 853B

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