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.
19 20 21 22 |
# File 'lib/openid/consumer/associationmanager.rb', line 19 def initialize(dh = nil) dh = DiffieHellman.from_defaults if dh.nil? @dh = dh end |
Class Attribute Details
.allowed_assoc_types ⇒ Object (readonly)
Returns the value of attribute allowed_assoc_types.
13 14 15 |
# File 'lib/openid/consumer/associationmanager.rb', line 13 def allowed_assoc_types @allowed_assoc_types end |
.hashfunc ⇒ Object (readonly)
Returns the value of attribute hashfunc.
13 14 15 |
# File 'lib/openid/consumer/associationmanager.rb', line 13 def hashfunc @hashfunc end |
.secret_size ⇒ Object (readonly)
Returns the value of attribute secret_size.
13 14 15 |
# File 'lib/openid/consumer/associationmanager.rb', line 13 def secret_size @secret_size end |
.session_type ⇒ Object (readonly)
Returns the value of attribute session_type.
13 14 15 |
# File 'lib/openid/consumer/associationmanager.rb', line 13 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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/openid/consumer/associationmanager.rb', line 38 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) @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
26 27 28 29 30 31 32 33 34 |
# File 'lib/openid/consumer/associationmanager.rb', line 26 def get_request args = {"dh_consumer_public" => CryptUtil.num_to_base64(@dh.public)} unless @dh.using_default_values? args["dh_modulus"] = CryptUtil.num_to_base64(@dh.modulus) args["dh_gen"] = CryptUtil.num_to_base64(@dh.generator) end args end |