source:
creddy/creddy.h
@
3131b19
Last change on this file since 3131b19 was 3131b19, checked in by , 14 years ago | |
---|---|
|
|
File size: 1.7 KB |
Rev | Line | |
---|---|---|
[abd7c25] | 1 | #ifndef __CREDDY_H__ |
2 | #define __CREDDY_H__ | |
3 | ||
[fd0febd] | 4 | #include <library.h> |
5 | #include <credentials/certificates/certificate.h> | |
6 | #include <credentials/certificates/x509.h> | |
7 | ||
[980a7b6] | 8 | typedef struct _subject_t { |
9 | char *cert; | |
10 | char *id; | |
11 | char *role; | |
12 | } subject_t; | |
13 | ||
[abd7c25] | 14 | typedef struct _options_t { |
15 | int help; | |
16 | int mode; | |
17 | ||
[fd0febd] | 18 | char *cert; |
19 | ||
[abd7c25] | 20 | // generate options |
21 | char *cn; | |
22 | int validity; | |
[085f159] | 23 | |
24 | // attribute options | |
25 | char *issuer; | |
26 | char *key; | |
27 | char *role; | |
[980a7b6] | 28 | subject_t *subjects; |
29 | int num_subjects; | |
[085f159] | 30 | char *out; |
[784a398] | 31 | |
32 | // verify options | |
33 | char *attrcert; | |
[abd7c25] | 34 | } options_t; |
35 | ||
36 | #define MODE_GENERATE 1 | |
37 | #define MODE_VERIFY 2 | |
38 | #define MODE_KEYID 3 | |
39 | #define MODE_ATTRIBUTE 4 | |
40 | #define MODE_ROLES 5 | |
[19be896] | 41 | #define MODE_VERSION 6 |
[abd7c25] | 42 | |
43 | // returns true if a name starts with a letter and is otherwise alphanumeric | |
44 | int clean_name(char *string); | |
45 | ||
[784a398] | 46 | // load an ID/attr cert from file (aborts on fail) |
[fd0febd] | 47 | certificate_t *cert_from_file(char *filename); |
[784a398] | 48 | certificate_t *attr_cert_from_file(char *filename); |
[fd0febd] | 49 | |
[085f159] | 50 | // generate a random serial |
51 | chunk_t generate_serial(); | |
52 | ||
[abd7c25] | 53 | void usage(options_t *opts); |
54 | void *xmalloc(size_t len); | |
[980a7b6] | 55 | void *xrealloc(void *ptr, size_t size); |
[abd7c25] | 56 | char *xstrdup(char *string); |
57 | ||
58 | // sub programs | |
59 | void generate_main(options_t *opts); | |
[fd0febd] | 60 | void keyid_main(options_t *opts); |
[085f159] | 61 | void attribute_main(options_t *opts); |
[9410b51] | 62 | void roles_main(options_t *opts); |
[784a398] | 63 | void verify_main(options_t *opts); |
[abd7c25] | 64 | |
[a0772a2] | 65 | #define CREDDY_SUCCESS 0 |
66 | #define CREDDY_GENERATE_INVALID_CN -1 | |
67 | #define CREDDY_GENERATE_INVALID_VALIDITY -2 | |
68 | ||
69 | /** | |
70 | * Generate an ID cert / private key pair. Returns one of the error | |
71 | * codes above. Validity is in days. Output is in ${cn}_ID.pem and | |
72 | * ${cn}_private.der. | |
73 | */ | |
74 | int creddy_generate(char *cn, int validity); | |
75 | ||
[abd7c25] | 76 | #endif /* __CREDDY_H__ */ |
Note: See TracBrowser
for help on using the repository browser.