source: doc/creddy_API @ 757e2fb

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

document creddy API

  • Property mode set to 100644
File size: 2.6 KB
Line 
1C++ API
2
3(see bottom for notes on C, Perl, and Python)
4
5Creddy::ID
6    ID(char *filename)
7        load an ID cert from a file
8        Will throw an exception if the cert cannot be loaded
9
10    ID(char *cn, int validity)
11        generates a new ID with the supplied CN and validity period
12        - CN must be alphanumeric and begin with a letter
13        - validity must be at least one day
14        Will throw an exception if either of the above is violated
15
16    void load_privkey(char *filename)
17        loads the private key associated with the cert
18        will throw an exception if the key cannot be loaded
19
20    char *keyid()
21        returns the SHA1 keyid of the cert
22
23    char *cert_filename()
24        returns a suggested filename for the generated ID cert, namely:
25            ${CN}_id.pem
26
27    char *privkey_filename()
28        returns a suggested filename for the private key of the ID cert:
29            ${CN}_key.pem
30
31    void write_cert(FILE *out)
32        writes a PEM-encoded cert to the file handle
33
34    void write_privkey(FILE *out)
35        writes a PEM-encoded private key to the file handle
36        throws an exception if no private key is loaded
37
38Creddy::Attribute
39
40    N.B., The way you use this class is by instantiating the object, adding
41    subjects to it, and then baking it. Only once it's baked can you access the
42    X.509 cert. Once it's been baked you can no longer add subjects to it.
43
44    Attribute(ID &issuer, char *role, int validity)
45        Create an object to be signed by the given issuer with the given role
46        and validity period
47        An exception will be thrown if:
48            - the issuer has no private key
49            - the role name is invalid (must be alphanumeric)
50            - the validity period is invalid (must be >= 1 day)
51
52    (The following three methods will throw an exception if the certificate has
53    been baked. They return false if there's an invalid principal or role name.)
54
55    bool principial(char *keyid)
56        Add a principal subject
57
58    bool role(char *keyid, char *role)
59        Add a role subject
60
61    bool linking_role(char *keyid, char *role, char *linked)
62        Add a linking role subject
63
64    bool bake()
65        Generate the cert. Call this after you've added subjects to your cert.
66        This returns false if there are no subjects
67        This will throw an exception if the cert's already been baked.
68
69    bool baked()
70        Returns true iff the cert has been baked.
71
72    void write(FILE *out)
73        Write the DER-encoded X.509 attribute cert to the open file handle
74        Throws an exception if the cert isn't baked
Note: See TracBrowser for help on using the repository browser.