The syntax is:
-c hexc:nr[,hexc:nr,...]
As example, filling with 16 byte counter with following:
ffffffff3333337a7a7a7a88882a0b0c
is possible with following pattern:
-c ff:4,33:3,7a:4,88:2,2a:1,0b:1,0c:1
To fill with zeroes (or any other static byte) is simple:
-c 0:16
Note that any bytes that tend to overflow counter space are dropped, and any
unused bytes not filled by pattern are set to zeroes.
tfc_say(" head: when decrypting, read CTR from beginning of stream,");
tfc_say(" rand: generate random CTR and write it to beginning of stream,");
tfc_say(" zero: assume zero CTR is used, do not read from and write it to stream,");
+ tfc_say(" hexc:nr[,hexc:nr,...]: construct counter from given pattern.");
+ tfc_say(" Example: \"ff:124,08:2,80:2\" will fill counter first with 124 0xff bytes,");
+ tfc_say(" then with 2 0x08 bytes, then 2 0x80 bytes. To fill with zeroes, it is");
+ tfc_say(" simple to specify just a \"0:128\" as a pattern. Note that bytes that");
+ tfc_say(" exceed CTR space will be just dropped, and any unused bytes are set to zeroes.");
tfc_say(" <file>: read CTR from given file (both when encrypting/decrypting).");
tfc_say(" default is to derive CTR from user provided password or keyfile with");
tfc_say(" a single Skein function turn over derived, %u byte raw key", TFC_U(TF_KEY_SIZE));
counter_opt = TFC_CTR_RAND;
else if (!strcasecmp(optarg, "zero"))
counter_opt = TFC_CTR_ZERO;
+ else if (strchr(optarg, ':')) {
+ char *ss, chr;
+
+ counter_opt = TFC_CTR_SSET;
+ n = sizeof(ctr);
+
+ s = d = optarg; t = NULL;
+ while ((s = strtok_r(d, ",", &t))) {
+ if (d) d = NULL;
+
+ if (n == 0) break;
+ ss = strchr(s, ':');
+ if (!ss) continue;
+ *ss = 0; ss++;
+ chr = (char)strtoul(s, &stoi, 16);
+ if (!str_empty(stoi)) continue;
+ x = (size_t)strtoul(ss, &stoi, 10);
+ if (!str_empty(stoi)) continue;
+ if (x > n) x = n;
+ memset(ctr+(sizeof(ctr)-n), (int)chr, x);
+ n -= x;
+ }
+ }
else counter_file = sksum_hashlist_file = optarg;
break;
case 'C':
TFC_MODE_SKSUM = -2, TFC_MODE_PLAIN = -1, TFC_MODE_CTR = 1,
TFC_MODE_STREAM, TFC_MODE_XTS, TFC_MODE_ECB, TFC_MODE_CBC, TFC_MODE_OCB
};
-enum { TFC_CTR_SHOW = 1, TFC_CTR_HEAD, TFC_CTR_RAND, TFC_CTR_ZERO };
+enum { TFC_CTR_SHOW = 1, TFC_CTR_HEAD, TFC_CTR_RAND, TFC_CTR_ZERO, TFC_CTR_SSET };
#endif