diff --git a/CHANGELOG.md b/CHANGELOG.md index f5d26c7..d557fc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,11 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Global constants fully shared among components through `sflc_constants.h`. -## [0.4.0] - 2023-07-23 +## [0.4.0] - 2023-07-24 ### Added - Benchmark suite with tools for Shufflecake, LUKS, and VeraCrypt. - Improved documentation in `README.md` on using `init` non-interactively. + - `doc` section which for now includes figure of Shufflecake header structure. ### Refactored @@ -31,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - - BREAKING CHANGE: slightly modified header field format, removing redundant data and making it adherent to documentation. + - BREAKING CHANGE: slightly modified header field format, removing redundant MAC field and making it adherent to documentation. - Action `init` now reads password from secure interface (not showing characters, etc). diff --git a/doc/headers.png b/doc/headers.png new file mode 100644 index 0000000..acd60a9 Binary files /dev/null and b/doc/headers.png differ diff --git a/doc/headers.svg b/doc/headers.svg new file mode 100644 index 0000000..dca326c --- /dev/null +++ b/doc/headers.svg @@ -0,0 +1,1232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DMB + Header + Device / Cake + + Header + + Encrypted Slices + IVs + + VMB + i + + 1 + + PositionMap + 1 + . . . + + VMB + 2 + + PositionMap + 2 + + VMB + 15 + + PositionMap + 15 + + + DMB + + salt + + IV + 1 + . . . + + ctxt + 1 + + IV + 15 + + ctxt + 15 + + + + HMAC + 1 + + HMAC + 15 + Password + Argon2 + + + + KEK + AES-GCM + + + + + VMBkey + + 1 + VMB + + + IV + ' + + ctxt + i + ' + i + + + AES-CTR + + + + + 1 + 1 + VEK + i + VMBkey + i + -1 + NumSlices + i + Metadata + i + | + | + | + | + | + | + AES-CTR + + + + Data I/O + + + diff --git a/shufflecake-userland/include/utils/input.h b/shufflecake-userland/include/utils/input.h index 5fbc8e4..9463999 100644 --- a/shufflecake-userland/include/utils/input.h +++ b/shufflecake-userland/include/utils/input.h @@ -40,5 +40,7 @@ /* Reads a line (discarding the newline) from stdin. No buffer overflow */ int sflc_safeReadLine(char *buf, size_t bufsize); +/* Reads a password or passphrase (discarding the newline) from stdin in a secure way (no echo) */ +int sflc_safeReadPassphrase(char *buf, size_t bufsize); #endif /* _UTILS_FILE_H_ */ diff --git a/shufflecake-userland/src/cli/open.c b/shufflecake-userland/src/cli/open.c index bb51a0a..e0f10dc 100644 --- a/shufflecake-userland/src/cli/open.c +++ b/shufflecake-userland/src/cli/open.c @@ -72,7 +72,7 @@ int sflc_cli_open(char *block_device) /* Gather password */ printf("Enter the password for the most secret volume you want to open: "); - err = sflc_safeReadLine(pwd, SFLC_BIGBUFSIZE); // TODO TOMGAG: replace with sflc_safeReadPassword + err = sflc_safeReadPassphrase(pwd, SFLC_BIGBUFSIZE); if (err) { sflc_log_error("Could not read password; error %d", err); return err; diff --git a/shufflecake-userland/src/utils/input.c b/shufflecake-userland/src/utils/input.c index a3ccc12..67b4f99 100644 --- a/shufflecake-userland/src/utils/input.c +++ b/shufflecake-userland/src/utils/input.c @@ -58,7 +58,24 @@ int sflc_safeReadLine(char *buf, size_t bufsize) } -// TODO TOMGAG: add sflc_safeReadPassword() to read passwords in a secure way, and add declaration in header .h if needed - +// TODO TOMGAG: placeholder for sflc_safeReadPassphrase() to read passwords in a secure way, and add declaration in header .h if needed +int sflc_safeReadPassphrase(char *buf, size_t bufsize) +{ + size_t len; + + /* Read from stdin */ + if (fgets(buf, bufsize, stdin) == NULL) { + sflc_log_error("Could not read from stdin"); + return EBADFD; + } + + /* Discard newline */ + len = strlen(buf); + if (buf[len - 1] == '\n') { + buf[len - 1] = '\0'; + } + + return 0; +}