Module: Ronin::Support::Crypto::Key
- Defined in:
- lib/ronin/support/crypto/key.rb,
lib/ronin/support/crypto/key/dh.rb,
lib/ronin/support/crypto/key/ec.rb,
lib/ronin/support/crypto/key/dsa.rb,
lib/ronin/support/crypto/key/rsa.rb,
lib/ronin/support/crypto/key/methods.rb
Overview
Top-level methods for working with public/private keys.
Defined Under Namespace
Modules: Methods Classes: DH, DSA, EC, RSA
Class Method Summary collapse
-
.load(key, **kwargs) ⇒ DH, ...
Alias for Key.parse.
-
.load_file(path) ⇒ DH, ...
Loads the key from the file.
-
.parse(key, password: nil) ⇒ OpenSSL::PKey, ...
Parses an PEM encoded key.
Class Method Details
.load(key, **kwargs) ⇒ DH, ...
Alias for parse.
86 87 88 |
# File 'lib/ronin/support/crypto/key.rb', line 86 def self.load(key,**kwargs) parse(key,**kwargs) end |
.load_file(path) ⇒ DH, ...
Loads the key from the file.
104 105 106 |
# File 'lib/ronin/support/crypto/key.rb', line 104 def self.load_file(path) parse(File.read(path)) end |
.parse(key, password: nil) ⇒ OpenSSL::PKey, ...
Parses an PEM encoded key.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ronin/support/crypto/key.rb', line 51 def self.parse(key, password: nil) key_class = if key.start_with?('-----BEGIN RSA PRIVATE KEY-----') RSA elsif key.start_with?('-----BEGIN DSA PRIVATE KEY-----') DSA elsif key.start_with?('-----BEGIN DH PARAMETERS-----') DH elsif key.start_with?('-----BEGIN EC PRIVATE KEY-----') EC else raise(ArgumentError,"cannot determine the key type for key: #{key.inspect}") end key_class.parse(key, password: password) end |