https://github.com/hakavlad/tird
Encrypt files and hide encrypted data
https://github.com/hakavlad/tird
argon2 blake2b chacha20 data-hiding deniable-encryption encryption file-encryption hiding plausible-deniability purb stealth steganography undetectable
Last synced: about 1 month ago
JSON representation
Encrypt files and hide encrypted data
- Host: GitHub
- URL: https://github.com/hakavlad/tird
- Owner: hakavlad
- License: cc0-1.0
- Created: 2023-03-19T14:14:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-17T13:01:48.000Z (6 months ago)
- Last Synced: 2024-10-29T20:22:21.253Z (6 months ago)
- Topics: argon2, blake2b, chacha20, data-hiding, deniable-encryption, encryption, file-encryption, hiding, plausible-deniability, purb, stealth, steganography, undetectable
- Language: Python
- Homepage:
- Size: 417 KB
- Stars: 9
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
![]()
πΒ manΒ page Β
πΒ Specification Β
πΒ InputΒ Options Β
πΒ Tutorial Β
βΒ FAQ
[](https://github.com/hakavlad/tird/releases)
[](https://pypi.org/project/tird/)
[](https://github.com/hakavlad/tird/actions/workflows/github-code-scanning/codeql)
[](https://github.com/hakavlad/tird/actions/workflows/semgrep.yml)
[](https://github.com/hakavlad/tird/actions/workflows/codacy.yml)Β Contents
> - [About](#about)
> - [Goals](#goals)
> - [Cryptographic Primitives](#cryptographic-primitives)
> - [Encrypted Data Format](#encrypted-data-format)
> - [Hidden File System and Container Format](#hidden-file-system-and-container-format)
> - [Visualization of Embedding](#visualization-of-embedding)
> - [Storing and Carrying Concealed Encrypted Data](#storing-and-carrying-concealed-encrypted-data)
> - [Usage](#usage)
> - [Input Options](#input-options)
> - [Debug Mode](#debug-mode)
> - [Tradeoffs and Limitations](#tradeoffs-and-limitations)
> - [Warnings](#warnings)
> - [Requirements](#requirements)
> - [Installation](#installation)
> - [TODO](#todo)
> - [Feedback](#feedback)## About
`tird` *(an acronym for "this is random data")* is a file encryption tool focused on
- minimizing metadata and
- hiding encrypted data.With `tird`, you can:
1. Create files filled with random data to use as containers or keyfiles.
2. Overwrite the contents of block devices and regular files with random data. This can be used to prepare containers and to destroy residual data.
3. Encrypt file contents and comments with modern cryptographic primitives. The encrypted data format (called cryptoblob) is a [padded uniform random blob (PURB)](https://en.wikipedia.org/wiki/PURB_(cryptography)): it looks like random data and has a randomized size. This reduces metadata leakage from file format and length, and also allows cryptoblobs to be hidden among random data. You can use keyfiles and passphrases at your choice to enhance security.
4. Create [steganographic](https://en.wikipedia.org/wiki/Steganography) (hidden, undetectable) user-driven file systems inside container files and block devices. Unlike [VeraCrypt](https://veracrypt.fr) and [Shufflecake](https://shufflecake.net/) containers, `tird` containers do not contain headers at all; the user specifies the location of the data in the container and is responsible for ensuring that this location is separated from the container.
5. Resist [coercive](https://en.wikipedia.org/wiki/Coercion) attacks (keywords: [key disclosure law](https://en.wikipedia.org/wiki/Key_disclosure_law), [rubber-hose cryptanalysis](https://en.wikipedia.org/wiki/Deniable_encryption), [xkcd 538](https://xkcd.com/538/)). `tird` provides some forms of [plausible deniability](https://en.wikipedia.org/wiki/Plausible_deniability) out of the box, even if you encrypt files without hiding them in containers.## Goals
- **File Protection:** Ensuring protection for individual files, including:
- Symmetric encryption and authentication.
- Minimizing metadata leakage.
- Preventing access to data in cases of user coercion.
- Plausible deniability of payload existence.
- Hiding encrypted data.
- **Stable Format:** Ensuring a stable encryption format with no [cryptographic agility](https://en.wikipedia.org/wiki/Cryptographic_agility) for long-term data storage.
- **Simplicity:** Ensuring simplicity and avoiding [feature creep](https://en.wikipedia.org/wiki/Feature_creep): refusal to implement features that are not directly related to primary security goals.## Cryptographic Primitives
The following cryptographic primitives are utilized by `tird`:
- `ChaCha20` cipher ([RFC 8439](https://www.rfc-editor.org/rfc/rfc8439.html)) for data encryption.
- `BLAKE2` ([RFC 7693](https://www.rfc-editor.org/rfc/rfc7693.html)) for hashing and authentication.
- `Argon2` memory-hard function ([RFC 9106](https://www.rfc-editor.org/rfc/rfc9106.html)) for key stretching and key derivation.For more details, refer to the [specification](https://github.com/hakavlad/tird/blob/main/docs/SPECIFICATION.md).
## Encrypted Data Format
The format of the encrypted data is quite simple and consists of ciphertext with a MAC tag, located *somewhere* among the surrounding random data:
```
+βββββββββββββ+ββββββββββββ+βββββββββ+βββββββββββββ+
| Random data | Ciphertext | MAC tag | Random data |
+βββββββββββββ+ββββββββββββ+βββββββββ+βββββββββββββ+
```Β Show more detailed scheme
```
+ββββββββββββββββββββββββββββββββββββββββ+βββββββββ+
| Salt for key stretching (Argon2): 16 B | |
+ββββββββββββββββββββββββββββββββββββββββ+ Random |
| Randomized padding: 0-20% of the | data |
| unpadded cryptoblob size by default | |
+ββββββββββββββββββββββββββββββββββββββββ+βββββββββ+
| Ciphertext (ChaCha20): 512+ B, | |
| consists of: | |
| - Encrypted padded/truncated | Random- |
| comments, always 512 B | looking |
| - Encrypted payload file | data |
| contents, 0+ B | |
+ββββββββββββββββββββββββββββββββββββββββ+ |
| Optional MAC tag (BLAKE2/random): 64 B | |
+ββββββββββββββββββββββββββββββββββββββββ+βββββββββ+
| Randomized padding: 0-20% of the | |
| unpadded cryptoblob size by default | Random |
+ββββββββββββββββββββββββββββββββββββββββ+ data |
| Salt for prehashing (BLAKE2): 16 B | |
+ββββββββββββββββββββββββββββββββββββββββ+βββββββββ+
```Data encrypted with `tird` cannot be distinguished from random data without knowledge of the keys. It also does not contain identifiable headers. `tird` produces cryptoblobs that contain bilateral [randomized padding](https://en.wikipedia.org/wiki/Padding_(cryptography)#Randomized_padding) with uniform random data (PURBs). This minimizes metadata leaks from the file format and makes it possible to hide cryptoblobs among other random data. Bilateral padding also conceals the exact location of the ciphertext and MAC tag within the cryptoblob.
## Hidden File System and Container Format
`tird` employs a technique that is [described](https://en.wikipedia.org/wiki/List_of_steganography_techniques#Digital) as follows:
> Concealing data within encrypted data or within random data. The message to conceal is encrypted, then used to overwrite part of a much larger block of encrypted data or a block of random data (an unbreakable cipher like the one-time pad generates ciphertexts that look perfectly random without the private key).
You can encrypt files and embed cryptoblobs into containers starting at arbitrary positions. After writing the cryptoblob, you will need to remember its location in the container (the starting and ending positions), which will be used later to extract the cryptoblobs. In this way, you can create a **hidden, headerless, user-driven file system** inside a container:
- It is **hidden** because it is impossible to distinguish between random container data and cryptoblob data, as well as to determine the location of written cryptoblobs without knowing the positions and keys.
- It is **headerless** because containers do not contain any headers; all data about cryptoblob locations must be stored separately by the user.
- The starting position of the cryptoblob in the container is **user-defined**, and the **user must** store both the starting and ending positions separately from the container. This is why it is called a **user-driven file system**.Any file, disk, or partition larger than the minimum cryptonlob size (863 B) can be a valid container. Cryptoblobs can be embedded into any area.
**Examples of Valid Containers Include:**
1. Specially generated files with random data.
2. `tird` cryptoblobs, as they contain unauthenticated padding of random data by default, which can be used to embed smaller cryptoblobs.
3. Disk areas containing random data. For example, you can overwrite a disk with random data, format it in FAT32 or exFAT, and use a large portion of the disk, leaving a few dozen MB from the beginning. The disk will appear empty unless you add some files to it.
4. [LUKS](https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup) encrypted volumes.
5. VeraCrypt containers, even those that already contain hidden volumes.**Example of Container Structure:**
```
+βββββββββ+βββββββββββββ+ <β Position 0 of the container
| | |
| | Random data |
| | |
| +βββββββββββββ+ <β Cryptoblob1 start position
| Header- | |
| less | Cryptoblob1 |
| | |
| Layer +βββββββββββββ+ <β Cryptoblob1 end position
| | Random data |
| Cake +βββββββββββββ+ <β Cryptoblob2 start position
| | |
| | Cryptoblob2 |
| | |
| +βββββββββββββ+ <β Cryptoblob2 end position
| | Random data |
+βββββββββ+βββββββββββββ+
```## Visualization of Embedding
The next image visualizes how hard it is to distinguish one random data entry from another and the process of embedding cryptoblobs in a container.
Β Show Images
*Empty container with random data:*
*One cryptoblob embedded in the container:*
*Two cryptoblobs embedded in the container:*
*Three cryptoblobs embedded in the container:*
*Animation: visualization of embedding:*
## Storing and Carrying Concealed Encrypted Data
Please look at the following screenshot.
It looks like this 16 GB volume contains only one 8.7 MiB file. Is it really true? Maybe yes, maybe no.
The file system tells us that there is only one file here. But is there really only one file on the volume? We cannot determine this using the file system. In fact, data may be located outside the file system and be undetectable by file system tools. The 15.2 GiB of space marked as free may be occupied by a hidden file system. This "free" space may be taken up by hidden encrypted data.
Can we disprove the existence of this data? Yes, for example, by examining the entropy level of this free space using `binwalk`. Low entropy indicates a likely absence of hidden data. High entropy *does not*, *by itself*, prove the presence of encrypted hidden data. Areas with high entropy can be either just residual data or hidden encrypted data.
If you are interested in hiding data outside the visible file system, then `tird` is at your service to provide an Invisibility Cloak for your files.
## Usage
You don't need to memorize command-line options to use `tird`. This tool features a prompt-based CLI: simply start it, select a menu option, and answer the questions that will follow.
```
$ tirdMENU
βββββββββββββββββββββββββββββββββββββββββββ
0. Exit 1. Info & Warnings
2. Encrypt 3. Decrypt
4. Embed 5. Extract
6. Encrypt & Embed 7. Extract & Decrypt
8. Create w/ Random 9. Overwrite w/ Random
βββββββββββββββββββββββββββββββββββββββββββ
A0. Select an option [0-9]:
```## Input Options
There are 5 groups of input options. They are numbered for ease of description.
```
+ββββββββββββββββββββββββββ+ββββββββββββββββββββββββ+
| A0. Select an option | A. Select an action |
+ββββββββββββββββββββββββββ+ββββββββββββββββββββββββ+
| C0. Use custom settings? | |
| C1. Time cost | C. Set custom settings |
| C2. Max padding size | |
| C3. Set fake MAC tag? | |
+ββββββββββββββββββββββββββ+ββββββββββββββββββββββββ+
| D1. Input file path | |
| D2. Comments | D. Enter data, |
| D3. Output file path | data location, |
| D4. Output file size | data size |
| D5. Start position | |
| D6. End position | |
+ββββββββββββββββββββββββββ+ββββββββββββββββββββββββ+
| K1. Keyfile path | K. Specify input |
| K2. Passphrase | keying material |
+ββββββββββββββββββββββββββ+ββββββββββββββββββββββββ+
| P0. Proceed? | P. Confirm to continue |
+ββββββββββββββββββββββββββ+ββββββββββββββββββββββββ+
```A detailed description of these options with examples can be found [here](https://github.com/hakavlad/tird/blob/main/docs/INPUT_OPTIONS.md).
## Debug Mode
Start `tird` with the `--debug` option to look under the hood while the program is running:
```bash
$ tird --debug
```Enabling debug messages additionally shows:
- File operations:
- Opening and closing of file descriptors.
- Real paths to opened files.
- Movement of file pointers.
- Byte strings related to cryptographic operations: salts, passphrases, digests, keys, nonces, and tags.
- Some other information, including various sizes.## Tradeoffs and Limitations
- `tird` does not support:
- [Public-key cryptography](https://en.wikipedia.org/wiki/Public-key_cryptography).
- File compression.
- ASCII armored output.
- [ReedβSolomon error correction](https://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction).
- Splitting the output into chunks.
- The use of [standard streams](https://en.wikipedia.org/wiki/Standard_streams) for processing files.
- Low-level block device reading and writing on MS Windows. As a result, these devices cannot be used as keyfiles, cannot be overwritten, and cannot be encrypted or embedded.
- `tird` does not provide:
- A graphical user interface.
- A password generator.
- `tird` cannot handle (encrypt/embed) more than one file in one pass. Encryption of directories and multiple files is not supported.
- `tird` does not fake file access, modification, and creation timestamps (atime, mtime, ctime).
- `tird`'s encryption speed is not very high (up to 420 MiB/s in my tests).## Warnings
> Crypto can help, but it wonβt save you from misuse, vulnerabilities, social engineering, or physical threats.
β Loup Vaillant

- β οΈ The author does not have a background in cryptography.
- β οΈ The code has 0% test coverage.
- β οΈ `tird` has not been independently audited.
- β οΈ `tird` is ineffective in a compromised environment; executing it in such cases may cause disastrous data leaks.
- β οΈ `tird` is unlikely to be effective when used with short and predictable keys.
- β οΈ Sensitive data may leak into swap space.
- β οΈ `tird` does not erase its sensitive data from memory after use.
- β οΈ `tird` always releases unverified plaintext, violating [the Cryptographic Doom Principle](https://moxie.org/2011/12/13/the-cryptographic-doom-principle.html); decrypted output is untrusted until the MAC tag is verified.
- β οΈ Padding contents are never authenticated; authentication only applies to the ciphertext, salts, and certain sizes.
- β οΈ Padding sizes depend on secret values.
- β οΈ `tird` does not sort digests of keyfiles and passphrases in constant-time.
- β οΈ Overwriting file contents does not guarantee secure destruction of data on the media.
- β οΈ You cannot prove to an adversary that your random data does not contain encrypted information.
- β οΈ `tird` protects data, not the user; it cannot prevent torture if you are under suspicion.
- β οΈ Development is not complete, and there may be backward compatibility issues.## Requirements
- Python >= 3.9.2
- [cryptography](https://pypi.org/project/cryptography/) >= 2.1 (provides `ChaCha20`)
- [PyNaCl](https://pypi.org/project/PyNaCl/) >= 1.2.0 (provides `Argon2` and `BLAKE2`)## Installation
### Installation from PyPI
Install `python3` and `python3-pip` (or `python-pip`), then run
```bash
$ pip install tird
```### Building and Installing the Package on Debian-based Linux Distros
It's easy to build a deb package for Debian and Ubuntu-based distros with the latest git snapshot.
1. Install the build dependencies:
```bash
$ sudo apt install make fakeroot
```2. Clone the repository (if `git` is already installed) and enter the directory:
```bash
$ git clone https://github.com/hakavlad/tird.git && cd tird
```3. Build the package:
```bash
$ make build-deb
```4. Install or reinstall the package:
```bash
$ sudo make install-deb
```### Standalone Executables
Standalone executables (made with [PyInstaller](https://pyinstaller.org/en/stable/)) are also available (see [Releases](https://github.com/hakavlad/tird/releases)) for Windows and Linux (amd64). Please use at your own risk.

Β How to Verify Signatures
Use [Minisign](https://jedisct1.github.io/minisign/) to verify signatures. You can find my public key [here](https://github.com/hakavlad/hakavlad).
For example:
```
$ minisign -Vm tird-v0.19.0-linux-amd64.zip -P RWQLYkPbRQ8b56zEe8QdbjLFqC9UrjOaYxW5JxwsWV7v0ct/F/XfJlel
```This requires the signature `tird-v0.19.0-linux-amd64.zip.minisig` to be present in the same directory.
## TODO
Write or improve the documentation:
- Features
- User Guide
- Specification
- Design Rationale## Feedback
Please feel free to ask questions, leave feedback, or provide critiques in the [Discussions](https://github.com/hakavlad/tird/discussions) section.