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

Public Instance methods

[Source]

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

Private Instance methods

[Source]

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

[Validate]