commsec-keyexchange 0.3.1 → 0.3.2
raw patch · 4 files changed
+10/−12 lines, 4 filesdep ~commsec
Dependency ranges changed: commsec
Files
- Network/CommSec/KeyExchange.hs +0/−1
- Network/CommSec/KeyExchange/Internal.hs +7/−8
- Test/test.hs +1/−1
- commsec-keyexchange.cabal +2/−2
Network/CommSec/KeyExchange.hs view
@@ -33,7 +33,6 @@ import Crypto.Cipher.AES128 import Crypto.Classes import Crypto.Util-import Crypto.Modes (zeroIV) import Crypto.Hash.CryptoAPI import Control.Exception (bracket) import Control.Monad
Network/CommSec/KeyExchange/Internal.hs view
@@ -12,7 +12,6 @@ import Crypto.Cipher.AES128 import Crypto.Classes import Crypto.Util-import Crypto.Modes (zeroIV) import Crypto.Hash.CryptoAPI import Control.Monad import Control.Monad.CryptoRandom@@ -31,7 +30,7 @@ -- For types import Network.CommSec hiding (accept, connect)-import Network.CommSec.Package (InContext(..), OutContext(..))+import Network.CommSec.Package (inContext, outContext, InContext, OutContext) -- |This prime is from RFC 5114 section 2.3 thePrime :: Integer@@ -62,14 +61,14 @@ ax = modexp theGenerator x thePrime return (x,ax) -buildSigMessage :: AESKey -> PrivateKey -> Integer -> Integer -> ByteString+buildSigMessage :: AESKey128 -> PrivateKey -> Integer -> Integer -> ByteString buildSigMessage aesKey privateMe ax ay = let publicMe = encode . sha256 . encode . private_pub $ privateMe mySig = signExps ax ay privateMe plaintext = B.append publicMe mySig in fst . ctr aesKey zeroIV $ plaintext -parseSigMessage :: AESKey -> [PublicKey] -> ByteString -> Integer -> Integer -> Maybe PublicKey+parseSigMessage :: AESKey128 -> [PublicKey] -> ByteString -> Integer -> Integer -> Maybe PublicKey parseSigMessage aesKey thems enc ax ay = let (pubHash, theirSig) = B.splitAt (256 `div` 8) . fst . unCtr aesKey zeroIV@@ -113,11 +112,11 @@ in (bk key1tmp, bk key2tmp, op salt1tmp, op salt2tmp) msg2 = buildSigMessage aesKey1 privateMe ay ax outCtr = fromIntegral $ B.length msg2 `div` (blockSizeBytes `for` aesKey1)- outCtx = Out outCtr salt1 aesKey1+ outCtx = outContext outCtr salt1 aesKey1 sendMsg sock (runPut $ put ay >> put msg2) encSaAxAy <- recvMsg sock let inCtr = fromIntegral $ B.length encSaAxAy `div` (blockSizeBytes `for` aesKey2)- inCtx = InStrict inCtr salt2 aesKey2+ inCtx = inContext inCtr salt2 aesKey2 case parseSigMessage aesKey2 thems encSaAxAy ax ay of Just t -> return (Just (t, outCtx, inCtx)) Nothing -> return Nothing@@ -163,9 +162,9 @@ in (bk key1tmp, bk key2tmp, op salt1tmp, op salt2tmp) msg3 = buildSigMessage aesKey2 privateMe ax ay outCtr = fromIntegral $ B.length msg3 `div` (blockSizeBytes `for` aesKey2)- outCtx = Out outCtr salt2 aesKey2+ outCtx = outContext outCtr salt2 aesKey2 inCtr = fromIntegral $ B.length encSbAyAx `div` (blockSizeBytes `for` aesKey1)- inCtx = InStrict inCtr salt1 aesKey1+ inCtx = inContext inCtr salt1 aesKey1 case parseSigMessage aesKey1 thems encSbAyAx ay ax of Just t -> do sendMsg sock msg3
Test/test.hs view
@@ -34,7 +34,7 @@ connecter privB pubA listener priv pub = do- conn <- snd `fmap` accept port [pub] priv+ conn <- snd `fmap` accept port [pub] priv Nothing recv conn >>= print send conn "Hello to you too!" return ()
commsec-keyexchange.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: commsec-keyexchange-version: 0.3.1+version: 0.3.2 synopsis: Key agreement for commsec. description: Use RSA keys to authenticate a key exchange to establish a commsec 'Connection'. This package comes with@@ -30,7 +30,7 @@ cipher-aes128, crypto-api >= 0.12.2, bytestring,- commsec >= 0.3,+ commsec >= 0.3.5, RSA, cryptohash-cryptoapi, DRBG >= 0.5,