X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tfcrypt.c;h=df62420769d0b07b0db2a72a424cb72f6885d081;hb=a7a8ae5408eed270854e69adf40ccaf3a401f830;hp=8608cf16011399202e66f08b8855211c6368a56e;hpb=4ae16105a9849ffbd2a9bb0e02fa4dfe8b83ebd6;p=tfcrypt.git diff --git a/tfcrypt.c b/tfcrypt.c index 8608cf1..df62420 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -328,13 +328,25 @@ int main(int argc, char **argv) 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; @@ -814,7 +826,7 @@ _pwdagain: memset(&getps, 0, sizeof(struct getpasswd_state)); 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"); }