51 broke -E logic completely, rewise it
[tfcrypt.git] / tfctrapi.c
1 #include <string.h>
2 #include "tfdef.h"
3
4 void tf_ctr_set(void *ctr, const void *sctr, size_t sctrsz)
5 {
6         TF_UNIT_TYPE usctr[TF_NR_BLOCK_UNITS];
7         TF_UNIT_TYPE *uctr = ctr;
8
9         data_to_words(uctr, TF_BLOCK_SIZE);
10
11         memset(usctr, 0, TF_BLOCK_SIZE);
12         memcpy(usctr, sctr, sctrsz > TF_BLOCK_SIZE ? TF_BLOCK_SIZE : sctrsz);
13         data_to_words(usctr, TF_BLOCK_SIZE);
14
15         ctr_add(uctr, TF_NR_BLOCK_UNITS, usctr, TF_NR_BLOCK_UNITS);
16         memset(usctr, 0, TF_BLOCK_SIZE);
17 }