Class Net::IMAP::CramMD5Authenticator
In: lib/net/imap.rb
Parent: Object

Authenticator for the "CRAM-MD5" authentication type. See authenticate().

Methods

hmac_md5   new   process  

Public Class methods

[Source]

      # File lib/net/imap.rb, line 3162
3162:       def initialize(user, password)
3163:         @user = user
3164:         @password = password
3165:       end

Public Instance methods

[Source]

      # File lib/net/imap.rb, line 3155
3155:       def process(challenge)
3156:         digest = hmac_md5(challenge, @password)
3157:         return @user + " " + digest
3158:       end

Private Instance methods

[Source]

      # File lib/net/imap.rb, line 3167
3167:       def hmac_md5(text, key)
3168:         if key.length > 64
3169:           key = Digest::MD5.digest(key)
3170:         end
3171: 
3172:         k_ipad = key + "\0" * (64 - key.length)
3173:         k_opad = key + "\0" * (64 - key.length)
3174:         for i in 0..63
3175:           k_ipad[i] ^= 0x36
3176:           k_opad[i] ^= 0x5c
3177:         end
3178: 
3179:         digest = Digest::MD5.digest(k_ipad + text)
3180: 
3181:         return Digest::MD5.hexdigest(k_opad + digest)
3182:       end

[Validate]