diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2b73450 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.checkOnSave": false +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 74f3bbb..ad05ae8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if 1.0.0", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.7.8" @@ -91,12 +102,30 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bincode" version = "1.3.3" @@ -121,6 +150,12 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitfield" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d7e60934ceec538daadb9d8432424ed043a904d8e0243f3c6446bce549a46ac" + [[package]] name = "bitflags" version = "1.3.2" @@ -159,6 +194,45 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-padding" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blowfish" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e412e2cd0f2b2d93e02543ceae7917b3c70331573df19ee046bcbc35e45e87d7" +dependencies = [ + "byteorder", + "cipher", +] + +[[package]] +name = "bstr" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "buffer-redux" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2886ea01509598caac116942abd33ab5a88fa32acdf7e4abfa0fc489ca520c9" +dependencies = [ + "memchr", + "safemem", +] + [[package]] name = "bumpalo" version = "3.15.0" @@ -199,6 +273,16 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +[[package]] +name = "camellia" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3264e2574e9ef2b53ce6f536dea83a69ac0bc600b762d1523ff83fe07230ce30" +dependencies = [ + "byteorder", + "cipher", +] + [[package]] name = "camino" version = "1.1.6" @@ -231,6 +315,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cast5" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b07d673db1ccf000e90f54b819db9e75a8348d6eb056e9b8ab53231b7a9911" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.0.83" @@ -240,6 +333,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cfb-mode" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "738b8d467867f80a71351933f70461f5b56f24d5c93e0cf216e59229c968d330" +dependencies = [ + "cipher", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -265,6 +367,22 @@ dependencies = [ "windows-targets 0.52.0", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -388,6 +506,21 @@ version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" +[[package]] +name = "crc24" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd121741cf3eb82c08dd3023eb55bf2665e5f60ec20f89760cf836ae4562e6a0" + +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -422,6 +555,18 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -432,6 +577,34 @@ dependencies = [ "typenum", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "platforms", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.49", +] + [[package]] name = "darling" version = "0.14.4" @@ -514,6 +687,17 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + [[package]] name = "derivative" version = "2.2.0" @@ -525,6 +709,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling 0.14.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -538,6 +753,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "des" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdd80ce8ce993de27e9f063a444a4d53ce8e8db4c1f00cc03af5ad5a9867a1e" +dependencies = [ + "cipher", +] + [[package]] name = "digest" version = "0.10.7" @@ -545,7 +769,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", ] [[package]] @@ -554,12 +780,71 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" +dependencies = [ + "curve25519-dalek", + "ed25519", + "serde", + "sha2", + "subtle", + "zeroize", +] + [[package]] name = "either" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "hkdf", + "pem-rfc7468", + "pkcs8", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "enum-iterator" version = "0.7.0" @@ -613,6 +898,32 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -752,6 +1063,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -782,6 +1094,17 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -868,13 +1191,31 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + [[package]] name = "holo_hash" version = "0.3.0-beta-dev.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8775ba0e9b8ebbbe089794c399cb6acd659f8213261fdee0febc2f4fff229d4" dependencies = [ - "base64", + "base64 0.13.1", "blake2b_simd", "derive_more", "holochain_serialized_bytes", @@ -1063,6 +1404,15 @@ dependencies = [ "cc", ] +[[package]] +name = "idea" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "075557004419d7f2031b8bb7f44bb43e55a83ca7b63076a8fb8fe75753836477" +dependencies = [ + "cipher", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1105,6 +1455,15 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "intervallum" version = "1.4.1" @@ -1142,13 +1501,22 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + [[package]] name = "kitsune_p2p_bin_data" version = "0.3.0-beta-dev.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe2bc530cd368de90546ff0cc3d53c321834b91c5a1bd4d67518222339f1a95c" dependencies = [ - "base64", + "base64 0.13.1", "derive_more", "holochain_util", "kitsune_p2p_dht_arc", @@ -1197,6 +1565,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "leb128" @@ -1210,6 +1581,12 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "lock_api" version = "0.4.11" @@ -1235,6 +1612,16 @@ dependencies = [ "libc", ] +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if 1.0.0", + "digest", +] + [[package]] name = "memchr" version = "2.7.1" @@ -1268,6 +1655,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.2" @@ -1283,6 +1676,45 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "serde", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.49", +] + [[package]] name = "num-integer" version = "0.1.46" @@ -1292,6 +1724,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.18" @@ -1299,6 +1742,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1326,6 +1770,30 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + +[[package]] +name = "p384" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70786f51bcc69f6a4c0360e063a4cac5419ef7c5cd5b3c99ad70f3be5ba79209" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -1355,6 +1823,15 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1372,6 +1849,58 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "pgp" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27e1f8e085bfa9b85763fe3ddaacbe90a09cd847b3833129153a6cb063bbe132" +dependencies = [ + "aes", + "base64 0.21.7", + "bitfield", + "block-padding", + "blowfish", + "bstr", + "buffer-redux", + "byteorder", + "camellia", + "cast5", + "cfb-mode", + "chrono", + "cipher", + "crc24", + "curve25519-dalek", + "derive_builder", + "des", + "digest", + "ed25519-dalek", + "elliptic-curve", + "flate2", + "generic-array", + "hex", + "idea", + "log", + "md-5", + "nom", + "num-bigint-dig", + "num-derive", + "num-traits", + "p256", + "p384", + "rand", + "ripemd", + "rsa", + "sha1", + "sha2", + "sha3", + "signature", + "smallvec", + "thiserror", + "twofish", + "x25519-dalek", + "zeroize", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1384,6 +1913,48 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "platforms" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -1452,6 +2023,36 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "rayon" version = "1.8.1" @@ -1543,6 +2144,25 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest", +] + [[package]] name = "rkyv" version = "0.7.44" @@ -1595,6 +2215,26 @@ dependencies = [ "serde", ] +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1622,6 +2262,12 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "same-file" version = "1.0.6" @@ -1643,6 +2289,20 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + [[package]] name = "self_cell" version = "1.0.3" @@ -1748,6 +2408,38 @@ dependencies = [ "digest", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + [[package]] name = "shared-buffer" version = "0.1.4" @@ -1771,6 +2463,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + [[package]] name = "simdutf8" version = "0.1.4" @@ -1798,6 +2500,22 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -2021,6 +2739,9 @@ name = "trusted" version = "0.0.1" dependencies = [ "hdk", + "hex", + "pgp", + "regex", "serde", "trusted_integrity", ] @@ -2033,6 +2754,15 @@ dependencies = [ "serde", ] +[[package]] +name = "twofish" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a78e83a30223c757c3947cd144a31014ff04298d8719ae10d03c31c0448c8013" +dependencies = [ + "cipher", +] + [[package]] name = "typenum" version = "1.17.0" @@ -2566,3 +3296,35 @@ checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] + +[[package]] +name = "x25519-dalek" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +dependencies = [ + "curve25519-dalek", + "rand_core", + "serde", + "zeroize", +] + +[[package]] +name = "zeroize" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.49", +] diff --git a/dnas/trusted/zomes/coordinator/trusted/Cargo.toml b/dnas/trusted/zomes/coordinator/trusted/Cargo.toml index d536b43..ef32023 100644 --- a/dnas/trusted/zomes/coordinator/trusted/Cargo.toml +++ b/dnas/trusted/zomes/coordinator/trusted/Cargo.toml @@ -13,3 +13,7 @@ hdk = { workspace = true } serde = { workspace = true } trusted_integrity = { workspace = true } + +pgp = "0.10.2" +hex = "0.4.3" +regex = "1.10.3" diff --git a/dnas/trusted/zomes/coordinator/trusted/src/gpg_key_dist.rs b/dnas/trusted/zomes/coordinator/trusted/src/gpg_key_dist.rs index 890dc1c..067c5dd 100644 --- a/dnas/trusted/zomes/coordinator/trusted/src/gpg_key_dist.rs +++ b/dnas/trusted/zomes/coordinator/trusted/src/gpg_key_dist.rs @@ -1,6 +1,8 @@ use hdk::prelude::*; use trusted_integrity::prelude::*; +use crate::gpg_util::{try_extract_public_key, PublicKeySummary}; + #[derive(Serialize, Deserialize, Debug, Clone, SerializedBytes)] pub struct DistributeGpgKeyRequest { pub public_key: String, @@ -8,9 +10,15 @@ pub struct DistributeGpgKeyRequest { #[hdk_extern] pub fn distribute_gpg_key(gpg_key: DistributeGpgKeyRequest) -> ExternResult { + let public_key = try_extract_public_key(gpg_key.public_key.clone())?; + + let summary = PublicKeySummary::try_from_public_key(&public_key)?; + let gpg_key_hash = create_entry(&EntryTypes::GpgKeyDist(GpgKeyDist { public_key: gpg_key.public_key, - fingerprint: "TODO".to_string(), + fingerprint: summary.fingerprint, + user_id: summary.user_id, + email: summary.email, }))?; let record = get(gpg_key_hash.clone(), GetOptions::default())? .ok_or( @@ -21,6 +29,18 @@ pub fn distribute_gpg_key(gpg_key: DistributeGpgKeyRequest) -> ExternResult ExternResult> { + let q = ChainQueryFilter::default() + .action_type(ActionType::Create) + .entry_type(EntryType::App(UnitEntryTypes::GpgKeyDist.try_into()?)) + .include_entries(true) + .ascending(); + + let gpg_key_dist_entries = query(q)?; + Ok(gpg_key_dist_entries) +} + #[hdk_extern] pub fn get_gpg_key_dist(gpg_key_hash: ActionHash) -> ExternResult> { let Some(details) = get_details(gpg_key_hash, GetOptions::default())? else { diff --git a/dnas/trusted/zomes/coordinator/trusted/src/gpg_util.rs b/dnas/trusted/zomes/coordinator/trusted/src/gpg_util.rs new file mode 100644 index 0000000..6f5bc40 --- /dev/null +++ b/dnas/trusted/zomes/coordinator/trusted/src/gpg_util.rs @@ -0,0 +1,182 @@ +use hdk::prelude::*; +use std::{ + collections::BTreeMap, + io::{Read, Seek}, +}; + +use pgp::types::KeyTrait; +use pgp::{ + armor::{BlockType, Dearmor}, + from_bytes_many, PublicOrSecret, SignedPublicKey, +}; +use std::io::Cursor; + +pub fn try_extract_public_key(input: String) -> ExternResult { + let c = Cursor::new(input.as_bytes()); + let (typ, _headers, bytes) = parse(c).unwrap(); + + if typ != Some(BlockType::PublicKey) { + return Err(wasm_error!(WasmErrorInner::Guest( + "Expected a public key".to_string() + ))); + } + + let content = from_bytes_many(&bytes[..]) + .collect::, _>>() + .map_err(|e| { + wasm_error!(WasmErrorInner::Guest(format!( + "Error parsing PGP data: {}", + e + ))) + })?; + + if content.len() != 1 { + return Err(wasm_error!(WasmErrorInner::Guest( + "Expected exactly one PGP key".to_string() + ))); + } + + match &content[0] { + PublicOrSecret::Public(public_key) => Ok(public_key.clone()), + _ => Err(wasm_error!(WasmErrorInner::Guest( + "Expected a public key".to_string() + ))), + } +} + +pub struct PublicKeySummary { + pub fingerprint: String, + pub user_id: String, + pub email: Option, +} + +impl PublicKeySummary { + pub fn try_from_public_key(public_key: &SignedPublicKey) -> ExternResult { + let fingerprint = public_key.fingerprint(); + + match public_key.details.users.first() { + None => Err(wasm_error!(WasmErrorInner::Guest( + "No user id found on the public key".to_string() + ))), + Some(user_id) => { + let user_id = user_id.id.id().to_string(); + + let pattern = regex::Regex::new(r"^([^ ]+)( <([^>]+)>)?$").unwrap(); + let captures = pattern.captures(&user_id).ok_or_else(|| { + wasm_error!(WasmErrorInner::Guest("Invalid user id format".to_string())) + })?; + + let user_id = match captures.get(1) { + Some(user_id) => user_id.as_str().to_string(), + None => { + return Err(wasm_error!(WasmErrorInner::Guest( + "Missing user id".to_string() + ))); + } + }; + let email = captures.get(3).map(|email| email.as_str().to_string()); + + Ok(PublicKeySummary { + fingerprint: hex::encode(fingerprint).to_uppercase(), + user_id, + email, + }) + } + } + } +} + +fn parse( + mut input: R, +) -> std::io::Result<(Option, BTreeMap, Vec)> { + let mut dearmor = Dearmor::new(input.by_ref()); + + let mut bytes = Vec::new(); + dearmor.read_to_end(&mut bytes)?; + + Ok((dearmor.typ, dearmor.headers, bytes)) +} + +#[cfg(test)] +mod tests { + use pgp::{types::KeyTrait, PublicKey}; + + use super::*; + + const TEST_KEY_1: &str = r#" +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEZc/RVBYJKwYBBAHaRw8BAQdA/pL2Vk0GwBWhsMRgpoeI2Os0UlxpWFHzdvuH +XUHKnjG0BnRlc3RlcoiZBBMWCgBBFiEE+EdcI9xicATMCx3Benquor8GXMoFAmXP +0VQCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQenquor8G +XMqa9gD/Vtvj91GMGfYujOXVOO9r1EEaz/J/lKwOGemVJPQG0UQBAI6tDkiCEruX +7ra/pO5frPMqUjJeqNhUgH7bQHwqZz4LuDgEZc/RVBIKKwYBBAGXVQEFAQEHQAI/ +BVg8bP9fKzKRO1uvGm6cpo8Ht+X9JkSnsMacnRUNAwEIB4h4BBgWCgAgFiEE+Edc +I9xicATMCx3Benquor8GXMoFAmXP0VQCGwwACgkQenquor8GXMogCQD+KNg9+ukK +oSr87qDC0dehXKeYN7NiR985Y5TtvRTkZeoA/ROsHS3dzWIMjHOn8kWNU8n93VUt +x//CtSMXRrqvlAIF +=zuwf +-----END PGP PUBLIC KEY BLOCK----- + "#; + + const TEST_KEY_2: &str = r#" +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEZc/svhYJKwYBBAHaRw8BAQdA0eZIgnzMYpUS07cPQxkHob6T53nt8o3qw58t +JdFTxmC0H3Rlc3RlcjIgPHRlc3RlcjJAbWFpbGhhcHB5LmNvbT6ImQQTFgoAQRYh +BFl3mfcvqmAioFNJofiLypseg5Z4BQJlz+y+AhsDBQkFo5qABQsJCAcCAiICBhUK +CQgLAgQWAgMBAh4HAheAAAoJEPiLypseg5Z4qsgBAL/hkFGa+tJvdqxs639b/WhJ +N6ouTIcLqaCKIjdvEy/kAQCLrKOtLKNshnTM8whhMr4Akf4OCSRS0sfZqBeFSSqZ +Cbg4BGXP7L4SCisGAQQBl1UBBQEBB0A6enyZUTt8Leo7ZFlG68L6b+kL5VLsQjpe +AYs3iJnSSAMBCAeIfgQYFgoAJhYhBFl3mfcvqmAioFNJofiLypseg5Z4BQJlz+y+ +AhsMBQkFo5qAAAoJEPiLypseg5Z4rRAA/A4sNX8GyWopybZJGXu++lJ4lY1/Rgj8 +oo0Dy+qQjDoTAPwMQD9dqZJX0eDz2j9JhyOiVI7ezjRTTef0+r4Ox152Bg== +=Arm4 +-----END PGP PUBLIC KEY BLOCK----- + "#; + + #[test] + fn extract() { + let public_key = try_extract_public_key(TEST_KEY_2.to_string()).unwrap(); + + assert_eq!( + "tester2 ", + public_key.details.users.first().unwrap().id.id() + ); + assert_eq!( + vec![ + 89, 119, 153, 247, 47, 170, 96, 34, 160, 83, 73, 161, 248, 139, 202, 155, 30, 131, + 150, 120 + ], + public_key.fingerprint() + ); + } + + #[test] + fn summary() { + let public_key = try_extract_public_key(TEST_KEY_2.to_string()).unwrap(); + + let summary = PublicKeySummary::try_from_public_key(&public_key).unwrap(); + + assert_eq!( + "597799F72FAA6022A05349A1F88BCA9B1E839678", + summary.fingerprint + ); + assert_eq!("tester2", summary.user_id); + assert_eq!(Some("tester2@mailhappy.com".to_string()), summary.email); + } + + #[test] + fn summary_no_email() { + let public_key = try_extract_public_key(TEST_KEY_1.to_string()).unwrap(); + + let summary = PublicKeySummary::try_from_public_key(&public_key).unwrap(); + + assert_eq!( + "F8475C23DC627004CC0B1DC17A7AAEA2BF065CCA", + summary.fingerprint + ); + assert_eq!("tester", summary.user_id); + assert_eq!(None, summary.email); + } +} diff --git a/dnas/trusted/zomes/coordinator/trusted/src/lib.rs b/dnas/trusted/zomes/coordinator/trusted/src/lib.rs index 3f15084..1ed25ec 100644 --- a/dnas/trusted/zomes/coordinator/trusted/src/lib.rs +++ b/dnas/trusted/zomes/coordinator/trusted/src/lib.rs @@ -1,4 +1,6 @@ -pub mod gpg_key_dist; +mod gpg_key_dist; +mod gpg_util; + use hdk::prelude::*; use trusted_integrity::*; diff --git a/dnas/trusted/zomes/integrity/trusted/src/gpg_key_dist.rs b/dnas/trusted/zomes/integrity/trusted/src/gpg_key_dist.rs index 48cde46..236dcdc 100644 --- a/dnas/trusted/zomes/integrity/trusted/src/gpg_key_dist.rs +++ b/dnas/trusted/zomes/integrity/trusted/src/gpg_key_dist.rs @@ -4,6 +4,8 @@ use hdi::prelude::*; pub struct GpgKeyDist { pub public_key: String, pub fingerprint: String, + pub user_id: String, + pub email: Option, } pub fn validate_create_gpg_key_dist( diff --git a/dnas/trusted/zomes/integrity/trusted/src/lib.rs b/dnas/trusted/zomes/integrity/trusted/src/lib.rs index ca126c7..fcd62eb 100644 --- a/dnas/trusted/zomes/integrity/trusted/src/lib.rs +++ b/dnas/trusted/zomes/integrity/trusted/src/lib.rs @@ -4,7 +4,7 @@ use hdi::prelude::*; pub mod prelude { pub use crate::gpg_key_dist::*; - pub use crate::EntryTypes; + pub use crate::{EntryTypes, UnitEntryTypes}; } #[derive(Serialize, Deserialize)] diff --git a/ui/src/App.vue b/ui/src/App.vue index 1cd2a68..03377b8 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -6,6 +6,8 @@
+ +
@@ -16,11 +18,13 @@ import { AppAgentClient, AppAgentWebsocket } from '@holochain/client'; import '@material/mwc-circular-progress'; import '@material/mwc-button'; import CreateGpgKey from './trusted/trusted/CreateGpgKey.vue'; +import MyKeys from './trusted/trusted/MyKeys.vue'; export default defineComponent({ components: { - CreateGpgKey - }, + CreateGpgKey, + MyKeys +}, data(): { client: AppAgentClient | undefined; loading: boolean; diff --git a/ui/src/trusted/trusted/MyKeys.vue b/ui/src/trusted/trusted/MyKeys.vue new file mode 100644 index 0000000..edbadec --- /dev/null +++ b/ui/src/trusted/trusted/MyKeys.vue @@ -0,0 +1,51 @@ + + + diff --git a/ui/src/trusted/trusted/types.ts b/ui/src/trusted/trusted/types.ts index f9625a0..4550041 100644 --- a/ui/src/trusted/trusted/types.ts +++ b/ui/src/trusted/trusted/types.ts @@ -45,4 +45,6 @@ export interface DistributeGpgKeyRequest { export interface GpgKeyDist { public_key: string; fingerprint: string; + user_id: string; + email?: string; }