From 6aec0b13fda0838f8fbef044826575e5adfad8b4 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Mon, 12 Feb 2024 22:31:31 +0000 Subject: [PATCH] use different algorithms to authorize snd/rcv commands, use random correlation ID --- src/Simplex/Messaging/Agent.hs | 4 +- src/Simplex/Messaging/Agent/Client.hs | 9 +- src/Simplex/Messaging/Agent/Env/SQLite.hs | 10 +- .../Messaging/Agent/NtfSubSupervisor.hs | 2 +- src/Simplex/Messaging/Client.hs | 14 +-- src/Simplex/Messaging/Crypto.hs | 4 + tests/AgentTests/FunctionalAPITests.hs | 2 +- tests/CoreTests/BatchingTests.hs | 109 +++++++++--------- 8 files changed, 81 insertions(+), 73 deletions(-) diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index 9889044de..8e6e43f88 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -1636,7 +1636,7 @@ registerNtfToken' c suppliedDeviceToken suppliedNtfMode = createToken = getNtfServer c >>= \case Just ntfServer -> - asks (cmdAuthAlg . config) >>= \case + asks (rcvAuthAlg . config) >>= \case C.AuthAlg a -> do g <- asks random tknKeys <- atomically $ C.generateAuthKeyPair a g @@ -2501,7 +2501,7 @@ agentRatchetDecrypt' g db connId rc encAgentMsg = do newSndQueue :: (MonadUnliftIO m, MonadReader Env m) => UserId -> ConnId -> Compatible SMPQueueInfo -> m NewSndQueue newSndQueue userId connId (Compatible (SMPQueueInfo smpClientVersion SMPQueueAddress {smpServer, senderId, dhPublicKey = rcvE2ePubDhKey})) = do - C.AuthAlg a <- asks $ cmdAuthAlg . config + C.AuthAlg a <- asks $ sndAuthAlg . config g <- asks random (sndPublicKey, sndPrivateKey) <- atomically $ C.generateAuthKeyPair a g (e2ePubKey, e2ePrivKey) <- atomically $ C.generateKeyPair g diff --git a/src/Simplex/Messaging/Agent/Client.hs b/src/Simplex/Messaging/Agent/Client.hs index 1151ab16f..ad28e79de 100644 --- a/src/Simplex/Messaging/Agent/Client.hs +++ b/src/Simplex/Messaging/Agent/Client.hs @@ -864,14 +864,15 @@ data ProtocolTestFailure = ProtocolTestFailure runSMPServerTest :: AgentMonad m => AgentClient -> UserId -> SMPServerWithAuth -> m (Maybe ProtocolTestFailure) runSMPServerTest c userId (ProtoServerWithAuth srv auth) = do cfg <- getClientConfig c smpCfg - C.AuthAlg a <- asks $ cmdAuthAlg . config + C.AuthAlg ra <- asks $ rcvAuthAlg . config + C.AuthAlg sa <- asks $ sndAuthAlg . config g <- asks random liftIO $ do let tSess = (userId, srv, Nothing) getProtocolClient g tSess cfg Nothing (\_ -> pure ()) >>= \case Right smp -> do - rKeys@(_, rpKey) <- atomically $ C.generateAuthKeyPair a g - (sKey, _) <- atomically $ C.generateAuthKeyPair a g + rKeys@(_, rpKey) <- atomically $ C.generateAuthKeyPair ra g + (sKey, _) <- atomically $ C.generateAuthKeyPair sa g (dhKey, _) <- atomically $ C.generateKeyPair g r <- runExceptT $ do SMP.QIK {rcvId} <- liftError (testErr TSCreateQueue) $ createSMPQueue smp rKeys dhKey auth SMSubscribe @@ -952,7 +953,7 @@ getSessionMode = fmap sessionMode . readTVarIO . useNetworkConfig newRcvQueue :: AgentMonad m => AgentClient -> UserId -> ConnId -> SMPServerWithAuth -> VersionRange -> SubscriptionMode -> m (NewRcvQueue, SMPQueueUri) newRcvQueue c userId connId (ProtoServerWithAuth srv auth) vRange subMode = do - C.AuthAlg a <- asks (cmdAuthAlg . config) + C.AuthAlg a <- asks (rcvAuthAlg . config) g <- asks random rKeys@(_, rcvPrivateKey) <- atomically $ C.generateAuthKeyPair a g (dhKey, privDhKey) <- atomically $ C.generateKeyPair g diff --git a/src/Simplex/Messaging/Agent/Env/SQLite.hs b/src/Simplex/Messaging/Agent/Env/SQLite.hs index 2d1821b85..a028da52f 100644 --- a/src/Simplex/Messaging/Agent/Env/SQLite.hs +++ b/src/Simplex/Messaging/Agent/Env/SQLite.hs @@ -83,7 +83,8 @@ data InitialAgentServers = InitialAgentServers data AgentConfig = AgentConfig { tcpPort :: ServiceName, - cmdAuthAlg :: C.AuthAlg, + rcvAuthAlg :: C.AuthAlg, + sndAuthAlg :: C.AuthAlg, connIdBytes :: Int, tbqSize :: Natural, smpCfg :: ProtocolClientConfig, @@ -148,9 +149,10 @@ defaultAgentConfig :: AgentConfig defaultAgentConfig = AgentConfig { tcpPort = "5224", - -- while the current client version supports X25519, it can only be enabled once support for SMP v6 is dropped, - -- and all servers are required to support v7 to be compatible. - cmdAuthAlg = C.AuthAlg C.SEd448, + -- while the current client version supports X25519, it can only be enabled once support for SMP v7 is dropped, + -- and all servers are required to support v8 to be compatible. + rcvAuthAlg = C.AuthAlg C.SEd25519, -- this will stay as Ed25519 + sndAuthAlg = C.AuthAlg C.SEd25519, -- TODO replace with X25519 when switching to v8 connIdBytes = 12, tbqSize = 64, smpCfg = defaultSMPClientConfig {defaultTransport = (show defaultSMPPort, transport @TLS)}, diff --git a/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs b/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs index 002a82fcc..aa2c0e9c6 100644 --- a/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs +++ b/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs @@ -253,7 +253,7 @@ runNtfSMPWorker c srv Worker {doWork} = do getNtfToken >>= \case Just NtfToken {ntfTknStatus = NTActive, ntfMode = NMInstant} -> do rq <- withStore c (`getPrimaryRcvQueue` connId) - C.AuthAlg a <- asks (cmdAuthAlg . config) + C.AuthAlg a <- asks (rcvAuthAlg . config) g <- asks random (ntfPublicKey, ntfPrivateKey) <- atomically $ C.generateAuthKeyPair a g (rcvNtfPubDhKey, rcvNtfPrivDhKey) <- atomically $ C.generateKeyPair g diff --git a/src/Simplex/Messaging/Client.hs b/src/Simplex/Messaging/Client.hs index 70e1f512b..dbd8c2d6a 100644 --- a/src/Simplex/Messaging/Client.hs +++ b/src/Simplex/Messaging/Client.hs @@ -132,17 +132,17 @@ data PClient err msg = PClient tcpTimeout :: Int, batchDelay :: Maybe Int, pingErrorCount :: TVar Int, - clientCorrId :: TVar Natural, + clientCorrId :: TVar ChaChaDRG, sentCommands :: TMap CorrId (Request err msg), sndQ :: TBQueue ByteString, rcvQ :: TBQueue (NonEmpty (SignedTransmission err msg)), msgQ :: Maybe (TBQueue (ServerTransmission msg)) } -clientStub :: ByteString -> Version -> Maybe THandleAuth -> STM (ProtocolClient err msg) -clientStub sessionId thVersion thAuth = do +clientStub :: TVar ChaChaDRG -> ByteString -> Version -> Maybe THandleAuth -> STM (ProtocolClient err msg) +clientStub g sessionId thVersion thAuth = do connected <- newTVar False - clientCorrId <- newTVar 0 + clientCorrId <- C.newRandomDRG g sentCommands <- TM.empty sndQ <- newTBQueue 100 rcvQ <- newTBQueue 100 @@ -328,7 +328,7 @@ getProtocolClient g transportSession@(_, srv, _) cfg@ProtocolClientConfig {qSize mkProtocolClient transportHost = do connected <- newTVar False pingErrorCount <- newTVar 0 - clientCorrId <- newTVar 0 + clientCorrId <- C.newRandomDRG g sentCommands <- TM.empty sndQ <- newTBQueue qSize rcvQ <- newTBQueue qSize @@ -710,9 +710,7 @@ mkTransmission ProtocolClient {thParams, client_ = PClient {clientCorrId, sentCo pure ((,tToSend) <$> auth, r) where getNextCorrId :: STM CorrId - getNextCorrId = do - i <- stateTVar clientCorrId $ \i -> (i, i + 2) - pure . CorrId $ bshow i + getNextCorrId = CorrId <$> C.randomBytes 24 clientCorrId -- also used as nonce mkRequest :: CorrId -> STM (Request err msg) mkRequest corrId = do r <- Request entId <$> newEmptyTMVar diff --git a/src/Simplex/Messaging/Crypto.hs b/src/Simplex/Messaging/Crypto.hs index 920fbd722..5d021d502 100644 --- a/src/Simplex/Messaging/Crypto.hs +++ b/src/Simplex/Messaging/Crypto.hs @@ -66,6 +66,7 @@ module Simplex.Messaging.Crypto ADhSecret (..), KeyHash (..), newRandom, + newRandomDRG, generateAKeyPair, generateKeyPair, generateSignatureKeyPair, @@ -698,6 +699,9 @@ type AAuthKeyPair = KeyPairType APrivateAuthKey newRandom :: IO (TVar ChaChaDRG) newRandom = newTVarIO =<< drgNew +newRandomDRG :: TVar ChaChaDRG -> STM (TVar ChaChaDRG) +newRandomDRG g = newTVar =<< stateTVar g (`withDRG` drgNew) + generateAKeyPair :: AlgorithmI a => SAlgorithm a -> TVar ChaChaDRG -> STM AKeyPair generateAKeyPair a g = bimap (APublicKey a) (APrivateKey a) <$> generateKeyPair g diff --git a/tests/AgentTests/FunctionalAPITests.hs b/tests/AgentTests/FunctionalAPITests.hs index d4508d6f3..4deab8276 100644 --- a/tests/AgentTests/FunctionalAPITests.hs +++ b/tests/AgentTests/FunctionalAPITests.hs @@ -150,7 +150,7 @@ agentCfgVPrev = agentCfgV8 :: AgentConfig agentCfgV8 = agentCfg - { cmdAuthAlg = C.AuthAlg C.SX25519, + { sndAuthAlg = C.AuthAlg C.SX25519, smpCfg = smpCfgV7, ntfCfg = ntfCfgV2 } diff --git a/tests/CoreTests/BatchingTests.hs b/tests/CoreTests/BatchingTests.hs index 83787bb90..7f64c28ad 100644 --- a/tests/CoreTests/BatchingTests.hs +++ b/tests/CoreTests/BatchingTests.hs @@ -22,7 +22,7 @@ batchingTests :: Spec batchingTests = do describe "batchTransmissions" $ do describe "SMP v7 (current)" $ do - it "should batch with 109 subscriptions per batch" $ testBatchSubscriptions + it "should batch with 109 subscriptions per batch" testBatchSubscriptions it "should break on message that does not fit" testBatchWithMessage it "should break on large message" testBatchWithLargeMessage describe "v8 (next)" $ do @@ -42,14 +42,14 @@ batchingTests = do testBatchSubscriptions :: IO () testBatchSubscriptions = do sessId <- atomically . C.randomBytes 32 =<< C.newRandom - subs <- replicateM 250 $ randomSUB sessId + subs <- replicateM 300 $ randomSUB sessId let batches1 = batchTransmissions False smpBlockSize $ L.fromList subs all lenOk1 batches1 `shouldBe` True - length batches1 `shouldBe` 250 + length batches1 `shouldBe` 300 let batches = batchTransmissions True smpBlockSize $ L.fromList subs length batches `shouldBe` 3 [TBTransmissions s1 n1 _, TBTransmissions s2 n2 _, TBTransmissions s3 n3 _] <- pure batches - (n1, n2, n3) `shouldBe` (32, 109, 109) + (n1, n2, n3) `shouldBe` (28, 136, 136) all lenOk [s1, s2, s3] `shouldBe` True testBatchSubscriptionsV8 :: IO () @@ -62,7 +62,7 @@ testBatchSubscriptionsV8 = do let batches = batchTransmissions True smpBlockSize $ L.fromList subs length batches `shouldBe` 3 [TBTransmissions s1 n1 _, TBTransmissions s2 n2 _, TBTransmissions s3 n3 _] <- pure batches - (n1, n2, n3) `shouldBe` (16, 142, 142) + (n1, n2, n3) `shouldBe` (28, 136, 136) all lenOk [s1, s2, s3] `shouldBe` True testBatchWithMessage :: IO () @@ -78,7 +78,7 @@ testBatchWithMessage = do let batches = batchTransmissions True smpBlockSize $ L.fromList cmds length batches `shouldBe` 2 [TBTransmissions s1 n1 _, TBTransmissions s2 n2 _] <- pure batches - (n1, n2) `shouldBe` (45, 56) + (n1, n2) `shouldBe` (32, 69) all lenOk [s1, s2] `shouldBe` True testBatchWithMessageV8 :: IO () @@ -94,26 +94,26 @@ testBatchWithMessageV8 = do let batches = batchTransmissions True smpBlockSize $ L.fromList cmds length batches `shouldBe` 2 [TBTransmissions s1 n1 _, TBTransmissions s2 n2 _] <- pure batches - (n1, n2) `shouldBe` (29, 72) + (n1, n2) `shouldBe` (32, 69) all lenOk [s1, s2] `shouldBe` True testBatchWithLargeMessage :: IO () testBatchWithLargeMessage = do sessId <- atomically . C.randomBytes 32 =<< C.newRandom - subs1 <- replicateM 60 $ randomSUB sessId + subs1 <- replicateM 50 $ randomSUB sessId send <- randomSEND sessId 17000 - subs2 <- replicateM 120 $ randomSUB sessId + subs2 <- replicateM 150 $ randomSUB sessId let cmds = subs1 <> [send] <> subs2 batches1 = batchTransmissions False smpBlockSize $ L.fromList cmds all lenOk1 batches1 `shouldBe` False - length batches1 `shouldBe` 181 - let batches1' = take 60 batches1 <> drop 61 batches1 + length batches1 `shouldBe` 201 + let batches1' = take 50 batches1 <> drop 51 batches1 all lenOk1 batches1' `shouldBe` True - length batches1' `shouldBe` 180 + length batches1' `shouldBe` 200 let batches = batchTransmissions True smpBlockSize $ L.fromList cmds length batches `shouldBe` 4 [TBTransmissions s1 n1 _, TBError TELargeMsg _, TBTransmissions s2 n2 _, TBTransmissions s3 n3 _] <- pure batches - (n1, n2, n3) `shouldBe` (60, 11, 109) + (n1, n2, n3) `shouldBe` (50, 14, 136) all lenOk [s1, s2, s3] `shouldBe` True testBatchWithLargeMessageV8 :: IO () @@ -132,21 +132,20 @@ testBatchWithLargeMessageV8 = do let batches = batchTransmissions True smpBlockSize $ L.fromList cmds length batches `shouldBe` 4 [TBTransmissions s1 n1 _, TBError TELargeMsg _, TBTransmissions s2 n2 _, TBTransmissions s3 n3 _] <- pure batches - (n1, n2, n3) `shouldBe` (60, 8, 142) + (n1, n2, n3) `shouldBe` (60, 14, 136) all lenOk [s1, s2, s3] `shouldBe` True testClientBatchSubscriptions :: IO () testClientBatchSubscriptions = do - sessId <- atomically . C.randomBytes 32 =<< C.newRandom - client <- atomically $ clientStub sessId currentClientSMPRelayVersion Nothing - subs <- replicateM 250 $ randomSUBCmd client + client <- testClientStub + subs <- replicateM 300 $ randomSUBCmd client let batches1 = batchTransmissions' False smpBlockSize $ L.fromList subs all lenOk1 batches1 `shouldBe` True let batches = batchTransmissions' True smpBlockSize $ L.fromList subs length batches `shouldBe` 3 [TBTransmissions s1 n1 rs1, TBTransmissions s2 n2 rs2, TBTransmissions s3 n3 rs3] <- pure batches - (n1, n2, n3) `shouldBe` (31, 110, 109) - (length rs1, length rs2, length rs3) `shouldBe` (31, 110, 109) + (n1, n2, n3) `shouldBe` (28, 136, 136) + (length rs1, length rs2, length rs3) `shouldBe` (28, 136, 136) all lenOk [s1, s2, s3] `shouldBe` True testClientBatchSubscriptionsV8 :: IO () @@ -158,14 +157,13 @@ testClientBatchSubscriptionsV8 = do let batches = batchTransmissions' True smpBlockSize $ L.fromList subs length batches `shouldBe` 3 [TBTransmissions s1 n1 rs1, TBTransmissions s2 n2 rs2, TBTransmissions s3 n3 rs3] <- pure batches - (n1, n2, n3) `shouldBe` (16, 142, 142) - (length rs1, length rs2, length rs3) `shouldBe` (16, 142, 142) + (n1, n2, n3) `shouldBe` (28, 136, 136) + (length rs1, length rs2, length rs3) `shouldBe` (28, 136, 136) all lenOk [s1, s2, s3] `shouldBe` True testClientBatchWithMessage :: IO () testClientBatchWithMessage = do - sessId <- atomically . C.randomBytes 32 =<< C.newRandom - client <- atomically $ clientStub sessId currentClientSMPRelayVersion Nothing + client <- testClientStub subs1 <- replicateM 60 $ randomSUBCmd client send <- randomSENDCmd client 8000 subs2 <- replicateM 40 $ randomSUBCmd client @@ -176,8 +174,8 @@ testClientBatchWithMessage = do let batches = batchTransmissions' True smpBlockSize $ L.fromList cmds length batches `shouldBe` 2 [TBTransmissions s1 n1 rs1, TBTransmissions s2 n2 rs2] <- pure batches - (n1, n2) `shouldBe` (45, 56) - (length rs1, length rs2) `shouldBe` (45, 56) + (n1, n2) `shouldBe` (32, 69) + (length rs1, length rs2) `shouldBe` (32, 69) all lenOk [s1, s2] `shouldBe` True testClientBatchWithMessageV8 :: IO () @@ -193,38 +191,37 @@ testClientBatchWithMessageV8 = do let batches = batchTransmissions' True smpBlockSize $ L.fromList cmds length batches `shouldBe` 2 [TBTransmissions s1 n1 rs1, TBTransmissions s2 n2 rs2] <- pure batches - (n1, n2) `shouldBe` (28, 73) - (length rs1, length rs2) `shouldBe` (28, 73) + (n1, n2) `shouldBe` (32, 69) + (length rs1, length rs2) `shouldBe` (32, 69) all lenOk [s1, s2] `shouldBe` True testClientBatchWithLargeMessage :: IO () testClientBatchWithLargeMessage = do - sessId <- atomically . C.randomBytes 32 =<< C.newRandom - client <- atomically $ clientStub sessId currentClientSMPRelayVersion Nothing - subs1 <- replicateM 60 $ randomSUBCmd client + client <- testClientStub + subs1 <- replicateM 50 $ randomSUBCmd client send <- randomSENDCmd client 17000 - subs2 <- replicateM 120 $ randomSUBCmd client + subs2 <- replicateM 150 $ randomSUBCmd client let cmds = subs1 <> [send] <> subs2 batches1 = batchTransmissions' False smpBlockSize $ L.fromList cmds all lenOk1 batches1 `shouldBe` False - length batches1 `shouldBe` 181 - let batches1' = take 60 batches1 <> drop 61 batches1 + length batches1 `shouldBe` 201 + let batches1' = take 50 batches1 <> drop 51 batches1 all lenOk1 batches1' `shouldBe` True - length batches1' `shouldBe` 180 + length batches1' `shouldBe` 200 -- let batches = batchTransmissions' True smpBlockSize $ L.fromList cmds length batches `shouldBe` 4 [TBTransmissions s1 n1 rs1, TBError TELargeMsg _, TBTransmissions s2 n2 rs2, TBTransmissions s3 n3 rs3] <- pure batches - (n1, n2, n3) `shouldBe` (60, 11, 109) - (length rs1, length rs2, length rs3) `shouldBe` (60, 11, 109) + (n1, n2, n3) `shouldBe` (50, 14, 136) + (length rs1, length rs2, length rs3) `shouldBe` (50, 14, 136) all lenOk [s1, s2, s3] `shouldBe` True -- let cmds' = [send] <> subs1 <> subs2 let batches' = batchTransmissions' True smpBlockSize $ L.fromList cmds' length batches' `shouldBe` 3 [TBError TELargeMsg _, TBTransmissions s1' n1' rs1', TBTransmissions s2' n2' rs2'] <- pure batches' - (n1', n2') `shouldBe` (71, 109) - (length rs1', length rs2') `shouldBe` (71, 109) + (n1', n2') `shouldBe` (64, 136) + (length rs1', length rs2') `shouldBe` (64, 136) all lenOk [s1', s2'] `shouldBe` True testClientBatchWithLargeMessageV8 :: IO () @@ -244,37 +241,43 @@ testClientBatchWithLargeMessageV8 = do let batches = batchTransmissions' True smpBlockSize $ L.fromList cmds length batches `shouldBe` 4 [TBTransmissions s1 n1 rs1, TBError TELargeMsg _, TBTransmissions s2 n2 rs2, TBTransmissions s3 n3 rs3] <- pure batches - (n1, n2, n3) `shouldBe` (60, 8, 142) - (length rs1, length rs2, length rs3) `shouldBe` (60, 8, 142) + (n1, n2, n3) `shouldBe` (60, 14, 136) + (length rs1, length rs2, length rs3) `shouldBe` (60, 14, 136) all lenOk [s1, s2, s3] `shouldBe` True -- let cmds' = [send] <> subs1 <> subs2 let batches' = batchTransmissions' True smpBlockSize $ L.fromList cmds' length batches' `shouldBe` 3 [TBError TELargeMsg _, TBTransmissions s1' n1' rs1', TBTransmissions s2' n2' rs2'] <- pure batches' - (n1', n2') `shouldBe` (68, 142) - (length rs1', length rs2') `shouldBe` (68, 142) + (n1', n2') `shouldBe` (74, 136) + (length rs1', length rs2') `shouldBe` (74, 136) all lenOk [s1', s2'] `shouldBe` True +testClientStub :: IO (ProtocolClient ErrorType BrokerMsg) +testClientStub = do + g <- C.newRandom + sessId <- atomically $ C.randomBytes 32 g + atomically $ clientStub g sessId currentClientSMPRelayVersion Nothing + clientStubV8 :: IO (ProtocolClient ErrorType BrokerMsg) clientStubV8 = do g <- C.newRandom sessId <- atomically $ C.randomBytes 32 g (rKey, _) <- atomically $ C.generateAuthKeyPair C.SX25519 g thAuth_ <- testTHandleAuth authEncryptCmdsSMPVersion g rKey - atomically $ clientStub sessId authEncryptCmdsSMPVersion thAuth_ + atomically $ clientStub g sessId authEncryptCmdsSMPVersion thAuth_ randomSUB :: ByteString -> IO (Either TransportError (Maybe TransmissionAuth, ByteString)) -randomSUB = randomSUB_ C.SEd448 currentClientSMPRelayVersion +randomSUB = randomSUB_ C.SEd25519 currentClientSMPRelayVersion randomSUBv8 :: ByteString -> IO (Either TransportError (Maybe TransmissionAuth, ByteString)) -randomSUBv8 = randomSUB_ C.SX25519 authEncryptCmdsSMPVersion +randomSUBv8 = randomSUB_ C.SEd25519 authEncryptCmdsSMPVersion randomSUB_ :: (C.AlgorithmI a, C.AuthAlgorithm a) => C.SAlgorithm a -> Version -> ByteString -> IO (Either TransportError (Maybe TransmissionAuth, ByteString)) randomSUB_ a v sessId = do g <- C.newRandom rId <- atomically $ C.randomBytes 24 g - corrId <- atomically $ CorrId <$> C.randomBytes 3 g + corrId <- atomically $ CorrId <$> C.randomBytes 24 g (rKey, rpKey) <- atomically $ C.generateAuthKeyPair a g thAuth_ <- testTHandleAuth v g rKey let thParams = testTHandleParams v sessId @@ -282,10 +285,10 @@ randomSUB_ a v sessId = do pure $ (,tToSend) <$> authTransmission thAuth_ (Just rpKey) corrId tForAuth randomSUBCmd :: ProtocolClient ErrorType BrokerMsg -> IO (PCTransmission ErrorType BrokerMsg) -randomSUBCmd = randomSUBCmd_ C.SEd448 +randomSUBCmd = randomSUBCmd_ C.SEd25519 randomSUBCmdV8 :: ProtocolClient ErrorType BrokerMsg -> IO (PCTransmission ErrorType BrokerMsg) -randomSUBCmdV8 = randomSUBCmd_ C.SX25519 +randomSUBCmdV8 = randomSUBCmd_ C.SEd25519 -- same as v7 randomSUBCmd_ :: (C.AlgorithmI a, C.AuthAlgorithm a) => C.SAlgorithm a -> ProtocolClient ErrorType BrokerMsg -> IO (PCTransmission ErrorType BrokerMsg) randomSUBCmd_ a c = do @@ -295,7 +298,7 @@ randomSUBCmd_ a c = do mkTransmission c (Just rpKey, rId, Cmd SRecipient SUB) randomSEND :: ByteString -> Int -> IO (Either TransportError (Maybe TransmissionAuth, ByteString)) -randomSEND = randomSEND_ C.SEd448 currentClientSMPRelayVersion +randomSEND = randomSEND_ C.SEd25519 currentClientSMPRelayVersion randomSENDv8 :: ByteString -> Int -> IO (Either TransportError (Maybe TransmissionAuth, ByteString)) randomSENDv8 = randomSEND_ C.SX25519 authEncryptCmdsSMPVersion @@ -305,12 +308,12 @@ randomSEND_ a v sessId len = do g <- C.newRandom sId <- atomically $ C.randomBytes 24 g corrId <- atomically $ CorrId <$> C.randomBytes 3 g - (rKey, rpKey) <- atomically $ C.generateAuthKeyPair a g - thAuth_ <- testTHandleAuth v g rKey + (sKey, spKey) <- atomically $ C.generateAuthKeyPair a g + thAuth_ <- testTHandleAuth v g sKey msg <- atomically $ C.randomBytes len g let thParams = testTHandleParams v sessId ClntTransmission {tForAuth, tToSend} = encodeClntTransmission thParams (corrId, sId, Cmd SSender $ SEND noMsgFlags msg) - pure $ (,tToSend) <$> authTransmission thAuth_ (Just rpKey) corrId tForAuth + pure $ (,tToSend) <$> authTransmission thAuth_ (Just spKey) corrId tForAuth testTHandleParams :: Version -> ByteString -> THandleParams testTHandleParams v sessionId = @@ -331,7 +334,7 @@ testTHandleAuth v g (C.APublicAuthKey a k) = case a of _ -> pure Nothing randomSENDCmd :: ProtocolClient ErrorType BrokerMsg -> Int -> IO (PCTransmission ErrorType BrokerMsg) -randomSENDCmd = randomSENDCmd_ C.SEd448 +randomSENDCmd = randomSENDCmd_ C.SEd25519 randomSENDCmdV8 :: ProtocolClient ErrorType BrokerMsg -> Int -> IO (PCTransmission ErrorType BrokerMsg) randomSENDCmdV8 = randomSENDCmd_ C.SX25519