Commit Graph

1357 Commits

Author SHA1 Message Date
David Runge
66ee42f337
Allow providing a password when adding a new subkey
When providing `--with-password` to `sq key subkey add`, prompt the user
for a password, which will be added to encrypt the new subkey.
If the option is not provided and the key material is encrypted, the
password of the primary key is used.
2023-09-04 18:23:22 +02:00
David Runge
ccbbd64828
Attempt to use previously submitted password for decrypting keys.
When decrypting encrypted key material in `get_keys()` first attempt to
use passwords previously provided and only afterwards prompt the user
for a password.
2023-09-04 15:42:12 +02:00
David Runge
4e891fe36f
Allow adding new subkeys to certificates with encrypted secret keys
Without providing a password to the `KeyBuilder` and setting a primary
key signer for the `SubKeyBuilder`, it is not possible to add a new
subkey to a certificate with encrypted secret key material.

Adapt the helper function `get_primary_keys()` to return the optional
`Password` as provided by the user input, so that it may be used when
attaching a new subkey.
2023-09-04 15:42:07 +02:00
Neal H. Walfield
0dd20af066
Release 0.31.0.
* New functionality
  - `sq key subkey add` allows to create and add a new subkey to an
    existing certificate.
  - The functionality of `sq-keyring-linter` is now available as
    `sq keyring lint`.
  - The new subcommands `sq key revoke`, `sq key subkey revoke` and
    `sq key userid revoke`, allow writing to a file using the
    `--output` option.
 * Notable changes
  - The `--keyring` option is now global and can be specified anywhere
    when calling `sq`.
 * Deprecated functionality
  - The `--expires` and `--expires-in` options used in various
    subcommands are deprecated in favor of the unifying `--expiry`.
  - `sq key generate --export FILE` is deprecated in favor of the more
    generic `sq key generate --output FILE`.
  - The `sq revoke certificate` command has been renamed to `sq key
    revoke`.
  - The `sq revoke subkey` command has been renamed to `sq key subkey
    revoke`.
  - The `sq revoke userid` command has been renamed to `sq key userid
    revoke`.
2023-07-05 14:07:56 +02:00
Neal H. Walfield
8bc9c3e578
Upgrade rpassword.
- Upgrade to the latest version of rpassword.
2023-07-05 14:07:44 +02:00
Neal H. Walfield
0c7c48d044
Upgrade subplot.
- Upgrade to the latest version of subplot.
2023-07-05 14:07:39 +02:00
Neal H. Walfield
494e46b06c
Widen the itertools' version requirements.
- `sq` works with 0.11, but other depenedencies pull in 0.10.

  - We prefer fewer dependencies so keep the version in `Cargo.lock`
    at 0.10.
2023-07-05 14:00:02 +02:00
Neal H. Walfield
3f0a6facc4
Update Cargo.lock. 2023-07-05 13:54:05 +02:00
David Runge
e3954d176a
Fix publishing of container image to registry
Use the name of the git repository to match that of the published
target, as otherwise the registry denies it.

Fixes #120
2023-07-04 11:07:22 +02:00
David Runge
283370b155
Add NEWS entries for 0.31.0. 2023-07-03 16:35:16 +02:00
David Runge
82a866c18d
Consolidate sq revoke commands as sq key subcommands
- Move the `sq revoke certificate`, `sq revoke subkey` and `sq revoke
  userid` subcommands below the `sq key` namespace as `sq key revoke`,
  `sq key subkey revoke` and `sq key userid revoke` (respectively). This
  consolidates commands relevant to key management below `sq key`, which
  is in line with already existing subcommands (e.g. `sq key generate`,
  `sq key subkey add` or `sq key userid add`).
- Replace the use of a common `revoke()` with `CertificateRevocation`,
  `SubkeyRevocation` and `UserIDRevocation` to reduce complexity and
  allow for easier per target (i.e., certificate, subkey or userid)
  command modification.
- Allow specifying an output file using `--output`/ `-o` for all
  revocation subcommands (i.e., `sq key revoke`, `sq key subkey revoke`,
  `sq key userid revoke`). If unspecified, output goes to stdout as
  before.
- Add common test facilities to create a default certificate in a
  temporary directory.
- Add common test function to compare a set of notations with those in
  a `Signature`.
- Replace the integration tests which used to test a combined `sq
  revoke` subcommand with integration tests for `sq key subkey revoke`,
  `sq key userid revoke` and `sq key revoke` using direct and third
  party revocation.

