X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=tfcrypt.c;h=e5ac31a33f99f600324ae2dbb8f13b52ceb65041;hb=8cf1129abf5f42bd57fe0f6f0c5308d425b95027;hp=dd137ae6ba4d9ac26d05fd5596bee5c4e9d22d6e;hpb=cdd9119e29f2f865403303adb8b6004b863db968;p=tfcrypt.git diff --git a/tfcrypt.c b/tfcrypt.c index dd137ae..e5ac31a 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -29,6 +29,7 @@ #include "tfcrypt.h" static tfc_byte svctr[TF_BLOCK_SIZE]; +static tfc_fsize rwd, do_read_loops, loopcnt; static void open_log(const char *logfile) { @@ -129,7 +130,6 @@ int main(int argc, char **argv) double td; char *s, *d, *t, *stoi; size_t x, n; - tfc_fsize rwd; progpid = getpid(); progname = basename(argv[0]); @@ -339,6 +339,10 @@ _baddfname: show_when_done = YES; else if (!strcmp(s, "pid")) show_pid = YES; + else if (!strncmp(s, "readloops", 9) && *(s+9) == '=') { + do_read_loops = tfc_humanfsize(s+10, &stoi); + if (!str_empty(stoi)) do_read_loops = NOSIZE; + } else if (!strncmp(s, "logfile", 7) && *(s+7) == '=') open_log(s+8); else if (!strncmp(s, "iobs", 4) && *(s+4) == '=') { @@ -576,6 +580,7 @@ _baddfname: break; case 'q': quiet = YES; + xexit_no_nl = YES; verbose = NO; do_full_hexdump = NO; status_timer = 0; @@ -768,12 +773,6 @@ _nokeyfd: } if (sfd == -1) xerror(NO, NO, YES, "%s", argv[idx]); - if (do_edcrypt == TFC_DO_DECRYPT && do_mac != NO && maxlen != NOFSIZE) { - if (verbose) tfc_esay("%s: disabling signature verification on " - "requested partial decryption.", tfc_format_pid(progname)); - do_mac = NO; - } - if ((do_mac >= TFC_MAC_VRFY || do_mac == TFC_MAC_DROP) && !do_mac_file) { maxlen = tfc_fdsize(sfd); if (maxlen == NOFSIZE) @@ -1021,12 +1020,6 @@ _xts2genkey: if (xwrite(krfd, pblk, TF_FROM_BITS(TFC_KEY_BITS)) == NOSIZE) xerro xexit(0); } - if (iseek_blocks && (do_edcrypt == TFC_DO_DECRYPT && do_mac != NO)) { - if (verbose) tfc_esay("%s: disabling signature verification on " - "requested partial decryption.", tfc_format_pid(progname)); - do_mac = NO; - } - if (do_mac != NO) { if (mackey_opt == TFC_MACKEY_RAWKEY) skein(mackey, TF_MAX_BITS, key, key, TF_FROM_BITS(TFC_KEY_BITS)); if (ctr_mode < TFC_MODE_OCB) { @@ -1156,6 +1149,7 @@ _decrypt_again_vrfy2: } _nodecrypt_again_vrfy2: + loopcnt = 1; errno = 0; do_stop = NO; while (1) { @@ -1165,7 +1159,15 @@ _nodecrypt_again_vrfy2: lrem = lblock = blk_len_adj(maxlen, total_processed_src, blksize); if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(sfd); _ragain: lio = xread(sfd, pblk, lrem); - if (lio == 0) do_stop = YES; + if (lio == 0) { + if ((do_read_loops != 0 && sfd != 0) && (loopcnt < do_read_loops)) { + lseek(sfd, 0L, SEEK_SET); + loopcnt++; + goto _ragain; + } + + do_stop = YES; + } if (lio != NOSIZE) ldone += lio; else { if (errno != EIO && catch_all_errors != YES)