ssh-box: use ssh keys to encrypt files

Related tags

Cryptography ssh-box
Overview

ssh-box: use ssh keys to encrypt files

work in progress

ssh-box file format

A file encrypted by ssh-box is an ASCII-armored binary file. The binary consists of a header followed by the ciphertext.

ASCII armor

The binary file is base64-encoded and delimited by prefix and suffix lines. For example,

-----BEGIN SSH-BOX ENCRYPTED FILE-----
c3NoLWJveC12MQAAAAABAAAAC3NzaC1lZDI1NTE5AAAAIHRE3hd+N+jMlLuQsnB/IozFl/5O
4SBvM4uWlCN+Fs8PAAAAAmVnAAAAaKZcNtnpfC0VwHKA2EX/s7zNyuSraWc9xGVmpYJqeKMC
Py10Oi9sXUN/Q4Kk9aNvbSXVaXQz76Q94cGT89pPx/lD5QusSNxmc8F1PmaGlakDwinczXT7
JDoDtw/CJDXQ7qdnt/OVDnTRDakxZU+eGgRVMeiwAgkzphgDXFN0IXvW
-----END SSH-BOX ENCRYPTED FILE-----

header

The header is encoded in ssh style, using data types from RFC 4251 section 5.

It starts with a nul-terminated string to indicate the file format and version number, "ssh-box-v1\0".

After the version string is a uint32 that counts the number of recipients that can decrypt the file.

Each recipient has four fields:

    string    key type, always "ssh-ed25519"
    string    ssh public key blob
    string    human-readable public key comment
    string    encrypted AEAD nonce and key

(Each line in an OpenSSH authorized keys or public key file contains the key type in ASCII, followed by a base64-encoded blob, followed by the comment. The base64 blob has the same contents as the first two recipient fields above. These two fields frequently occur together in the SSH protocol.)

The comment is only used when listing an encrypted file's recipients.

encryption

When encrypting a file, a fresh AEAD nonce and key are generated, and concatenated into a secret blob without any framing. (They have fixed sizes determined by the AEAD construction, which is also fixed.)

Each recipient's ssh public key is converted using libsodium crypto_sign_ed25519_pk_to_curve25519() and the resulting key used to encrypt the secret blob using libsodium crypto_box_seal().

decryption

When decrypting a file, the header is searched for a recipient whose key type and public key blob match the user's ssh key.

The user's ssh key pair is converted using libsodium crypto_sign_ed25519_pk_to_curve25519() and crypto_sign_ed25519_sk_to_curve25519(), and the resulting key pair used to decrypt the AEAD secret blob using libsodium crypto_box_seal_open().

ciphertext

The file's contents follow immediately after the header. The file is encrypted using libsodium's XChaCha20-Poly1305 AEAD construction, with the file's contents as the message and the header as the additional data.

todo

  • RSA support

licence

This was written by Tony Finch <[email protected]>
You may do anything with it. It has no warranty.
https://creativecommons.org/publicdomain/zero/1.0/
SPDX-License-Identifier: CC0-1.0

You might also like...
Convert private keys to PKCS#8 format in pure Rust

topk8 Convert private keys to PKCS#8 format in pure Rust. The following formats are supported at the moment: PKCS#1 PEM (RSA PRIVATE KEY) SEC1 PEM (EC

A tool to identify related SSL keys, CSRs, and certificates.

⛓ sslchains A tool to identify related SSL keys, CSRs, and certificates. Usage Default Display Mode Run with any number of path arguments to define th

MimiRust - Hacking the Windows operating system to hand us the keys to the kingdom with Rust
MimiRust - Hacking the Windows operating system to hand us the keys to the kingdom with Rust

MimiRust - Hacking the Windows operating system to hand us the keys to the kingdom with Rust

Project Masterpass is a deterministic databaseless key management algorithm, aimed to help those who cannot protect their encryption keys in storage

Project Masterpass (working title) Attention! This project is still under heavy development, and SHOULD NOT be used in practice, as the algorithms cou

