Class: Izokatu::Openssl::PublicKey::RSA::KeysGenerator

Inherits:
KeysGenerator
  • Object
show all
Defined in:
lib/izokatu/openssl/public_key/rsa/keys_generator.rb

Overview

OpenSSL RSA keys generator

Constant Summary collapse

DEFAULT_OPTIONS =

Default options for OpenSSL RSA keys generation

{
  bit_number: 4096
}.freeze

Constants inherited from KeysGenerator

KeysGenerator::KEYS_SYMBOLS, KeysGenerator::KEY_CLASSES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Callable

#call

Constructor Details

#initialize(bit_number:) ⇒ KeysGenerator

Initialize option for OpenSSL RSA keys generation

Parameters:

Since:

  • 0.1.0



24
25
26
27
# File 'lib/izokatu/openssl/public_key/rsa/keys_generator.rb', line 24

def initialize(bit_number:)
  super()
  @bit_number = bit_number || DEFAULT_OPTIONS[:bit_number]
end

Instance Attribute Details

#bit_numberInteger (readonly)

Returns bit number for OpenSSL RSA encryption/decryption.

Returns:

  • (Integer)

    bit number for OpenSSL RSA encryption/decryption



11
12
13
# File 'lib/izokatu/openssl/public_key/rsa/keys_generator.rb', line 11

def bit_number
  @bit_number
end

Instance Method Details

#generate_private_keyOpenSSL::PKey::RSA (private)

Performing generation of OpenSSL RSA private key

Returns:

  • (OpenSSL::PKey::RSA)

    OpenSSL private key

Since:

  • 0.1.0



47
48
49
# File 'lib/izokatu/openssl/public_key/rsa/keys_generator.rb', line 47

def generate_private_key
  OpenSSL::PKey::RSA.new(bit_number)
end

#generate_public_key(private_key) ⇒ OpenSSL::PKey::RSA (private)

Performing generation of OpenSSL RSA private key

Returns:

  • (OpenSSL::PKey::RSA)

    OpenSSL private key

Since:

  • 0.1.0



57
58
59
# File 'lib/izokatu/openssl/public_key/rsa/keys_generator.rb', line 57

def generate_public_key(private_key)
  private_key.public_key
end

#performHash

Performing generation of OpenSSL RSA private and public keys

Returns:

  • (Hash)

    OpenSSL RSA public and private keys

Since:

  • 0.1.0



35
36
37
# File 'lib/izokatu/openssl/public_key/rsa/keys_generator.rb', line 35

def perform
  super.transform_values(&:to_pem)
end