diff --git a/Cargo.lock b/Cargo.lock index accd12a..a07d5c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,6 +120,15 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.6.1" @@ -198,7 +207,7 @@ dependencies = [ "opentelemetry", "opentelemetry-jaeger", "pretty_env_logger", - "rand", + "rand 0.8.3", "regex", "reqwest", "ring", @@ -220,6 +229,11 @@ dependencies = [ "webpki", ] +[[package]] +name = "const-oid" +version = "0.5.2" +source = "git+https://github.com/RustCrypto/utils?rev=51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0#51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0" + [[package]] name = "const_fn" version = "0.4.8" @@ -265,6 +279,15 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" +[[package]] +name = "cpufeatures" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.2.1" @@ -298,6 +321,19 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "curve25519-dalek" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +dependencies = [ + "byteorder", + "digest", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + [[package]] name = "data-encoding" version = "2.3.2" @@ -314,6 +350,14 @@ dependencies = [ "byteorder", ] +[[package]] +name = "der" +version = "0.3.4" +source = "git+https://github.com/RustCrypto/utils?rev=51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0#51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0" +dependencies = [ + "const-oid", +] + [[package]] name = "derive_more" version = "0.99.14" @@ -356,6 +400,15 @@ dependencies = [ "syn", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "directories" version = "3.0.2" @@ -388,6 +441,29 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" +[[package]] +name = "ed25519" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand 0.7.3", + "serde", + "sha2", + "zeroize", +] + [[package]] name = "either" version = "1.6.1" @@ -584,6 +660,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "getrandom" version = "0.2.3" @@ -592,7 +689,7 @@ checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -1138,6 +1235,12 @@ version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "openssl-probe" version = "0.1.4" @@ -1156,7 +1259,7 @@ dependencies = [ "lazy_static", "percent-encoding", "pin-project", - "rand", + "rand 0.8.3", "thiserror", ] @@ -1285,6 +1388,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.6.0" +source = "git+https://github.com/RustCrypto/utils?rev=51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0#51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "png" version = "0.16.8" @@ -1372,6 +1485,19 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + [[package]] name = "rand" version = "0.8.3" @@ -1379,9 +1505,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.3.0", + "rand_core 0.6.2", + "rand_hc 0.3.0", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", ] [[package]] @@ -1391,7 +1527,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.2", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", ] [[package]] @@ -1400,7 +1545,16 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ - "getrandom", + "getrandom 0.2.3", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -1409,7 +1563,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core", + "rand_core 0.6.2", ] [[package]] @@ -1427,7 +1581,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom", + "getrandom 0.2.3", "redox_syscall", ] @@ -1567,7 +1721,7 @@ dependencies = [ "num_cpus", "parking_lot", "pin-project-lite", - "rand", + "rand 0.8.3", "ref-cast", "rocket_codegen", "rocket_http", @@ -1626,7 +1780,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.1.1" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "assign", "js_int", @@ -1647,7 +1801,7 @@ dependencies = [ [[package]] name = "ruma-api" version = "0.17.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "bytes", "http", @@ -1663,7 +1817,7 @@ dependencies = [ [[package]] name = "ruma-api-macros" version = "0.17.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1674,7 +1828,7 @@ dependencies = [ [[package]] name = "ruma-appservice-api" version = "0.2.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "ruma-api", "ruma-common", @@ -1688,7 +1842,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.10.1" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "assign", "bytes", @@ -1708,7 +1862,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.5.1" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "indexmap", "js_int", @@ -1723,7 +1877,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.22.2" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "indoc", "js_int", @@ -1738,7 +1892,7 @@ dependencies = [ [[package]] name = "ruma-events-macros" version = "0.22.2" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1749,7 +1903,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.1.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "js_int", "ruma-api", @@ -1764,10 +1918,10 @@ dependencies = [ [[package]] name = "ruma-identifiers" version = "0.19.1" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "paste", - "rand", + "rand 0.8.3", "ruma-identifiers-macros", "ruma-identifiers-validation", "ruma-serde", @@ -1778,7 +1932,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-macros" version = "0.19.1" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "quote", "ruma-identifiers-validation", @@ -1788,12 +1942,12 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.3.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" [[package]] name = "ruma-identity-service-api" version = "0.1.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "js_int", "ruma-api", @@ -1806,7 +1960,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.1.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "js_int", "ruma-api", @@ -1821,7 +1975,7 @@ dependencies = [ [[package]] name = "ruma-serde" version = "0.4.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "bytes", "form_urlencoded", @@ -1835,7 +1989,7 @@ dependencies = [ [[package]] name = "ruma-serde-macros" version = "0.4.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1846,13 +2000,17 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.7.1" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "base64 0.13.0", - "ring", + "ed25519-dalek", + "pkcs8", + "rand 0.7.3", "ruma-identifiers", "ruma-serde", "serde_json", + "sha2", + "thiserror", "tracing", "untrusted", ] @@ -1860,7 +2018,7 @@ dependencies = [ [[package]] name = "ruma-state-res" version = "0.1.0" -source = "git+https://github.com/ruma/ruma?rev=42bbb81bd2e3919080d3d8689aefb755b7ec8223#42bbb81bd2e3919080d3d8689aefb755b7ec8223" +source = "git+https://github.com/ruma/ruma?rev=e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9#e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9" dependencies = [ "itertools 0.10.0", "js_int", @@ -2065,6 +2223,19 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" +[[package]] +name = "sha2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +dependencies = [ + "block-buffer", + "cfg-if 1.0.0", + "cpufeatures", + "digest", + "opaque-debug", +] + [[package]] name = "sharded-slab" version = "0.1.1" @@ -2083,6 +2254,12 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" + [[package]] name = "simple_asn1" version = "0.4.1" @@ -2150,6 +2327,14 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.3.0" +source = "git+https://github.com/RustCrypto/utils?rev=51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0#51e7c9d734e4d3c5279ba1c181c65b1bd77bcad0" +dependencies = [ + "der", +] + [[package]] name = "stable-pattern" version = "0.1.0" @@ -2225,6 +2410,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" +[[package]] +name = "subtle" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" + [[package]] name = "syn" version = "1.0.72" @@ -2236,6 +2427,18 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + [[package]] name = "tempfile" version = "3.2.0" @@ -2244,7 +2447,7 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ "cfg-if 1.0.0", "libc", - "rand", + "rand 0.8.3", "redox_syscall", "remove_dir_all", "winapi", @@ -2548,7 +2751,7 @@ dependencies = [ "ipnet", "lazy_static", "log", - "rand", + "rand 0.8.3", "smallvec", "thiserror", "tinyvec", @@ -2592,6 +2795,12 @@ dependencies = [ "unchecked-index", ] +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + [[package]] name = "ubyte" version = "0.10.1" @@ -2687,6 +2896,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -2863,6 +3078,27 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" +[[package]] +name = "zeroize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zstd" version = "0.5.4+zstd.1.4.7" diff --git a/Cargo.toml b/Cargo.toml index 1488a3a..6ae9077 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ rust = "1.50" rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "801e04bd5369eb39e126c75f6d11e1e9597304d8", features = ["tls"] } # Used to handle requests # Used for matrix spec type definitions and helpers -ruma = { git = "https://github.com/ruma/ruma", rev = "42bbb81bd2e3919080d3d8689aefb755b7ec8223", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] } +ruma = { git = "https://github.com/ruma/ruma", rev = "e30c4a6d2071b2a93e8bd6aba52e07c9bb191fc9", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] } #ruma = { path = "../ruma/crates/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] } # Used for long polling and federation sender, should be the same as rocket::tokio diff --git a/src/client_server/keys.rs b/src/client_server/keys.rs index 7a88fb6..d856bf3 100644 --- a/src/client_server/keys.rs +++ b/src/client_server/keys.rs @@ -12,7 +12,7 @@ use ruma::{ }, }, encryption::UnsignedDeviceInfo, - DeviceId, UserId, + DeviceId, DeviceKeyAlgorithm, UserId, }; use std::collections::{BTreeMap, HashSet}; @@ -98,29 +98,11 @@ pub async fn claim_keys_route( db: State<'_, Database>, body: Ruma, ) -> ConduitResult { - let mut one_time_keys = BTreeMap::new(); - for (user_id, map) in &body.one_time_keys { - let mut container = BTreeMap::new(); - for (device_id, key_algorithm) in map { - if let Some(one_time_keys) = - db.users - .take_one_time_key(user_id, device_id, key_algorithm, &db.globals)? - { - let mut c = BTreeMap::new(); - c.insert(one_time_keys.0, one_time_keys.1); - container.insert(device_id.clone(), c); - } - } - one_time_keys.insert(user_id.clone(), container); - } + let response = claim_keys_helper(&body.one_time_keys, &db)?; db.flush().await?; - Ok(claim_keys::Response { - failures: BTreeMap::new(), - one_time_keys, - } - .into()) + Ok(response.into()) } #[cfg_attr( @@ -375,3 +357,29 @@ pub fn get_keys_helper bool>( failures: BTreeMap::new(), }) } + +pub fn claim_keys_helper( + one_time_keys_input: &BTreeMap, DeviceKeyAlgorithm>>, + db: &Database, +) -> Result { + let mut one_time_keys = BTreeMap::new(); + for (user_id, map) in one_time_keys_input { + let mut container = BTreeMap::new(); + for (device_id, key_algorithm) in map { + if let Some(one_time_keys) = + db.users + .take_one_time_key(user_id, device_id, key_algorithm, &db.globals)? + { + let mut c = BTreeMap::new(); + c.insert(one_time_keys.0, one_time_keys.1); + container.insert(device_id.clone(), c); + } + } + one_time_keys.insert(user_id.clone(), container); + } + + Ok(claim_keys::Response { + failures: BTreeMap::new(), + one_time_keys, + }) +} diff --git a/src/client_server/membership.rs b/src/client_server/membership.rs index 206ea9d..96fe800 100644 --- a/src/client_server/membership.rs +++ b/src/client_server/membership.rs @@ -945,7 +945,7 @@ pub async fn invite_helper( membership: member::MembershipState::Invite, displayname: db.users.displayname(&user_id)?, avatar_url: db.users.avatar_url(&user_id)?, - is_direct: None, + is_direct: Some(is_direct), third_party_invite: None, }) .expect("event is valid, we just created it"), diff --git a/src/client_server/sync.rs b/src/client_server/sync.rs index b0a22dd..63ad590 100644 --- a/src/client_server/sync.rs +++ b/src/client_server/sync.rs @@ -1,5 +1,6 @@ use super::State; use crate::{ConduitResult, Database, Error, Ruma}; +use log::error; use ruma::{ api::client::r0::sync::sync_events, events::{room::member::MembershipState, AnySyncEphemeralRoomEvent, EventType}, @@ -71,7 +72,12 @@ pub async fn sync_events_route( let mut non_timeline_pdus = db .rooms .pdus_since(&sender_user, &room_id, since)? - .filter_map(|r| r.ok()); // Filter out buggy events + .filter_map(|r| { + if r.is_err() { + error!("Bad pdu in pdus_since: {:?}", r); + } + r.ok() + }); // Filter out buggy events // Take the last 10 events for the timeline let timeline_pdus = non_timeline_pdus diff --git a/src/database/globals.rs b/src/database/globals.rs index 0dd73b2..5d91d37 100644 --- a/src/database/globals.rs +++ b/src/database/globals.rs @@ -94,7 +94,7 @@ impl Globals { .map(|key| (version, key)) }) .and_then(|(version, key)| { - ruma::signatures::Ed25519KeyPair::new(&key, version) + ruma::signatures::Ed25519KeyPair::from_der(&key, version) .map_err(|_| Error::bad_database("Private or public keys are invalid.")) }); diff --git a/src/database/rooms.rs b/src/database/rooms.rs index ede8589..6b17f39 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -1494,7 +1494,12 @@ impl Rooms { Ok(self .pduid_pdu .range(first_pdu_id..last_pdu_id) - .filter_map(|r| r.ok()) + .filter_map(|r| { + if r.is_err() { + error!("Bad pdu in pduid_pdu: {:?}", r); + } + r.ok() + }) .map(move |(pdu_id, v)| { let mut pdu = serde_json::from_slice::(&v) .map_err(|_| Error::bad_database("PDU in db is invalid."))?; diff --git a/src/main.rs b/src/main.rs index fc61a0b..e76cea4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -159,6 +159,7 @@ fn setup_rocket(config: Figment, data: Database) -> rocket::Rocket( .typing_remove(&typing.user_id, &typing.room_id, &db.globals)?; } } - Edu::DeviceListUpdate(_) => {} - Edu::DirectToDevice(_) => {} + Edu::DeviceListUpdate(_) => { + // TODO: Instead of worrying about stream ids we can just fetch all devices again + } + Edu::DirectToDevice(DirectDeviceContent { + sender, + ev_type, + message_id, + messages, + }) => { + // Check if this is a new transaction id + if db + .transaction_ids + .existing_txnid(&sender, None, &message_id)? + .is_some() + { + continue; + } + + for (target_user_id, map) in &messages { + for (target_device_id_maybe, event) in map { + match target_device_id_maybe { + to_device::DeviceIdOrAllDevices::DeviceId(target_device_id) => { + db.users.add_to_device_event( + &sender, + &target_user_id, + &target_device_id, + &ev_type, + serde_json::from_str(event.get()).map_err(|_| { + Error::BadRequest( + ErrorKind::InvalidParam, + "Event is invalid", + ) + })?, + &db.globals, + )? + } + + to_device::DeviceIdOrAllDevices::AllDevices => { + for target_device_id in db.users.all_device_ids(&target_user_id) { + db.users.add_to_device_event( + &sender, + &target_user_id, + &target_device_id?, + &ev_type, + serde_json::from_str(event.get()).map_err(|_| { + Error::BadRequest( + ErrorKind::InvalidParam, + "Event is invalid", + ) + })?, + &db.globals, + )?; + } + } + } + } + } + + // Save transaction id with empty data + db.transaction_ids + .add_txnid(&sender, None, &message_id, &[])?; + } Edu::_Custom(_) => {} } } @@ -2335,6 +2401,29 @@ pub fn get_keys_route<'a>( .into()) } +#[cfg_attr( + feature = "conduit_bin", + post("/_matrix/federation/v1/user/keys/claim", data = "") +)] +#[tracing::instrument(skip(db, body))] +pub async fn claim_keys_route<'a>( + db: State<'a, Database>, + body: Ruma, +) -> ConduitResult { + if !db.globals.allow_federation() { + return Err(Error::bad_config("Federation is disabled.")); + } + + let result = claim_keys_helper(&body.one_time_keys, &db)?; + + db.flush().await?; + + Ok(claim_keys::v1::Response { + one_time_keys: result.one_time_keys, + } + .into()) +} + pub async fn fetch_required_signing_keys( event: &BTreeMap, pub_key_map: &RwLock>>,