keygen_openssh_test/args.rs
1use clap::{Parser, ValueEnum};
2
3/// Generate an OpenSSH keypair.
4///
5/// Outputs the keys to `<name>.public` and `<name>.private`.
6#[derive(Parser, Debug)]
7#[command(author, version, about, long_about = None)]
8pub(crate) struct Args {
9 /// The type of key to generate.
10 ///
11 /// Options are `ed25519-expanded`, `x25519`.
12 #[arg(long)]
13 pub(crate) key_type: KeyType,
14
15 /// The algorithm name. Only used if the key type is expanded-ed25519 or x25519.
16 ///
17 /// If no algorithm is specified, it defaults to:
18 /// * `ed25519-expanded@torproject.org` for ed25519-expanded keys
19 /// * `x25519@torproject.org` for x25519
20 #[arg(long)]
21 pub(crate) algorithm: Option<String>,
22
23 /// The comment.
24 #[arg(long)]
25 pub(crate) comment: Option<String>,
26
27 /// The output file name.
28 #[arg(long)]
29 pub(crate) name: String,
30
31 /// Whether to output a public key file.
32 #[arg(long)]
33 pub(crate) public: bool,
34
35 /// Whether to output a private key file.
36 #[arg(long)]
37 pub(crate) private: bool,
38}
39
40#[derive(Copy, Clone, Debug, PartialEq, ValueEnum)]
41pub(crate) enum KeyType {
42 /// An Ed25519 key.
43 Ed25519,
44 /// A DSA key.
45 Dsa,
46 /// An expanded Ed25519 key.
47 ExpandedEd25519,
48 /// An X25519 key.
49 X25519,
50}