From 7274f5687aeae3d14e686cff6fb8626e644b09c9 Mon Sep 17 00:00:00 2001 From: Andrey Rys Date: Sun, 30 Oct 2022 21:30:21 +0100 Subject: [PATCH] -g, -j: shortcuts for stream ciphers with random counter --- VERSION | 2 +- tfc_error.c | 2 ++ tfcrypt.c | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 38b10c1..b5489e5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -68 +69 diff --git a/tfc_error.c b/tfc_error.c index 953ba07..8e41482 100644 --- a/tfc_error.c +++ b/tfc_error.c @@ -281,6 +281,8 @@ void usage(void) tfc_say(" -v: print number of read and written encrypted bytes, and explain stages."); tfc_say(" -V seconds: activate timer that will repeatedly print statistics to stderr."); tfc_say(" -a: shortcut of -O xtime."); + tfc_say(" -g: same as '-e -C stream -c rand' or '-d -C stream -c head', depending on mode."); + tfc_say(" -j: same as '-e -C ctr -c rand' or '-d -C ctr -c head', depending on mode."); tfc_say(" -l length: read only these first bytes of source."); tfc_say(" -r : specify random source instead of /dev/urandom."); tfc_say(" -R nr_bytes: generate nr_bytes of random bytes suitable for use as key data."); diff --git a/tfcrypt.c b/tfcrypt.c index a540db4..5182a34 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -164,7 +164,7 @@ _baddfname: } opterr = 0; - while ((c = getopt(argc, argv, "L:s:aU:C:r:K:t:PXkzxc:l:qedn:vV:pwE:o:O:S:AmuM:R:Z:WHD:")) != -1) { + while ((c = getopt(argc, argv, "L:s:aU:C:r:K:t:PXkzxc:l:qedn:vV:pwE:o:O:S:AmuM:R:Z:WHD:gj")) != -1) { switch (c) { case 'L': read_defaults(optarg, NO); @@ -175,6 +175,14 @@ _baddfname: case 'r': randsource = optarg; break; + case 'j': + case 'g': + if (c == 'j') ctr_mode = TFC_MODE_CTR; + else if (c == 'g') ctr_mode = TFC_MODE_STREAM; + if (do_edcrypt == TFC_DO_DECRYPT) counter_opt = TFC_CTR_HEAD; + else if (do_edcrypt == TFC_DO_ENCRYPT) counter_opt = TFC_CTR_RAND; + else xerror(NO, YES, YES, "plain mode was selected with -%c, cannot continue", c); + break; case 'c': if (!strcasecmp(optarg, "show")) counter_opt = TFC_CTR_SHOW; -- 2.31.1