fix -C stream -c rand regression.
[tfcrypt.git] / tfcrypt.c
index c8664cca99aad14cbc4cb9e84c4bb964483f5b4a..8d01618ce361abcbf6821ff77ea7bc106bc1538c 100644 (file)
--- a/tfcrypt.c
+++ b/tfcrypt.c
@@ -920,8 +920,6 @@ _xts2genkey:        if (xwrite(krfd, pblk, TF_FROM_BITS(TFC_KEY_BITS)) == NOSIZE) xerro
        tfc_data_to_words64(&iseek_blocks, sizeof(iseek_blocks));
        tf_ctr_set(ctr, &iseek_blocks, sizeof(iseek_blocks));
 
-       if (ctr_mode == TFC_MODE_STREAM) tfe_init_iv(&tfe, key, ctr);
-
        switch (counter_opt) {
                case TFC_CTR_SHOW:
                        switch (do_outfmt) {
@@ -1003,6 +1001,8 @@ _ctrwagain:       lio = xwrite(dfd, pblk, lrem);
                delta_processed += ldone;
        }
 
+       if (ctr_mode == TFC_MODE_STREAM) tfe_init_iv(&tfe, key, ctr);
+
        errno = 0;
        do_stop = NO;
        while (1) {