Class KeyStoreManagement
java.lang.Object
zeroecho.KeyStoreManagement
Command-line utility for managing an encrypted software keyring.
Overview
TheKeyStoreManagement subcommand provides
lifecycle operations on key material stored in
KeyringStore. It supports listing algorithms
and aliases and generating key pairs or symmetric keys. Passwords are
supplied through a destroyable unlock provider and are never accepted as
command-line text.
Usage
Invoked as:ZeroEcho -K [options]
Modes
Exactly one action must be chosen:--list-algorithms- list catalog algorithms and whether they support symmetric/asymmetric builders.--list-aliases- list aliases present in the keystore.--generate- generate a new key pair or secret and store under the given alias.
General options
-k | --keystore <file>- path to keystore file (required).--overwrite- overwrite existing aliases on conflict.
Generate options
--alg <id>- algorithm id (e.g., RSA, Ed25519, AES, Frodo).--alias <name>- base alias; for asymmetric, both public and private entries will be created.--kind sym|asym- force symmetric or asymmetric if the algorithm supports both (optional).--pub-suffix <sfx>- suffix for public alias (default: .pub).--prv-suffix <sfx>- suffix for private alias (default: .prv).
Examples
# List available algorithms
ZeroEcho -K --list-algorithms
# Generate a new RSA key pair and store as alice.pub / alice.prv
ZeroEcho -K --generate --alg RSA --alias alice --keystore keys.zekr
# Generate a new AES secret key and store as "backup-key"
ZeroEcho -K --generate --alg AES --alias backup-key --kind sym --keystore keys.zekr
# List aliases in the keystore
ZeroEcho -K --list-aliases --keystore keys.zekr
Exit codes
- 0 - operation succeeded
- non-zero - error occurred (parse error, I/O failure, or invalid arguments)
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voiddefineOptions(org.apache.commons.cli.Options options) Adds this subcommand's options to the providedOptionsinstance.static voiddoGenerate(ZeroEchoSession session, KeyringStore store, org.apache.commons.cli.CommandLine cmd) Generates a keypair or secret and stores entries under the chosen aliases.static voidLists available algorithms with builder availability to stdout.static voidlistAliases(KeyringStore store) Lists aliases present in the store to stdout.static intParses arguments, executes the requested action, and returns an exit code.static intmain(String[] args, org.apache.commons.cli.Options dispatcherOptions, KeyringUnlockProvider unlockProvider) Executes the command with an explicit unlock source.
-
Method Details
-
main
public static int main(String[] args, org.apache.commons.cli.Options dispatcherOptions) throws org.apache.commons.cli.ParseException, IOException, GeneralSecurityException Parses arguments, executes the requested action, and returns an exit code. Parser and IO exceptions are intentionally propagated for the central CLI to handle.- Parameters:
args- arguments passed by the application dispatcherdispatcherOptions- an existingOptionsinstance used by the dispatcher; this method only adds its own options- Returns:
- process exit code (0 for success; non-zero for semantic errors)
- Throws:
org.apache.commons.cli.ParseException- if the parser failsIOException- if keyring or console I/O failsGeneralSecurityException- if cryptographic provider setup or command processing fails
-
main
public static int main(String[] args, org.apache.commons.cli.Options dispatcherOptions, KeyringUnlockProvider unlockProvider) throws org.apache.commons.cli.ParseException, IOException, GeneralSecurityException Executes the command with an explicit unlock source.- Parameters:
args- arguments passed by the application dispatcherdispatcherOptions- dispatcher optionsunlockProvider- explicit destroyable-password provider- Returns:
- process exit code
- Throws:
org.apache.commons.cli.ParseException- if parsing failsIOException- if keyring I/O failsGeneralSecurityException- if cryptographic processing fails
-
defineOptions
public static void defineOptions(org.apache.commons.cli.Options options) Adds this subcommand's options to the providedOptionsinstance.- Parameters:
options- an existingOptionsinstance from the central dispatcher
-
listAlgorithms
public static void listAlgorithms()Lists available algorithms with builder availability to stdout. -
listAliases
Lists aliases present in the store to stdout.- Parameters:
store- loaded keyring store
-
doGenerate
public static void doGenerate(ZeroEchoSession session, KeyringStore store, org.apache.commons.cli.CommandLine cmd) throws IOException, GeneralSecurityException Generates a keypair or secret and stores entries under the chosen aliases.This reuses the same import-spec construction heuristic as the project's dynamic tests: find plausible import-spec classes and build specs from SPKI/PKCS8/RAW bytes.
- Parameters:
session- active cryptographic session used to generate key materialstore- open keyring store to mutatecmd- parsed command line containing generation options- Throws:
IOException- if generated material cannot be written to the keyringGeneralSecurityException- if the requested key generation operation fails
-