From 6437b955d70d2632a5dbb6eb33bec3ad3ff4d005 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Tue, 14 Mar 2023 08:58:05 +0800 Subject: [PATCH] feat: update crates --- Cargo.lock | 352 +++++++++++++++++++++----------------- Cargo.toml | 4 +- src/cmd_list.rs | 38 ++++ src/cmd_pgpcardadmin.rs | 4 +- src/cmd_pgpcarddecrypt.rs | 4 +- src/cmd_pgpcardlist.rs | 4 +- src/cmd_pgpcardmake.rs | 4 +- src/cmd_pgpcardsign.rs | 4 +- src/cmd_sshagent.rs | 18 +- src/main.rs | 2 + 10 files changed, 258 insertions(+), 176 deletions(-) create mode 100644 src/cmd_list.rs diff --git a/Cargo.lock b/Cargo.lock index 13b67aa..33b641d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,14 +75,14 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.20", ] [[package]] name = "asn1-rs" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6690c370453db30743b373a60ba498fc0d6d83b11f4abfd87a84a075db5dd4" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ "asn1-rs-derive 0.4.0", "asn1-rs-impl", @@ -91,7 +91,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.20", ] [[package]] @@ -101,7 +101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", "synstructure", ] @@ -113,7 +113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", "synstructure", ] @@ -125,7 +125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", ] @@ -183,9 +183,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bindgen" @@ -200,7 +200,7 @@ dependencies = [ "lazycell", "peeking_take_while", "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "regex", "rustc-hash", "shlex", @@ -235,7 +235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b04ce3d2372d05d1ef4ea3fdf427da6ae3c17ca06d688a107b5344836276bc3" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", ] @@ -250,9 +250,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -338,7 +338,7 @@ dependencies = [ "clap", "digest 0.10.6", "hex", - "openpgp-card 0.2.7", + "openpgp-card", "openpgp-card-pcsc", "openpgp-card-sequoia", "openssl", @@ -389,9 +389,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", @@ -413,9 +413,9 @@ dependencies = [ [[package]] name = "cipher" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" dependencies = [ "glob", "libc", @@ -468,9 +468,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "cookie-factory" @@ -600,9 +600,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc831ee6a32dd495436e317595e639a587aa9907bef96fe6e6abc290ab6204e9" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" dependencies = [ "cc", "cxxbridge-flags", @@ -612,33 +612,33 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94331d54f1b1a8895cd81049f7eaaaef9d05a7dcb4d1fd08bf3ff0806246789d" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" dependencies = [ "cc", "codespan-reporting", "once_cell", "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "scratch", "syn", ] [[package]] name = "cxxbridge-flags" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dcd35ba14ca9b40d6e4b4b39961f23d835dbb8eed74565ded361d93e1feb8a" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" [[package]] name = "cxxbridge-macro" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bbeb29798b407ccd82a3324ade1a7286e0d29851475990b612670f6f5124d2" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", ] @@ -675,11 +675,11 @@ dependencies = [ [[package]] name = "der-parser" -version = "8.1.0" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d4bc9b0db0a0df9ae64634ac5bdefb7afcb534e182275ca0beadbe486701c1" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", "displaydoc", "nom", "num-bigint", @@ -693,7 +693,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffdd80ce8ce993de27e9f063a444a4d53ce8e8db4c1f00cc03af5ad5a9867a1e" dependencies = [ - "cipher 0.4.3", + "cipher 0.4.4", ] [[package]] @@ -727,7 +727,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -761,15 +761,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", ] [[package]] name = "dyn-clone" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" @@ -813,18 +813,39 @@ dependencies = [ [[package]] name = "ena" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" +checksum = "b2e5d13ca2353ab7d0230988629def93914a8c4015f621f9b13ed2955614731d" dependencies = [ "log", ] [[package]] -name = "fastrand" -version = "1.8.0" +name = "errno" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -1077,6 +1098,16 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "io-lifetimes" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +dependencies = [ + "libc", + "windows-sys 0.45.0", +] + [[package]] name = "iovec" version = "0.1.4" @@ -1106,9 +1137,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" @@ -1174,9 +1205,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libloading" @@ -1235,6 +1266,12 @@ dependencies = [ "cc", ] +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + [[package]] name = "lock_api" version = "0.3.4" @@ -1286,9 +1323,9 @@ dependencies = [ [[package]] name = "memsec" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac78937f19a0c7807e45a931eac41f766f210173ec664ec046d58e6d388a5cb" +checksum = "0fa0916b001582d253822171bd23f4a0229d32b9507fae236f5da8cad515ba7c" [[package]] name = "minimal-lexical" @@ -1360,9 +1397,9 @@ dependencies = [ [[package]] name = "nettle" -version = "7.2.0" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d193a809310369c5d16e45bc0a88cb27935edd5d3375bcfc2371b167694035" +checksum = "45a005f7e5d6fc678c2858352e6bc6675f6dda4f4c33750341780b5063a975b2" dependencies = [ "getrandom 0.2.8", "libc", @@ -1485,14 +1522,14 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", ] [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -1502,23 +1539,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openpgp-card" -version = "0.2.7" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c821855d394b22482c4b8b0cb7ede19f6cbdc7d3eff073a3cbe87601f547c4f9" -dependencies = [ - "blanket", - "chrono", - "hex-slice", - "log", - "nom", - "thiserror", -] - -[[package]] -name = "openpgp-card" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e4ca9441e57f78bba17d8c2a5df618fba221b235c4f5fd9fc6c24cc85e0f776" +checksum = "748b17daf8c6d5c802e8448136c0e39802bee4a05996457b08048dc21fc3d984" dependencies = [ "blanket", "chrono", @@ -1530,13 +1553,13 @@ dependencies = [ [[package]] name = "openpgp-card-pcsc" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ced2ca281675f58341162043963f9fe2067381b23ca934cfa7e2b1fa36d721a" +checksum = "629349f5b215af68f7f7a6d8e7f80f227f27fa2258bb4f4b5a1b82ed1f009740" dependencies = [ "iso7816-tlv", "log", - "openpgp-card 0.2.7", + "openpgp-card", "pcsc", ] @@ -1550,7 +1573,7 @@ dependencies = [ "chrono", "log", "nettle", - "openpgp-card 0.3.3", + "openpgp-card", "sequoia-openpgp", "thiserror", ] @@ -1577,7 +1600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", ] @@ -1662,7 +1685,7 @@ dependencies = [ "libc", "redox_syscall 0.2.16", "smallvec 1.10.0", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1793,9 +1816,9 @@ checksum = "7be55bf0ae1635f4d7c7ddd6efc05c631e98a82104a73d35550bbc52db960027" [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] @@ -1814,9 +1837,9 @@ checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -1935,15 +1958,6 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "rfc6979" version = "0.3.1" @@ -2045,16 +2059,30 @@ dependencies = [ ] [[package]] -name = "rustversion" -version = "1.0.11" +name = "rustix" +version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "scopeguard" @@ -2064,9 +2092,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sec1" @@ -2137,29 +2165,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.152" +version = "1.0.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", ] [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" dependencies = [ "itoa", "ryu", @@ -2245,9 +2273,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -2300,9 +2328,9 @@ dependencies = [ [[package]] name = "string_cache" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213494b7a2b503146286049378ce02b482200519accc31872ee8be91fa820a08" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", @@ -2346,12 +2374,12 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "unicode-ident", ] @@ -2362,23 +2390,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", "unicode-xid", ] [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if 1.0.0", "fastrand", - "libc", "redox_syscall 0.2.16", - "remove_dir_all", - "winapi 0.3.9", + "rustix", + "windows-sys 0.42.0", ] [[package]] @@ -2422,21 +2449,21 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", ] @@ -2453,9 +2480,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ "itoa", "serde", @@ -2471,9 +2498,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" dependencies = [ "time-core", ] @@ -2709,15 +2736,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -2817,7 +2844,7 @@ dependencies = [ "log", "once_cell", "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", "wasm-bindgen-shared", ] @@ -2828,7 +2855,7 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ - "quote 1.0.23", + "quote 1.0.26", "wasm-bindgen-macro-support", ] @@ -2839,7 +2866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", - "quote 1.0.23", + "quote 1.0.26", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -2904,6 +2931,21 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -2915,9 +2957,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -2930,45 +2972,45 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "ws2_32-sys" @@ -3005,7 +3047,7 @@ dependencies = [ "oid-registry 0.4.0", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.20", ] [[package]] @@ -3014,16 +3056,16 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", "base64 0.13.1", "data-encoding", - "der-parser 8.1.0", + "der-parser 8.2.0", "lazy_static", "nom", "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.20", ] [[package]] @@ -3057,7 +3099,7 @@ dependencies = [ "base16ct", "chrono", "cookie-factory", - "der-parser 8.1.0", + "der-parser 8.2.0", "des", "elliptic-curve", "hmac 0.12.1", diff --git a/Cargo.toml b/Cargo.toml index d2cb723..a67e7d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,8 +17,8 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" hex = "0.4" u2f = "0.2" -openpgp-card = "0.2" -openpgp-card-pcsc = "0.2" +openpgp-card = "0.3" +openpgp-card-pcsc = "0.3" openpgp-card-sequoia = "0.0.20" sequoia-openpgp = "1.3" chrono = "0.4" diff --git a/src/cmd_list.rs b/src/cmd_list.rs new file mode 100644 index 0000000..05bf99d --- /dev/null +++ b/src/cmd_list.rs @@ -0,0 +1,38 @@ +use std::collections::BTreeMap; + +use clap::{App, Arg, ArgMatches, SubCommand}; +use rust_util::util_clap::{Command, CommandError}; +use yubikey::YubiKey; + +pub struct CommandImpl; + +impl Command for CommandImpl { + fn name(&self) -> &str { "list" } + + fn subcommand<'a>(&self) -> App<'a, 'a> { + SubCommand::with_name(self.name()).about("YubiKey list") + .arg(Arg::with_name("json").long("json").help("JSON output")) + } + + fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError { + let json_output = sub_arg_matches.is_present("json"); + if json_output { rust_util::util_msg::set_logger_std_out(false); } + + let yk = opt_result!(YubiKey::open(), "YubiKey not found: {}"); + + if json_output { + let mut json = BTreeMap::<&'_ str, String>::new(); + json.insert("name", yk.name().to_string()); + json.insert("version", yk.version().to_string()); + json.insert("serial", yk.serial().0.to_string()); + + println!("{}", serde_json::to_string_pretty(&json).expect("Convert to JSON failed!")); + } else { + success!("Name: {}", yk.name()); + success!("Version: {}", yk.version()); + success!("Serial: {}", yk.serial().0); + } + + Ok(None) + } +} diff --git a/src/cmd_pgpcardadmin.rs b/src/cmd_pgpcardadmin.rs index b762d24..8e60e6f 100644 --- a/src/cmd_pgpcardadmin.rs +++ b/src/cmd_pgpcardadmin.rs @@ -24,8 +24,8 @@ impl Command for CommandImpl { let pin = opt_value_result!(pin_opt, "Pin must be assigned"); if pin.len() < 8 { return simple_error!("Admin pin length:{}, must >= 8!", pin.len()); } - let mut card = crate::pgpcardutil::get_card()?; - let mut pgp = OpenPgp::new(&mut card); + let card = crate::pgpcardutil::get_card()?; + let mut pgp = OpenPgp::new(card); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); if sub_arg_matches.is_present("reset") { diff --git a/src/cmd_pgpcarddecrypt.rs b/src/cmd_pgpcarddecrypt.rs index 2d6c2eb..ad1d623 100644 --- a/src/cmd_pgpcarddecrypt.rs +++ b/src/cmd_pgpcarddecrypt.rs @@ -38,8 +38,8 @@ impl Command for CommandImpl { return simple_error!("cipher or cipher-base64 must assign one"); }; - let mut card = crate::pgpcardutil::get_card()?; - let mut pgp = OpenPgp::new(&mut card); + let card = crate::pgpcardutil::get_card()?; + let mut pgp = OpenPgp::new(card); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); opt_result!(trans.verify_pw1_user(pin.as_ref()), "User pin verify failed: {}"); diff --git a/src/cmd_pgpcardlist.rs b/src/cmd_pgpcardlist.rs index 7bf6c61..1f12213 100644 --- a/src/cmd_pgpcardlist.rs +++ b/src/cmd_pgpcardlist.rs @@ -27,9 +27,9 @@ impl Command for CommandImpl { let cards = opt_result!(PcscBackend::cards(None), "Failed to list OpenPGP cards: {}"); information!("Found {} card(s)", cards.len()); - for (i, mut card) in cards.into_iter().enumerate() { + for (i, card) in cards.into_iter().enumerate() { let mut json = BTreeMap::new(); - let mut pgp = OpenPgp::new(&mut card); + let mut pgp = OpenPgp::new(card); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); if let Ok(application_related_data) = trans.application_related_data() { success!("Found card #{}: {:?}", i, application_related_data.application_id()); diff --git a/src/cmd_pgpcardmake.rs b/src/cmd_pgpcardmake.rs index 11d51d9..69b4eec 100644 --- a/src/cmd_pgpcardmake.rs +++ b/src/cmd_pgpcardmake.rs @@ -234,8 +234,8 @@ impl Command for CommandImpl { } warning!("Force make is ON, try to write private keys to card!"); - let mut card = crate::pgpcardutil::get_card()?; - let mut pgp = OpenPgp::new(&mut card); + let card = crate::pgpcardutil::get_card()?; + let mut pgp = OpenPgp::new(card); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); opt_result!(trans.verify_pw3(pin.as_ref()), "Admin pin verify failed: {}"); diff --git a/src/cmd_pgpcardsign.rs b/src/cmd_pgpcardsign.rs index cba01dd..dfb3831 100644 --- a/src/cmd_pgpcardsign.rs +++ b/src/cmd_pgpcardsign.rs @@ -78,8 +78,8 @@ impl Command for CommandImpl { return simple_error!("SHA256, SHA384 or SHA512 must assign at least one"); } - let mut card = crate::pgpcardutil::get_card()?; - let mut pgp = OpenPgp::new(&mut card); + let card = crate::pgpcardutil::get_card()?; + let mut pgp = OpenPgp::new(card); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); if let Some(sha256) = sha256 { diff --git a/src/cmd_sshagent.rs b/src/cmd_sshagent.rs index 7054d00..dd2cad2 100644 --- a/src/cmd_sshagent.rs +++ b/src/cmd_sshagent.rs @@ -6,7 +6,6 @@ use std::sync::Mutex; use clap::{App, Arg, ArgMatches, SubCommand}; use openpgp_card::{KeyType, OpenPgp}; use openpgp_card::crypto_data::{Hash, PublicKeyMaterial}; -use openpgp_card_pcsc::PcscBackend; use openssl::hash::MessageDigest; use rust_util::util_clap::{Command, CommandError}; use rust_util::XResult; @@ -19,7 +18,7 @@ use crate::digest::{copy_sha256, copy_sha512}; use crate::sshutil::{generate_ssh_string, with_sign}; struct SshAgent { - card: Mutex, + open_pgp: Mutex, use_sign: bool, pin: String, public_key: PublicKey, @@ -29,9 +28,9 @@ struct SshAgent { impl SshAgent { fn new(pin: String, use_sign: bool) -> XResult { - let mut card = crate::pgpcardutil::get_card()?; - let (public_key, comment, ssh_string) = { - let mut pgp = OpenPgp::new(&mut card); + let card = crate::pgpcardutil::get_card()?; + let (public_key, comment, ssh_string, open_pgp) = { + let mut pgp = OpenPgp::new(card); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); let serial = trans.application_related_data() .map(|d| d.application_id().map(|i| i.serial())) @@ -51,10 +50,11 @@ impl SshAgent { n: with_sign(n.to_vec()), }); let comment = format!("pgp-card:{}:{}", iff!(use_sign, "sign", "auth"), serial); - (public_key, comment.clone(), generate_ssh_string(e, n, &comment)) + drop(trans); + (public_key, comment.clone(), generate_ssh_string(e, n, &comment), pgp) }; Ok(Self { - card: Mutex::new(card), + open_pgp: Mutex::new(open_pgp), use_sign, pin, public_key, @@ -98,8 +98,8 @@ impl SshAgent { }; information!("SSH request, algorithm: {}", algorithm); - let mut card_mut = self.card.lock().unwrap(); - let mut pgp = OpenPgp::new(&mut *card_mut); + let mut pgp = self.open_pgp.lock().unwrap(); + // let mut pgp = OpenPgp::new(*card_mut); let mut trans = opt_result!(pgp.transaction(), "Open card failed: {}"); let sig = if self.use_sign { debugging!("User pin verify for pw1 sign, use sign: {}", self.use_sign); diff --git a/src/main.rs b/src/main.rs index 519d9d2..13cea34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ mod digest; mod rsautil; mod pkiutil; mod pgpcardutil; +mod cmd_list; mod cmd_u2fregister; mod cmd_u2fsign; mod cmd_rsaencrypt; @@ -51,6 +52,7 @@ fn main() { fn inner_main() -> CommandError { let commands: Vec> = vec![ + Box::new(cmd_list::CommandImpl), Box::new(cmd_chall::CommandImpl), Box::new(cmd_challconfig::CommandImpl), Box::new(cmd_rsaencrypt::CommandImpl),