* tfcrypt -- high security Threefish encryption tool.
*
* tfcrypt is copyrighted:
- * Copyright (C) 2012-2018 Andrey Rys. All rights reserved.
+ * Copyright (C) 2012-2019 Andrey Rys. All rights reserved.
*
* tfcrypt is licensed to you under the terms of std. MIT/X11 license:
*
skein_final(hash, &sk);
}
-void tf_key_tweak_compat(void *key)
-{
- TF_UNIT_TYPE *ukey = key, c = THREEFISH_CONST;
- size_t x;
-
- for (x = 0; x < TF_NR_BLOCK_UNITS; x++) c ^= ukey[x];
- ukey[x] = c;
- ukey[TF_TWEAK_WORD3] = ukey[TF_TWEAK_WORD1] ^ ukey[TF_TWEAK_WORD2];
-}
-
-tfc_yesno skeinfd(void *hash, size_t bits, const void *key, int fd, tfc_fsize readto)
+tfc_yesno skeinfd(void *hash, size_t bits, const void *key, int fd, tfc_fsize offset, tfc_fsize readto)
{
static tfc_byte skblk[TFC_BLKSIZE];
if (ctr_mode == TFC_MODE_SKSUM) total_processed_src = total_processed_dst = delta_processed = 0;
if (fd == -1) goto _fail;
- if (fd > 2 && readto == NOFSIZE) {
- readto = tfc_fdsize(fd);
- if (readto == NOFSIZE) goto _fail;
+ if (fd > 2) {
+ if (readto == NOFSIZE) {
+ readto = tfc_fdsize(fd);
+ if (readto == NOFSIZE) goto _fail;
+ }
+ if (offset != 0 && offset != NOFSIZE) {
+ if (lseek(fd, (off_t)offset, SEEK_SET) == -1) {
+ if (ignore_seek_errors == NO) goto _fail;
+ }
+ }
}
if (key) skein_init_key(&sk, key, bits);
while (1) {
memset(sksblk, 0, sizeof(sksblk));
- x = xfgets(sksblk, sizeof(sksblk), f);
- if (x == 0) break;
+ if (xfgets(sksblk, sizeof(sksblk), f) != YES) break;
s = d = sksblk; t = NULL;
shash = fname = NULL;
}
if (status_timer) setup_next_alarm(status_timer);
- if (skeinfd(hash, bits, mackey_opt ? mackey : NULL, fd, maxlen) != YES) {
+ if (skeinfd(hash, bits, mackey_opt ? mackey : NULL, fd, iseek, maxlen) != YES) {
xerror(YES, NO, YES, "%s", fname);
exitcode = 1;
continue;
}
_dohash: if (status_timer) setup_next_alarm(status_timer);
- if (skeinfd(hash, bits, mackey_opt ? mackey : NULL, fd, maxlen) != YES) {
+ if (skeinfd(hash, bits, mackey_opt ? mackey : NULL, fd, iseek, maxlen) != YES) {
xerror(YES, NO, YES, "%s", fargv[x]);
exitcode = 1;
continue;