sksum: now honors -O iseek= too to seek into source.
tfc_say(" oseek=val: seek destination file/device by these val bytes.");
tfc_say(" count=val: process only these val bytes, both input and output.");
tfc_say(" xkey=val: take only val bytes from user keyfile.");
+ tfc_say(" okey=val: seek the key before reading it (usually a device).");
tfc_say(" xctr=val: specify size in bytes of initial counter prepended or read.");
tfc_say(" -P: plain IO mode: disable encryption/decryption code at all.");
tfc_say("\n");
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) goto _fail;
+ }
}
if (key) skein_init_key(&sk, key, bits);
}
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;
tfc_fsize delta_processed;
tfc_fsize genrandom_nr_bytes, genzero_nr_bytes;
tfc_fsize rdpos = NOFSIZE;
+tfc_fsize maxkeylen = NOFSIZE, keyoffset;
int sfd, kfd = -1, dfd = 1;
struct stat s_stat;
size_t blksize = TFC_BLKSIZE, xtsblocks = TFC_XTSBLOCKS;
char pwdask[512], pwdagain[512];
size_t lio, lrem, ldone, lblock;
-size_t maxkeylen = NOSIZE, ctrsz = NOSIZE;
+size_t ctrsz = NOSIZE;
struct sigaction sigact;
s += 5;
maxkeylen = tfc_humanfsize(s, &stoi);
if (!str_empty(stoi)) {
- maxkeylen = (size_t)tfc_fnamesize(s, YES);
- maxkeylen = (size_t)tfc_modifysize((tfc_fsize)maxkeylen, strchr(s, ':'));
+ maxkeylen = tfc_fnamesize(s, YES);
+ maxkeylen = tfc_modifysize(maxkeylen, strchr(s, ':'));
if (maxkeylen == NOSIZE)
xerror(NO, YES, YES,
"%s: invalid key length value", s);
}
- else maxkeylen = (size_t)tfc_modifysize((tfc_fsize)maxkeylen, strchr(s, ':'));
+ else maxkeylen = tfc_modifysize(maxkeylen, strchr(s, ':'));
+ }
+ else if (!strncmp(s, "okey", 4) && *(s+4) == '=') {
+ s += 5;
+ keyoffset = tfc_humanfsize(s, &stoi);
+ if (!str_empty(stoi)) {
+ keyoffset = tfc_fnamesize(s, YES);
+ keyoffset = tfc_modifysize(keyoffset, strchr(s, ':'));
+ if (keyoffset == NOFSIZE)
+ xerror(NO, YES, YES,
+ "%s: invalid key offset value", s);
+ }
+ else keyoffset = tfc_modifysize(keyoffset, strchr(s, ':'));
}
else if (!strncmp(s, "xctr", 4) && *(s+4) == '=') {
s += 5;
memset(pwdagain, 0, sizeof(pwdagain));
}
else {
- if (skeinfd(key, TFC_KEY_BITS, mackey_opt ? mackey : NULL, kfd, maxkeylen) != YES)
+ if (skeinfd(key, TFC_KEY_BITS, mackey_opt ? mackey : NULL, kfd, keyoffset, maxkeylen) != YES)
xerror(NO, NO, YES, "hashing key");
}
extern tfc_fsize delta_processed;
extern tfc_fsize genrandom_nr_bytes, genzero_nr_bytes;
extern tfc_fsize rdpos;
+extern tfc_fsize maxkeylen, keyoffset;
extern int sfd, kfd, dfd;
extern struct stat s_stat;
extern size_t blksize, xtsblocks;
extern char pwdask[512], pwdagain[512];
extern size_t lio, lrem, ldone, lblock;
-extern size_t maxkeylen, ctrsz;
+extern size_t ctrsz;
extern struct sigaction sigact;
extern size_t sksum_turns;
extern int do_edcrypt, do_stop, quiet, error_action;
void setup_next_alarm(tfc_useconds useconds);
void skein(void *hash, size_t bits, const void *key, const void *data, size_t szdata);
void tf_key_tweak_compat(void *key);
-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);
void gen_write_bytes(const char *foutname, tfc_fsize offset, tfc_fsize nrbytes);
void do_edbase64(char **fargv);