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 3164
3164:       def initialize(user, password)
3165:         @user = user
3166:         @password = password
3167:       end

Public Instance methods

[Source]

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

Private Instance methods

[Source]

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

[Validate]