The vault file is used to store keys and key-signatures on disk. More...
Classes | |
struct | _vault_t |
This structure represents a vault. More... | |
struct | _vault_header_t |
Defines the vault header. More... | |
struct | _vault_item_header_t |
An item header. More... | |
Typedefs | |
typedef struct _vault_t | vault_t |
Name of the struct. More... | |
typedef struct _vault_header_t | vault_header_t |
Name of the struct. More... | |
typedef struct _vault_item_header_t | vault_item_header_t |
Name of the struct. More... | |
Functions | |
vault_t * | pcpvault_init (PCPCTX *ptx, char *filename) |
Open a vault file. More... | |
int | pcpvault_additem (PCPCTX *ptx, vault_t *vault, void *item, size_t itemsize, uint8_t type) |
Add an item to the vault. More... | |
int | pcpvault_addkey (PCPCTX *ptx, vault_t *vault, void *item, uint8_t type) |
Add a key to the vault. More... | |
int | pcpvault_close (PCPCTX *ptx, vault_t *vault) |
Close a vault file. More... | |
void | pcpvault_free (vault_t *vault) |
Free vault resources. More... | |
int | pcpvault_fetchall (PCPCTX *ptx, vault_t *vault) |
Reads in the vault contents. More... | |
The vault file is used to store keys and key-signatures on disk.
It works like a keyring.
The vault file contains all public and secret keys. It's a portable binary file.
The file starts with a header:
The checksum is a checksum of all keys.
The header is followed by the keys. Each key is preceded by an item header which looks like this:
Type can be one of:
The item header is followed by the actual key contents.
typedef struct _vault_header_t vault_header_t |
typedef struct _vault_item_header_t vault_item_header_t |
Add an item to the vault.
Adds item with the size itemsize and type type to the vault. Generates the item header and the checksum of the item.
This function writes directly into the vault file. Use with care. To be safe, use pcpvault_addkey() instead.
[in] | ptx | pcp context. |
[out] | vault | The vault object. |
[in] | item | The item to write. |
[in] | itemsize | Size of the item. |
[in] | type | Type of the item. |
Add a key to the vault.
This function determines the size of the item to write based on the given type. It converts the internal structure to a binary blob and converty multibyte values to big endian.
It copies the given vault file to a temporary vault file, adds the item and if this went ok, copies the temporary file back to the original location. It then re-calculates the vault checksum and puts it into the vault header.
[in] | ptx | pcp context. |
[out] | vault | The vault object. |
[in] | item | The item to write (a key or keysig) |
[in] | type | Type of the item. |
Close a vault file.
If the vault is in unsafed state, write everything to disk and close the vault. Before overwriting the current vault file a backup will be made. If anything fails during writing the backup file will be retained and the error message will contain the filename of the backup file, so that the user doesn't loose data.
[in] | ptx | pcp context. |
[out] | vault | The vault object. |
Reads in the vault contents.
This function reads the open vault contents and puts them into the apropriate hashes.
Currently only known types can be read. If your're saving unknown types to the vault, an error will occur.
Each item will be converted put into the aproprieate structure, multibyte values will be converted to host endianess. It also calculates the checksum of the vault contents and compares it with the one stored in the vault header. If it doesn't match an error will be thrown.
[in] | ptx | pcp context. |
[out] | vault | The vault object. |
void pcpvault_free | ( | vault_t * | vault | ) |
Free vault resources.
[in] | vault | The vault object. |