Skip to content

Commit 65cc198

Browse files
authored
servers: restore constant time for absent queue/wrong key (regression in 6.4-beta.9) (#1567)
1 parent 656f290 commit 65cc198

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Simplex/Messaging/Server.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,8 +1272,8 @@ verifyCmdAuth thAuth k authenticator authorized (CorrId corrId) = case thAuth of
12721272
Just THAuthServer {serverPrivKey = pk} -> C.cbVerify k pk (C.cbNonce corrId) authenticator authorized
12731273
Nothing -> False
12741274

1275-
dummyVerifyCmd :: Maybe (THandleAuth 'TServer) -> Maybe TAuthorizations -> ByteString -> CorrId -> Maybe Bool
1276-
dummyVerifyCmd thAuth tAuth authorized corrId = verify <$> tAuth
1275+
dummyVerifyCmd :: Maybe (THandleAuth 'TServer) -> Maybe TAuthorizations -> ByteString -> CorrId -> Bool
1276+
dummyVerifyCmd thAuth tAuth authorized corrId = maybe False verify tAuth
12771277
where
12781278
verify = \case
12791279
(TASignature (C.ASignature a s), _) -> C.verify' (dummySignKey a) s authorized

tests/ServerTests.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ testTiming =
939939
]
940940
timeRepeat n = fmap fst . timeItT . forM_ (replicate n ()) . const
941941
similarTime t1 t2
942-
| t1 <= t2 = abs (1 - t1 / t2) < 0.35 -- normally the difference between "no queue" and "wrong key" is less than 5%
942+
| t1 <= t2 = abs (1 - t1 / t2) < 0.3 -- normally the difference between "no queue" and "wrong key" is less than 5%
943943
| otherwise = similarTime t2 t1
944944
testSameTiming :: forall c. Transport c => THandleSMP c 'TClient -> THandleSMP c 'TClient -> (C.AuthAlg, C.AuthAlg, Int) -> Expectation
945945
testSameTiming rh sh (C.AuthAlg goodKeyAlg, C.AuthAlg badKeyAlg, n) = do

0 commit comments

Comments
 (0)