-g, -j: shortcuts for stream ciphers with random counter
authorAndrey Rys <rys@lynxlynx.ru>
Sun, 30 Oct 2022 20:30:21 +0000 (21:30 +0100)
committerAndrey Rys <rys@lynxlynx.ru>
Sun, 30 Oct 2022 20:30:21 +0000 (21:30 +0100)
VERSION
tfc_error.c
tfcrypt.c

diff --git a/VERSION b/VERSION
index 38b10c1b2badd802b554ecc944a7a40c5f055d47..b5489e5e51a9e547d42a398df654a8dfee00b82f 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-68
+69
index 953ba0725a648f1079be4d5cd0ac2ec76f63a5c6..8e4148251f0a4e15d3f95df252fd8b72b81230b5 100644 (file)
@@ -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 <file>: specify random source instead of /dev/urandom.");
        tfc_say("  -R nr_bytes: generate nr_bytes of random bytes suitable for use as key data.");
index a540db4b77e7586fb00f351b682244e2ce7f1ca7..5182a34a8467344dd3b306d17d10340b1f49efb3 100644 (file)
--- 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;