core: new message decryption error - ratchet synchronization (#3367)

This commit is contained in:
spaced4ndy 2023-11-14 18:23:05 +04:00 committed by GitHub
parent 1e8ae6d861
commit 5bbde22ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 4 deletions

View File

@ -9,7 +9,7 @@ constraints: zip +disable-bzip2 +disable-zstd
source-repository-package source-repository-package
type: git type: git
location: https://github.com/simplex-chat/simplexmq.git location: https://github.com/simplex-chat/simplexmq.git
tag: 9460551a042ce9dbd3f686576942fade823a6941 tag: 7aae6f3cbe4aa2942371f8dd968eb439ccec3b15
source-repository-package source-repository-package
type: git type: git

View File

@ -1,5 +1,5 @@
{ {
"https://github.com/simplex-chat/simplexmq.git"."9460551a042ce9dbd3f686576942fade823a6941" = "1j5s7h55j6dpmiajdh380mma1jkffbn88qyqfgjn5nx6il2svkmz"; "https://github.com/simplex-chat/simplexmq.git"."7aae6f3cbe4aa2942371f8dd968eb439ccec3b15" = "0qx7l1jq0ll1448s077v37s0rv7vlbrdbdgf46x734cl9g0gndk3";
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38"; "https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
"https://github.com/kazu-yamamoto/http2.git"."f5525b755ff2418e6e6ecc69e877363b0d0bcaeb" = "0fyx0047gvhm99ilp212mmz37j84cwrfnpmssib5dw363fyb88b6"; "https://github.com/kazu-yamamoto/http2.git"."f5525b755ff2418e6e6ecc69e877363b0d0bcaeb" = "0fyx0047gvhm99ilp212mmz37j84cwrfnpmssib5dw363fyb88b6";
"https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d"; "https://github.com/simplex-chat/direct-sqlcipher.git"."f814ee68b16a9447fbb467ccc8f29bdd3546bfd9" = "1ql13f4kfwkbaq7nygkxgw84213i0zm7c1a8hwvramayxl38dq5d";

View File

@ -3635,6 +3635,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
RATCHET_HEADER -> (MDERatchetHeader, 1) RATCHET_HEADER -> (MDERatchetHeader, 1)
RATCHET_EARLIER _ -> (MDERatchetEarlier, 1) RATCHET_EARLIER _ -> (MDERatchetEarlier, 1)
RATCHET_SKIPPED n -> (MDETooManySkipped, n) RATCHET_SKIPPED n -> (MDETooManySkipped, n)
RATCHET_SYNC -> (MDERatchetSync, 0)
mdeUpdatedCI :: (MsgDecryptError, Word32) -> CChatItem c -> Maybe (ChatItem c 'MDRcv, CIContent 'MDRcv) mdeUpdatedCI :: (MsgDecryptError, Word32) -> CChatItem c -> Maybe (ChatItem c 'MDRcv, CIContent 'MDRcv)
mdeUpdatedCI (mde', n') (CChatItem _ ci@ChatItem {content = CIRcvDecryptionError mde n}) mdeUpdatedCI (mde', n') (CChatItem _ ci@ChatItem {content = CIRcvDecryptionError mde n})
@ -3643,6 +3644,7 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do
MDETooManySkipped -> r n' -- the numbers are not added as sequential MDETooManySkipped will have it incremented by 1 MDETooManySkipped -> r n' -- the numbers are not added as sequential MDETooManySkipped will have it incremented by 1
MDERatchetEarlier -> r (n + n') MDERatchetEarlier -> r (n + n')
MDEOther -> r (n + n') MDEOther -> r (n + n')
MDERatchetSync -> r 0
| otherwise = Nothing | otherwise = Nothing
where where
r n'' = Just (ci, CIRcvDecryptionError mde n'') r n'' = Just (ci, CIRcvDecryptionError mde n'')

View File

@ -150,7 +150,12 @@ ciMsgContent = \case
CIRcvMsgContent mc -> Just mc CIRcvMsgContent mc -> Just mc
_ -> Nothing _ -> Nothing
data MsgDecryptError = MDERatchetHeader | MDETooManySkipped | MDERatchetEarlier | MDEOther data MsgDecryptError
= MDERatchetHeader
| MDETooManySkipped
| MDERatchetEarlier
| MDEOther
| MDERatchetSync
deriving (Eq, Show, Generic) deriving (Eq, Show, Generic)
instance ToJSON MsgDecryptError where instance ToJSON MsgDecryptError where
@ -460,6 +465,7 @@ msgDecryptErrorText err n =
MDETooManySkipped -> Just $ "too many skipped messages" <> counter MDETooManySkipped -> Just $ "too many skipped messages" <> counter
MDERatchetEarlier -> Just $ "earlier message" <> counter MDERatchetEarlier -> Just $ "earlier message" <> counter
MDEOther -> counter_ MDEOther -> counter_
MDERatchetSync -> Just "synchronization error"
counter_ = if n == 1 then Nothing else Just $ tshow n <> " messages" counter_ = if n == 1 then Nothing else Just $ tshow n <> " messages"
counter = maybe "" (", " <>) counter_ counter = maybe "" (", " <>) counter_

View File

@ -49,7 +49,7 @@ extra-deps:
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561 # - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
# - ../simplexmq # - ../simplexmq
- github: simplex-chat/simplexmq - github: simplex-chat/simplexmq
commit: 9460551a042ce9dbd3f686576942fade823a6941 commit: 7aae6f3cbe4aa2942371f8dd968eb439ccec3b15
- github: kazu-yamamoto/http2 - github: kazu-yamamoto/http2
commit: f5525b755ff2418e6e6ecc69e877363b0d0bcaeb commit: f5525b755ff2418e6e6ecc69e877363b0d0bcaeb
# - ../direct-sqlcipher # - ../direct-sqlcipher