Module: Ronin::Support::Crypto::Key::Methods::ClassMethods Private

Defined in:
lib/ronin/support/crypto/key/methods.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class-methods.

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#load(key, **kwargs) ⇒ OpenSSL::PKey

Alias for #parse.

Parameters:

  • key (String)

    The PEM or DER encoded key string.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for #parse.

Options Hash (**kwargs):

  • :password (String, nil)

    Optional password to decrypt the key.

Returns:

  • (OpenSSL::PKey)

    The parsed key.

See Also:

Since:

  • 1.0.0



99
100
101
# File 'lib/ronin/support/crypto/key/methods.rb', line 99

def load(key,**kwargs)
  parse(key,**kwargs)
end

#load_file(path, **kwargs) ⇒ OpenSSL::PKey

Loads a key from a file.

Parameters:

  • path (String)

    The path to the PEM or DER encoded key file.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for #parse.

Options Hash (**kwargs):

  • :password (String, nil)

    Optional password to decrypt the key.

Returns:

  • (OpenSSL::PKey)

    The parsed key.

Since:

  • 1.0.0



120
121
122
# File 'lib/ronin/support/crypto/key/methods.rb', line 120

def load_file(path,**kwargs)
  parse(File.read(path),**kwargs)
end

#parse(key, password: nil) ⇒ OpenSSL::PKey

Parses an PEM encoded key.

Parameters:

  • key (String)

    The PEM or DER encoded key string.

  • password (String, nil) (defaults to: nil)

    Optional password to decrypt the key.

Returns:

  • (OpenSSL::PKey)

    The parsed key.

Since:

  • 1.0.0



76
77
78
# File 'lib/ronin/support/crypto/key/methods.rb', line 76

def parse(key, password: nil)
  new(key,*password)
end

#random(*arguments, &block) ⇒ Class<Methods>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Alias for generate.

Generates a new random key.

Parameters:

  • arguments (Array)

    Additional arguments for generate.

Returns:

  • (Class<Methods>)

    The newly generated key.

Since:

  • 1.0.0



58
59
60
# File 'lib/ronin/support/crypto/key/methods.rb', line 58

def random(*arguments,&block)
  generate(*arguments,&block)
end