Skip to main content

Create encrypted files whose decryption key is split and shared between multiple individuals.

Project description

Sharelock


  • Command line tool to create encrypted files whose decryption key is split and shared between multiple individuals.
  • The program uses Shamir's Secret Sharing, meaning that you can specify the number of keys and how many keys are required to decrypt the data.
  • This program is mainly useful in situations where high security is required.
    • For example, a database dump could be piped into this program.
      • The dump would be encrypted with a split key shared among some number of database administrators.
      • If one or two administrator keys were compromised, the data would still be secure.
      • The tradeoff is that the number of compromised administrators for a succesful attack is the same number that would be needed to restore the backup.

Security Warning


  • This tool is in early development.
  • Although it uses established cryptographic libraries to handle encryption/decryption, it has not been independently audited.
  • Use this software to protect sensitive data at your own risk.

Install


Pip

pip install sharelock

# Verify installation
sharelock -h

From source

git clone https://www.github.com/holden_wells/sharelock.git

cd sharelock

pip install .

# Verify installation
sharelock -h

How it works


  • Sharelock has three main modes:

Generation

  1. Generate Private/Public Key Encryption Key Pair
  2. Save the Public key to a file
  3. Split the Private key using Shamir's Secret Sharing and write to stdout
  • This split key pieces should be securely distributed to their responsible parties.
  • Whatever threshold is specified at key creation time is the number of key pieces required to decrypt the data.

Encryption

  1. Take in a file on stdin
  2. Generate a Symetric Data Encryption Key
  3. Encrypt stdin using the Data Encryption Key and write to an output file
  4. Encrypt the Data Encryption Key using the Key Encryption Key's Public Key
  5. Write the encrypted Data Encryption Key to an output file

Decryption

  1. Take in a file via cli args
  2. Take in key shares on stdin
  3. Combine the key shares to derive the Private Key Encryption Key
  4. Decrypt the Data Encryption Key using the Private Key
  5. Decrypt the Encrypted Data File using the Decrypted Data Encryption Key

Basic Usage


Generate

usage: sharelock.py generate [-h] [-k KEK_FILE] -s SHARES -t THRESHOLD [-q QUIET]

options:
  -h, --help            show this help message and exit
  -k, --kek-file KEK_FILE
                        Path to Public Key Encryption Key file
  -s, --shares SHARES   The number of key shares to break the generate Key Encryption Key into
  -t, --threshold THRESHOLD
                        The number of key shares required to perform decryption ( Should be <= the
                        number of shares )
  -q, --quiet QUIET     Whether or not to print additional instructions to the user.
  • Command for generating a random Key Encryption Key
  • The value of 'SHARES' is how many keys will be created to be shared with responsible individuals
    • These key shares will only ever be printed to stdout once and there is no way to recover them or the encrypted data if too many of them are lost
  • The Public Key Encryption Key will be written to the file supplied with '-k'.

Encrypt

usage: sharelock.py encrypt [-h] -o OUTPUT_FILE [-d DEK_FILE] [-k KEK_FILE]

options:
  -h, --help            show this help message and exit
  -o, --output-file OUTPUT_FILE
                        File to which to write encrypted data ( use - for stdout )
  -d, --dek-file DEK_FILE
                        Path at which Data Encryption Key file will be written
  -k, --kek-file KEK_FILE
                        Path to Public Key Encryption Key file
  • Command for encrypting a file on stdin.
  • The "-d" and "-k" arguments are optional overrides and will use a default file name if left empty.
  • This will generate the output file at "-o" and the DEK file at "-d" and requires the public key file at "-k"

Decrypt

usage: sharelock.py decrypt [-h] -i INPUT_FILE [-d DEK_FILE]

options:
  -h, --help            show this help message and exit
  -i, --input-file INPUT_FILE
                        File from which to read encrypted data and attempt decryption
  -d, --dek-file DEK_FILE
                        Path from which to read the encrypted Data Encryption Key
  • Command for decrypting a file and writing its contents to stdout.
  • The "-d" argument is an optional override and will use a default file name if left empty.

Planned Updates


  • 0.2.0
    • Ability to roll Key Encryption Keys in case of lost or stolen key
  • 0.3.0
    • Stricter file integrity checks
  • 1.0.0
    • Use a basic file format that stores the Public Key Encryption Key and Data Encryption Key with the data
    • Ability to use a keyring that stores public keys per user.
      • Ability to add or remove a public key by name

Licensed under the MIT License - see LICENSE for details. Third-party licenses: see THIRDPARTYLICENSES

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

sharelock-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

sharelock-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file sharelock-0.1.0.tar.gz.

File metadata

  • Download URL: sharelock-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sharelock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d18b88ff9cfed99a9575045e7fefc902e7b6b5eb43c287f33f889471f54315dd
MD5 6be8e1f6c920fd28962f48045b033fec
BLAKE2b-256 3ea4959bc60fa97c961c79dd1ef86b0c9da717b99c391b9296e4785bc516f8f8

See more details on using hashes here.

File details

Details for the file sharelock-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sharelock-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sharelock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31a4c2986e8c51d25795400ce7bbe26e878fc54914d85e5d3dedb48a97b3df22
MD5 34d36901ea02246ce16878db77ea8e95
BLAKE2b-256 c2e11e6ec12f6eeeceec4d22a526f7429b6a4ea6a6d92c62a69e2f3fefb616a9

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