51 broke -E logic completely, rewise it
[tfcrypt.git] / tfctrapi.c
index 2845b2dba0b820a7a87222810111a6944180d9ba..67ec44b714f37efcc78686f7f3857f41afa45c1d 100644 (file)
@@ -6,9 +6,12 @@ void tf_ctr_set(void *ctr, const void *sctr, size_t sctrsz)
        TF_UNIT_TYPE usctr[TF_NR_BLOCK_UNITS];
        TF_UNIT_TYPE *uctr = ctr;
 
+       data_to_words(uctr, TF_BLOCK_SIZE);
+
        memset(usctr, 0, TF_BLOCK_SIZE);
        memcpy(usctr, sctr, sctrsz > TF_BLOCK_SIZE ? TF_BLOCK_SIZE : sctrsz);
+       data_to_words(usctr, TF_BLOCK_SIZE);
+
        ctr_add(uctr, TF_NR_BLOCK_UNITS, usctr, TF_NR_BLOCK_UNITS);
-       data_to_words(uctr, TF_BLOCK_SIZE);
        memset(usctr, 0, TF_BLOCK_SIZE);
 }