From 93ae9c4a35b3fa7026ef0d97b94258853df4c3b8 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Tue, 13 Feb 2024 16:56:13 +0000 Subject: [PATCH] remove dhSecret from THandle --- src/Simplex/Messaging/Notifications/Transport.hs | 4 ++-- src/Simplex/Messaging/Transport.hs | 7 +++---- tests/AgentTests/NotificationTests.hs | 4 ++-- tests/CoreTests/BatchingTests.hs | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Simplex/Messaging/Notifications/Transport.hs b/src/Simplex/Messaging/Notifications/Transport.hs index a0564a079..5475c0e24 100644 --- a/src/Simplex/Messaging/Notifications/Transport.hs +++ b/src/Simplex/Messaging/Notifications/Transport.hs @@ -126,9 +126,9 @@ ntfClientHandshake c (k, pk) keyHash ntfVRange = do Nothing -> throwError $ TEHandshake VERSION ntfThHandle :: forall c. THandle c -> Version -> C.PrivateKeyX25519 -> Maybe C.PublicKeyX25519 -> THandle c -ntfThHandle th@THandle {params} v pk k_ = +ntfThHandle th@THandle {params} v privKey k_ = -- TODO drop SMP v6: make thAuth non-optional - let thAuth = (\k -> THandleAuth {peerPubKey = k, privKey = pk, dhSecret = C.dh' k pk}) <$> k_ + let thAuth = (\k -> THandleAuth {peerPubKey = k, privKey}) <$> k_ params' = params {thVersion = v, thAuth, encrypt = v >= dontSendSessionIdNTFVersion} in (th :: THandle c) {params = params'} diff --git a/src/Simplex/Messaging/Transport.hs b/src/Simplex/Messaging/Transport.hs index f51e14fb7..e641a49d3 100644 --- a/src/Simplex/Messaging/Transport.hs +++ b/src/Simplex/Messaging/Transport.hs @@ -314,8 +314,7 @@ data THandleParams = THandleParams data THandleAuth = THandleAuth { peerPubKey :: C.PublicKeyX25519, -- used only in the client to combine with per-queue key - privKey :: C.PrivateKeyX25519, -- used to combine with peer's per-queue key (currently only in the server) - dhSecret :: C.DhSecretX25519 -- used by both parties to encrypt entity IDs in for version >= 7 + privKey :: C.PrivateKeyX25519 -- used to combine with peer's per-queue key (currently only in the server) } -- | TLS-unique channel binding @@ -472,9 +471,9 @@ smpClientHandshake c (k, pk) keyHash@(C.KeyHash kh) smpVRange = do Nothing -> throwE $ TEHandshake VERSION smpThHandle :: forall c. THandle c -> Version -> C.PrivateKeyX25519 -> Maybe C.PublicKeyX25519 -> THandle c -smpThHandle th@THandle {params} v pk k_ = +smpThHandle th@THandle {params} v privKey k_ = -- TODO drop SMP v6: make thAuth non-optional - let thAuth = (\k -> THandleAuth {peerPubKey = k, privKey = pk, dhSecret = C.dh' k pk}) <$> k_ + let thAuth = (\k -> THandleAuth {peerPubKey = k, privKey}) <$> k_ params' = params {thVersion = v, thAuth, encrypt = v >= dontSendSessionIdSMPVersion, batch = v >= batchCmdsSMPVersion} in (th :: THandle c) {params = params'} diff --git a/tests/AgentTests/NotificationTests.hs b/tests/AgentTests/NotificationTests.hs index 75de107d6..097e75052 100644 --- a/tests/AgentTests/NotificationTests.hs +++ b/tests/AgentTests/NotificationTests.hs @@ -73,9 +73,9 @@ notificationTests t = do withAPNSMockServer $ \apns -> testNtfTokenChangeServers t apns describe "Managing notification subscriptions" $ do - fdescribe "should create notification subscription for existing connection" $ + describe "should create notification subscription for existing connection" $ testNtfMatrix t testNotificationSubscriptionExistingConnection - fdescribe "should create notification subscription for new connection" $ + describe "should create notification subscription for new connection" $ testNtfMatrix t testNotificationSubscriptionNewConnection it "should change notifications mode" $ withSmpServer t $ diff --git a/tests/CoreTests/BatchingTests.hs b/tests/CoreTests/BatchingTests.hs index 81f416643..6b0984769 100644 --- a/tests/CoreTests/BatchingTests.hs +++ b/tests/CoreTests/BatchingTests.hs @@ -329,8 +329,8 @@ testTHandleParams v sessionId = testTHandleAuth :: Version -> TVar ChaChaDRG -> C.APublicAuthKey -> IO (Maybe THandleAuth) testTHandleAuth v g (C.APublicAuthKey a k) = case a of C.SX25519 | v >= authEncryptCmdsSMPVersion -> do - (_, pk) <- atomically $ C.generateKeyPair g - pure $ Just THandleAuth {peerPubKey = k, privKey = pk, dhSecret = C.dh' k pk} + (_, privKey) <- atomically $ C.generateKeyPair g + pure $ Just THandleAuth {peerPubKey = k, privKey} _ -> pure Nothing randomSENDCmd :: ProtocolClient ErrorType BrokerMsg -> Int -> IO (PCTransmission ErrorType BrokerMsg)