fix counter adjustment on "-c zero -O iseek=".
authorAndrey Rys <rys@lynxlynx.ru>
Sat, 6 Apr 2019 07:54:52 +0000 (14:54 +0700)
committerAndrey Rys <rys@lynxlynx.ru>
Sat, 6 Apr 2019 07:54:52 +0000 (14:54 +0700)
VERSION
tfcrypt.c

diff --git a/VERSION b/VERSION
index a45fd52cc5891570d6299fab38643103c3955474..7273c0fa8c522b7eed7762a353d46f7768e9b6f2 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-24
+25
index 125e5c9c3743e56c0ad01b6ef15a6bf931070730..5ed5bbf1979cad49d5ee15bc876495b82ebc822a 100644 (file)
--- a/tfcrypt.c
+++ b/tfcrypt.c
@@ -950,20 +950,20 @@ _xts2genkey:      if (xwrite(krfd, pblk, TF_FROM_BITS(TFC_KEY_BITS)) == NOSIZE) xerro
                tf_tweak_set(key, tweak);
        }
        if (ctr_mode == TFC_MODE_ECB) goto _ctrskip2;
+
+       if (counter_opt == TFC_CTR_ZERO) memset(ctr, 0, ctrsz);
+
        tfc_data_to_words64(&iseek_blocks, sizeof(iseek_blocks));
        tf_ctr_set(ctr, &iseek_blocks, sizeof(iseek_blocks));
 
-       switch (counter_opt) {
-               case TFC_CTR_SHOW:
-                       switch (do_outfmt) {
-                               case TFC_OUTFMT_B64: tfc_printbase64(stderr, ctr, ctrsz, YES); break;
-                               case TFC_OUTFMT_RAW: xwrite(2, ctr, ctrsz); break;
-                               case TFC_OUTFMT_HEX: mehexdump(ctr, ctrsz, ctrsz, YES); break;
-                       }
-                       break;
-               case TFC_CTR_RAND: tfc_getrandom(ctr, ctrsz); break;
-               case TFC_CTR_ZERO: memset(ctr, 0, ctrsz); break;
+       if (counter_opt == TFC_CTR_SHOW) {
+               switch (do_outfmt) {
+                       case TFC_OUTFMT_B64: tfc_printbase64(stderr, ctr, ctrsz, YES); break;
+                       case TFC_OUTFMT_RAW: xwrite(2, ctr, ctrsz); break;
+                       case TFC_OUTFMT_HEX: mehexdump(ctr, ctrsz, ctrsz, YES); break;
+               }
        }
+       else if (counter_opt == TFC_CTR_RAND) tfc_getrandom(ctr, ctrsz);
 
 _ctrskip2:
        if (kfd != -1) {