Skip to content

Commit

Permalink
Add information on how to use hybrid cryptography (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne authored Dec 28, 2020
1 parent 06d10e8 commit 0af2a5b
Showing 1 changed file with 42 additions and 14 deletions.
56 changes: 42 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ brew install nakabonne/pbgopy/pbgopy
#### RHEL/CentOS

```
rpm -ivh https://github.com/nakabonne/pbgopy/releases/download/v0.2.1/pbgopy_0.2.1_linux_amd64.rpm
rpm -ivh https://github.com/nakabonne/pbgopy/releases/download/v0.3.0/pbgopy_0.3.0_linux_amd64.rpm
```

#### Debian/Ubuntu

```
wget https://github.com/nakabonne/pbgopy/releases/download/v0.2.1/pbgopy_0.2.1_linux_amd64.deb
apt install ./pbgopy_0.2.1_linux_amd64.deb
wget https://github.com/nakabonne/pbgopy/releases/download/v0.3.0/pbgopy_0.3.0_linux_amd64.deb
apt install ./pbgopy_0.3.0_linux_amd64.deb
```

#### Arch Linux
Expand Down Expand Up @@ -79,49 +79,77 @@ pbgopy paste >foo.png
## Options

### End-to-end encryption
`pbgopy` comes with a built-in ability to encrypt/decrypt with a symmetric-key. Hence allows you to perform end-to-end encryption without working with external tools.
`pbgopy` comes with a built-in ability to encrypt/decrypt with a variety of keys.

You can derive the key from password with the `-p` flag.
#### With symmetric-key

You can derive the key from password with the `-p` flag, which is provided so that you can encrypt/decrypt without previous setting.
```bash
pbgopy copy -p your-password <secret.txt
pbgopy copy -p your-password <plaintext.txt
```

```bash
pbgopy paste -p your-password
```

This flag is provided so that you can encrypt/decrypt without previous setting. Be aware that this way cannot prevent a dictionary attack.
Be aware that this way cannot prevent a dictionary attack.

For more safety, it is highly recommended to use a 32-bytes symmetric key generated by other methods.
The `-k` flag or the `PBGOPY_SYMMETRIC_KEY_FILE` environment variable is available to indicate the path to key file.

```bash
pbgopy copy -k /path/to/pbgopy.key <secret.txt
pbgopy copy -k /path/to/pbgopy.key <plaintext.txt
```

### Authentication
HTTP Basic Authentication is available with `-a` flag.
#### With public/private key-pair
`pbgopy` can also encrypt using hybrid cryptosystem. If you have already exchanged public keys between devices you want to share data with, this is the way to go.

```bash
pbgopy serve -a user:pass
pbgopy copy --public-key-file /path/to/public.key <plaintext.txt
```

```bash
pbgopy copy -a user:pass <foo.png
pbgopy paste --private-key-file /path/to/private.key <plaintext.txt
```

You manage your keyring in GPG? The `--gpg-user-id` (`-u`) flag is for you!
Suppose you want to encrypt with a public key whose user id is `alice`:

```bash
pbgopy paste -a user:pass >foo.png
pbgopy copy -u alice <plaintext.txt
```

Then you decrypt it with the private key by specifying the user id on another device:

```bash
pbgopy paste -u alice
```

There are a couple of ways to specify a user ID. Visit [here](https://www.gnupg.org/documentation/manuals/gnupg/Specify-a-User-ID.html) to see the entire list.

### TTL
You can set TTL for the cache. Give `0s` for disabling it. Default is `24h`.
If you don't want more data to be cached on the server than necessary, use the `--ttl` flag to set TTL for the cache.
Give `0s` for disabling it. Default is `24h`.

```bash
pbgopy serve --ttl 10m
```

### Authentication
HTTP Basic Authentication is available with `-a` flag.

```bash
pbgopy serve -a user:pass
```

```bash
pbgopy copy -a user:pass <foo.png
```

```bash
pbgopy paste -a user:pass >foo.png
```

### From clipboard on your OS
You can put the data stored at the clipboard on your OS into pbgopy server.

Expand Down

0 comments on commit 0af2a5b

Please sign in to comment.