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 3169
3169:       def initialize(user, password)
3170:         @user = user
3171:         @password = password
3172:       end

Public Instance methods

[Source]

      # File lib/net/imap.rb, line 3162
3162:       def process(challenge)
3163:         digest = hmac_md5(challenge, @password)
3164:         return @user + " " + digest
3165:       end

Private Instance methods

[Source]

      # File lib/net/imap.rb, line 3174
3174:       def hmac_md5(text, key)
3175:         if key.length > 64
3176:           key = Digest::MD5.digest(key)
3177:         end
3178: 
3179:         k_ipad = key + "\0" * (64 - key.length)
3180:         k_opad = key + "\0" * (64 - key.length)
3181:         for i in 0..63
3182:           k_ipad[i] ^= 0x36
3183:           k_opad[i] ^= 0x5c
3184:         end
3185: 
3186:         digest = Digest::MD5.digest(k_ipad + text)
3187: 
3188:         return Digest::MD5.hexdigest(k_opad + digest)
3189:       end

[Validate]