Skip to main content

A CLI tool for Unix-like environments to encrypt a RTTY session using NaCl

Project description

rtty-soda

A CLI tool for Unix-like environments to encrypt a RTTY session using NaCl.

Features

  • Public Key encryption (Curve25519-XSalsa20-Poly1305)
  • Secret Key encryption (XSalsa20-Poly1305)
  • Key derivation (Argon2id-Blake2b)
  • Text compression (brotli, zstd, zlib, bz2, lzma)
  • Custom encodings:
    • Base26 (Latin)
    • Base31 (Cyrillic)
    • Base36 (Latin with numbers)
    • Base64 (RFC 4648)
    • Base94 (ASCII printable)
    • Binary

Installation

Package manager

  1. Install uv
  2. Install rtty-soda:
    % uv tool install "rtty-soda[cli]"
    
  3. Remove rtty-soda:
    % uv tool uninstall rtty-soda
    

Docker

% docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.3.8
% docker run -it --rm -h rtty-soda -v .:/app/host nett/rtty-soda:0.3.8-tools

Getting help

All commands have [-h | --help] option.

% soda
Usage: soda [OPTIONS] COMMAND [ARGS]...

Options:
  --version   Show the version and exit.
  -h, --help  Show this message and exit.

Commands:
  decrypt-password (dp)  Decrypt Message (Password).
  decrypt-public (d)     Decrypt Message (Public).
  decrypt-secret (ds)    Decrypt Message (Secret).
  encode                 Encode File.
  encrypt-password (ep)  Encrypt Message (Password).
  encrypt-public (e)     Encrypt Message (Public).
  encrypt-secret (es)    Encrypt Message (Secret).
  genkey                 Generate Private Key.
  kdf                    Key Derivation Function.
  pubkey                 Get Public Key.

Some commands have aliases, so % soda encrypt-password ... and % soda ep ... are equivalent.

Public Key encryption

Key generation

% soda genkey | tee alice | soda pubkey - | tee alice_pub
vIvNpFgG54XCI9wBhx+ttgF9W4PXDpJC0IeUY0oiilo=

% soda genkey | tee bob | soda pubkey - | tee bob_pub
3Zqm1I1c9Oi7Vc8zcfC2cnF0ViRwhGwAfDK8SrB4f28=

% soda genkey -h
Usage: soda genkey [OPTIONS]

  Generate Private Key.

  Encoding: base26 | base31 | base36 | base64 | base94 | binary

Options:
  -e, --encoding TEXT     [default: base64]
  -o, --output-file FILE  Write output to file.
  --group-len INTEGER     [default: 0]
  --line-len INTEGER      [default: 80]
  --padding INTEGER       [default: 0]
  -v, --verbose           Show verbose output.
  -h, --help              Show this message and exit.

Encryption

Alice sends the message to Bob:

% cat message
A telegraph key is a specialized electrical switch used by a trained operator to
transmit text messages in Morse code in a telegraphy system.
The first telegraph key was invented by Alfred Vail, an associate of Samuel Morse.
(c) Wikipedia

% soda encrypt-public alice bob_pub message | tee encrypted | cut -c 1-80
XCo7tFf0fjnKALbnYTi1FZGNlwM60Jgvwmv2fLjKZEOn6U5asMB46VNXDlKbh5jtJFUxudq2mb3MfgYV

% soda encrypt-public -h
Usage: soda encrypt-public [OPTIONS] PRIVATE_KEY_FILE PUBLIC_KEY_FILE
                           MESSAGE_FILE

  Encrypt Message (Public).

  Encoding: base26 | base31 | base36 | base64 | base94 | binary

  Compression: brotli | zstd | zlib | bz2 | lzma | raw

Options:
  -t, --text                Treat message as text (binary if not specified).
  --key-encoding TEXT       [default: base64]
  -e, --data-encoding TEXT  [default: base64]
  -c, --compression TEXT    [default: brotli]
  -o, --output-file FILE    Write output to file.
  --group-len INTEGER       [default: 0]
  --line-len INTEGER        [default: 80]
  --padding INTEGER         [default: 0]
  -v, --verbose             Show verbose output.
  -h, --help                Show this message and exit.

Decryption

% soda decrypt-public bob alice_pub encrypted
A telegraph key is a specialized electrical switch used by a trained operator to
transmit text messages in Morse code in a telegraphy system.
The first telegraph key was invented by Alfred Vail, an associate of Samuel Morse.
(c) Wikipedia

Secret Key encryption

Alice and Bob share a key for symmetric encryption:

% soda genkey > shared
% soda encrypt-secret shared message -o encrypted
% soda decrypt-secret shared encrypted -o message

Another day, they share a password:

% echo qwerty | soda encrypt-password - message -p interactive -o encrypted
% echo qwerty | soda decrypt-password - encrypted -p interactive -o message

Key derivation

The KDF function derives the key from the password. It accepts different profiles: interactive, moderate, and sensitive.

% echo qwerty | soda kdf - -p interactive
HqbvUXflAG+no3YS9njezZ3leyr8IwERAyeNoG2l41U=