Fixes #93
2023-07-03 16:04:51 +02:00
David Runge
27d04a26f1
Make commands::get_certification_keys() public
As we have to use it in further subcommands it is easier to have a public function.
2023-07-03 14:51:24 +02:00
David Runge
3adec8e545
Rename sq keyring linter to sq keyring lint
To match the setup of the other subcommands (which follow a noun [noun]
verb approach), rename `sq keyring linter` to `sq keyring lint`.

Fixes #136
2023-07-03 14:23:17 +02:00
Heiko Schaefer
da0660a1c3
Terminology fix. 2023-06-30 17:53:40 +02:00
Jan Christian Grünhage
5fb976a2a9
Update Cargo.lock. 2023-06-22 11:56:19 +02:00
Jan Christian Grünhage
01cb33e27a
ci: Make codespell happy.
- `codespell` is unhappy with the names `certp`, `certi`, and
  `certo`.  Allow them.
2023-06-22 11:19:28 +02:00
Jan Christian Grünhage
1504a3aa2c
Clean up emacs comments in sq keyring linter subcommand definition 2023-06-22 11:19:28 +02:00
Jan Christian Grünhage
74fd9dd8fe
Move keyring-linter into sq keyring as a subcommand
This commit is mostly a copy over from the keyring-linter repository,
with a few changes included to make it work in the sq codebase. These
changes are:
 - replaced calls to atty with calls to is-terminal. This was done due
   to is-terminal already being in the dependency tree of sq, and atty
   being unmaintained.
 - replace ansi_term with termcolor, because ansi_term is unmaintained
 - removed a few things from the keyring linter, that were also present
   in sq itself, to avoid duplication. This included the reference time
   parameter, key decryption and IO handling
 - added output file and binary parameters to the linter, so that I
   could handle output the same as the other commands do
2023-06-22 11:19:27 +02:00
Jan Christian Grünhage
f3cfb1b602
Only prompt for passwords when trying to decrypt a key if stdin is a terminal 2023-06-21 10:36:58 +02:00
David Runge
6ac9c2761a
Fix use of --output when importing to cert-store is the default
- As clap can not use `Default` as advertised for certain types [1], use
  `Option<FileOrStdout>` instead in cases where the default is to import
  to cert-store. Semantically, this works as before: By default import
  to cert-store, when providing "-" output to stdout and when providing
  a file name output to the file.
- Since `FileOrCertStore` can not wrap any other type under the given
  circumstances, turn it into an empty struct that only implements
  `ClapData` to provide static strings for the clap setup.
- Adapt the help message for `FileOrCertStore` to mention, that
  providing "-" leads to output on stdout.

Fixes #133

[1] https://github.com/clap-rs/clap/issues/4558
2023-06-20 10:45:58 +02:00
Stacey Sheldon
e8b31100cb
Fix minor typo in help text. 2023-06-19 09:31:00 +02:00
David Runge
3c90428112
Rename --export option of sq key generate to the generic --output
Instead of using a non-uniform `--export` for `sq key generate` to
indicate the file path to output to, rely on the generic `--output`,
provided by `sq_cli::types::FileOrStdout`.
2023-06-17 15:51:25 +02:00
David Runge
ed6069623b
Replace CLI I/O argument duplication with common facilities
- Replace `sq_cli::types::IoArgs` with the more granular
  `sq_cli::types::FileOrStdin`, `sq_cli::types::FileOrCertStore` and
  `sq_cli::types::FileOrStdout`.
- Replace all generic `input` (describing single files) and `output`
  arguments with the respective new facilities to share code and not
  repeat ourselves.
- Replace the `open_or_stdin()` function with `FileOrStdin::open()`.
- Replace the `create_or_stdout()` function with the private
  `FileOrStdout::create()`, so that it can not be called directly.
- Replace the `emit_unstable_cli_warning()`
  and `create_or_stdout_unsafe()` functions with
  `FileOrStdout::create_unsafe()`.
- Replace the `create_or_stdout_safe()` function with
  `FileOrStdout::create_safe()`.
- Replace the `create_or_stdout_pgp()` function with
  `FileOrStdout::create_pgp_safe()`.
- Remove the field `unstable_cli_warning_emitted` from `Config`, as
  it is replaced by the static `UNSTABLE_CLI_WARNING`, which allows for
  tracking whether a warning has been emitted across several instances
  of `FileOrStdout`.
