1 | #ifndef __LIBCREDDY_H__ |
---|
2 | #define __LIBCREDDY_H__ |
---|
3 | |
---|
4 | #include <stdio.h> |
---|
5 | |
---|
6 | #define CREDDY_SUCCESS 0 |
---|
7 | #define CREDDY_GENERATE_INVALID_CN -1 |
---|
8 | #define CREDDY_GENERATE_INVALID_VALIDITY -2 |
---|
9 | |
---|
10 | /** |
---|
11 | * Creddy identifiers. |
---|
12 | */ |
---|
13 | |
---|
14 | typedef struct _creddy_id_t creddy_id_t; |
---|
15 | |
---|
16 | // create an ID from an X.509 certificate |
---|
17 | creddy_id_t *creddy_id_from_file(char *filename); |
---|
18 | |
---|
19 | // load an X.509 private key for an from a file |
---|
20 | // handles keys with a password |
---|
21 | int creddy_id_load_privkey(creddy_id_t *id, char *filename); |
---|
22 | |
---|
23 | // generate an ID |
---|
24 | // returns one of CREDDY_SUCCESS or CREDDY_GENERATE_* (see top) |
---|
25 | int creddy_id_generate(creddy_id_t **ret, char *cn, int validity); |
---|
26 | |
---|
27 | // get the SHA1 keyid, pointer is valid for the lifetime of the object |
---|
28 | char *creddy_id_keyid(creddy_id_t *id); |
---|
29 | |
---|
30 | // default filename for the cert: ${CN}_ID.pem |
---|
31 | // caller must free the returned string |
---|
32 | char *creddy_id_cert_filename(creddy_id_t *id); |
---|
33 | |
---|
34 | // write the cert fo an open file pointer |
---|
35 | void creddy_id_write_cert(creddy_id_t *id, FILE *out); |
---|
36 | |
---|
37 | // default filename for the private key: ${CN}_key.pem |
---|
38 | // caller must free the return value |
---|
39 | char *creddy_id_privkey_filename(creddy_id_t *id); |
---|
40 | |
---|
41 | // write the private key to a file |
---|
42 | // it is recommended that you open this file mode 0600 |
---|
43 | void creddy_id_write_privkey(creddy_id_t *id, FILE *out); |
---|
44 | |
---|
45 | // destroy the id |
---|
46 | void creddy_id_free(creddy_id_t *id); |
---|
47 | |
---|
48 | #endif /* __LIBCREDDY_H__ */ |
---|