% soda kdf -h
Usage: soda kdf [OPTIONS] PASSWORD_FILE

  Key Derivation Function.

  Encoding: base26 | base31 | base36 | base64 | base94 | binary

  Profile: interactive | moderate | sensitive

Options:
  -e, --encoding TEXT     [default: base64]
  -p, --profile TEXT      [default: sensitive]
  -o, --output-file FILE  Write output to file.
  --group-len INTEGER     [default: 0]
  --line-len INTEGER      [default: 80]
  --padding INTEGER       [default: 0]
  -v, --verbose           Show verbose output.
  -h, --help              Show this message and exit.

Text compression

That works as follows:

  1. The plaintext is prepared:
    • In binary mode (default), the message is read as bytes
    • In text mode (-t, --text), the message is read as a string, stripped, and encoded with SCSU, reducing the size of Unicode messages by 15–50%
  2. The plaintext is compressed with the compression lib
  3. The 16-byte MAC and 24-byte nonce are added
  4. The result is encoded with Base64, which adds ~33% overhead
% soda es shared message -t -v -c brotli > /dev/null
Plaintext: 238
Ciphertext: 216
Overhead: 0.908
Groups: 1
% soda es shared message -t -v -c zstd > /dev/null
Plaintext: 238
Ciphertext: 276
Overhead: 1.160
Groups: 1
% soda es shared message -t -v -c zlib > /dev/null
Plaintext: 238
Ciphertext: 280
Overhead: 1.176
Groups: 1
% soda es shared message -t -v -c bz2 > /dev/null
Plaintext: 238
Ciphertext: 336
Overhead: 1.412
Groups: 1
% soda es shared message -t -v -c lzma > /dev/null
Plaintext: 238
Ciphertext: 320
Overhead: 1.345
Groups: 1
% soda es shared message -t -v -c raw > /dev/null
Plaintext: 238
Ciphertext: 372
Overhead: 1.563
Groups: 1

Encoding

The rtty-soda supports various encodings:

% soda encrypt-public alice bob_pub message --data-encoding base36 --group-len 5 --text
1CF5T OXYFQ 2VGTE 3CCWO S36TX SZXV8 MSXDB JEBMS FZ0AC WZBD5 ZJ4AX FAON4 NYKOM
U9MYD 0ZRJP SWHJH P7H4B CBSC1 M9Z2K VYSD3 JJW5R 9TVLF OANVZ 0O7AQ G2KS7 6W3HB
GBU85 AKR5E XLS8K 7GMXT E6NH1 UQM53 BFEZ0 RB86O P6W0M CSVYO NXRMA JM5I2 O14TZ
CPIU1 LHZSL X8B0U ZUDNJ 6EDF9 74OYS 591KN AHWOK 31MY3 6UK8V EGO

Environment variables

Common options can be set in the environment variables:

% cat ~/.soda/bin.env
SODA_TEXT=0
SODA_KEY_ENCODING=binary
SODA_DATA_ENCODING=binary
SODA_COMPRESSION=brotli
SODA_KDF_PROFILE=sensitive
SODA_GROUP_LEN=0
SODA_LINE_LEN=0
SODA_PADDING=0
SODA_VERBOSE=0

Alternative usage

  • Password source

    % echo "A line from a book or a poem" | soda kdf - -e base94 -p interactive
    x\R9"~8Ujh^_uh:Ty<!t(ZNzK=5w^ukew~#-x!n
    
  • WireGuard keyer

    % echo "A line from a book or a poem" | soda kdf - -p interactive -o privkey
    % cat privkey
    uIoBJdgaz8ZP3/n/9KzdUNvFi7DxbUQdQ9t8ujwGnMk=
    % soda pubkey privkey
    F2B674kXVcTznnRPWCVasx1miCT+yUtXQ3P5Ecee4zI=
    % cat privkey | wg pubkey
    F2B674kXVcTznnRPWCVasx1miCT+yUtXQ3P5Ecee4zI=
    

Compatibility

During the initial development (versions prior to 1.0.0), I can break backwards compatibility.

Releases

This project follows a rolling release cycle. Each version bump represents where I completed a full test cycle. When testing passes successfully, I commit and release - so every release is a verified stable point.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtty_soda-0.3.8.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rtty_soda-0.3.8-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file rtty_soda-0.3.8.tar.gz.

File metadata

  • Download URL: rtty_soda-0.3.8.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rtty_soda-0.3.8.tar.gz
Algorithm Hash digest
SHA256 8f7813495228dbce6f4d6f7cbec7a9b6c1ac17a565cab527e685237a4f50d42b
MD5 6411bf96cc34b7cbd238be3209a4764c
BLAKE2b-256 62c1bfea44ba64e045e282ff499078878e3fa6a856f6ce3eca946a4d4d351e55

See more details on using hashes here.

File details

Details for the file rtty_soda-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: rtty_soda-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rtty_soda-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 610ac40d41f54e62cbe09f9e8c9f5d204658df2925af76dd02f1d2a1d4f77940
MD5 9687f4af2a0fffd750cf7c287b9fbc38
BLAKE2b-256 c1c49955ea5ee15a590ff3ac0dafd85e2d53a07d5e2a8e8eb400c382fb7cd045

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page