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
