Class KeyStoreManagement

java.lang.Object
zeroecho.KeyStoreManagement

public final class KeyStoreManagement extends Object
Command-line utility for managing an encrypted software keyring.

Overview

The KeyStoreManagement 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 Type
    Method
    Description
    static void
    defineOptions(org.apache.commons.cli.Options options)
    Adds this subcommand's options to the provided Options instance.
    static void
    doGenerate(ZeroEchoSession session, KeyringStore store, org.apache.commons.cli.CommandLine cmd)
    Generates a keypair or secret and stores entries under the chosen aliases.
    static void
    Lists available algorithms with builder availability to stdout.
    static void
    Lists aliases present in the store to stdout.
    static int
    main(String[] args, org.apache.commons.cli.Options dispatcherOptions)
    Parses arguments, executes the requested action, and returns an exit code.
    static int
    main(String[] args, org.apache.commons.cli.Options dispatcherOptions, KeyringUnlockProvider unlockProvider)
    Executes the command with an explicit unlock source.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 dispatcher
      dispatcherOptions - an existing Options instance 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 fails
      IOException - if keyring or console I/O fails
      GeneralSecurityException - 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 dispatcher
      dispatcherOptions - dispatcher options
      unlockProvider - explicit destroyable-password provider
      Returns:
      process exit code
      Throws:
      org.apache.commons.cli.ParseException - if parsing fails
      IOException - if keyring I/O fails
      GeneralSecurityException - if cryptographic processing fails
    • defineOptions

      public static void defineOptions(org.apache.commons.cli.Options options)
      Adds this subcommand's options to the provided Options instance.
      Parameters:
      options - an existing Options instance from the central dispatcher
    • listAlgorithms

      public static void listAlgorithms()
      Lists available algorithms with builder availability to stdout.
    • listAliases

      public static void listAliases(KeyringStore store)
      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 material
      store - open keyring store to mutate
      cmd - parsed command line containing generation options
      Throws:
      IOException - if generated material cannot be written to the keyring
      GeneralSecurityException - if the requested key generation operation fails