Class: OpenID::Consumer::DiffieHellmanSession
- Inherits:
-
Object
- Object
- OpenID::Consumer::DiffieHellmanSession
- Defined in:
- lib/openid/consumer/associationmanager.rb
Overview
A superclass for implementing Diffie-Hellman association sessions.
Direct Known Subclasses
Class Attribute Summary collapse
-
.allowed_assoc_types ⇒ Object
readonly
Returns the value of attribute allowed_assoc_types.
-
.hashfunc ⇒ Object
readonly
Returns the value of attribute hashfunc.
-
.secret_size ⇒ Object
readonly
Returns the value of attribute secret_size.
-
.session_type ⇒ Object
readonly
Returns the value of attribute session_type.
Instance Method Summary collapse
-
#extract_secret(response) ⇒ Object
Process the response from a successful association request and return the shared secret for this association.
-
#get_request ⇒ Object
Return the query parameters for requesting an association using this Diffie-Hellman association session.
-
#initialize(dh = nil) ⇒ DiffieHellmanSession
constructor
A new instance of DiffieHellmanSession.
Constructor Details
#initialize(dh = nil) ⇒ DiffieHellmanSession
Returns a new instance of DiffieHellmanSession.
18 19 20 21 22 23 |
# File 'lib/openid/consumer/associationmanager.rb', line 18 def initialize(dh=nil) if dh.nil? dh = DiffieHellman.from_defaults end @dh = dh end |
Class Attribute Details
.allowed_assoc_types ⇒ Object (readonly)
Returns the value of attribute allowed_assoc_types.
14 15 16 |
# File 'lib/openid/consumer/associationmanager.rb', line 14 def allowed_assoc_types @allowed_assoc_types end |
.hashfunc ⇒ Object (readonly)
Returns the value of attribute hashfunc.
14 15 16 |
# File 'lib/openid/consumer/associationmanager.rb', line 14 def hashfunc @hashfunc end |
.secret_size ⇒ Object (readonly)
Returns the value of attribute secret_size.
14 15 16 |
# File 'lib/openid/consumer/associationmanager.rb', line 14 def secret_size @secret_size end |
.session_type ⇒ Object (readonly)
Returns the value of attribute session_type.
14 15 16 |
# File 'lib/openid/consumer/associationmanager.rb', line 14 def session_type @session_type end |
Instance Method Details
#extract_secret(response) ⇒ Object
Process the response from a successful association request and return the shared secret for this association
39 40 41 42 43 44 45 46 47 |
# File 'lib/openid/consumer/associationmanager.rb', line 39 def extract_secret(response) dh_server_public64 = response.get_arg(OPENID_NS, 'dh_server_public', NO_DEFAULT) enc_mac_key64 = response.get_arg(OPENID_NS, 'enc_mac_key', NO_DEFAULT) dh_server_public = CryptUtil.base64_to_num(dh_server_public64) enc_mac_key = Util.from_base64(enc_mac_key64) return @dh.xor_secret(self.class.hashfunc, dh_server_public, enc_mac_key) end |
#get_request ⇒ Object
Return the query parameters for requesting an association using this Diffie-Hellman association session
27 28 29 30 31 32 33 34 35 |
# File 'lib/openid/consumer/associationmanager.rb', line 27 def get_request args = {'dh_consumer_public' => CryptUtil.num_to_base64(@dh.public)} if (!@dh.using_default_values?) args['dh_modulus'] = CryptUtil.num_to_base64(@dh.modulus) args['dh_gen'] = CryptUtil.num_to_base64(@dh.generator) end return args end |