51 broke -E logic completely, rewise it
[tfcrypt.git] / tfcrypt.c
index a540db4b77e7586fb00f351b682244e2ce7f1ca7..590cb33d2fa4ea2ae104a371ce862c4c8fde716a 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;
@@ -635,7 +643,6 @@ _baddfname:
                                break;
                        case 'q':
                                quiet = YES;
-                               xexit_no_nl = YES;
                                verbose = NO;
                                do_full_hexdump = NO;
                                status_timer = 0;
@@ -1197,6 +1204,7 @@ _decrypt_again_vrfy2:
                }
                total_processed_src = rwd;
                memcpy(ctr, svctr, TF_BLOCK_SIZE);
+               if (ctr_mode == TFC_MODE_STREAM) tfe_init_iv(&tfe, key, ctr);
                memset(svctr, 0, TF_BLOCK_SIZE);
        }
 
@@ -1465,7 +1473,7 @@ _macwagain:               lio = xwrite(dfd, pblk, lrem);
        }
        else if (do_mac == TFC_MAC_DROP2) total_processed_src += SKEIN_DIGEST_SIZE;
 
-       if (verbose || status_timer || (do_stop == YES && quiet == NO)) print_crypt_status(0);
+       if (verbose || status_timer || (do_stop == YES && quiet == NO)) print_crypt_status(TFC_SIGLAST);
 
        xexit(exitcode);
        return -1;