Commit Graph

95 Commits

Author SHA1 Message Date
Evgeny Poberezkin
82ae5c623f Merge branch 'master' into v5 2021-12-06 09:22:45 +00:00
Evgeny Poberezkin
57c9ccfc08 use base64url encoding for public key in connection requests; only allow accepting invitations that were not accepted (#213)
* use base64url encoding for public key in connection requests; only allow accepting invitations that were not accepted

* subscribe ContactConnection, fix test to use base64url encoding in key example
2021-12-06 09:05:13 +00:00
Evgeny Poberezkin
b116408ec3 Merge branch 'master' into v5 2021-12-04 18:55:23 +00:00
Evgeny Poberezkin
04c65d98da support permanent connection link ("contact") in SMP agent protocols (#143)
* open/public queue extension for SMP and SMP agent protocols

* add connection mode - invitation or contact

* use ConnectionMode with REQ and ACPT agent notification/command

* parameterize ConnectionRequest with ConnectionMode

* implement Contact connection mode for permanent connection links

* tests for contact connections
2021-12-04 18:42:08 +00:00
Evgeny Poberezkin
6126e72d4f Merge branch 'master' into v5 2021-12-02 18:06:42 +00:00
Evgeny Poberezkin
606bbf5062 URI syntax for SMP queues and connection requests (#210)
* URI syntax for SMP queues and connection requests

* fix connection request parsing/serializing

* add ConnectionRequest sqlite instances
2021-12-02 17:43:05 +00:00
Evgeny Poberezkin
e1002d5ac0 GADTs for cryptographic keys (#208)
* GADTs for cryptographic keys

* update tests (signature timing tests still fail)

* fix signature verification timing tests

* configurable algorithm to sign commands to SMP queues (Ed448 by default)

* add dummy Ed keys, add timing tests for Ed keys

* re-enable Connection subscriptions tests
2021-11-28 11:44:22 +00:00
Evgeny Poberezkin
99b3749890 simplify RSA private key types (#207)
* simplify RSA private key types

* remove updateSignKey method
2021-11-28 07:08:47 +00:00
Evgeny Poberezkin
eb941f7435 simplify pending message delivery (#202)
* simplify pending message delivery (WIP)

* refactor
2021-11-19 16:26:51 +00:00
Evgeny Poberezkin
9a3afda290 ACK command, ackMessage, do not send ACK to SMP server on MSG (after the initial handshake) (#187) 2021-09-01 08:29:12 +01:00
Evgeny Poberezkin
26b0edabfc refactor with RecordWildCards (#181) 2021-08-22 13:19:38 +01:00
Evgeny Poberezkin
dd5137c336 asynchronous message sending to allow accepting messages when agent (or server) is offline (#179)
* asynchronous message sending to allow accepting messages when agent (or server) is offline

* send pending messages after agent restart; test for pending messages delivery when server restarted

* test pending message delivery after agent restart

* message delivery process per server

* test layout
2021-08-12 22:15:55 +01:00
Evgeny Poberezkin
e045774caa reconnect server and resubscribe connections after disconnection (#178) 2021-08-09 08:49:49 +01:00
Evgeny Poberezkin
d9084522af agent lock to avoid running subscriber and client processing in parallel; remove check that the connection is active when delivering a message (#176)
* agent lock to avoid running subscriber and client processing in parallel; remove check that the connection is active when delivering a message

* use agent lock in agent functions
2021-08-05 08:33:48 +01:00
Evgeny Poberezkin
3829479a21 Remove introductions, rename CONF/LET to REQ/ACPT (#175)
* remove intros and functions in Reader monad

* rename CONF/LET to REQ/ACPT, allowConnection to acceptConnection
2021-08-05 08:27:44 +01:00
Evgeny Poberezkin
10fcb9771a use explicit immediate transactions in all functions that change db (#170) 2021-07-20 21:21:30 +01:00
Evgeny Poberezkin
8ba3e3e45a remove connection ID parameter from agent functions (#166)
* remove connection ID parameter from agent functions

* remove unused extension
2021-07-03 20:18:37 +01:00
Efim Poberezkin
3d9ceff691 ask client for confirmation of sender; make establishment of connection asynchronous (#163)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-07-04 04:48:24 +10:00
Evgeny Poberezkin
e4d9b481ec refactor message meta to MsgMeta type (#164) 2021-06-30 10:29:45 +01:00
Evgeny Poberezkin
7af7272635 SQLiteStore connection pool (#162)
* SQLiteStore connection pool

* move SQLiteStore to agent env - single store instance is used for all clients
2021-06-25 18:17:11 +01:00
Evgeny Poberezkin
09c6adeabc pass migration as parameter (to use in simplex-chat) (#161)
* pass migration as parameter (to use in simplex-chat)

* add connId parameter to create/joinConnection
2021-06-24 18:39:59 +01:00
Evgeny Poberezkin
bf5561c89c remove entities, remove broadcasts (#158) 2021-06-12 20:01:36 +01:00
Evgeny Poberezkin
ab89963f45 introduction protocol (#156)
* commands to support introduction

* agent messages / envelopes to support introductions

* introductions and invitations table; insert record with random unique ID

* store class methods and types for introductions

* process INTRO and ACPT commands for connection introductions

* fix tests: add MonadFail constraint, remove OK response to JOIN

* process agent messages for introductions

* ICON notification when introduction is completed

* replace multiway if with case

* correction

* support random connection IDs

* save additional connection fields, refactor create connection funcs

* refactor

* refactor

* test duplex connection with random IDs

* store methods for introductions

* test introduction

* fix parsing of CON agent message

* test introduction with random connection IDs

* broadcast with random connection and broadcast IDs

* clean up sql
2021-06-11 21:33:13 +01:00
Evgeny Poberezkin
bc780343df broadcast commands (#154)
* broadcast commands (WIP)

* broadcasts: store and commands implementation

* test broadcast

* broadcast test

* rename migration, handle SEBadConnType errors

* query semicolons
2021-06-01 18:11:16 +01:00
Evgeny Poberezkin
84ce001598 database migrations (#153)
* database migrations

* fix: reverse order of down migrations

* use positional parameters in queries

* simplify migrations

* typo

* rename SchemaMigration to Migration

* move store initialization to IO monad
2021-05-31 16:38:35 +01:00
Efim Poberezkin
f7f419224f reduce transaction retry back-off factor to 1.125 (#137) 2021-05-10 14:24:08 +04:00
Evgeny Poberezkin
8ac47b9bbf reduce transaction retry back-off factor to 1.25 (31 retries) (#136) 2021-05-09 12:49:52 +01:00
Efim Poberezkin
fa5a8cb5cd agent: change sqlite busy retry handling; set journal_mode = WAL (#132)
* agent: change sqlite busy retry handling; set journal_mode = WAL

* fix accumulation

* add exponential back-off (*1.5) to transaction retries

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-05-09 10:24:02 +01:00
Evgeny Poberezkin
5d59e4b2bd package and module docs, remove Simplex.Markdown (moved to simplex-chat), rename Agent.Transmission to Agent.Protocol (#133)
* package and module docs, remove Simplex.Markdown (moved to simplex-chat), rename Agent.Transmission to Agent.Protocol

* move errors.md to haddock comments, Transport docs

* add CHANGELOG.md, add missing package versions

* changelog, copyright

* docs for Simplex.Messaging.Crypto

* consistent punctuation

* use absolute URLs in readme

* correction
2021-05-09 09:36:08 +01:00
Efim Poberezkin
ad87442811 sqlite busy stress test (#131)
* sqlite busy stress test

* refactor withStore2

* refactor withStore2

* pragmas

* swith to IMMEDIATE sqlite transactions and add retry on ErrorBusy

* refactor

* increase timeout, print errors and results

* remove logging errors/results

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-05-08 16:30:40 +01:00
Evgeny Poberezkin
7aacee405e agent: send CON to user when the 1st party responds HELLO; fix REPLY vulnerability (#130)
* agent: send CON to user when the 1st party responds HELLO; fix REPLY vulnerability

* test for getRcvConn

* add commented OK response to JOIN command

* store: use Only newtype to select one field
2021-05-07 06:57:53 +01:00
Evgeny Poberezkin
1c7d7e5083 base64 encode keyhash in DB (#126) 2021-05-03 15:52:41 +01:00
Efim Poberezkin
b7902ee4c8 agent sqlite: store msg hashes and integrity (#118, #119, #120)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-05-02 10:48:31 +04:00
Efim Poberezkin
6be4839703 agent: verify msg integrity based on previous msg hash and id (#110)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-05-02 00:38:32 +04:00
Evgeny Poberezkin
5fec6c1755 Sign and verify agent messages (#106)
* sign and verify agent messages with key sent in HELLO (TODO: hardcoded block size - should use size from handshake; verify signature of HELLO message itself; possibly, different MSG status if signature was not verified (currently ignored) or failed to verify (currently fails with AGENT A_ENCRYPTION - alternatively, change it to AGENT A_SIGNATURE))

* remove hardcoded block size, make it 4096 bytes

* verify signature of HELLO message before it is added to RcvQueue

* refactor

* update doc

* rename functions
2021-04-26 20:05:46 +01:00
Efim Poberezkin
40ad6db51a return error on creation of duplicate connection (#102)
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2021-04-19 00:46:01 +04:00
Evgeny Poberezkin
5e3bc7ee6c improve error handling (#101)
* inventory of error handling problems and types

* Change SMP protocol errors syntax

* connection errors in agent protocol (ERR CONN), STORE error -> AGENT error

* include exception in SEInternal error

* add MESSAGE errors, remove CRYPTO and SIZE errors

* agent protocol SYNTAX and AGENT errors

* BROKER errors

* group all client command (and agent response) errors

* BROKER TRANSPORT error

* simplify Client

* clean up

* transport errors

* simplify client

* parse / serialize agent errors

* differentiate crypto errors

* update errors.md

* make agent and SMP protocol errors consistent, simplify

* update doc

* test: parse / serialize protocol errors with QuickCheck

* add String to internal error

* exponential back-off when retrying to send HELLO

* refactor Client.hs

* replace fold with recursion in startTCPClient

* fail test if server did not start, refactor

* test: wait till TCP server stops

* test: refactor waiting for server to stop

* test: fail with error if server did not start/stop
2021-04-18 18:37:54 +01:00
Efim Poberezkin
bd753dbe47 agent sqlite: enable FKs in *all* db connections (#75) 2021-03-29 19:27:05 +04:00
Efim Poberezkin
08171e987d agent sqlite: initialize database in home directory by default (#74) 2021-03-29 19:18:54 +04:00
Efim Poberezkin
b9943c359d chat: subscribe to all connections on startup (#70) 2021-03-06 15:39:00 +04:00
Efim Poberezkin
11c8bee836 agent store: make newtypes for msg internal Ids (#68) 2021-03-04 23:19:12 +04:00
Efim Poberezkin
93e782b874 agent store: organize sender and broker fields into tuples (#67) 2021-03-04 23:00:00 +04:00
Efim Poberezkin
660e35d1d1 check that sqlite library is compiled with threadsafe code (#63) 2021-03-02 22:30:59 +04:00
Evgeny Poberezkin
a3990ea170 Types.hs -> Protocol.hs (#62) 2021-02-28 17:00:14 +00:00
Evgeny Poberezkin
927ff230da Separate db connection for each TCP client connection (#60)
* use separate db connections for each TCP client connection

* refactor atomically, increast delay in tests

* increase test delay for SMP server to start

* increase SMP ping frequency

* remove comment

* separate SQLite connection per thread, to support multi-threaded mode

* remove redundant import
2021-02-28 14:59:29 +00:00
Efim Poberezkin
3af34dea8b agent store: accept internal ts and return internal id (#58) 2021-02-27 15:06:51 +04:00
Efim Poberezkin
8134bb0eb9 agent store: settle naming of Rcv and Snd entities (#55) 2021-02-26 18:17:56 +04:00
Efim Poberezkin
dac35d8ea8 agent sqlite: merge SQLite and SQLite.Util (#54) 2021-02-26 18:17:56 +04:00
Efim Poberezkin
0f60c53a66 agent: save messages (#45) 2021-02-25 19:02:27 +04:00
Evgeny Poberezkin
435ab21e71 E2E message encryption (#38)
* RSA OAEP functions

* encrypt/decrypt using AES AEAD GSM

* fix JOIN syntax test

* encrypt/decrypt functions working

* e2e encryption!

* refactor monadic transitions

* rename liftError' to liftEitherError

* combine CryproFailable functions
2021-02-26 18:14:22 +04:00