Class: Ronin::Support::Crypto::Key::EC
- Inherits:
-
OpenSSL::PKey::EC
- Object
- OpenSSL::PKey::EC
- Ronin::Support::Crypto::Key::EC
- Includes:
- Methods
- Defined in:
- lib/ronin/support/crypto/key/ec.rb
Overview
Represents an EC key.
Examples
List supported curves
Crypto::Key::EC.supported_curves
# => ["secp224r1", "secp256k1", "secp384r1", "secp521r1", "prime256v1"]
Generate a random key
ec = Crypto::Key::EC.random("secp224r1")
Class Method Summary collapse
-
.generate(curve = 'prime256v1') ⇒ EC
Generates a new random EC key.
-
.supported_curves ⇒ Array<String>
The supported elliptical curves.
Instance Method Summary collapse
-
#curve ⇒ String
The Elliptical Curve name.
-
#initialize(*args) ⇒ EC
constructor
Initializes the EC key.
-
#size ⇒ Integer?
The size of the EC key in bits.
Methods included from Methods
Constructor Details
#initialize(*args) ⇒ EC
Note:
Will print a warning message when running on JRuby about jruby-openssl's EC key bugs:
Initializes the EC key.
85 86 87 88 89 90 91 92 93 |
# File 'lib/ronin/support/crypto/key/ec.rb', line 85 def initialize(*args) if RUBY_ENGINE == 'jruby' warn "WARNING: jruby-openssl has multiple bugs wrt parsing EC keys" warn " * https://github.com/jruby/jruby-openssl/issues/256" warn " * https://github.com/jruby/jruby-openssl/issues/257" end super(*args) end |
Class Method Details
.generate(curve = 'prime256v1') ⇒ EC
Generates a new random EC key.
69 70 71 |
# File 'lib/ronin/support/crypto/key/ec.rb', line 69 def self.generate(curve='prime256v1') super(curve) end |
Instance Method Details
#curve ⇒ String
The Elliptical Curve name.
102 103 104 |
# File 'lib/ronin/support/crypto/key/ec.rb', line 102 def curve group.curve_name end |
#size ⇒ Integer?
The size of the EC key in bits.
113 114 115 116 117 |
# File 'lib/ronin/support/crypto/key/ec.rb', line 113 def size if (match = to_text.match(/\((\d+) bit\)/)) match[1].to_i end end |