2023-06-17 15:39:14 +02:00
David Runge
8f57c0d9f2
Refactor: Use PathBuf instead of String for file related CLI options
- Replace `Option<String>` and `Vec<String>` based CLI options dealing
  with files with `Option<PathBuf>` and `Vec<PathBuf>` based ones
  (respectively).
  This allows us to unify the use of input and output facilities using
  globally available CLI options while ensuring (cross-platform) type
  safety.
2023-06-12 17:44:55 +02:00
David Runge
3f147af820
Make --keyring option globally available and use it in sq key adopt
- Set the `--keyring` option to be globally available, allowing it to
  be added anywhere on the commandline and not just as first parameter
  before any subcommand.
- Replace the `Vec<String>` based `--keyring` option for `sq key adopt`
  with the now globally available `Vec<PathBuf>` based `--keyring`
  option and adopt the code accordingly.
2023-06-12 17:44:52 +02:00
David Runge
3ea5afe4e3
Add instructions on man page creation to README
- Add instructions on how to build the `sq` executable and its shell
 completions.
- Add information on how to generate the man pages using the `SQ_MAN`
  environment variable.
- Disable printing of info about `clap_mangen` generated man pages,
  since they still lack features and are partially incorrect.
2023-06-12 16:14:50 +02:00
David Runge
dc501f7a6e
Add specific information on validity period to subcommand docs
Add specific information on default validity periods to the long
documentation of `sq certify`, `sq key generate` and `sq link add`.
2023-06-05 15:57:45 +02:00
David Runge
96bd7e9b9e
Fix help output for sq key generate
Make a specific connection between "both" and "universal", so that the
user has an easier time to infer, that with choosing "universal" both
encryption purposes are added.
2023-06-05 15:57:43 +02:00
David Runge
9c35ffa019
Use common abstraction to get CipherSuite in sq key generate
Use `sq_cli:🔑:CipherSuite::as_ciphersuite()` in `sq key` subcommand
to derive a valid `openpgp::cert::CipherSuite` from a variant of
`sq_cli:🔑:CipherSuite`.
2023-06-05 15:57:40 +02:00
David Runge
778741b2f8
Simplify use of validity in certify, key and link subcommands
- Change the behavior of the `sq certify`, `sq key generate` and `sq
  link add` subcommands to rely on a single `--expiry` input argument
  (same as `sq key subkey generate`), which replaces `--expires` and
  `--expires-in`. This allows to directly parse a specific ISO 8601
  timestamp, a custom duration or `"never"` and create a verified data
  type that can be used further.
- Use `Expiry::as_duration()` in `sq certify` and `sq key`
  subcommands to calculate the validity (duration until expiration) of
  certifications and keys.
- Add the constants `KEY_VALIDITY_IN_YEARS` and
  `THIRD_PARTY_CERTIFICATION_VALIDITY_IN_YEARS` to `sq_cli` to allow
  centralized modifications of the default validity duration of keys and
  certifications (in years).
- Add the constants `KEY_VALIDITY_DURATION` and
  `THIRD_PARTY_CERTIFICATION_VALIDITY_DURATION` to provide
  the default `Duration` for keys/subkeys and third party
  certifications (based on `KEY_VALIDITY_IN_YEARS` and
  `THIRD_PARTY_CERTIFICATION_VALIDITY_IN_YEARS`).
2023-06-05 15:57:38 +02:00
David Runge
57e4958dfe
Add sq key subkey add command to add newly generated subkeys
- Add `sq key subkey add` to allow to add a newly generated `SubKey` to
  an existing key.
- Add `sq_cli::types::Expiry` to allow providing expiry with a
  single `--expiry` input argument, that covers providing an ISO 8601
  timestamp, a custom duration and "never".
- Add impl block for `sq_cli:🔑:CipherSuite` to allow returning a
  `sequoia_openpgp::cert::CipherSuite`.
2023-06-05 15:56:08 +02:00
David Runge
5033e8842b
Move expiry constants to CLI module
Move the constants `SECONDS_IN_DAY` and `SECONDS_IN_YEAR` to the CLI
module so that they can be used there and export them in the top-level
module agaian so that they can be used elsewhere as well.
2023-06-05 13:35:30 +02:00
David Runge
4587269d1f
Move key subcommands to their own modules
Move the code for `adopt`, `attest-certifications`, `extract-cert`,
`generate`, `password` and `userid` subcommands to their respective
own modules.
This separates the various features from one another and makes adding
new features less unwieldy.
2023-06-05 13:35:20 +02:00
Neal H. Walfield
3433e6e806
Release 0.30.1.
* Changes in 0.30.1
 * Notable changes
   - The `crypto-botan` feature now selects Botan's v3 interface.  Use
     the new `crypto-botan2` feature to continue using Botan's v2
     interface.
 * Notable fixes
   - Several parser bugs were fixed in sequoia-openpgp 1.16.0 and
     buffered-reader 1.2.0.  These are all low-severity as Rust
     correctly detects the out of bounds access and panics.  Update
     Cargo.lock to make sure we use these versions.
