Class: OpenID::Server::DiffieHellmanSHA1ServerSession

### Home Classes Methods

### In Files

- lib/openid/server.rb

### Parent

OpenID::Server::BaseServerSession

### Methods

- ::from_message
- ::new
- #answer

### Files

- LICENSE

### Class/Module Index

Quicksearch

- OpenID
- OpenID::AX
- OpenID::AX::AXMessage
- OpenID::AX::AttrInfo
- OpenID::AX::Error
- OpenID::AX::FetchRequest
- OpenID::AX::FetchResponse
- OpenID::AX::KeyValueMessage
- OpenID::AX::StoreRequest
- OpenID::AX::StoreResponse
- OpenID::AssertionError
- OpenID::Association
- OpenID::AssociationNegotiator
- OpenID::Consumer
- OpenID::Consumer::AssociationManager
- OpenID::Consumer::CancelResponse
- OpenID::Consumer::CheckIDRequest
- OpenID::Consumer::DiffieHellmanSHA1Session
- OpenID::Consumer::DiffieHellmanSHA256Session
- OpenID::Consumer::DiffieHellmanSession
- OpenID::Consumer::DiscoveredServices
- OpenID::Consumer::DiscoveryManager
- OpenID::Consumer::FailureResponse
- OpenID::Consumer::IdResHandler
- OpenID::Consumer::NoEncryptionSession
- OpenID::Consumer::Response
- OpenID::Consumer::Session
- OpenID::Consumer::SetupNeededResponse
- OpenID::Consumer::SuccessResponse
- OpenID::CryptUtil
- OpenID::DiffieHellman
- OpenID::DiscoveryFailure
- OpenID::Extension
- OpenID::FetchingError
- OpenID::HTTPRedirectLimitReached
- OpenID::HTTPResponse
- OpenID::HTTPStatusError
- OpenID::InvalidOpenIDNamespace
- OpenID::KVFormError
- OpenID::KVPostNetworkError
- OpenID::Message
- OpenID::Message::KeyNotFound
- OpenID::NamespaceAliasRegistrationError
- OpenID::NamespaceMap
- OpenID::Nonce
- OpenID::OAuth
- OpenID::OAuth::Request
- OpenID::OAuth::Response
- OpenID::OpenIDError
- OpenID::OpenIDServiceEndpoint
- OpenID::PAPE
- OpenID::PAPE::Request
- OpenID::PAPE::Response
- OpenID::ProtocolError
- OpenID::RealmVerificationRedirected
- OpenID::SReg
- OpenID::SReg::NamespaceError
- OpenID::SReg::Request
- OpenID::SReg::Response
- OpenID::SSLFetchingError
- OpenID::Server
- OpenID::Server::AlreadySigned
- OpenID::Server::AssociateRequest
- OpenID::Server::BaseServerSession
- OpenID::Server::CheckAuthRequest
- OpenID::Server::CheckIDRequest
- OpenID::Server::Decoder
- OpenID::Server::DiffieHellmanSHA1ServerSession
- OpenID::Server::DiffieHellmanSHA256ServerSession
- OpenID::Server::Encoder
- OpenID::Server::EncodingError
- OpenID::Server::MalformedReturnURL
- OpenID::Server::MalformedTrustRoot
- OpenID::Server::NoReturnToError
- OpenID::Server::OpenIDRequest
- OpenID::Server::OpenIDResponse
- OpenID::Server::PlainTextServerSession
- OpenID::Server::ProtocolError
- OpenID::Server::Server
- OpenID::Server::Signatory
- OpenID::Server::SigningEncoder
- OpenID::Server::UntrustedReturnURL
- OpenID::Server::VersionError
- OpenID::Server::WebResponse
- OpenID::ServerError
- OpenID::StandardFetcher
- OpenID::Store
- OpenID::Store::Filesystem
- OpenID::Store::Interface
- OpenID::Store::Memcache
- OpenID::Store::Memory
- OpenID::TrustRoot
- OpenID::TrustRoot::TrustRoot
- OpenID::TypeURIMismatch
- OpenID::UI
- OpenID::UI::Request
- OpenID::URINorm
- OpenID::UndefinedOpenIDNamespace
- OpenID::Util
- OpenID::Yadis
- OpenID::Yadis::BasicServiceEndpoint
- OpenID::Yadis::CompoundFilter
- OpenID::Yadis::DiscoveryResult
- OpenID::Yadis::TransformFilterMaker
- OpenID::Yadis::XRDSError
- OpenID::Yadis::XRDSFraud
- OpenID::Yadis::XRI
- OpenID::Yadis::XRI::ProxyResolver
- OpenID::Yadis::XRI::XRIHTTPError
- HMAC
- HMAC::Base
- HMAC::SHA1
- HMAC::SHA256
- HMAC::SHA384
- HMAC::SHA512
- Net
- Net::HTTP
- HTMLComment
- HTMLTag
- HTMLText
- HTMLToken
- HTMLTokenizer
- HTMLTokenizerError
- Object

No matching classes.

# OpenID::Server::DiffieHellmanSHA1ServerSession

An object that knows how to handle association requests with the Diffie-Hellman session type.

See OpenID Specs, Section 8: Establishing Associations <openid.net/specs/openid-authentication-2_0-12.html#associations>

### Attributes

consumer_pubkey[RW]

The public key sent by the consumer in the associate request

dh[RW]

The Diffie-Hellman algorithm values for this request

session_type[R]

The session_type for this association session.

### Public Class Methods

from_message(message) click to toggle source

Construct me from OpenID Message

Raises ProtocolError when parameters required to establish the session are missing.

    # File lib/openid/server.rb, line 222
    def self.from_message(message)
      dh_modulus = message.get_arg(OPENID_NS, 'dh_modulus')
      dh_gen = message.get_arg(OPENID_NS, 'dh_gen')
      if ((!dh_modulus and dh_gen) or
          (!dh_gen and dh_modulus))

        if !dh_modulus
          missing = 'modulus'
        else
          missing = 'generator'
        end

        raise ProtocolError.new(message,
                sprintf('If non-default modulus or generator is ' +
                        'supplied, both must be supplied. Missing %s',
                        missing))
      end

      if dh_modulus or dh_gen
        dh_modulus = CryptUtil.base64_to_num(dh_modulus)
        dh_gen = CryptUtil.base64_to_num(dh_gen)
        dh = DiffieHellman.new(dh_modulus, dh_gen)
      else
        dh = DiffieHellman.from_defaults()
      end

      consumer_pubkey = message.get_arg(OPENID_NS, 'dh_consumer_public')
      if !consumer_pubkey
        raise ProtocolError.new(message,
                sprintf("Public key for DH-SHA1 session " +
                        "not found in message %s", message))
      end

      consumer_pubkey = CryptUtil.base64_to_num(consumer_pubkey)

      return self.new(dh, consumer_pubkey)
    end

new(dh, consumer_pubkey) click to toggle source

    # File lib/openid/server.rb, line 210
    def initialize(dh, consumer_pubkey)
      super('DH-SHA1', ['HMAC-SHA1'])

      @hash_func = CryptUtil.method('sha1')
      @dh = dh
      @consumer_pubkey = consumer_pubkey
    end

### Public Instance Methods

answer(secret) click to toggle source

    # File lib/openid/server.rb, line 260
    def answer(secret)
      mac_key = @dh.xor_secret(@hash_func,
                               @consumer_pubkey,
                               secret)
      return {
          'dh_server_public' => CryptUtil.num_to_base64(@dh.public),
          'enc_mac_key' => Util.to_base64(mac_key),
          }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.