module Net::IMAP::SASL::ScramAlgorithm
For method descriptions, see RFC5802 §2.2 and RFC5802 §3.
Public Instance Methods
H(str)
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 24 def H(str) digest.digest str end
HMAC(key, data)
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 26 def HMAC(key, data) OpenSSL::HMAC.digest(digest, key, data) end
Hi(str, salt, iterations)
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 13 def Hi(str, salt, iterations) length = digest.digest_length OpenSSL::KDF.pbkdf2_hmac( str, salt: salt, iterations: iterations, length: length, hash: digest, ) end
Normalize(str)
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 11 def Normalize(str) SASL.saslprep(str) end
XOR(str1, str2)
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 28 def XOR(str1, str2) str1.unpack("C*") .zip(str2.unpack("C*")) .map {|a, b| a ^ b } .pack("C*") end
auth_message()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 35 def auth_message [ client_first_message_bare, server_first_message, client_final_message_without_proof, ] .join(",") end
client_key()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 48 def client_key; HMAC(salted_password, "Client Key") end
client_proof()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 53 def client_proof; XOR(client_key, client_signature) end
client_signature()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 51 def client_signature; HMAC(stored_key, auth_message) end
salted_password()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 44 def salted_password Hi(Normalize(password), salt, iterations) end
server_key()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 49 def server_key; HMAC(salted_password, "Server Key") end
server_signature()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 52 def server_signature; HMAC(server_key, auth_message) end
stored_key()
click to toggle source
# File net-imap-0.4.9.1/lib/net/imap/sasl/scram_algorithm.rb, line 50 def stored_key; H(client_key) end