From: Andrey Rys Date: Wed, 24 Apr 2019 20:22:02 +0000 (+0700) Subject: Display hash of current defaults. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=72672c5cb76597fdc07cbc9bc190394d1c1d3ee1;p=tfcrypt.git Display hash of current defaults. --- diff --git a/VERSION b/VERSION index f04c001..64bb6b7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -29 +30 diff --git a/tfc_conf.c b/tfc_conf.c index c583b86..da45231 100644 --- a/tfc_conf.c +++ b/tfc_conf.c @@ -104,3 +104,35 @@ _nspc: memset(ln, 0, sizeof(ln)); fclose(f); } + +void hash_defaults(char *uhash, size_t szuhash) +{ + struct skein sk; + char shash[56]; + const char *mode; + tfc_byte hash[TF_FROM_BITS(256)]; + + skein_init(&sk, 256); + + skein_update(&sk, tfc_salt, tfc_saltsz); + + memset(shash, 0, sizeof(shash)); + sprintf(shash, "%zu", nr_turns); + skein_update(&sk, shash, strlen(shash)); + + mode = tfc_modename(ctr_mode); + skein_update(&sk, mode, strlen(mode)); + + memset(shash, 0, sizeof(shash)); + sprintf(shash, "%zu", macbits); + skein_update(&sk, shash, strlen(shash)); + + skein_update(&sk, do_full_key ? "1" : "0", 1); + + skein_final(hash, &sk); + memset(shash, 0, sizeof(shash)); + base64_encode(shash, (const char *)hash, sizeof(hash)); + memset(hash, 0, sizeof(hash)); + + xstrlcpy(uhash, shash, szuhash); +} diff --git a/tfc_error.c b/tfc_error.c index c4e51f1..5729de0 100644 --- a/tfc_error.c +++ b/tfc_error.c @@ -91,7 +91,11 @@ void usage(void) tfc_yesno is_embedded_prog = NO; if (optopt == 'V') { + char shash[64]; tfc_say("tfcrypt toolkit, version %s.", _TFCRYPT_VERSION); + hash_defaults(shash, sizeof(shash)); + tfc_say("Defaults hash: %s", shash); + memset(shash, 0, sizeof(shash)); xexit(0); } diff --git a/tfcrypt.h b/tfcrypt.h index 49073c9..e33e858 100644 --- a/tfcrypt.h +++ b/tfcrypt.h @@ -207,6 +207,7 @@ void skein(void *hash, size_t bits, const void *key, const void *data, size_t sz tfc_yesno skeinfd(void *hash, size_t bits, const void *key, int fd, tfc_fsize offset, tfc_fsize readto); void read_defaults(const char *path, tfc_yesno noerr); +void hash_defaults(char *uhash, size_t szuhash); void gen_write_bytes(const char *foutname, tfc_fsize offset, tfc_fsize nrbytes); void do_edbase64(char **fargv); diff --git a/tfcrypt_defs.h b/tfcrypt_defs.h index c7b3ae7..9e54d80 100644 --- a/tfcrypt_defs.h +++ b/tfcrypt_defs.h @@ -1,6 +1,8 @@ #ifndef _TFCRYPT_DEFAULTS_HEADER #define _TFCRYPT_DEFAULTS_HEADER +/* 5uouFzawL37Un6RtVqWbv0SOX48ew/xntAG5sNaOSlk= */ + size_t nr_turns = 262144; int ctr_mode = TFC_MODE_XTS; size_t macbits = TF_MAX_BITS;