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)
-
- (Object) e
readonly
private
-
- (Object) g
readonly
private
-
- (Object) p
readonly
private
-
- (Object) q
readonly
private
-
- (Object) x
readonly
private
Instance Method Summary (collapse)
-
- (Object) generate(tries = 16)
private
-
- (DiffieHellman) initialize(p, g, q)
constructor
private
A new instance of DiffieHellman.
-
- (Object) secret(f)
private
compute the shared secret, given the public key.
Constructor Details
- (DiffieHellman) initialize(p, g, q)
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.
A new instance of DiffieHellman
6 7 8 9 10 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 6 def initialize(p, g, q) @p = p @g = g @q = q end |
Instance Attribute Details
- (Object) e (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.
4 5 6 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 4 def e @e end |
- (Object) g (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.
4 5 6 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 4 def g @g end |
- (Object) p (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.
4 5 6 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 4 def p @p end |
- (Object) q (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.
4 5 6 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 4 def q @q end |
- (Object) x (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.
4 5 6 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 4 def x @x end |
Instance Method Details
- (Object) generate(tries = 16)
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.
12 13 14 15 16 17 18 19 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 12 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 |
- (Object) secret(f)
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
22 23 24 |
# File 'lib/cinch/sasl/diffie_hellman.rb', line 22 def secret(f) mod_exp(f, @x, @p) end |