Add MIT license, rewrite README and add path reference docs
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# Encrypt and decrypt
|
||||
|
||||
Messages are standard OpenPGP messages. Anything encrypted to the key's public
|
||||
key, whether by this engine, `gpg` or `pass`, can be decrypted here.
|
||||
|
||||
## Encrypt
|
||||
|
||||
`POST /gpg/encrypt/:name`
|
||||
|
||||
Encrypts to the latest key version.
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-----------|------|---------|-------------|
|
||||
| `plaintext` | string | required | Base64-encoded plaintext. |
|
||||
| `format` | string | `base64` | `base64` (base64-encoded binary OpenPGP), or `ascii-armor`. |
|
||||
|
||||
The response has `ciphertext` and `key_version`.
|
||||
|
||||
```sh
|
||||
vault write -field=ciphertext gpg/encrypt/app plaintext=$(base64 <<<"secret")
|
||||
vault write -field=ciphertext gpg/encrypt/app plaintext=$(base64 <<<"secret") format=ascii-armor
|
||||
```
|
||||
|
||||
## Decrypt
|
||||
|
||||
`POST /gpg/decrypt/:name`
|
||||
|
||||
Tries every key version at or above `min_decryption_version`. The engine
|
||||
detects whether the input is armored or binary.
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `ciphertext` | string | ASCII-armored message, or base64-encoded binary (the format `gpg`/`pass` write by default). |
|
||||
|
||||
The response has `plaintext` (base64).
|
||||
|
||||
```sh
|
||||
vault write -field=plaintext gpg/decrypt/app ciphertext="$ct" | base64 -d
|
||||
|
||||
# decrypt a file written by gpg or pass
|
||||
vault write -field=plaintext gpg/decrypt/app \
|
||||
ciphertext=$(base64 -w0 ~/.password-store/email/example.gpg) | base64 -d
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
# Export
|
||||
|
||||
`GET /gpg/export/:type/:name(/:version)`
|
||||
|
||||
Returns armored key material. `public-key` can always be exported, and is what
|
||||
`gpg` or `pass` imports to encrypt to the key. `private-key` works only if the
|
||||
key is `exportable`.
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `type` | string | `public-key` or `private-key`. |
|
||||
| `name` | string | Name of the key. |
|
||||
| `version` | int | Version to export. `0` means the latest version. Leave it out to export every version. |
|
||||
|
||||
The response has `name`, `type` and `keys`. `keys` maps each version number to
|
||||
its armored key.
|
||||
|
||||
```sh
|
||||
# all public versions
|
||||
vault read gpg/export/public-key/app
|
||||
|
||||
# latest public key, ready for gpg
|
||||
vault read -format=json gpg/export/public-key/app/0 \
|
||||
| jq -r '.data.keys | to_entries[0].value' | gpg --import
|
||||
|
||||
# private key of version 1 (key must be exportable)
|
||||
vault read gpg/export/private-key/app/1
|
||||
```
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
# Keys
|
||||
|
||||
These paths create, read, configure, rotate, import, list and delete named
|
||||
OpenPGP keys. All examples assume the engine is mounted at `gpg/`.
|
||||
|
||||
Every key is versioned. Each version is a separate OpenPGP entity with its own
|
||||
fingerprint. Private keys are stored seal-wrapped.
|
||||
|
||||
## Create key
|
||||
|
||||
`POST /gpg/keys/:name`
|
||||
|
||||
Generates a new key. Creating a key is idempotent: if the key already exists,
|
||||
the request returns it unchanged and does not regenerate it.
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-----------|------|---------|-------------|
|
||||
| `name` | string | required | Name of the key (in the URL). |
|
||||
| `algorithm` | string | `rsa-3072` | One of `rsa-2048`, `rsa-3072`, `rsa-4096`, `ed25519`. |
|
||||
| `identity` | string | key name | OpenPGP User ID, e.g. `Jane Doe <jane@example.com>`. |
|
||||
| `exportable` | bool | `false` | Allow the private key to be exported. Once enabled, this cannot be disabled. |
|
||||
|
||||
```sh
|
||||
vault write gpg/keys/app algorithm=ed25519 identity="App <app@example.com>"
|
||||
```
|
||||
|
||||
## Read key
|
||||
|
||||
`GET /gpg/keys/:name`
|
||||
|
||||
Returns key metadata and the armored public key of every version.
|
||||
|
||||
```sh
|
||||
vault read gpg/keys/app
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| `name`, `algorithm`, `identity` | As set at creation. |
|
||||
| `latest_version` | Highest key version. |
|
||||
| `min_decryption_version` | Lowest version used for decryption. |
|
||||
| `deletion_allowed`, `exportable` | Key policy. |
|
||||
| `imported` | `true` if the key was imported, not generated. |
|
||||
| `creation_time` | RFC 3339 timestamp. |
|
||||
| `fingerprint`, `public_key` | Fingerprint and armored public key of the latest version. |
|
||||
| `keys` | Map of version to `creation_time`, `fingerprint`, `key_id`, `public_key`. |
|
||||
|
||||
The create, config, rotate and import endpoints return the same response.
|
||||
|
||||
## List keys
|
||||
|
||||
`LIST /gpg/keys`
|
||||
|
||||
```sh
|
||||
vault list gpg/keys
|
||||
```
|
||||
|
||||
## Delete key
|
||||
|
||||
`DELETE /gpg/keys/:name`
|
||||
|
||||
Deletes the key and all of its versions. This fails unless `deletion_allowed`
|
||||
has been set to `true` through the config endpoint.
|
||||
|
||||
```sh
|
||||
vault write gpg/keys/app/config deletion_allowed=true
|
||||
vault delete gpg/keys/app
|
||||
```
|
||||
|
||||
## Configure key
|
||||
|
||||
`POST /gpg/keys/:name/config`
|
||||
|
||||
Changes key policy. The key material is not touched. Only the parameters you
|
||||
send are changed.
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `min_decryption_version` | int | Lowest version usable for decryption. Must be between 1 and `latest_version`. |
|
||||
| `deletion_allowed` | bool | Whether the key may be deleted. |
|
||||
| `exportable` | bool | Allow private key export. Once enabled, this cannot be disabled. |
|
||||
|
||||
```sh
|
||||
vault write gpg/keys/app/config min_decryption_version=2
|
||||
```
|
||||
|
||||
## Rotate key
|
||||
|
||||
`POST /gpg/keys/:name/rotate`
|
||||
|
||||
Generates a new version with the same algorithm and identity, and makes it the
|
||||
latest version. Older versions are kept, so older ciphertext still decrypts and
|
||||
older signatures still verify. Decryption is limited to versions at or above
|
||||
`min_decryption_version`.
|
||||
|
||||
```sh
|
||||
vault write -field=latest_version gpg/keys/app/rotate
|
||||
```
|
||||
|
||||
## Import key
|
||||
|
||||
`POST /gpg/keys/:name/import`
|
||||
|
||||
Imports an existing armored OpenPGP private key as version 1 of a new key.
|
||||
This fails if the name is already in use.
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-----------|------|---------|-------------|
|
||||
| `private_key` | string | required | ASCII-armored private key. It must not be passphrase-protected. |
|
||||
| `exportable` | bool | `false` | Allow the private key to be exported again later. |
|
||||
|
||||
```sh
|
||||
gpg --export-secret-keys --armor app@example.com > app.asc
|
||||
vault write gpg/keys/app/import private_key=@app.asc
|
||||
```
|
||||
@@ -0,0 +1,43 @@
|
||||
# Sign and verify
|
||||
|
||||
These paths create and check detached OpenPGP signatures. The input message is
|
||||
always base64-encoded.
|
||||
|
||||
## Sign
|
||||
|
||||
`POST /gpg/sign/:name`
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-----------|------|---------|-------------|
|
||||
| `input` | string | required | Base64-encoded message to sign. |
|
||||
| `key_version` | int | `0` (latest) | Key version to sign with. |
|
||||
| `format` | string | `ascii-armor` | `ascii-armor`, or `base64` for a raw binary signature. |
|
||||
|
||||
The response has `signature`.
|
||||
|
||||
```sh
|
||||
vault write -field=signature gpg/sign/app input=$(base64 -w0 release.tar.gz) > release.tar.gz.asc
|
||||
|
||||
# check it with gpg, using the exported public key
|
||||
vault read -field=public_key gpg/keys/app | gpg --import
|
||||
gpg --verify release.tar.gz.asc release.tar.gz
|
||||
```
|
||||
|
||||
## Verify
|
||||
|
||||
`POST /gpg/verify/:name`
|
||||
|
||||
Checks the signature against every key version.
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `input` | string | Base64-encoded message that was signed. |
|
||||
| `signature` | string | Detached signature, either ASCII-armored or base64-encoded binary. |
|
||||
|
||||
The response has `valid` (`true` or `false`). A malformed signature returns
|
||||
`valid=false`, not an error.
|
||||
|
||||
```sh
|
||||
vault write -field=valid gpg/verify/app \
|
||||
input=$(base64 -w0 release.tar.gz) signature=@release.tar.gz.asc
|
||||
```
|
||||
Reference in New Issue
Block a user