diff --git a/Network/CommSec/KeyExchange/Internal.hs b/Network/CommSec/KeyExchange/Internal.hs
--- a/Network/CommSec/KeyExchange/Internal.hs
+++ b/Network/CommSec/KeyExchange/Internal.hs
@@ -112,8 +112,8 @@
                 bk = maybe (error "failed to build key") id . buildKey
             in (bk key1tmp, bk key2tmp, op salt1tmp, op salt2tmp)
         msg2     = buildSigMessage aesKey1 privateMe ay ax
-        outCtx   = Out 2 salt1 aesKey1
-        inCtx    = InStrict 1 salt2 aesKey2
+        outCtx   = Out (B.length msg2 `div` (blockSizeBytes `for` aesKey1))  salt1 aesKey1
+        inCtx    = InStrict (B.length encSaAxAy `div` (blockSizeBytes `for` aesKey2)) salt2 aesKey2
     sendMsg sock (runPut $ put ay >> put msg2)
     encSaAxAy <- recvMsg sock
     case parseSigMessage aesKey2 thems encSaAxAy ax ay of
@@ -160,8 +160,8 @@
                 bk = maybe (error "failed to build key") id . buildKey
             in (bk key1tmp, bk key2tmp, op salt1tmp, op salt2tmp)
         msg3     = buildSigMessage aesKey2 privateMe ax ay
-        outCtx   = Out 2 salt2 aesKey2
-        inCtx    = InStrict 1 salt1 aesKey1
+        outCtx   = Out (B.length msg3 `div` (blockSizeBytes `for` aesKey2)) salt2 aesKey2
+        inCtx    = InStrict (B.length encSbAyAx `div` (blockSizeBytes `for` aesKey2)) salt1 aesKey1
     case parseSigMessage aesKey1 thems encSbAyAx ay ax of
         Just t -> do
             sendMsg sock msg3
diff --git a/commsec-keyexchange.cabal b/commsec-keyexchange.cabal
--- a/commsec-keyexchange.cabal
+++ b/commsec-keyexchange.cabal
@@ -2,7 +2,7 @@
 -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                commsec-keyexchange
-version:             0.2.1.1
+version:             0.3
 synopsis:            Key agreement for commsec.
 description:         Use RSA keys to authenticate a key exchange to
                      establish a commsec 'Connection'.  This package comes with
