Hi Dirk,

I'm glad you want to add authentication to the SMTP library. Once your 
cram-md5 code is ready all it takes to integrate it in the library is add a 
new : auth word in the 'Command routines' section.

You first need to check for a 250-AUTH LOGIN PLAIN response after the esmtp 
(extended smtp) ehlo command called by the start word. If AUTH LOGIN is 
listed you can login to the server with:

: auth ( -- )
    "AUTH LOGIN\r\n" get-ok ! sends AUTH command
     (then in pseudo-code)
     check 334 response (i.e. get-ok)
     send your base64 encoded username (look at the get-ok word)
     check 334 response
     send your base64 encoded password
     check 235 ... OK Authenticated response ;

You'll also need to add two new response codes (334 and 235) to the 
check-response word and a watch for 250-AUTH in the process-multiline word. 
A multi-line response, such as that following the EHLO command, begins with 
a line containing a hyphen in the 4th column and ends with a line containing 
the same reply code but no hyphen (it is handled by the process-multiline 
word.)

Then in test.factor that gives a usage example you'll be able to call the 
auth word right after 'start' and before giving your email address in 
'mailfrom'. Let me know if the above workflow works  (untested) or if you 
need any help in implementing it.

Elie

>From: "Dirk Vleugels" <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: Re: [Factor-talk] SMTP Library
>Date: Thu, 24 May 2007 17:33:50 +0200
>
>Hi,
>
>im lurking on the list for quite a while, but this is my first try to
>generate some factor code:
>
>=cut
>
>USING: crypto sequences math kernel base64 ;
>IN: cram-md5
>
>! see http://en.wikipedia.org/wiki/HMAC
>
>: ipad ( key -- ipad ) [ HEX: 36 bitxor ] map ;
>: opad ( key -- opad ) [ HEX: 5C bitxor ] map ;
>
>: padto64 ( str -- padded-str ) 64 0 pad-right ;
>
>: trim-key ( key -- padded-key )  dup length 64 > [ string>md5 ] [
>padto64 ] if ;
>
>! MD5(K XOR opad, MD5(K XOR ipad, text))
>: hmac-md5 ( challenge key -- digest )
>   trim-key 2dup ipad swap append string>md5
>   >r nip opad r>  append string>md5str ;
>
>! calculate response string, challenge expected i clear text
>: cram-md5 ( user challenge key -- reponse )
>   hmac-md5 " " swap append append >base64 ;
>
>=cut
>
>The goal is to add cram-md5 authentication support to the smtp lib (
>which will be the hard part). It took to long to get this running (90
>mins), but was fun anyways ...
>
>Is the code above ok?
>
>Question: is there a way to copy&paste something from the
>factor-listener (a string representation) to a terminal for example?
>This is on macosx-x86 running 0.89.
>
>Cheers,
>Dirk
>
>-------------------------------------------------------------------------
>This SF.net email is sponsored by DB2 Express
>Download DB2 Express C - the FREE version of DB2 express and take
>control of your XML. No limits. Just data. Click to get it now.
>http://sourceforge.net/powerbar/db2/
>_______________________________________________
>Factor-talk mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/factor-talk

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to