diff --git a/Cargo.lock b/Cargo.lock index 24e352d305..b75f704d37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,6 +196,41 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + [[package]] name = "agency_client" version = "0.61.0" @@ -320,6 +355,42 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "arc-swap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" + +[[package]] +name = "argon2" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ba4cac0a46bc1d2912652a751c47f2a9f3a7fe89bcae2275d418f5270402f9" +dependencies = [ + "base64ct", + "blake2", + "cpufeatures", + "password-hash", +] + +[[package]] +name = "aries-askar" +version = "0.3.0" +source = "git+https://github.com/hyperledger/aries-askar.git?tag=v0.3.0#6543d01da953203482277271c0b31cb50260c740" +dependencies = [ + "askar-crypto", + "askar-storage", + "async-lock 3.1.1", + "env_logger 0.10.0", + "ffi-support", + "log", + "once_cell", + "serde", + "serde_cbor", + "serde_json", + "zeroize", +] + [[package]] name = "aries-vcx-agent" version = "0.61.0" @@ -394,7 +465,9 @@ name = "aries_vcx_core" version = "0.1.0" dependencies = [ "agency_client", + "aries-askar", "async-trait", + "bs58 0.5.0", "derive_builder", "futures", "indy-api-types", @@ -409,6 +482,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", + "test_utils", "thiserror", "time 0.3.20", "tokio", @@ -460,6 +534,74 @@ dependencies = [ "toml 0.5.11", ] +[[package]] +name = "askar-crypto" +version = "0.3.0" +source = "git+https://github.com/hyperledger/aries-askar.git?tag=v0.3.0#6543d01da953203482277271c0b31cb50260c740" +dependencies = [ + "aead", + "aes", + "aes-gcm", + "argon2", + "base64", + "blake2", + "block-modes", + "bls12_381", + "cbc", + "chacha20", + "chacha20poly1305", + "cipher", + "crypto_box", + "curve25519-dalek", + "digest", + "ed25519-dalek", + "elliptic-curve", + "group", + "hkdf", + "hmac", + "k256", + "p256", + "p384", + "rand 0.8.5", + "serde", + "serde-json-core", + "sha2", + "subtle", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "askar-storage" +version = "0.1.0" +source = "git+https://github.com/hyperledger/aries-askar.git?tag=v0.3.0#6543d01da953203482277271c0b31cb50260c740" +dependencies = [ + "arc-swap", + "askar-crypto", + "async-lock 3.1.1", + "async-stream", + "bs58 0.5.0", + "chrono", + "digest", + "futures-lite 2.0.0", + "hex", + "hmac", + "itertools 0.11.0", + "log", + "once_cell", + "percent-encoding", + "rmp-serde", + "serde", + "serde_cbor", + "serde_json", + "sha2", + "sqlx", + "tokio", + "url", + "uuid 1.5.0", + "zeroize", +] + [[package]] name = "async-attributes" version = "1.1.2" @@ -477,7 +619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] @@ -487,11 +629,11 @@ version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c1da3ae8dabd9c00f453a329dfe1fb28da3c0a72e2478cdcd93171740c20499" dependencies = [ - "async-lock", + "async-lock 2.8.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite", + "futures-lite 1.13.0", "slab", ] @@ -504,9 +646,9 @@ dependencies = [ "async-channel", "async-executor", "async-io", - "async-lock", + "async-lock 2.8.0", "blocking", - "futures-lite", + "futures-lite 1.13.0", "once_cell", ] @@ -516,11 +658,11 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "cfg-if", "concurrent-queue", - "futures-lite", + "futures-lite 1.13.0", "log", "parking", "polling", @@ -536,7 +678,18 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" +dependencies = [ + "event-listener 3.1.0", + "event-listener-strategy", + "pin-project-lite", ] [[package]] @@ -549,12 +702,12 @@ dependencies = [ "async-channel", "async-global-executor", "async-io", - "async-lock", + "async-lock 2.8.0", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite", + "futures-lite 1.13.0", "gloo-timers", "kv-log-macro", "log", @@ -719,6 +872,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.21.4" @@ -764,6 +923,15 @@ dependencies = [ "serde", ] +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -773,6 +941,21 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-modes" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2211b0817f061502a8dd9f11a37e879e79763e3c698d2418cf824d8cb2f21e" + +[[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 = "blocking" version = "1.4.1" @@ -780,15 +963,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" dependencies = [ "async-channel", - "async-lock", + "async-lock 2.8.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite", + "futures-lite 1.13.0", "piper", "tracing", ] +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +dependencies = [ + "ff", + "group", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "brotli" version = "3.4.0" @@ -884,6 +1080,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.0.83" @@ -900,6 +1105,30 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + [[package]] name = "chrono" version = "0.4.31" @@ -915,6 +1144,17 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + [[package]] name = "clap" version = "3.2.25" @@ -1142,6 +1382,18 @@ dependencies = [ "winapi", ] +[[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 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1149,9 +1401,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", + "rand_core 0.6.4", "typenum", ] +[[package]] +name = "crypto_box" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16182b4f39a82ec8a6851155cc4c0cda3065bb1db33651726a29e1951de0f009" +dependencies = [ + "aead", + "crypto_secretbox", + "curve25519-dalek", + "salsa20", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto_secretbox" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d6cf87adf719ddf43a805e92c6870a531aedda35ff640442cbaf8674e141e1" +dependencies = [ + "aead", + "cipher", + "generic-array", + "poly1305", + "salsa20", + "subtle", + "zeroize", +] + [[package]] name = "ctor" version = "0.2.5" @@ -1162,6 +1444,15 @@ dependencies = [ "syn 2.0.38", ] +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + [[package]] name = "cursive" version = "0.20.0" @@ -1624,6 +1915,19 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" +[[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", +] + [[package]] name = "ed25519" version = "2.2.2" @@ -1660,6 +1964,25 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562cc8504a01eb20c10fb154abd7c4baeb9beba2329cf85838ee2bd48a468b18" +[[package]] +name = "elliptic-curve" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9775b22bc152ad86a0cf23f0f348b884b26add12bf741e7ffc4d4ab2ab4d205" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "hkdf", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encoding_rs" version = "0.8.33" @@ -1793,6 +2116,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +dependencies = [ + "event-listener 3.1.0", + "pin-project-lite", +] + [[package]] name = "failure" version = "0.1.8" @@ -1836,6 +2180,16 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "ffi-support" version = "0.4.4" @@ -2005,6 +2359,21 @@ dependencies = [ "waker-fn", ] +[[package]] +name = "futures-lite" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c1155db57329dca6d018b61e76b1488ce9a2e5e44028cac420a5898f4fcef63" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + [[package]] name = "futures-macro" version = "0.3.28" @@ -2054,6 +2423,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -2080,6 +2450,16 @@ dependencies = [ "wasi 0.11.0+wasi-snapshot-preview1", ] +[[package]] +name = "ghash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +dependencies = [ + "opaque-debug", + "polyval", +] + [[package]] name = "gimli" version = "0.28.0" @@ -2129,6 +2509,17 @@ dependencies = [ "scroll", ] +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "h2" version = "0.3.21" @@ -2148,6 +2539,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "hashbrown" version = "0.12.3" @@ -2562,6 +2959,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "block-padding", + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -2656,6 +3063,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2", +] + [[package]] name = "keccak" version = "0.1.4" @@ -3285,6 +3704,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "openssl" version = "0.10.57" @@ -3350,6 +3775,30 @@ dependencies = [ "stable_deref_trait", ] +[[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" version = "2.1.1" @@ -3379,6 +3828,17 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" @@ -3526,6 +3986,29 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "polyval" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -3562,6 +4045,15 @@ dependencies = [ "termtree", ] +[[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" @@ -3784,6 +4276,16 @@ dependencies = [ "winreg", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "ring" version = "0.16.20" @@ -3927,6 +4429,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + [[package]] name = "schannel" version = "0.1.22" @@ -3972,6 +4483,19 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "subtle", + "zeroize", +] + [[package]] name = "security-framework" version = "2.9.2" @@ -4013,6 +4537,26 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-json-core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c9e1ab533c0bc414c34920ec7e5f097101d126ed5eac1a1aac711222e0bbb33" +dependencies = [ + "ryu", + "serde", +] + +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.189" @@ -4274,11 +4818,12 @@ dependencies = [ "atoi", "byteorder", "bytes", + "chrono", "crc", "crossbeam-queue", "dotenvy", "either", - "event-listener", + "event-listener 2.5.3", "futures-channel", "futures-core", "futures-intrusive", @@ -4338,6 +4883,7 @@ dependencies = [ "sha2", "sqlx-core", "sqlx-mysql", + "sqlx-postgres", "sqlx-sqlite", "syn 1.0.109", "tempfile", @@ -4356,6 +4902,7 @@ dependencies = [ "bitflags 2.4.0", "byteorder", "bytes", + "chrono", "crc", "digest", "dotenvy", @@ -4397,6 +4944,7 @@ dependencies = [ "base64", "bitflags 2.4.0", "byteorder", + "chrono", "crc", "dotenvy", "etcetera", @@ -4433,6 +4981,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d59dc83cf45d89c555a577694534fcd1b55c545a816c816ce51f20bbe56a4f3f" dependencies = [ "atoi", + "chrono", "flume", "futures-channel", "futures-core", @@ -5143,6 +5692,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + [[package]] name = "unsigned-varint" version = "0.7.2" diff --git a/aries/aries_vcx_core/Cargo.toml b/aries/aries_vcx_core/Cargo.toml index 2130f3e441..517cd362e2 100644 --- a/aries/aries_vcx_core/Cargo.toml +++ b/aries/aries_vcx_core/Cargo.toml @@ -5,14 +5,17 @@ edition = "2021" [features] ########################## DEP FLAGS ################################ -vdrtools_wallet = ["dep:libvdrtools", "dep:indy-api-types"] +vdrtools_wallet = ["dep:libvdrtools", "dep:indy-api-types", "test_utils/vdrtools_wallet"] # Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx) credx = ["dep:indy-credx"] vdr_proxy_ledger = ["credx", "dep:indy-vdr-proxy-client"] # Feature flag to allow legacy proof verification legacy_proof = [] +askar_wallet = ["dep:aries-askar"] [dependencies] +aries-askar = { git = "https://github.com/hyperledger/aries-askar.git", tag = "v0.3.0" } +bs58 = { version = "0.5" } agency_client = { path = "../misc/legacy/agency_client" } indy-vdr = { git = "https://github.com/hyperledger/indy-vdr.git", rev = "c143268", default-features = false, features = ["log"] } indy-credx = { git = "https://github.com/hyperledger/indy-shared-rs", tag = "v1.1.0", optional = true } @@ -35,4 +38,5 @@ indy-ledger-response-parser = { path = "../misc/indy_ledger_response_parser" } lru = { version = "0.12.0" } [dev-dependencies] +test_utils = { path = "../misc/test_utils" } tokio = { version = "1.20", features = ["rt", "macros", "rt-multi-thread"] } diff --git a/aries/aries_vcx_core/src/errors/mapping_askar.rs b/aries/aries_vcx_core/src/errors/mapping_askar.rs new file mode 100644 index 0000000000..4110b0e577 --- /dev/null +++ b/aries/aries_vcx_core/src/errors/mapping_askar.rs @@ -0,0 +1,37 @@ +use aries_askar::ErrorKind; + +use super::error::{AriesVcxCoreError, AriesVcxCoreErrorKind}; + +impl From for AriesVcxCoreError { + fn from(err: aries_askar::Error) -> Self { + match err.kind() { + ErrorKind::Backend => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletUnexpected, err) + } + ErrorKind::Busy => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletUnexpected, err) + } + ErrorKind::Custom => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletUnexpected, err) + } + ErrorKind::Duplicate => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::DuplicationWalletRecord, err) + } + ErrorKind::Encryption => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletUnexpected, err) + } + ErrorKind::Input => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletUnexpected, err) + } + ErrorKind::NotFound => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletRecordNotFound, err) + } + ErrorKind::Unexpected => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletUnexpected, err) + } + ErrorKind::Unsupported => { + AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::WalletUnexpected, err) + } + } + } +} diff --git a/aries/aries_vcx_core/src/errors/mod.rs b/aries/aries_vcx_core/src/errors/mod.rs index 841ab45fe2..da71893dd3 100644 --- a/aries/aries_vcx_core/src/errors/mod.rs +++ b/aries/aries_vcx_core/src/errors/mod.rs @@ -9,3 +9,5 @@ mod mapping_indyvdr; mod mapping_indyvdr_proxy; mod mapping_ledger_response_parser; mod mapping_others; +#[cfg(feature = "askar_wallet")] +mod mapping_askar; diff --git a/aries/aries_vcx_core/src/wallet2/askar_wallet.rs b/aries/aries_vcx_core/src/wallet2/askar_wallet.rs new file mode 100644 index 0000000000..2a134f0601 --- /dev/null +++ b/aries/aries_vcx_core/src/wallet2/askar_wallet.rs @@ -0,0 +1,356 @@ +use aries_askar::{ + entry::{Entry, EntryTag, TagFilter}, + kms::{KeyAlg, KeyEntry, LocalKey, SecretBytes}, + PassKey, Session, Store, StoreKeyMethod, +}; +use async_trait::async_trait; +use futures::stream::BoxStream; + +use crate::{ + errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult}, + utils::async_fn_iterator::AsyncFnIterator, + wallet::{base_wallet::BaseWallet, structs_io::UnpackMessageOutput}, +}; + +use super::{DidWallet, RecordWallet, SigType, Wallet}; + +pub enum RngMethod { + Bls, + RandomDet, +} + +impl From for Option<&str> { + fn from(value: RngMethod) -> Self { + match value { + RngMethod::RandomDet => None, + RngMethod::Bls => Some("bls_keygen"), + } + } +} + +#[derive(Debug)] +pub struct AskarWallet { + pub backend: Store, + profile: Option, +} + +impl AskarWallet { + pub async fn create( + db_url: &str, + key_method: StoreKeyMethod, + pass_key: PassKey<'_>, + recreate: bool, + profile: Option, + ) -> Result { + let backend = + Store::provision(db_url, key_method, pass_key, profile.clone(), recreate).await?; + + Ok(Self { backend, profile }) + } + + pub async fn open( + db_url: &str, + key_method: Option, + pass_key: PassKey<'_>, + profile: Option, + ) -> Result { + let backend = Store::open(db_url, key_method, pass_key, profile.clone()).await?; + + Ok(Self { backend, profile }) + } + + async fn fetch_key_entry( + &self, + session: &mut Session, + key_name: &str, + ) -> Result { + session.fetch_key(key_name, false).await?.ok_or_else(|| { + AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::WalletRecordNotFound, + format!("no key with name '{}' found in wallet", key_name), + ) + }) + } + + async fn find(&self, category: &str) -> VcxCoreResult>> { + let mut res = self + .backend + .scan( + self.profile.clone(), + Some(category.into()), + None, + None, + None, + ) + .await?; + let mut all: Vec> = vec![]; + let rs = res + .fetch_next() + .await + .map_err(|err| AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::IOError, err))?; + if let Some(found) = rs { + println!("found: {:?}", found); + all = found.into_iter().map(|entry| Ok(entry)).collect(); + } + Ok(Box::pin(futures::stream::iter(all))) + } +} + +pub struct Record { + pub category: String, + pub name: String, + pub value: SecretBytes, + pub tags: Option>, + pub expiry_ms: Option, +} + +pub struct RecordId { + name: String, + category: String, + for_update: bool, +} + +pub struct DidAttrs { + key_name: String, + category: String, + tags: Option>, + expiry_ms: Option, +} + +pub struct KeyAttrs { + name: String, + alg: KeyAlg, + seed: String, + rng_method: RngMethod, + metadata: Option, + tags: Option>, + expiry_ms: Option, +} + +#[async_trait] +impl Wallet for AskarWallet {} + +#[async_trait] +impl DidWallet for AskarWallet { + type DidAttrs = DidAttrs; + type CreatedDid = (); + type DidKey = Option; + type KeyAttrs = KeyAttrs; + + async fn create_key(&self, key_attrs: Self::KeyAttrs) -> Result<(), AriesVcxCoreError> { + let mut session = self.backend.session(self.profile.clone()).await?; + + let key = LocalKey::from_seed( + key_attrs.alg, + key_attrs.seed.as_bytes(), + key_attrs.rng_method.into(), + )?; + Ok(session + .insert_key( + &key_attrs.name, + &key, + key_attrs.metadata.as_deref(), + key_attrs.tags.as_deref(), + key_attrs.expiry_ms, + ) + .await?) + } + + async fn create_did(&self, attrs: Self::DidAttrs) -> VcxCoreResult { + let mut session = self.backend.session(self.profile.clone()).await?; + + let key_entry = self.fetch_key_entry(&mut session, &attrs.key_name).await?; + + let local_key = key_entry.load_local_key()?; + + let did_bytes = &local_key.to_public_bytes()?[0..16]; + + let did = bs58::encode(did_bytes).into_string(); + Ok(session + .insert( + &attrs.category, + &did, + &did_bytes, + attrs.tags.as_deref(), + attrs.expiry_ms, + ) + .await?) + } + + async fn did_key(&self, did: &str) -> VcxCoreResult { + let mut session = self.backend.session(self.profile.clone()).await?; + Ok(session.fetch_key(did, false).await?) + } + + async fn replace_did_key(&self, did: &str) -> VcxCoreResult { + todo!("Not yet implemented"); + } + + async fn sign( + &self, + verkey_name: &str, + msg: &[u8], + sig_type: SigType, + ) -> VcxCoreResult> { + let mut session = self.backend.session(self.profile.clone()).await?; + let res = session.fetch_key(verkey_name, false).await?; + + if let Some(key) = res { + let local_key = key.load_local_key()?; + let res = local_key.sign_message(msg, Some(sig_type.into()))?; + return Ok(res); + } + + Ok(vec![]) + } + + async fn verify( + &self, + verkey_name: &str, + msg: &[u8], + signature: &[u8], + sig_type: SigType, + ) -> VcxCoreResult { + let mut session = self.backend.session(self.profile.clone()).await?; + + if let Some(key) = session.fetch_key(verkey_name, false).await? { + let local_key = key.load_local_key()?; + let res = local_key.verify_signature(msg, signature, Some(sig_type.into()))?; + return Ok(res); + } + + Ok(false) + } +} + +pub struct SearchFilter { + category: Option, + tag_filter: Option, + offset: Option, + limit: Option, +} + +#[async_trait] +impl RecordWallet for AskarWallet { + type Record = Record; + type RecordId = RecordId; + type FoundRecord = Entry; + type SearchFilter = SearchFilter; + + async fn add_record(&self, record: Self::Record) -> VcxCoreResult<()> { + let mut session = self.backend.session(self.profile.clone()).await?; + + Ok(session + .insert( + &record.category, + &record.name, + &record.value, + record.tags.as_deref(), + record.expiry_ms, + ) + .await?) + } + + async fn get_record(&self, id: &Self::RecordId) -> VcxCoreResult { + let mut session = self.backend.session(self.profile.clone()).await?; + + session + .fetch(&id.category, &id.name, id.for_update) + .await? + .ok_or_else(|| { + AriesVcxCoreError::from_msg( + AriesVcxCoreErrorKind::WalletRecordNotFound, + "not found", + ) + }) + } + + async fn update_record(&self, update: Self::Record) -> VcxCoreResult<()> { + todo!("Not yet implemented"); + } + + async fn delete_record(&self, id: &Self::RecordId) -> VcxCoreResult<()> { + todo!("Not yet implemented"); + } + + async fn search_record( + &self, + filter: Self::SearchFilter, + ) -> VcxCoreResult>> { + let mut res = self + .backend + .scan( + self.profile.clone(), + filter.category, + filter.tag_filter, + filter.offset, + filter.limit, + ) + .await?; + let mut all: Vec> = vec![]; + let rs = res + .fetch_next() + .await + .map_err(|err| AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::IOError, err))?; + if let Some(found) = rs { + all = found.into_iter().map(|entry| Ok(entry)).collect(); + } + Ok(Box::pin(futures::stream::iter(all))) + } +} + +#[cfg(test)] +mod test { + use super::*; + use futures::StreamExt; + + use crate::wallet2::askar_wallet::AskarWallet; + + #[tokio::test] + async fn test_askar_should_find_records() { + let wallet = AskarWallet::create( + "sqlite:memory:", + StoreKeyMethod::Unprotected, + None.into(), + true, + None, + ) + .await + .unwrap(); + + let record1 = Record { + category: "my".into(), + name: "foofar".into(), + tags: None, + value: "ff".into(), + expiry_ms: None, + }; + wallet.add_record(record1).await.unwrap(); + + let record2 = Record { + category: "my".into(), + name: "foobar".into(), + tags: None, + value: "fb".into(), + expiry_ms: None, + }; + wallet.add_record(record2).await.unwrap(); + + let record3 = Record { + category: "your".into(), + name: "football".into(), + tags: None, + value: "fbl".into(), + expiry_ms: None, + }; + wallet.add_record(record3).await.unwrap(); + + let mut res = wallet.find("my").await.unwrap(); + + let mut all = vec![]; + while let Some(item) = res.next().await { + all.push(item.unwrap()); + } + assert_eq!(2, all.len()); + } +} diff --git a/aries/aries_vcx_core/src/wallet2/mod.rs b/aries/aries_vcx_core/src/wallet2/mod.rs index 37ba2d7747..fba281a4e0 100644 --- a/aries/aries_vcx_core/src/wallet2/mod.rs +++ b/aries/aries_vcx_core/src/wallet2/mod.rs @@ -3,6 +3,9 @@ use futures::stream::BoxStream; use crate::errors::error::VcxCoreResult; +#[cfg(feature = "askar_wallet")] +pub mod askar_wallet; + pub enum SigType { EdDSA, ES256,