core: rename migration to remote-control, comments (#3393)

This commit is contained in:
Evgeny Poberezkin 2023-11-18 19:18:02 +00:00 committed by GitHub
parent cc434cda55
commit e95d9d0b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 70 deletions

View File

@ -123,7 +123,7 @@ library
Simplex.Chat.Migrations.M20231030_xgrplinkmem_received
Simplex.Chat.Migrations.M20231107_indexes
Simplex.Chat.Migrations.M20231113_group_forward
Simplex.Chat.Migrations.M20231114_remote_controller
Simplex.Chat.Migrations.M20231114_remote_control
Simplex.Chat.Mobile
Simplex.Chat.Mobile.File
Simplex.Chat.Mobile.Shared

View File

@ -0,0 +1,45 @@
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Migrations.M20231114_remote_control where
import Database.SQLite.Simple (Query)
import Database.SQLite.Simple.QQ (sql)
m20231114_remote_control :: Query
m20231114_remote_control =
[sql|
CREATE TABLE remote_hosts ( -- e.g., mobiles known to a desktop app
remote_host_id INTEGER PRIMARY KEY AUTOINCREMENT,
host_device_name TEXT NOT NULL,
store_path TEXT NOT NULL, -- relative folder name for host files
ca_key BLOB NOT NULL,
ca_cert BLOB NOT NULL,
id_key BLOB NOT NULL, -- long-term/identity signing key
host_fingerprint BLOB NOT NULL, -- remote host CA cert fingerprint, set when connected
host_dh_pub BLOB NOT NULL -- last session DH key
);
CREATE UNIQUE INDEX idx_remote_hosts_host_fingerprint ON remote_hosts(host_fingerprint);
CREATE TABLE remote_controllers ( -- e.g., desktops known to a mobile app
remote_ctrl_id INTEGER PRIMARY KEY AUTOINCREMENT,
ctrl_device_name TEXT NOT NULL,
ca_key BLOB NOT NULL,
ca_cert BLOB NOT NULL,
ctrl_fingerprint BLOB NOT NULL, -- remote controller CA cert fingerprint, set when connected
id_pub BLOB NOT NULL, -- remote controller long-term/identity key to verify signatures
dh_priv_key BLOB NOT NULL, -- last session DH key
prev_dh_priv_key BLOB -- previous session DH key
);
CREATE UNIQUE INDEX idx_remote_controllers_ctrl_fingerprint ON remote_controllers(ctrl_fingerprint);
|]
down_m20231114_remote_control :: Query
down_m20231114_remote_control =
[sql|
DROP INDEX idx_remote_hosts_host_fingerprint;
DROP INDEX idx_remote_controllers_ctrl_fingerprint;
DROP TABLE remote_hosts;
DROP TABLE remote_controllers;
|]

View File

@ -1,47 +0,0 @@
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Migrations.M20231114_remote_controller where
import Database.SQLite.Simple (Query)
import Database.SQLite.Simple.QQ (sql)
m20231114_remote_controller :: Query
m20231114_remote_controller =
[sql|
CREATE TABLE remote_hosts ( -- hosts known to a controlling app
remote_host_id INTEGER PRIMARY KEY AUTOINCREMENT,
host_device_name TEXT NOT NULL,
store_path TEXT NOT NULL, -- file path for host files relative to app storage (must not contain "/")
-- RCHostPairing
ca_key BLOB NOT NULL, -- private key to sign session certificates
ca_cert BLOB NOT NULL, -- root certificate
id_key BLOB NOT NULL, -- long-term/identity signing key
-- KnownHostPairing
host_fingerprint BLOB NOT NULL, -- pinned remote host CA, set when connected
-- stored host session key
host_dh_pub BLOB NOT NULL, -- session DH key
UNIQUE (host_fingerprint) ON CONFLICT FAIL
);
CREATE TABLE remote_controllers ( -- controllers known to a hosting app
remote_ctrl_id INTEGER PRIMARY KEY AUTOINCREMENT,
ctrl_device_name TEXT NOT NULL,
-- RCCtrlPairing
ca_key BLOB NOT NULL, -- CA key
ca_cert BLOB NOT NULL, -- CA certificate for TLS clients
ctrl_fingerprint BLOB NOT NULL, -- remote controller CA, set when connected
id_pub BLOB NOT NULL, -- remote controller long-term/identity key to verify signatures
-- stored session key, commited on connection confirmation
dh_priv_key BLOB NOT NULL, -- session DH key
-- prev session key
prev_dh_priv_key BLOB, -- previous session DH key
UNIQUE (ctrl_fingerprint) ON CONFLICT FAIL
);
|]
down_m20231114_remote_controller :: Query
down_m20231114_remote_controller =
[sql|
DROP TABLE remote_hosts;
DROP TABLE remote_controllers;
|]

View File

@ -528,34 +528,26 @@ CREATE TABLE IF NOT EXISTS "received_probes"(
updated_at TEXT CHECK(updated_at NOT NULL)
);
CREATE TABLE remote_hosts(
-- hosts known to a controlling app
-- e.g., mobiles known to a desktop app
remote_host_id INTEGER PRIMARY KEY AUTOINCREMENT,
host_device_name TEXT NOT NULL,
store_path TEXT NOT NULL, -- file path for host files relative to app storage(must not contain "/")
-- RCHostPairing
ca_key BLOB NOT NULL, -- private key to sign session certificates
ca_cert BLOB NOT NULL, -- root certificate
store_path TEXT NOT NULL, -- relative folder name for host files
ca_key BLOB NOT NULL,
ca_cert BLOB NOT NULL,
id_key BLOB NOT NULL, -- long-term/identity signing key
-- KnownHostPairing
host_fingerprint BLOB NOT NULL, -- pinned remote host CA, set when connected
-- stored host session key
host_dh_pub BLOB NOT NULL, -- session DH key
UNIQUE(host_fingerprint) ON CONFLICT FAIL
host_fingerprint BLOB NOT NULL, -- remote host CA cert fingerprint, set when connected
host_dh_pub BLOB NOT NULL -- last session DH key
);
CREATE TABLE remote_controllers(
-- controllers known to a hosting app
-- e.g., desktops known to a mobile app
remote_ctrl_id INTEGER PRIMARY KEY AUTOINCREMENT,
ctrl_device_name TEXT NOT NULL,
-- RCCtrlPairing
ca_key BLOB NOT NULL, -- CA key
ca_cert BLOB NOT NULL, -- CA certificate for TLS clients
ctrl_fingerprint BLOB NOT NULL, -- remote controller CA, set when connected
ca_key BLOB NOT NULL,
ca_cert BLOB NOT NULL,
ctrl_fingerprint BLOB NOT NULL, -- remote controller CA cert fingerprint, set when connected
id_pub BLOB NOT NULL, -- remote controller long-term/identity key to verify signatures
-- stored session key, commited on connection confirmation
dh_priv_key BLOB NOT NULL, -- session DH key
-- prev session key
prev_dh_priv_key BLOB, -- previous session DH key
UNIQUE(ctrl_fingerprint) ON CONFLICT FAIL
dh_priv_key BLOB NOT NULL, -- last session DH key
prev_dh_priv_key BLOB -- previous session DH key
);
CREATE INDEX contact_profiles_index ON contact_profiles(
display_name,
@ -808,3 +800,9 @@ CREATE INDEX idx_messages_group_id_shared_msg_id ON messages(
CREATE INDEX idx_chat_items_forwarded_by_group_member_id ON chat_items(
forwarded_by_group_member_id
);
CREATE UNIQUE INDEX idx_remote_hosts_host_fingerprint ON remote_hosts(
host_fingerprint
);
CREATE UNIQUE INDEX idx_remote_controllers_ctrl_fingerprint ON remote_controllers(
ctrl_fingerprint
);

View File

@ -89,7 +89,7 @@ import Simplex.Chat.Migrations.M20231019_indexes
import Simplex.Chat.Migrations.M20231030_xgrplinkmem_received
import Simplex.Chat.Migrations.M20231107_indexes
import Simplex.Chat.Migrations.M20231113_group_forward
import Simplex.Chat.Migrations.M20231114_remote_controller
import Simplex.Chat.Migrations.M20231114_remote_control
import Simplex.Messaging.Agent.Store.SQLite.Migrations (Migration (..))
schemaMigrations :: [(String, Query, Maybe Query)]
@ -179,7 +179,7 @@ schemaMigrations =
("20231030_xgrplinkmem_received", m20231030_xgrplinkmem_received, Just down_m20231030_xgrplinkmem_received),
("20231107_indexes", m20231107_indexes, Just down_m20231107_indexes),
("20231113_group_forward", m20231113_group_forward, Just down_m20231113_group_forward),
("20231114_remote_controller", m20231114_remote_controller, Just down_m20231114_remote_controller)
("20231114_remote_control", m20231114_remote_control, Just down_m20231114_remote_control)
]
-- | The list of migrations in ascending order by date