Happy,
Check out the Jabber source code. I think you'll find it smooths over some of the rough spots of the task.
Some things you might want to do to give them a real run:
Rolling algorithms
Offer symetric and asymetric crypto
Make it pkcs11 and X.509 compliant to allow Entrust/Baltimore Whistler users to use their exsisting certs and keys to chat.
I also have source code to allow you to generate keys on a PC/SC compliant smart card.