source: creddy/libcreddy.h @ aa33ad9

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change on this file since aa33ad9 was aa33ad9, checked in by Mike Ryan <mikeryan@…>, 14 years ago

pull out attribute object

  • Property mode set to 100644
File size: 2.8 KB
Line 
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#define CREDDY_ATTRIBUTE_ISSUER_NOKEY       -3
10#define CREDDY_ATTRIBUTE_INVALID_ROLE       -4
11#define CREDDY_ATTRIBUTE_INVALID_VALIDITY   -5
12
13/**
14 * Creddy identifiers.
15 */
16
17typedef struct _creddy_id_t creddy_id_t;
18
19// create an ID from an X.509 certificate
20creddy_id_t *creddy_id_from_file(char *filename);
21
22// load an X.509 private key for an from a file
23// handles keys with a password
24int creddy_id_load_privkey(creddy_id_t *id, char *filename);
25
26// generate an ID
27// returns one of CREDDY_SUCCESS or CREDDY_GENERATE_* (see top)
28int creddy_id_generate(creddy_id_t **ret, char *cn, int validity);
29
30// get the SHA1 keyid, pointer is valid for the lifetime of the object
31char *creddy_id_keyid(creddy_id_t *id);
32
33// default filename for the cert: ${CN}_ID.pem
34// caller must free the returned string
35char *creddy_id_cert_filename(creddy_id_t *id);
36
37// write the cert fo an open file pointer
38void creddy_id_write_cert(creddy_id_t *id, FILE *out);
39
40// default filename for the private key: ${CN}_key.pem
41// caller must free the return value
42char *creddy_id_privkey_filename(creddy_id_t *id);
43
44// write the private key to a file
45// it is recommended that you open this file mode 0600
46void creddy_id_write_privkey(creddy_id_t *id, FILE *out);
47
48// destroy the id
49void creddy_id_free(creddy_id_t *id);
50
51/**
52 * Attribute cert
53 */
54typedef struct _creddy_attribute_t creddy_attribute_t;
55
56//
57// Here's the skinny:
58//  Attribute cert objects don't contain an actual cert until they're baked.
59//  First you construct the object using creddy_attribute_create, then you add
60//  subjects to it using creddy_attribute_{principal,role,linking_role}.
61//  Finally you bake it. Once you've done that, you can access the DER encoding
62//  or write it to a file.
63//
64
65// create an attribute cert
66// validity is in days
67// returns one of CREDDY_SUCCESS or CREDDY_ATTRIBUTE_* (see top)
68int creddy_attribute_create(creddy_attribute_t **attr, creddy_id_t *issuer, char *role, int validity);
69
70// add a principal subject to the cert
71int creddy_attribute_principal(creddy_attribute_t *attr, char *keyid);
72
73// add a role subject
74int creddy_attribute_role(creddy_attribute_t *attr, char *keyid, char *role);
75
76// add a linking role subject
77int creddy_attribute_linking_role(creddy_attribute_t *attr, char *keyid, char *role, char *linked);
78
79// create the attribute cert once all the subjects have been added
80// can return 0 if there are no subjects or there's a problem building the cert
81int creddy_attribute_bake(creddy_attribute_t *attr);
82
83// destroy the cert
84void creddy_attribute_free(creddy_attribute_t *attr);
85
86#endif /* __LIBCREDDY_H__ */
Note: See TracBrowser for help on using the repository browser.