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 3144
3144:       def initialize(user, password)
3145:         @user = user
3146:         @password = password
3147:       end

Public Instance methods

[Source]

      # File lib/net/imap.rb, line 3137
3137:       def process(challenge)
3138:         digest = hmac_md5(challenge, @password)
3139:         return @user + " " + digest
3140:       end

Private Instance methods

[Source]

      # File lib/net/imap.rb, line 3149
3149:       def hmac_md5(text, key)
3150:         if key.length > 64
3151:           key = Digest::MD5.digest(key)
3152:         end
3153: 
3154:         k_ipad = key + "\0" * (64 - key.length)
3155:         k_opad = key + "\0" * (64 - key.length)
3156:         for i in 0..63
3157:           k_ipad[i] ^= 0x36
3158:           k_opad[i] ^= 0x5c
3159:         end
3160: 
3161:         digest = Digest::MD5.digest(k_ipad + text)
3162: 
3163:         return Digest::MD5.hexdigest(k_opad + digest)
3164:       end

[Validate]