feat: improve pgp speed and offer even more improvements

This commit is contained in:
Anna 2023-08-31 01:54:29 -04:00
parent fae0bad9fa
commit fae0951f97
Signed by: anna
GPG Key ID: D0943384CD9F87D1
3 changed files with 76 additions and 151 deletions

192
Cargo.lock generated
View File

@ -247,26 +247,6 @@ version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
[[package]]
name = "bindgen"
version = "0.63.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885"
dependencies = [
"bitflags 1.3.2",
"cexpr",
"clang-sys",
"lazy_static",
"lazycell",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 1.0.109",
]
[[package]]
name = "bit-set"
version = "0.5.3"
@ -339,8 +319,6 @@ name = "buffered-reader"
version = "1.2.0"
source = "git+https://gitlab.com/sequoia-pgp/sequoia#bedff19babee71325e5c2be695a468df90892780"
dependencies = [
"bzip2",
"flate2",
"lazy_static",
"libc",
]
@ -363,27 +341,6 @@ version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bzip2"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8"
dependencies = [
"bzip2-sys",
"libc",
]
[[package]]
name = "bzip2-sys"
version = "0.1.11+1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc"
dependencies = [
"cc",
"libc",
"pkg-config",
]
[[package]]
name = "cc"
version = "1.0.83"
@ -394,15 +351,6 @@ dependencies = [
"libc",
]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom",
]
[[package]]
name = "cfg-expr"
version = "0.15.4"
@ -443,17 +391,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "clang-sys"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "clap"
version = "4.4.1"
@ -829,6 +766,21 @@ dependencies = [
"miniz_oxide",
]
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.2.0"
@ -980,12 +932,6 @@ dependencies = [
"url",
]
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "gpg-error"
version = "0.6.0"
@ -1263,12 +1209,6 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.147"
@ -1300,16 +1240,6 @@ dependencies = [
"winreg",
]
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "libssh2-sys"
version = "0.3.0"
@ -1395,12 +1325,6 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa0916b001582d253822171bd23f4a0229d32b9507fae236f5da8cad515ba7c"
[[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.1"
@ -1422,33 +1346,6 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "nettle"
version = "7.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9fdccf3eae7b161910d2daa2f0155ca35041322e8fe5c5f1f2c9d0b12356336"
dependencies = [
"getrandom 0.2.10",
"libc",
"nettle-sys",
"thiserror",
"typenum",
]
[[package]]
name = "nettle-sys"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e81c347b9002da0b6b0c4060993c280e99eb14b42ecf65a2fefcd6eb3d8a73"
dependencies = [
"bindgen",
"cc",
"libc",
"pkg-config",
"tempfile",
"vcpkg",
]
[[package]]
name = "new_debug_unreachable"
version = "1.0.4"
@ -1476,16 +1373,6 @@ dependencies = [
"memoffset",
]
[[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"
version = "0.4.1"
@ -1590,6 +1477,32 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
version = "0.10.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c"
dependencies = [
"bitflags 2.4.0",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.29",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
@ -1653,12 +1566,6 @@ dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "percent-encoding"
version = "2.3.0"
@ -1899,12 +1806,6 @@ version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.37.23"
@ -1994,10 +1895,8 @@ dependencies = [
"anyhow",
"base64",
"buffered-reader",
"bzip2",
"chrono",
"dyn-clone",
"flate2",
"getrandom 0.2.10",
"idna 0.3.0",
"lalrpop",
@ -2005,8 +1904,9 @@ dependencies = [
"lazy_static",
"libc",
"memsec",
"nettle",
"once_cell",
"openssl",
"openssl-sys",
"rand 0.7.3",
"regex",
"regex-syntax 0.6.29",
@ -2097,12 +1997,6 @@ dependencies = [
"digest 0.10.7",
]
[[package]]
name = "shlex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "signal-hook"
version = "0.3.17"

View File

@ -4,6 +4,14 @@ version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["crypto-openssl"]
crypto-openssl = ["sequoia-openpgp/crypto-openssl"]
crypto-rust = [
"sequoia-openpgp/crypto-rust",
"sequoia-openpgp/allow-experimental-crypto",
"sequoia-openpgp/allow-variable-time-crypto",
]
[dependencies]
anyhow = "1"
@ -20,7 +28,7 @@ itoa = "1"
keyring = "2"
num_cpus = "1"
rand = "0.8"
sequoia-openpgp = { git = "https://gitlab.com/sequoia-pgp/sequoia" }
sequoia-openpgp = { git = "https://gitlab.com/sequoia-pgp/sequoia", default-features = false }
serde = { version = "1", features = ["derive"] }
sha1 = { version = "0.10", features = ["asm"] }
toml = "0.7"

View File

@ -22,6 +22,29 @@ for 30 seconds using one thread.
header: 124,617,875 hashes (4,150,993.2260/s)
random: 110,886,440 hashes (3,715,452.2177/s)
increment: 107,137,532 hashes (3,573,438.8338/s)
sequoia: 136,952 hashes ( 4,486.4209/s)
sequoia*: 864,486 hashes ( 28,923.1870/s)
sequoia: 339,407 hashes ( 11,403.6102/s)
gpg-agent: 353 hashes ( 11.7519/s)
```
<small>The asterisked sequoia is using the `crypto-rust` feataure.</small>
## PGP performance
Signing commits drastically reduces the speed at which `git-vain` operates. By
default, OpenSSL is used as the cryptography backend. For a moderate speedup
(see table above), you can use the RustCrypto libraries as the cryptography
backend instead. See the warnings below from sequoia.
> As of this writing, the RustCrypto crates are not recommended for general use
> as they cannot offer the same security guarantees as more mature cryptographic
> libraries.
> Some cryptographic backends can not guarantee that cryptographic operations
> require a constant amount of time. This may leak secret keys in some
> settings.
The author cannot think of a scenario in which a timing attack would matter for
`git-vain`, but these warnings are worth acknowledging.
To use the RustCrypto libraries instead, compile with `cargo build --release
--no-default-features --features crypto-rust`.