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 3161
3161:       def initialize(user, password)
3162:         @user = user
3163:         @password = password
3164:       end

Public Instance methods

[Source]

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

Private Instance methods

[Source]

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

[Validate]