Class Guard
java.lang.Object
zeroecho.Guard
Guard is a unified subcommand that encrypts and decrypts using a
multi-recipient envelope with AES or ChaCha payloads.
Overview
The class replaces the previous MultiRecipientAes and PasswordBasedAes CLIs by exposing a single entry point. It builds an envelope with a recipients table (real and decoy) viaMultiRecipientDataSourceBuilder, then delegates the payload to either
AesDataContentBuilder or ChaChaDataContentBuilder.
Default behavior:
- Recipients are shuffled by default to harden traffic analysis. Disable
with
--no-shuffle. - The symmetric stage writes and parses its own header by default.
Keyring resolution
Recipient aliases and the unlocking alias are resolved fromKeyringStore. The algorithm id stored in the keyring
drives which recipient method to call, so the user does not have to specify
the algorithm again.
Payload selection
Use--alg to choose one of:
aes-gcm, aes-ctr, aes-cbc-pkcs7,
aes-cbc-nopad, chacha-aead, chacha-stream.
Examples
# Encrypt with KEM + RSA recipients, 2 decoy passwords, AES-GCM
ZeroEcho -G --encrypt in.bin --ks keys.txt \
--to-alias alice --to-alias bob \
--decoy-psw-rand 2 \
--pbkdf2-max "$PBKDF2_POLICY_MAX" \
--pbkdf2-hard-max "$PBKDF2_HARD_MAX" \
--alg aes-gcm --tag-bits 128 --aad-hex 01ff
# Decrypt with private key (payload is ChaCha20-Poly1305)
ZeroEcho -G --decrypt blob.bin --ks keys.txt \
--priv-alias alice \
--alg chacha-aead
-
Method Summary
Modifier and TypeMethodDescriptionstatic intEntry point for the Guard subcommand.static intmain(String[] args, org.apache.commons.cli.Options options, KeyringUnlockProvider keyringUnlockProvider) Executes Guard with an explicit keyring unlock source.
-
Method Details
-
main
public static int main(String[] args, org.apache.commons.cli.Options options) throws org.apache.commons.cli.ParseException, IOException, GeneralSecurityException Entry point for the Guard subcommand. It preserves Apache Commons CLI usage and the subcommand invocation pattern used byZeroEcho.- Parameters:
args- command-line argumentsoptions- options object provided by the dispatcher; this method augments it- Returns:
- exit code (0 = success, non-zero = failure)
- Throws:
org.apache.commons.cli.ParseException- on CLI parsing errorsIOException- on I/O errorsGeneralSecurityException- on cryptographic setup or keyring errors
-
main
public static int main(String[] args, org.apache.commons.cli.Options options, KeyringUnlockProvider keyringUnlockProvider) throws org.apache.commons.cli.ParseException, IOException, GeneralSecurityException Executes Guard with an explicit keyring unlock source.- Parameters:
args- command argumentsoptions- dispatcher optionskeyringUnlockProvider- destroyable-password provider- Returns:
- process exit code
- Throws:
org.apache.commons.cli.ParseException- if parsing failsIOException- if I/O failsGeneralSecurityException- if cryptographic processing fails
-