2023-05-31 10:33:31 +02:00
Neal H. Walfield
1b3568580e
Update Cargo.lock. 2023-05-31 10:33:15 +02:00
Neal H. Walfield
60ba1d11cc
Add a feature to build sq using Botan's version 2 interface.
- sequoia-openpgp 1.16 changed `sequoia-openpgp/crypto-botan` to
    build against Botan's v3 interface, and exposed
    `sequoia-openpgp/crypto-botan2` to build against the v2 interface.

  - Do the same.  Add a `crypto-botan2` feature to allow the user to
    build against Botan's v2 interface.
2023-05-31 09:36:15 +02:00
David Runge
0682d6dcea
Add cargo-deny integration
- Add `deny.toml` for `cargo deny` with advisory error for `RUSTSEC-
  2020-0071` disabled as it does not affect chrono (or us for that
  matter).
  Allow multiple versions as there is not much we can do about those
  anyways and it clutters the output immensely.
  Add all currently used licenses to allow list.
  Deny the use of `ring` as it does not have a responsible disclosure
  policy: https://github.com/briansmith/ring#bug-reporting
- Run `cargo deny` as further `test` step in GitLab CI, so that it is
  among the last things that may fail in a merge request.
2023-05-30 13:19:24 +02:00
David Runge
f6aa19294a
Replace the unmaintained term_size with terminal_size
As term_size is no longer maintained, switch to terminal_size.
2023-05-30 10:52:54 +02:00
David Runge
8cc4a64fba
Update bumpalo to 3.12.2
As bumpalo 3.12.1 has been yanked, update to 3.12.2.
2023-05-30 10:52:50 +02:00
David Runge
58ee338056
Update buffered-reader to 1.2.0
Update lock file to use buffered-reader 1.2.0.
2023-05-19 20:04:25 +02:00
David Runge
cd8ef12ef4
Update sequoia-openpgp to 1.16.0
Update lock file to use sequoia-openpgp 1.16.0.
2023-05-19 20:04:19 +02:00
Neal H. Walfield
a99c5acdd3
Update NEWS file
- Add missing news entries for 0.30.0.
2023-05-08 12:39:04 +02:00
Neal H. Walfield
be99608961
Release 0.30.0 2023-05-08 11:04:41 +02:00
Neal H. Walfield
f5a5d0d8dd
Fix spelling 2023-05-08 11:04:41 +02:00
Neal H. Walfield
7db05f8d18
Upgrade dirs to version 5 2023-05-08 11:04:41 +02:00
Neal H. Walfield
355352e467
Update Cargo.lock 2023-05-08 11:04:41 +02:00
Neal H. Walfield
68a2223d43
Don't spellcheck Cargo.lock 2023-05-08 11:04:40 +02:00
Gabriel de Perthuis
75b5360a38
Update subplot to fix tera issue
- See https://gitlab.com/subplot/subplot/-/merge_requests/317 .

  - Fixes #2
2023-04-19 10:55:09 +02:00
Gabriel de Perthuis
2c57cd77d7
Move subplot tests to a feature so subplot doesn't affect most builds
Installing sq from crates.io (cargo install sequoia-sq) was broken by a
semver-compatible change in Tera.  Running cargo test uses the lockfile
and isn't affected.

This has the side benefit of reducing dependency bloat, the baseline
depends on check/build/build --release but in the case of a non-release
build the dependency count goes from 403 to 315.

Fixes #2.

The subplot/tera issue was likely triggered by this change in tera
1.18: <https://github.com/Keats/tera/pull/799>.
2023-04-19 10:54:05 +02:00
Neal H. Walfield
689ed7428b
Add support for using pEp certificate stores
- Add the top-level option `--pep-cert-store` and the environment
    variable `PEP_CERT_STORE`, which allow users to use pEp
    certificate stores.

  - By default, no pEp certificate store is used.  Users can however
    put `export PEP_CERT_STORE=$HOME/.pEp` in their `.bashrc` file, for
    instance, to turn it on.
2023-04-19 10:31:33 +02:00