A robust Linux security tool written in Rust that provides:
- AES-256-GCM file encryption/decryption with authenticated encryption
- Argon2id password-based key derivation (resistant to GPU/ASIC attacks)
- File permissions security checker to identify unsafe permissions
-
Algorithm: AES-256-GCM (Galois/Counter Mode)
- Provides both confidentiality and authenticity
- Detects tampering automatically
- Industry-standard encryption
-
Key Derivation: Argon2id
- Winner of the Password Hashing Competition
- Resistant to GPU and ASIC cracking attempts
- Memory-hard function
- Protects against brute-force attacks
-
Random Generation: Uses OS-provided cryptographically secure random number generator
- Unique salt per file (16 bytes)
- Unique nonce per encryption (12 bytes)
-
Memory Safety:
- Rust's ownership system prevents buffer overflows
- Sensitive data (keys) are zeroized after use
- No use-after-free vulnerabilities
-
Secure Defaults:
- Encrypted files automatically set to 0600 permissions (owner-only access)
- Minimum 8-character password requirement
- Identifies world-writable files (critical security risk)
- Flags sensitive files with world-readable permissions
- Detects group-writable files
- Notices unusual executable bits on data files
- Recursive directory scanning support
- Rust 1.70 or newer
- Linux/Unix system (uses Unix file permissions)
# Clone or navigate to the project directory
cd secure_file_tool
# Build release version (optimized)
cargo build --release
# Binary will be at: target/release/secure-file-tool
# Optional: Install to system
cargo install --path .# Encrypt with default output name (adds .enc extension)
./target/release/secure-file-tool encrypt -i myfile.txt
# Encrypt with custom output name
./target/release/secure-file-tool encrypt -i myfile.txt -o encrypted.bin
# You'll be prompted for password (minimum 8 characters)What happens:
- Prompts for password (hidden input)
- Asks for confirmation
- Generates random salt and nonce
- Derives 256-bit key using Argon2id
- Encrypts file with AES-256-GCM
- Saves: [salt][nonce][ciphertext]
- Sets output file to 0600 permissions
# Decrypt (automatically removes .enc extension)
./target/release/secure-file-tool decrypt -i myfile.txt.enc
# Decrypt with custom output name
./target/release/secure-file-tool decrypt -i encrypted.bin -o decrypted.txt
# Enter the same password used for encryptionWhat happens:
- Prompts for password
- Reads salt and nonce from file
- Derives key using Argon2id
- Attempts decryption
- Verifies authenticity tag (detects tampering)
- Saves decrypted file
# Check a single file
./target/release/secure-file-tool check-perms myfile.txt
# Check all files in a directory (non-recursive)
./target/release/secure-file-tool check-perms /path/to/directory
# Check directory recursively
./target/release/secure-file-tool check-perms -r /path/to/directorySecurity checks performed:
⚠️ CRITICAL: World-writable files (anyone can modify)⚠️ WARNING: Sensitive files readable by everyone (.key, .pem, "secret", "private")⚠️ WARNING: Group-writable files- ℹ️ INFO: Executable bits on non-executable files
./target/release/secure-file-tool encrypt -i ~/.ssh/id_rsa -o id_rsa.enc
# Then securely delete original: shred -u ~/.ssh/id_rsa./target/release/secure-file-tool check-perms -r ~# Encrypt
./target/release/secure-file-tool encrypt -i confidential.pdf
# Send confidential.pdf.enc via email/transfer
# Share password through separate secure channel (Signal, phone call, etc.)
# Recipient decrypts
./target/release/secure-file-tool decrypt -i confidential.pdf.enc-
Password Management
- Use strong, unique passwords (16+ characters recommended)
- Never reuse encryption passwords
- Consider using a password manager
- Share passwords through separate secure channels
-
File Handling
- Securely delete original files after encryption:
shred -u original.txt - Don't email passwords with encrypted files
- Verify file integrity after transfers
- Keep backups of important encrypted files
- Securely delete original files after encryption:
-
Permissions
- Keep encrypted files at 0600 or 0400 (read-only)
- Never make encrypted files world-readable
- Regularly audit permissions with the check-perms command
-
System Security
- Keep your system updated
- Use full-disk encryption
- Encrypt swap space
- Use secure boot
- Monitor system logs
Encrypted files use this structure:
[16 bytes: Salt] [12 bytes: Nonce] [Variable: Ciphertext + Auth Tag]
- Salt is used for key derivation (unique per file)
- Nonce is used for encryption (unique per file)
- Ciphertext includes 16-byte authentication tag (GCM mode)
aes-gcm- AES-GCM implementation (RustCrypto)argon2- Argon2id key derivationrand- Cryptographically secure randomness
- LTO (Link-Time Optimization) enabled
- Maximum optimization level
- Single codegen unit for better optimization
- Debug symbols stripped
- No unsafe code in main logic
- Sensitive data zeroized after use
- Rust's ownership prevents memory bugs
- No null pointer dereferences possible
- Designed for files, not streaming data
- Entire file loaded into memory during encryption/decryption
- Maximum file size limited by available RAM
- Password-based encryption only (no key files or certificates)
- Unix/Linux only (uses Unix file permissions)
"Decryption failed - wrong password or corrupted file"
- Verify you're using the correct password
- Check if file was corrupted during transfer (verify checksums)
- Ensure complete file was transferred
"Permission denied"
- Check you have read access to input file
- Check you have write access to output directory
- Run with appropriate user permissions
Build errors
- Ensure Rust 1.70+ is installed:
rustc --version - Update Rust:
rustup update - Clean build:
cargo clean && cargo build --release
This is demonstration security software. Review and audit before production use.
Security improvements welcome! Please report vulnerabilities responsibly.
Before using in production:
- Review all source code
- Run security audit:
cargo audit - Test with various file sizes
- Verify password strength requirements
- Test error handling
- Review cryptographic parameters
- Check for memory leaks:
valgrind - Fuzz test encryption/decryption