123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Auth::Scram256::Conversation Private

Do not use. This class is for internal use only.

Overview

Defines behavior around a single SCRAM-SHA-256 conversation between the client and server.

Since:

  • 2.0.0

Constant Summary

::Mongo::Auth::SaslConversationBase - Inherited

CLIENT_CONTINUE_MESSAGE, CLIENT_FIRST_MESSAGE

::Mongo::Auth::ScramConversationBase - Inherited

MIN_ITER_COUNT

Class Method Summary

::Mongo::Auth::ScramConversationBase - Inherited

.new

Create the new conversation.

::Mongo::Auth::ConversationBase - Inherited

.new

Create the new conversation.

Instance Attribute Summary

::Mongo::Auth::ScramConversationBase - Inherited

#client_nonce,
#id

Get the id of the conversation.

#server_verified?

Whether the client verified the ServerSignature from the server.

#auth_message

::Mongo::Auth message algorithm implementation.

#iterations

Get the iterations from the server response.

#payload_data

Get the data from the returned payload.

#salt

Gets the salt from the server response.

#server_nonce

Get the server nonce from the payload.

::Mongo::Auth::ConversationBase - Inherited

Instance Method Summary

  • #digest private Internal use only
  • #hi(data) private Internal use only

    HI algorithm implementation.

  • #salted_password private Internal use only

    Salted password algorithm implementation.

::Mongo::Auth::ScramConversationBase - Inherited

#continue

Continue the SCRAM conversation.

#finalize

Finalize the SCRAM conversation.

#process_continue_response

Processes the second response from the server.

#speculative_auth_document

Returns the hash to provide to the server in the handshake as value of the speculativeAuthenticate key.

#cache_key,
#check_server_signature

Looks for field ‘v’ in payload data, if it is present verifies the server signature.

#client_empty_message

Get the empty client message.

#client_final

::Mongo::Client final implementation.

#client_final_message

Get the final client message.

#client_first_message_options, #client_first_payload,
#client_key

::Mongo::Client key algorithm implementation.

#client_proof

::Mongo::Client proof algorithm implementation.

#client_signature

::Mongo::Client signature algorithm implementation.

#compare_digest,
#first_bare

First bare implementation.

#h

H algorithm implementation.

#hmac

HMAC algorithm implementation.

#parse_payload

Parses a payload like a=value,b=value2 into a hash like => ‘value’, ‘b’ => ‘value2’.

#server_key

::Mongo::Server key algorithm implementation.

#server_signature

::Mongo::Server signature algorithm implementation.

#stored_key

Stored key algorithm implementation.

#without_proof

Get the without proof message.

#xor

XOR operation for two strings.

::Mongo::Auth::SaslConversationBase - Inherited

#start

Start the SASL conversation.

#auth_mechanism_name

Gets the auth mechanism name for the conversation class.

#client_first_document, #client_first_message_options,
#validate_server_nonce!

Helper method to validate that server nonce starts with the client nonce.

::Mongo::Auth::ConversationBase - Inherited

#build_message,
#speculative_auth_document

Returns the hash to provide to the server in the handshake as value of the speculativeAuthenticate key.

#validate_external_auth_source

Instance Method Details

#digest (private)

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/auth/scram256/conversation.rb', line 60

def digest
  @digest ||= OpenSSL::Digest::SHA256.new.freeze
end

#hi(data) (private)

HI algorithm implementation.

[ GitHub ]

  
# File 'lib/mongo/auth/scram256/conversation.rb', line 37

def hi(data)
  OpenSSL::PKCS5.pbkdf2_hmac(
    data,
    salt,
    iterations,
    digest.size,
    digest,
  )
end

#salted_password (private)

Salted password algorithm implementation.

[ GitHub ]

  
# File 'lib/mongo/auth/scram256/conversation.rb', line 54

def salted_password
  @salted_password ||= CredentialCache.cache(cache_key(:salted_password)) do
    hi(user.sasl_prepped_password)
  end
end