From 5ce2f8aedd8a21fe59e8d5896de9c4e68a593fc8 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Thu, 21 Jul 2011 23:15:26 +0200 Subject: [PATCH] calculated serverkey and serversignature to verify server success response --- Network/XMPP/SASL.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Network/XMPP/SASL.hs b/Network/XMPP/SASL.hs index 7ba4645..baaad26 100644 --- a/Network/XMPP/SASL.hs +++ b/Network/XMPP/SASL.hs @@ -26,7 +26,7 @@ with Pontarius XMPP. If not, see . -- TODO: Host is assumed to be ISO 8859-1; make list of assumptions. -- TODO: Can it contain newline characters? -module Network.XMPP.SASL (replyToChallenge, saltedPassword, clientKey, storedKey, authMessage, clientSignature, clientProof) where +module Network.XMPP.SASL (replyToChallenge, saltedPassword, clientKey, storedKey, authMessage, clientSignature, clientProof, serverKey, serverSignature) where import Prelude hiding (concat, zipWith) import Data.ByteString.Internal (c2w) @@ -160,6 +160,16 @@ clientProof :: ByteString -> ByteString -> ByteString clientProof ck cs = pack $ zipWith xor ck cs +serverKey :: ByteString -> ByteString + +serverKey sp = encodeLazy (hmac (MacKey (head $ toChunks sp)) (DBLC.pack "Server Key") :: SHA1) + + +serverSignature :: ByteString -> ByteString -> ByteString + +serverSignature servkey am = encodeLazy (hmac (MacKey (head $ toChunks servkey)) am :: SHA1) + + -- TODO: Implement SCRAM. replyToChallenge = replyToChallenge