Class: Cinch::SASL::DiffieHellman Private
- Inherits:
-
Object
- Object
- Cinch::SASL::DiffieHellman
- Defined in:
- lib/cinch/sasl/diffie_hellman.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
-
#e ⇒ Object
readonly
private
-
#g ⇒ Object
readonly
private
-
#p ⇒ Object
readonly
private
-
#q ⇒ Object
readonly
private
-
#x ⇒ Object
readonly
private
Instance Method Summary collapse
-
#generate(tries = 16) ⇒ Object
private
-
#initialize(p, g, q) ⇒ DiffieHellman
constructor
private
A new instance of DiffieHellman.
-
#secret(f) ⇒ Object
private
compute the shared secret, given the public key.
Constructor Details
#initialize(p, g, q) ⇒ DiffieHellman
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.
Returns a new instance of DiffieHellman.
8 9 10 11 12 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 8 def initialize(p, g, q) @p = p @g = g @q = q end |
Instance Attribute Details
#e ⇒ Object (readonly)
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.
6 7 8 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 6 def e @e end |
#g ⇒ Object (readonly)
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.
6 7 8 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 6 def g @g end |
#p ⇒ Object (readonly)
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.
6 7 8 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 6 def p @p end |
#q ⇒ Object (readonly)
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.
6 7 8 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 6 def q @q end |
#x ⇒ Object (readonly)
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.
6 7 8 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 6 def x @x end |
Instance Method Details
#generate(tries = 16) ⇒ Object
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.
14 15 16 17 18 19 20 21 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 14 def generate(tries = 16) tries.times do @x = rand(@q) @e = mod_exp(@g, @x, @p) return @e if valid? end raise ArgumentError, "can't generate valid e" end |
#secret(f) ⇒ Object
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.
compute the shared secret, given the public key
24 25 26 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 24 def secret(f) mod_exp(f, @x, @p) end |