Class: Net::SMTP::AuthCramMD5
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Authenticator
|
|
Instance Chain:
self,
Authenticator
|
|
Inherits: |
Net::SMTP::Authenticator
|
Defined in: | lib/net/smtp/auth_cram_md5.rb |
Constant Summary
-
CRAM_BUFSIZE =
# File 'lib/net/smtp/auth_cram_md5.rb', line 2764
-
IMASK =
# File 'lib/net/smtp/auth_cram_md5.rb', line 180x36
-
OMASK =
# File 'lib/net/smtp/auth_cram_md5.rb', line 190x5c
Class Method Summary
Authenticator
- Inherited
Instance Attribute Summary
Authenticator
- Inherited
Instance Method Summary
- #auth(user, secret)
-
#cram_md5_response(secret, challenge)
CRAM-MD5: [RFC2195].
- #cram_secret(secret, mask)
- #digest_class
Authenticator
- Inherited
Constructor Details
This class inherits a constructor from Net::SMTP::Authenticator
Instance Method Details
#auth(user, secret)
[ GitHub ]# File 'lib/net/smtp/auth_cram_md5.rb', line 12
def auth(user, secret) challenge = continue('AUTH CRAM-MD5') crammed = cram_md5_response(secret, challenge.unpack1('m')) finish(base64_encode("#{user} #{crammed}")) end
#cram_md5_response(secret, challenge)
CRAM-MD5: [RFC2195]
# File 'lib/net/smtp/auth_cram_md5.rb', line 22
def cram_md5_response(secret, challenge) tmp = digest_class::MD5.digest(cram_secret(secret, IMASK) + challenge) digest_class::MD5.hexdigest(cram_secret(secret, OMASK) + tmp) end
#cram_secret(secret, mask)
[ GitHub ]# File 'lib/net/smtp/auth_cram_md5.rb', line 29
def cram_secret(secret, mask) secret = digest_class::MD5.digest(secret) if secret.size > CRAM_BUFSIZE buf = secret.ljust(CRAM_BUFSIZE, "\0") 0.upto(buf.size - 1) do |i| buf[i] = (buf[i].ord ^ mask).chr end buf end
#digest_class
[ GitHub ]# File 'lib/net/smtp/auth_cram_md5.rb', line 38
def digest_class @digest_class ||= if defined?(OpenSSL::Digest) OpenSSL::Digest elsif defined?(::Digest) ::Digest else raise '"openssl" or "digest" library is required' end end