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 3197
3197:       def initialize(user, password)
3198:         @user = user
3199:         @password = password
3200:       end

Public Instance methods

[Source]

      # File lib/net/imap.rb, line 3190
3190:       def process(challenge)
3191:         digest = hmac_md5(challenge, @password)
3192:         return @user + " " + digest
3193:       end

Private Instance methods

[Source]

      # File lib/net/imap.rb, line 3202
3202:       def hmac_md5(text, key)
3203:         if key.length > 64
3204:           key = Digest::MD5.digest(key)
3205:         end
3206: 
3207:         k_ipad = key + "\0" * (64 - key.length)
3208:         k_opad = key + "\0" * (64 - key.length)
3209:         for i in 0..63
3210:           k_ipad[i] ^= 0x36
3211:           k_opad[i] ^= 0x5c
3212:         end
3213: 
3214:         digest = Digest::MD5.digest(k_ipad + text)
3215: 
3216:         return Digest::MD5.hexdigest(k_opad + digest)
3217:       end

[Validate]