Skip to content

Commit cfc1657

Browse files
committed
Vault
1 parent 0071be7 commit cfc1657

File tree

10 files changed

+150
-36
lines changed

10 files changed

+150
-36
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.vuepress/dist
1+
.vuepress/dist
2+
node_modules

.vuepress/config.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ module.exports = {
22
title: "keys.pub",
33
description:
44
"Cryptographic key management, saltpack, noise, sigchains, user identities, signing, encryption",
5+
extendMarkdown: (md) => {
6+
md.use(require("markdown-it-footnote"));
7+
},
58
head: [
69
[
710
"link",
@@ -145,9 +148,11 @@ module.exports = {
145148
collapsable: false,
146149
path: "/docs/restapi-index",
147150
children: [
151+
"/docs/restapi/auth",
152+
"/docs/restapi/errors",
148153
"/docs/restapi/user",
149154
"/docs/restapi/sigchain",
150-
"/docs/restapi/errors",
155+
"/docs/restapi/vault",
151156
],
152157
},
153158
{
@@ -169,9 +174,9 @@ module.exports = {
169174
"/docs/specs/auth",
170175
"/docs/specs/keys",
171176
"/docs/specs/kid",
172-
"/docs/specs/keyring",
173177
"/docs/specs/sigchain",
174178
"/docs/specs/user",
179+
"/docs/specs/vault",
175180
"/docs/specs/wormhole",
176181
],
177182
},

docs/restapi/auth.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Authorization
2+
3+
Some requests require an Authorization header which includes a signature of the HTTP request.
4+
5+
The signature should be specified with an `Authorization` header include the (EdX25519) key identifier and signature bytes (base64 encoded) in the format `{KID}:{Signature}`.
6+
7+
For example,
8+
9+
```text
10+
kex1nh4jwl3zy0xz8m7eaxvd6uluqwfg3tt2k0rvdlsa6f2jeckvfrtsfd6jh8:pJ/x7hzEcqPZ9cWGmX4UBB3Jh0csSP+7yDScIqI6SPiz9MKedySmQZlxFYSMZMNPKZPyYLVgQeU6NPK7YivJCg==
11+
```
12+
13+
The bytes to sign are `{Method},{URL},{ContentHash}`.
14+
15+
The Method is the HTTP method (GET, PUT, POST, DELETE, HEAD).
16+
The URL must be in a canonical form (parameters must be in alphabetical order).
17+
The ContentHash is the base64 encoded SHA256 hash of the HTTP body (or empty string if no body content).
18+
19+
The URL must include a timestamp (`ts`) and a nonce (`nonce`) parameter.
20+
The nonce is only allowed to be used once and the timestamp needs to be within 30 minutes of the current time. The server keeps track of nonce values up to an hour.
21+
22+
For example a vault GET request:
23+
24+
BytesToSign:
25+
26+
```text
27+
GET,https://keys.pub/vault/kex1nh4jwl3zy0xz8m7eaxvd6uluqwfg3tt2k0rvdlsa6f2jeckvfrtsfd6jh8?nonce=pFrY3aZiyYzaHjFF1YlyfZfHxG9QuQwXFv3iUoIQUj9&ts=1595367948129,
28+
```
29+
30+
cURL:
31+
32+
```shell
33+
curl -H "Authorization: kex1nh4jwl3zy0xz8m7eaxvd6uluqwfg3tt2k0rvdlsa6f2jeckvfrtsfd6jh8:pJ/x7hzEcqPZ9cWGmX4UBB3Jh0csSP+7yDScIqI6SPiz9MKedySmQZlxFYSMZMNPKZPyYLVgQeU6NPK7YivJCg==" \
34+
"https://keys.pub/vault/kex1nh4jwl3zy0xz8m7eaxvd6uluqwfg3tt2k0rvdlsa6f2jeckvfrtsfd6jh8?nonce=pFrY3aZiyYzaHjFF1YlyfZfHxG9QuQwXFv3iUoIQUj9&ts=1595367948129"
35+
```
36+
37+
Or a vault POST request:
38+
39+
BytesToSign:
40+
41+
```text
42+
POST,https://keys.pub/vault/kex1cze367q786xuf0xy9gt5g32n8ldpv9753aprn0zwpl5ql0xmu74qcs0mk4?nonce=bzTYFeAcYQH48MXv64B6tOCs1s4SmlAUOyiwSvCJSE6&ts=1595368769675,QcjV+e8ZP1QQ0CCyM3Gxf9JteKCzL5t/hdjB10VVlZY=
43+
```
44+
45+
cURL:
46+
47+
```shell
48+
curl -H "Authorization: kex1cze367q786xuf0xy9gt5g32n8ldpv9753aprn0zwpl5ql0xmu74qcs0mk4:lwQ/qB7qDayiK4opnN8ODWAD6TeZcNWhGF0JvMtNgPFpXLMrm7o5QyyIQpXuYVH/dO+Xw7CuryHDsHbMHV0iDA==" -d "[{\"data\":\"dGVzdGluZzE=\"},{\"data\":\"dGVzdGluZzI=\"}]" "https://keys.pub/vault/kex1cze367q786xuf0xy9gt5g32n8ldpv9753aprn0zwpl5ql0xmu74qcs0mk4?nonce=bzTYFeAcYQH48MXv64B6tOCs1s4SmlAUOyiwSvCJSE6&ts=1595368769675"
49+
```
50+
51+
The [github.com/keys-pub/keys-ext/http/api](https://pkg.go.dev/github.com/keys-pub/keys-ext/http/api) package can create a signed http.Request object, see [api.NewRequest](https://pkg.go.dev/github.com/keys-pub/keys-ext/http/api?tab=doc#pkg-examples).

docs/restapi/errors.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ The API returns errors in the format:
2020
| 409 | Resource already exists. |
2121
| 413 | Entity too large, if request body was too large. |
2222
| 429 | Too many requests, if you hit a request limit. |
23+
| 500 | Internal server error. |

docs/restapi/sigchain.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The _keys.pub_ server provides an API for publishing and accessing [sigchains](/
44

55
## GET /sigchain/:kid
66

7-
Get a sigchain for a user public key.
7+
Get a sigchain for a key.
88

99
```shell
1010
curl https://keys.pub/sigchain/kex1mnseg28xu6g3j4wur7hqwk8ag3fu3pmr2t5lync26xmgff0dtryqupf80c

docs/restapi/vault.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Vault
2+
3+
A vault is an append only log of data. Data can be requested from an index into this log.
4+
Vault [requests must be signed](/docs/restapi/auth.md) with the EdX25519 key associated with the vault.
5+
6+
The data itself is not verified in an way, it is stored just as it is received.
7+
It is up to the clients to encrypt this data (typically using the same EdX25519 key used for signing).
8+
9+
This API is used by the clients to (optionally) backup and sync vault items.
10+
11+
## GET /vault/:kid
12+
13+
Get vault.
14+
15+
| Request | Description |
16+
| ------- | ------------------------ |
17+
| idx | Index to start at. |
18+
| limit | Limit number of results. |
19+
20+
Requires [Authorization](/docs/restapi/auth.md).
21+
22+
```shell
23+
https://keys.pub/vault/kex16jvh9cc6na54xwpjs3ztlxdsj6q3scl65lwxxj72m6cadewm404qts0jw9
24+
```
25+
26+
Returns vault items with a timestamp and index. The timestamp included is when the server received the data.
27+
28+
```json
29+
{
30+
"vault": [
31+
{ "data": "dGVzdGluZzE=", "idx": 1, "ts": 1595285756121 },
32+
{ "data": "dGVzdGluZzI=", "idx": 2, "ts": 1595285756152 }
33+
],
34+
"idx": 2
35+
}
36+
```
37+
38+
## POST /vault/:kid
39+
40+
Requires [Authorization](/docs/restapi/auth.md).
41+
42+
Save items to a vault. The server can process up to 500 items at once.
43+
44+
The request body is a JSON array of data objects.
45+
46+
```json
47+
[{ "data": "dGVzdGluZzE=" }, { "data": "dGVzdGluZzI=" }]
48+
```
49+
50+
## DELETE /vault/:kid
51+
52+
Requires [Authorization](/docs/restapi/auth.md).
53+
54+
Remove all data associated with a vault.
55+
Subsequent requests (GET, POST, PUT) to the vault will return a 404.

docs/specs/keyring.md

-32
This file was deleted.

docs/specs/vault.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Vault
2+
3+
::: warning
4+
This documentation is in progress.
5+
:::
6+
7+
A vault is an append only encrypted log used to store secrets.
8+
9+
The format for the vault is designed to track changes and (optionally) for syncing to a remote server.
10+
11+
## Master Key
12+
13+
Vault items are encrypted[^1] with a master key (32 byte secret key) which can be unlocked by provisioned passwords or hardware security keys.
14+
15+
## API Key
16+
17+
If a vault is synced to the server, data is also encrypted with a vault API (EdX25519) key. This key is also used to sign (and authorize) requests to the server (via the [Vault API](/docs/restapi/vault.md)).
18+
This API key is derived from the master key (using HKDF with a random 32 byte salt).
19+
20+
[^1]: Provisioning info required to unlock the vault, such as salt values, are **NOT** encrypted.

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"markdown-it-footnote": "^3.0.2"
4+
}
5+
}

yarn.lock

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
markdown-it-footnote@^3.0.2:
6+
version "3.0.2"
7+
resolved "https://registry.yarnpkg.com/markdown-it-footnote/-/markdown-it-footnote-3.0.2.tgz#1575ee7a093648d4e096aa33386b058d92ac8bc1"
8+
integrity sha512-JVW6fCmZWjvMdDQSbOT3nnOQtd9iAXmw7hTSh26+v42BnvXeVyGMDBm5b/EZocMed2MbCAHiTX632vY0FyGB8A==

0 commit comments

Comments
 (0)