Skip to main content

A command line tool to help with key-to-paper and paper-to-key.

Project description

secrets-to-paper

A command-line tool to convert secret keys to printable PDFs and to parse those PDFs back to usable secret keys.

Note: Python 3.10+ is required to use this package. Python 3.8 introduced a new computation for modular inverses.

Changed in version 3.8: For int operands, the three-argument form of pow now allows the second argument to be negative, permitting computation of modular inverses.

Dependencies

  • paperkey source / Debian Package

    paperkey is a command line tool to export GnuPG keys on paper. It reduces the size of the exported key, by removing the public key parts from the private key. Paperkey also includes CRC-24 checksums in the key to allow the user to check whether their private key has been restored correctly.

  • zbar source / Debian Package

    for reading QR codes (2D matrix)

USB Scanner

https://github.com/libusb/hidapi

Note: in Linux, USB devices follow a path like this:

Kernel:

  • usb core
  • ushbid (a Linux kernel driver)
  • hid subsystem
  • input subsystem
  • event devices

Userspace:

  • libinput (a library for handling Linux input devices /dev/input/)
  • libinput Xorg driver
  • Xorg or Wayland Compositor driver (which uses the libinput library)
  • mouse drawn on the screen

Webcam Imports

You can also use a webcam with OpenCV to read QR codes.

Ubuntu/Linux

Add PPA

sudo apt install software-properties-common
sudo add-apt-repository ppa:jaredvacanti/security-dev
sudo apt-get update

# install the package
sudo apt install python3-secrets-to-paper

MacOS X

brew tap jaredvacanti/taps
brew install secrets-to-paper

Usage

Usage: stp [OPTIONS] COMMAND [ARGS]...

Options:
  --debug / --no-debug
  --help                Show this message and exit.

Commands:
  export      Helper functions for writing secret keys to paper.
  export-gpg  Helper functions for writing GPG keys to paper.
  gen         Helper function to generate RSA private key from P and Q or ECC
              private key from A, B, and D.
  parse       Helper functions to parse paper keys into usable PEM format.

Development

Initializing a virtual environment

# requires >= python3.10
pyenv shell 3.10

# init & activate virtualenvironment
python -m venv .venv
source .venv/bin/activate

# install poetry in venv, and use to install local package
pip install --upgrade pip
pip install poetry
poetry install

This makes an executable stp available in your $PATH after poetry installations. During development, it's often more convenient to run

poetry run stp ...

instead of re-installing before invocations.

Using GPGME

This is not installed from PyPI.

https://github.com/gpg/gpgme/blob/master/lang/python/doc/src/gpgme-python-howto.org

it appears that a copy of the compiled module may be installed into a virtualenv of the same major and minor version matching the build. Alternatively it is possible to utilise a sites.pth file in the site-packages/ directory of a virtualenv installation, which links back to the system installations corresponding directory in order to import anything installed system wide. This may or may not be appropriate on a case by case basis.

You can link the system installed version into your virtual environment during development:

ln -s /usr/lib/python3/dist-packages/gpg/ .venv/lib/python3.10/site-packages/

# delete the link
rm -rf .venv/lib/python3.10/site-packages/gpg/

Building Debian Package

git checkout debian/master
gbp buildpackage

Testing

You can generate a private and public key for testing purposes using openssl.

poetry run pytest

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

secrets_to_paper-0.0.13.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

secrets_to_paper-0.0.13-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file secrets_to_paper-0.0.13.tar.gz.

File metadata

  • Download URL: secrets_to_paper-0.0.13.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.12 Linux/6.2.0-35-generic

File hashes

Hashes for secrets_to_paper-0.0.13.tar.gz
Algorithm Hash digest
SHA256 8b76d5feda6ed4cbc56459d81dcc130987015e01786732be04c17d6df7907740
MD5 1bf8b7f1bd4a7c450eb9e21c67cb83b9
BLAKE2b-256 774cdcd13f254e66672a004c8a59b494f289fd0f1e24d5da175cf2cf5ca3df4f

See more details on using hashes here.

File details

Details for the file secrets_to_paper-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: secrets_to_paper-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.12 Linux/6.2.0-35-generic

File hashes

Hashes for secrets_to_paper-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 0b79c4a14d075d95fef708f0a135ca491123ac0a27856a47010f8e6beffeb2d8
MD5 311bd0a2c53c456e7c9681c6758abea9
BLAKE2b-256 ddf0475f6dbd3ecd4c0daa206ad2393fa23f4aad6705ffa73a2e11a817bfd10a

See more details on using hashes here.

Supported by

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