bletchley

package module
v0.0.0-...-83a7d0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2018 License: MIT Imports: 12 Imported by: 0

README

bletchley GoDoc

Bletchley is a simple command line application for basic public key based file exchange.

Usage

Suppose Alice has a file of secret information that she wants to share with her coworker, Bob. They regularly communicate, so authentication is not an issue. The issue is that Alice does not want her secrets to be in some email attachment, Slack history, or S3 bucket for an indefinite period of time, and she doesn't necessarily trust the network not to eavesdrop on her file exchange. Alice and Bob agree to exchange the file using bletchley.

  • Alice asks Bob to run bletchley-create to create a public/private key pair for himself.
  • Bob sends Alice his public.pem file through their normal communication channel. She saves it as bob.pem.
  • Alice runs bletchley-encode -key-src bob.pem -msg-src secrets.txt -cipher-dest secrets.pem.
  • Alice sends Bob her secrets.pem file through their normal communication channel.
  • Bob runs bletchley-decode -key-src private.pem -cipher-src secrets.pem -msg-dst secrets.txt.
  • Alice and Bob go back to work.

Installation

First install Go.

If you just want to install the binary to your current directory and don't care about the source code, run

GOBIN="$(pwd)" GOPATH="$(mktemp -d)" go get github.com/carlmjohnson/bletchley/...

Screenshots

$ bletchley-create -h
bletchley-create generates a new public/private RSA key pair.

Use -src to extract the public component out of an existing private key PEM
file. In that case, -bit-size and -private-dest will be ignored.

Usage of bletchley-create:

  -bit-size int
        bit size for RSA key (default 4096)
  -private-dest string
        file to save private key to (default "private.pem")
  -public-dest string
        file to save public key to (default "public.pem")
  -src string
        private key to extract public key from

$ bletchley-encode -h
bletchley-encode generates a one time use password and encodes it with a public
RSA key so that only the possessor of the private key can decode it, then
encodes the message with the one time use password.

Usage of bletchley-encode:

  -cipher-dest string
        file to save encrypted ciphertext into (default "cipher.pem")
  -key-src string
        public key to encode message with (default "public.pem")
  -msg-src string
        file to encrypt (default "-")

$ bletchley-decode -h
bletchley-decode decodes a bletchley cipher PEM file.

Usage of bletchley-decode:

  -cipher-src string
        file to decrypt (default "cipher.pem")
  -key-src string
        private key to decode cipher with (default "private.pem")
  -msg-dest string
        file to save decrypted message into (default "-")
        
Bob $ bletchley-create -private-dest private.pem -public-dest public.pem

... Bob sends public.pem ...

Alice $ bletchley-encode -key-src public.pem -msg-src <(echo 'Hello, World!') -cipher-dest cipher.txt

... Alice sends cipher.txt ...

Bob $ bletchley-decode -key-src private.pem -cipher-src cipher.txt
Hello, World!

Acknowledgements

Bletchley is based on code from github.com/gtank/cryptopasta/.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMessage

func DecodeMessage(key, ciphertext []byte, prv *rsa.PrivateKey) ([]byte, error)

func DecodeMessagePEM

func DecodeMessagePEM(w io.Writer, cipherpems []byte, prv *rsa.PrivateKey) error

func DecodePEMType

func DecodePEMType(pemContents []byte, blockType string) ([]byte, error)

func DecodePrivateKeyPEM

func DecodePrivateKeyPEM(pemContents []byte) (*rsa.PrivateKey, error)

func DecodePublicKeyPEM

func DecodePublicKeyPEM(pemContents []byte) (*rsa.PublicKey, error)

func Decrypt

func Decrypt(ciphertext []byte, key *[32]byte) (plaintext []byte, err error)

Decrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.

func EncodeMessage

func EncodeMessage(plaintext []byte, pub *rsa.PublicKey) (otp *[32]byte, key, ciphertext []byte, err error)

func EncodeMessagePEM

func EncodeMessagePEM(w io.Writer, plaintext []byte, pub *rsa.PublicKey) error

func EncodePrivateKeyPEM

func EncodePrivateKeyPEM(w io.Writer, key *rsa.PrivateKey) error

func EncodePublicKeyPEM

func EncodePublicKeyPEM(w io.Writer, key *rsa.PublicKey) error

func Encrypt

func Encrypt(plaintext []byte, key *[32]byte) (ciphertext []byte, err error)

Encrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.

func NewEncryptionKey

func NewEncryptionKey() *[32]byte

NewEncryptionKey generates a random 256-bit key for Encrypt() and Decrypt(). It panics if the source of randomness fails.

func NewRSAPrivateKey

func NewRSAPrivateKey(bitSize int) *rsa.PrivateKey

func ReadPrivateKeyPEM

func ReadPrivateKeyPEM(fileName string) (*rsa.PrivateKey, error)

func ReadPublicKeyPEM

func ReadPublicKeyPEM(fileName string) (*rsa.PublicKey, error)

func SavePrivateKeyPEM

func SavePrivateKeyPEM(fileName string, key *rsa.PrivateKey) error

func SavePublicKeyPEM

func SavePublicKeyPEM(fileName string, key *rsa.PublicKey) error

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL