- xstrlcat(s, d, PATH_MAX > sizeof(srcblk) ? sizeof(srcblk) : PATH_MAX);
- xstrlcat(s, "/.tfcrypt.defs", PATH_MAX > sizeof(srcblk) ? sizeof(srcblk) : PATH_MAX);
+ n = PATH_MAX > sizeof(srcblk) ? sizeof(srcblk) : PATH_MAX;
+ if (xstrlcpy(s, d, n) >= n) goto _baddfname;
+ if (xstrlcat(s, "/.tfcrypt.defs", n) >= n) goto _baddfname;
counter_opt = TFC_CTR_HEAD;
else if (!strcasecmp(optarg, "rand"))
counter_opt = TFC_CTR_RAND;
counter_opt = TFC_CTR_HEAD;
else if (!strcasecmp(optarg, "rand"))
counter_opt = TFC_CTR_RAND;
else if (!strncmp(s, "iobs", 4) && *(s+4) == '=') {
s += 5;
blksize = (size_t)tfc_humanfsize(s, &stoi);
else if (!strncmp(s, "iobs", 4) && *(s+4) == '=') {
s += 5;
blksize = (size_t)tfc_humanfsize(s, &stoi);
xerror(NO, YES, YES, "Cannot encrypt and read CTR from source!");
if (overwrite_source && counter_opt == TFC_CTR_RAND)
xerror(NO, YES, YES, "Cannot embed a CTR into file when overwriting it!");
xerror(NO, YES, YES, "Cannot encrypt and read CTR from source!");
if (overwrite_source && counter_opt == TFC_CTR_RAND)
xerror(NO, YES, YES, "Cannot embed a CTR into file when overwriting it!");
if (ctr_mode == TFC_MODE_PLAIN
&& (do_edcrypt || do_mac || rawkey
|| mackey_opt || counter_opt || counter_file))
if (ctr_mode == TFC_MODE_PLAIN
&& (do_edcrypt || do_mac || rawkey
|| mackey_opt || counter_opt || counter_file))
int twfd;
if (!strcmp(tweakf, "-")) twfd = 0;
else twfd = open(tweakf, O_RDONLY | O_LARGEFILE);
if (twfd == -1) xerror(NO, NO, YES, "%s", tweakf);
int twfd;
if (!strcmp(tweakf, "-")) twfd = 0;
else twfd = open(tweakf, O_RDONLY | O_LARGEFILE);
if (twfd == -1) xerror(NO, NO, YES, "%s", tweakf);
if (lio == NOSIZE) xerror(NO, NO, YES, "%s", tweakf);
if (lio == NOSIZE) xerror(NO, NO, YES, "%s", tweakf);
- if (ldone < 2*TF_SIZE_UNIT)
- xerror(NO, NO, YES, "%s: %zu bytes tweak required", tweakf, 2*TF_SIZE_UNIT);
+ if (ldone < TF_TWEAK_SIZE)
+ xerror(NO, NO, YES, "%s: %zu bytes tweak required", tweakf, TF_TWEAK_SIZE);
- if (do_tfcrypt1 == YES) {
- if (!tweakf) skein(key+TF_FROM_BITS(TF_MAX_BITS)+TF_SIZE_UNIT, 2*TF_UNIT_BITS, NULL, key, TF_FROM_BITS(TFC_KEY_BITS));
- tf_key_tweak_compat(key);
+ if (do_full_key == NO) {
+ if (!tweakf) skein(tweak, TF_NR_TWEAK_BITS, NULL, key, TF_FROM_BITS(TFC_KEY_BITS));
+ tf_tweak_set(key, tweak);
}
if (ctr_mode == TFC_MODE_ECB) goto _ctrskip2;
tfc_data_to_words64(&iseek_blocks, sizeof(iseek_blocks));
tf_ctr_set(ctr, &iseek_blocks, sizeof(iseek_blocks));
}
if (ctr_mode == TFC_MODE_ECB) goto _ctrskip2;
tfc_data_to_words64(&iseek_blocks, sizeof(iseek_blocks));
tf_ctr_set(ctr, &iseek_blocks, sizeof(iseek_blocks));