From: Andrey Rys Date: Sun, 30 Oct 2022 20:30:21 +0000 (+0100) Subject: -g, -j: shortcuts for stream ciphers with random counter X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=7274f5687aeae3d14e686cff6fb8626e644b09c9;p=tfcrypt.git -g, -j: shortcuts for stream ciphers with random counter --- 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;