Class: RSA::Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rsa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrivate

Returns a new instance of Private.



58
59
60
61
# File 'lib/rsa.rb', line 58

def initialize
  generated_p_and_q
  generated_totiente_n
end

Instance Attribute Details

#key_dObject (readonly)

Returns the value of attribute key_d.



56
57
58
# File 'lib/rsa.rb', line 56

def key_d
  @key_d
end

#key_pObject (readonly)

Returns the value of attribute key_p.



56
57
58
# File 'lib/rsa.rb', line 56

def key_p
  @key_p
end

#key_qObject (readonly)

Returns the value of attribute key_q.



56
57
58
# File 'lib/rsa.rb', line 56

def key_q
  @key_q
end

#totiente_nObject (readonly)

Returns the value of attribute totiente_n.



56
57
58
# File 'lib/rsa.rb', line 56

def totiente_n
  @totiente_n
end

Instance Method Details

#create_file(archive) ⇒ Object



77
78
79
80
# File 'lib/rsa.rb', line 77

def create_file(archive)
  key_n = @key_p * @key_q
  archive.write [key_n, @key_d]
end

#create_file_of_keysObject



72
73
74
75
# File 'lib/rsa.rb', line 72

def create_file_of_keys
  private_key_file = ArchivePrivate.new
  private_key_file.write keys
end

#generated_d(e) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/rsa.rb', line 63

def generated_d(e)
  number = 1
  until Mathematics.is_multiplicative_inverse?((number * e), @totiente_n)
    number += 1
  end

  @key_d = number
end