2016-11-13 18:21:00 +01:00
|
|
|
# Database
|
|
|
|
|
2017-05-03 21:08:38 +02:00
|
|
|
The database is encoded in a simple binary format with JSON content at its core.
|
2016-11-13 18:21:00 +01:00
|
|
|
|
|
|
|
## Encryption
|
|
|
|
|
2017-05-03 21:08:38 +02:00
|
|
|
The content of the database can be encrypted with AES in GCM mode. The nonce and
|
|
|
|
authentication tag are stored in the plain section of this file.
|
|
|
|
|
|
|
|
If there is no Slots and/or EncryptionParameters section in the file, it is
|
2017-08-19 13:52:22 +02:00
|
|
|
implied that the content is unencrypted and Aegis will try to parse it as such.
|
2016-11-13 18:21:00 +01:00
|
|
|
|
|
|
|
## Format
|
|
|
|
|
2017-05-03 21:08:38 +02:00
|
|
|
The file format starts with a small header that contains some magic and a
|
|
|
|
version number. A list of sections follows. These sections contain some
|
|
|
|
information needed to perform decryption of the database. The (encrypted)
|
|
|
|
content of the database starts after the end marker section.
|
2016-11-13 18:21:00 +01:00
|
|
|
|
|
|
|
All integers are encoded in Little Endian.
|
|
|
|
|
|
|
|
### Header
|
|
|
|
|
|
|
|
| Length | Contents |
|
|
|
|
|:-------|:-------------------------|
|
|
|
|
| `5` | "AEGIS" encoded in ASCII |
|
|
|
|
| `1` | `uint8_t` Version |
|
|
|
|
| `?` | List of sections |
|
|
|
|
| `?` | Content |
|
|
|
|
|
|
|
|
### Sections
|
|
|
|
|
|
|
|
| Length | Contents |
|
|
|
|
|:-------|:------------------|
|
|
|
|
| `1` | `uint8_t` ID |
|
|
|
|
| `4` | `uint32_t` Length |
|
|
|
|
| `?` | Section data |
|
|
|
|
|
|
|
|
ID can be one of:
|
|
|
|
|
|
|
|
| Value | Name |
|
|
|
|
|:-------|:---------------------|
|
|
|
|
| `0x00` | EncryptionParameters |
|
2017-05-03 21:08:38 +02:00
|
|
|
| `0x01` | Slots |
|
2016-11-13 18:21:00 +01:00
|
|
|
| `0xFF` | End marker |
|
|
|
|
|
|
|
|
#### EncryptionParameters
|
|
|
|
|
|
|
|
| Length | Contents |
|
|
|
|
|:-------|:---------|
|
|
|
|
| `12` | Nonce |
|
|
|
|
| `16` | Tag |
|
|
|
|
|
2017-05-03 21:08:38 +02:00
|
|
|
#### Slots
|
|
|
|
|
2017-08-18 22:12:45 +02:00
|
|
|
This section contains a SHA-256 hash of the master key and a list of slots. The
|
2017-08-19 13:52:22 +02:00
|
|
|
hash is used to verify the integrity of a decrypted slot. Note that this is
|
|
|
|
meant for convenience, not as a security measure.
|
2017-08-18 22:12:45 +02:00
|
|
|
|
|
|
|
| Length | Contents |
|
|
|
|
|:-------|:--------------------------|
|
|
|
|
| `32` | `uint8_t` Master Key Hash |
|
|
|
|
| `?` | Slots |
|
|
|
|
|
|
|
|
All slots contain the master key encrypted with raw AES. The key that is used for
|
|
|
|
encryption depends on the slot type.
|
2017-05-03 21:08:38 +02:00
|
|
|
|
|
|
|
A slot has the following structure.
|
|
|
|
|
|
|
|
| Length | Contents |
|
|
|
|
|:-------|:--------------------|
|
|
|
|
| `1` | `uint8_t` Type |
|
2018-02-10 17:20:41 +01:00
|
|
|
| `16` | ID |
|
2017-05-03 21:08:38 +02:00
|
|
|
| `32` | Encrypted key |
|
|
|
|
| `?` | Additional data |
|
|
|
|
|
|
|
|
Type can be one of:
|
|
|
|
|
|
|
|
| Value | Name |
|
|
|
|
|:-------|:------------|
|
|
|
|
| `0x00` | Raw |
|
|
|
|
| `0x01` | Password |
|
|
|
|
| `0x02` | Fingerprint |
|
|
|
|
|
|
|
|
##### Raw
|
|
|
|
|
|
|
|
This slot type contains no additional data.
|
|
|
|
|
|
|
|
##### Password
|
|
|
|
|
|
|
|
With this slot type the key used for the master key encryption is derived from a
|
2017-08-07 22:39:43 +02:00
|
|
|
user-provided password. The key derivation function is scrypt. The parameters
|
|
|
|
used for scrypt are stored as additional data.
|
|
|
|
|
|
|
|
| Length | Contents |
|
|
|
|
|:-------|:-------------|
|
|
|
|
| `4` | `uint32_t` N |
|
|
|
|
| `4` | `uint32_t` r |
|
|
|
|
| `4` | `uint32_t` p |
|
|
|
|
| `32` | Salt |
|
2016-11-13 18:21:00 +01:00
|
|
|
|
2017-05-03 21:08:38 +02:00
|
|
|
##### Fingerprint
|
|
|
|
|
|
|
|
A fingerprint slot is exactly the same as a Raw slot.
|
|
|
|
|
2016-11-13 18:21:00 +01:00
|
|
|
#### End marker
|
|
|
|
|
|
|
|
This section indicates the end of the list of sections. This section doesn't
|
|
|
|
have any content and thus its length is 0.
|
|
|
|
|
|
|
|
### Content
|
|
|
|
|
2017-05-03 21:08:38 +02:00
|
|
|
The content of the database is a JSON file encoded in UTF-8.
|
2016-11-13 18:21:00 +01:00
|
|
|
|
2017-05-03 21:08:38 +02:00
|
|
|
```json
|
2016-11-13 18:21:00 +01:00
|
|
|
{
|
|
|
|
"version": 1,
|
2017-12-27 22:04:22 +01:00
|
|
|
"counter": 10,
|
2016-11-13 18:21:00 +01:00
|
|
|
"entries":
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"name": "ACME Co/john@example.com",
|
|
|
|
"url": "otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30",
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|