Ethereum key tool - Lightweight CLI tool to deal with ETH keys written in rust

ekt - Etherum Key Tool ekt is a lightweight tool to generate ethereum keys and addresses. Installation Either clone it and run it with cargo or instal

In addition to encryption library, pure RUST implementation of SSH-2.0 client protocol

In addition to encryption library, pure RUST implementation of SSH-2.0 client protocol

Pure Rust implementation of components of the Secure Shell (SSH) protocol

RustCrypto: SSH Pure Rust implementation of components of the Secure Shell (SSH) protocol. Crates Name crates.io Docs Description ssh—encoding Decoder

An easy-to-use CLI tool to recover files from zfs snapshots

zfs-undelete an easy-to-use cli tool to recover files from zfs snapshots Usage Use zfs-undelete file-to-restore. Works for file and folders. By defa

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Comments
  • any plans for automatic encryption/description of git repository files

    any plans for automatic encryption/description of git repository files

    Such that it functions akin to these:

    • https://github.com/StackExchange/blackbox
    • https://github.com/AGWA/git-crypt
    • https://github.com/elasticdog/transcrypt
    • https://github.com/jswidler/lockgit

    As ssh-box uses ssh keys, it should be way easier and more automatic than all the above solutions.

    opened by balupton 1
Owner
Tony Finch
Tony Finch
Retrieving SSH and GPS keys from GitHub and GitLab

Dormarch Retrieving SSH and GPS keys from GitHub and GitLab Usage After having installed Dormarch, you can see all the options with dormarch -h. To re

Riccardo Padovani 2 Dec 24, 2021
Authorize an ssh session using your keys on GitHub.

GitHub AuthorizedKeysCommand (hubakc) Heavily inspired by https://github.com/sequencer/gitakc . It allows someone login to the server using their ssh

Wenzhuo Liu 5 Nov 11, 2022
Git FIDO Helper - Sign your Git commits with multiple resident SSH keys

gfh Git FIDO helper, or God Fucking Help me. gfh is a tool for helping you sign your commits in Git with resident SSH keys stored on multiple FIDO dev

Michael Mitchell 16 Nov 30, 2022
Encrypt your files in cow language 🐄

Cow-encryptor Encrypt your files in cow language ?? Installation ?? Arch Linux ?? cow-encryptor is in the AUR yay -S cow-encryptor Other ?? ?? With ma

Skwal 2 Sep 19, 2022
A simple self-contained CLI tool that makes it easy to efficiently encrypt/decrypt your files.

cryptic A simple self-contained CLI tool that makes it easy to efficiently encrypt/decrypt your files. Contents Features Building Usage License Featur

Arthur Ivanets 5 May 2, 2023
Use Touch ID / Secure Enclave for SSH Authentication!

SeKey About SeKey is a SSH Agent that allow users to authenticate to UNIX/Linux SSH servers using the Secure Enclave How it Works? The Secure Enclave

SeKey 2.3k Jan 5, 2023
Benson Box built on Substrate for a world UNcorporated.

Benson Box built on Substrate. For getting started and technical guides, please refer to the Benson Wiki.

Arthur·Thomas 13 Mar 13, 2022
A secure development tool box and fintech application made with Rust to be used for developing cryptocurrencies on the blockchain.

Crypto Fintech Tools for Rust (CFT) Dependencies Rust MacOS Homebrew # xcode cli tools xcode-select --install # install dependencies using Homebrew b

Phil Hills 1 Apr 15, 2022
A black-box raw calldata decoder using only calldata to guess types and parse parameters.

Calldata Decoder A black-box raw calldata decoder using only calldata. Based off the topics discussed in DeGatchi's article, Reverse The EVM: Raw Call

DeGatchi 78 Jan 24, 2023
A collection of algorithms that can do join between two parties while preserving the privacy of keys on which the join happens

Private-ID Private-ID is a collection of algorithms to match records between two parties, while preserving the privacy of these records. We present tw

Meta Research 169 Dec 5, 2022