File: keydb.h

package info (click to toggle)
ekeyd 1.1.3-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 628 kB
  • ctags: 859
  • sloc: ansic: 5,189; sh: 271; makefile: 199; perl: 148
file content (59 lines) | stat: -rw-r--r-- 1,552 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* daemon/keydb.h
 *
 * Keyring input/management
 *
 * Copyright 2009 Simtec Electronics
 *
 * For licence terms refer to the COPYING file.
 */

#ifndef DAEMON_KEYDB_H
#define DAEMON_KEYDB_H

#include <stdint.h>

/**
 * (re-)Initialise the key database and read a keyring into it.
 *
 * @param fname The file to read the keyring from.
 * @return -1 with errno set on failure, otherwise returns the number of keys read.
 * @note Format is "PEMSerial PEMLTK\n" * nkeys.
 */
extern int read_keyring(const char *fname);

/**
 * Write the current keyring to a file. 
 * 
 * @param fname The filename to write to.
 * @return The number of entries written or -1 and errno set.
 */
int write_keyring(const char *fname);

/**
 * Retrieve a long-term-key by serial number.
 *
 * @param snum The serial number of the LTK to retrieve.
 * @return A pointer to the LTK, or NULL if not found.
 * @note The returned pointer is owned by the caller. It is
 *       the caller's responsibility to free it when it is
 *       finished with it.
 */
extern uint8_t *snum_to_ltkey(const uint8_t *snum);

/** 
 * Add a long term session key to the keyring.
 *
 * @param snum Serial number of the key.
 * @param ltkey The long term session key.
 */
int add_ltkey(const uint8_t *snum, const uint8_t *ltkey);

/**
 * Format a serial number and long term session key for output to a stream.
 *
 * @param snum Serial number of the key.
 * @param ltkey The long term session key.
 */
int output_key(FILE *fh, const uint8_t *snum, const uint8_t *ltkey);

#endif /* DAEMON_KEYDB_H */