libpurple/certificate.h

Fri, 22 Jun 2007 20:49:32 +0000

author
William Ehlhardt <williamehlhardt@gmail.com>
date
Fri, 22 Jun 2007 20:49:32 +0000
branch
soc.2007.certmgr
changeset 18460
cceca1e961ad
parent 18457
e9e60bed8906
child 18461
8ae1cd456532
permissions
-rw-r--r--

- Fill out CertVerifier struct
- CertVerifiers now record only the name of the CertScheme they operate on, which is looked up when a request actually needs to be generated.

17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
1 /**
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
2 * @file certificate.h Public-Key Certificate API
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
3 * @ingroup core
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
4 */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
5
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
6 /*
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
7 *
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
8 * purple
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
9 *
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
10 * Purple is the legal property of its developers, whose names are too numerous
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
11 * to list here. Please refer to the COPYRIGHT file distributed with this
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
12 * source distribution.
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
13 *
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
14 * This program is free software; you can redistribute it and/or modify
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
15 * it under the terms of the GNU General Public License as published by
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
16 * the Free Software Foundation; either version 2 of the License, or
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
17 * (at your option) any later version.
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
18 *
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
19 * This program is distributed in the hope that it will be useful,
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
22 * GNU General Public License for more details.
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
23 *
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
24 * You should have received a copy of the GNU General Public License
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
25 * along with this program; if not, write to the Free Software
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
27 */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
28
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
29 #ifndef _PURPLE_CERTIFICATE_H
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
30 #define _PURPLE_CERTIFICATE_H
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
31
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
32 #include <glib.h>
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
33
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
34 #ifdef __cplusplus
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
35 extern "C" {
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
36 #endif /* __cplusplus */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
37
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
38
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
39 typedef enum
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
40 {
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
41 PURPLE_CERTIFICATE_INVALID = 0,
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
42 PURPLE_CERTIFICATE_VALID = 1
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
43 } PurpleCertificateVerificationStatus;
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
44
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
45 typedef struct _PurpleCertificate PurpleCertificate;
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
46 typedef struct _PurpleCertificateScheme PurpleCertificateScheme;
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
47 typedef struct _PurpleCertificateVerifier PurpleCertificateVerifier;
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
48 typedef struct _PurpleCertificateVerificationRequest PurpleCertificateVerificationRequest;
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
49
18460
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
50 /**
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
51 * Callback function for the results of a verification check
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
52 * @param vrq Request structure operated on
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
53 * @param st Status code
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
54 * @param userdata User-defined data
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
55 */
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
56 typedef void (*PurpleCertificateVerifiedCallback)
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
57 (PurpleCertificateVerificationRequest *vrq,
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
58 PurpleCertificateVerificationStatus,
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
59 gpointer userdata);
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
60
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
61 /** A certificate instance
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
62 *
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
63 * An opaque data structure representing a single certificate under some
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
64 * CertificateScheme
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
65 */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
66 struct _PurpleCertificate
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
67 {
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
68 /** Scheme this certificate is under */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
69 PurpleCertificateScheme * scheme;
17509
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
70 /** Opaque pointer to internal data */
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
71 gpointer data;
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
72 };
fa009823dbfd - Exposed the _Certificate struct definition in certificate.h
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17508
diff changeset
73
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
74 /** A certificate type
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
75 *
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
76 * A CertificateScheme must implement all of the fields in the structure,
18456
1971d0938744 - Documentation correction
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18454
diff changeset
77 * and register it using purple_certificate_register_scheme()
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
78 *
17508
65f10c9a063b - Fixed a comment
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17506
diff changeset
79 * There may be only ONE CertificateScheme provided for each certificate
65f10c9a063b - Fixed a comment
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17506
diff changeset
80 * type, as specified by the "name" field.
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
81 */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
82 struct _PurpleCertificateScheme
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
83 {
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
84 /** Name of the certificate type
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
85 * ex: "x509", "pgp", etc.
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
86 * This must be globally unique - you may not register more than one
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
87 * CertificateScheme of the same name at a time.
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
88 */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
89 gchar * name;
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
90
18247
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
91 /** User-friendly name for this type
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
92 * ex: N_("X.509 Certificates")
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
93 * When this is displayed anywhere, it should be i18ned
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
94 * ex: _(scheme->name)
18247
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
95 */
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
96 gchar * fullname;
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
97
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
98 /** Imports a certificate from a file
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
99 *
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
100 * @param filename File to import the certificate from
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
101 * @return Pointer to the newly allocated Certificate struct
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
102 * or NULL on failure.
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
103 */
18249
21467a007ea7 - Eliminate compiler warning
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18248
diff changeset
104 PurpleCertificate * (* import_certificate)(const gchar * filename);
18247
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
105
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
106 /** Destroys and frees a Certificate structure
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
107 *
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
108 * Destroys a Certificate's internal data structures and calls
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
109 * free(crt)
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
110 *
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
111 * @param crt Certificate instance to be destroyed. It WILL NOT be
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
112 * destroyed if it is not of the correct
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
113 * CertificateScheme. Can be NULL
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
114 */
18248
8f462eaffecd - Style issues
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18247
diff changeset
115 void (* destroy_certificate)(PurpleCertificate * crt);
18454
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
116
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
117 /**
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
118 * Retrieves the certificate public key fingerprint using SHA1
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
119 *
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
120 * @param crt Certificate instance
18457
e9e60bed8906 - More documentation
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18456
diff changeset
121 * @return Binary representation of SHA1 hash - must be freed using
e9e60bed8906 - More documentation
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18456
diff changeset
122 * g_byte_array_free()
18454
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
123 */
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
124 GByteArray * (* get_fingerprint_sha1)(PurpleCertificate *crt);
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
125
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
126 /**
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
127 * Reads "who the certificate is assigned to"
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
128 *
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
129 * For SSL X.509 certificates, this is something like
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
130 * "gmail.com" or "jabber.org"
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
131 *
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
132 * @param crt Certificate instance
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
133 * @return Newly allocated string specifying "whose certificate this
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
134 * is"
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
135 */
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
136 gchar * (* get_certificate_subject)(PurpleCertificate *crt);
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
137
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
138 /**
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
139 * Retrieves a unique certificate identifier
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
140 *
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
141 * @param crt Certificate instance
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
142 * @return Newly allocated string that can be used to uniquely
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
143 * identify the certificate.
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
144 */
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
145 gchar * (* get_unique_id)(PurpleCertificate *crt);
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
146
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
147 /**
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
148 * Retrieves a unique identifier for the certificate's issuer
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
149 *
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
150 * @param crt Certificate instance
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
151 * @return Newly allocated string that can be used to uniquely
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
152 * identify the issuer's certificate.
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
153 */
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
154 gchar * (* get_issuer_unique_id)(PurpleCertificate *crt);
9a56a88152b9 - Add more to the Certificate struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18453
diff changeset
155
18247
d9f7c426dbc9 - Expose some more functions in the x509 CertificateScheme. Doesn't
William Ehlhardt <williamehlhardt@gmail.com>
parents: 17509
diff changeset
156
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
157 /* TODO: Fill out this structure */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
158 };
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
159
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
160 /** A set of operations used to provide logic for verifying a Certificate's
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
161 * authenticity.
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
162 */
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
163 struct _PurpleCertificateVerifier
18460
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
164 {
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
165 /** Name of the Verifier - case insensitive */
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
166 gchar *name;
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
167
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
168 /** Name of the scheme this Verifier operates on
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
169 *
18460
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
170 * The scheme will be looked up by name when a Request is generated
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
171 * using this Verifier
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
172 */
18460
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
173 gchar *scheme_name;
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
174 };
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
175
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
176 /** Structure for a single certificate request
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
177 *
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
178 * Useful for keeping track of the state of a verification that involves
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
179 * several steps
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
180 */
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
181 struct _PurpleCertificateVerificationRequest
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
182 {
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
183 /** Reference to the verification logic used */
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
184 PurpleCertificateVerifier *verifier;
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
185
18460
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
186 /**
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
187 * Name to check that the certificate is issued to
18451
304d2fa12f6a - purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18448
diff changeset
188 *
304d2fa12f6a - purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18448
diff changeset
189 * For X.509 certificates, this is the Common Name
304d2fa12f6a - purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18448
diff changeset
190 */
304d2fa12f6a - purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18448
diff changeset
191 gchar *subject_name;
304d2fa12f6a - purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18448
diff changeset
192
304d2fa12f6a - purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18448
diff changeset
193 /** List of certificates in the chain to be verified (such as that returned by purple_ssl_get_peer_certificates )
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
194 *
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
195 * This is most relevant for X.509 certificates used in SSL sessions.
18451
304d2fa12f6a - purple_ssl_get_peer_certificates
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18448
diff changeset
196 * The list order should be: certificate, issuer, issuer's issuer, etc.
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
197 */
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
198 GList *cert_chain;
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
199
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
200 /** Internal data used by the Verifier code */
18460
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
201 gpointer data;
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
202
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
203 /** Function to call with the verification result */
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
204 PurpleCertificateVerifiedCallback cb;
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
205 /** Data to pass to the post-verification callback */
cceca1e961ad - Fill out CertVerifier struct
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18457
diff changeset
206 gpointer cb_data;
18448
961dae46f969 - More API additions
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18446
diff changeset
207 };
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
208
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
209 /*****************************************************************************/
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
210 /** @name PurpleCertificate Subsystem API */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
211 /*****************************************************************************/
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
212 /*@{*/
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
213
18251
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
214 /** Look up a registered CertificateScheme by name
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
215 * @param name The scheme name. Case insensitive.
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
216 * @return Pointer to the located Scheme, or NULL if it isn't found.
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
217 */
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
218 PurpleCertificateScheme *
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
219 purple_certificate_find_scheme(const gchar *name);
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
220
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
221 /** Register a CertificateScheme with libpurple
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
222 *
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
223 * No two schemes can be registered with the same name; this function enforces
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
224 * that.
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
225 *
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
226 * @param scheme Pointer to the scheme to register.
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
227 * @return TRUE if the scheme was successfully added, otherwise FALSE
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
228 */
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
229 gboolean
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
230 purple_certificate_register_scheme(PurpleCertificateScheme *scheme);
41e00264c49d - Add chunks of the certificate scheme registration interface
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18249
diff changeset
231
18446
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
232 /** Unregister a CertificateScheme from libpurple
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
233 *
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
234 * @param scheme Scheme to unregister.
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
235 * If the scheme is not registered, this is a no-op.
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
236 *
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
237 * @return TRUE if the unregister completed successfully
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
238 */
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
239 gboolean
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
240 purple_certificate_unregister_scheme(PurpleCertificateScheme *scheme);
3e79caab7088 - Add unregister_scheme
William Ehlhardt <williamehlhardt@gmail.com>
parents: 18251
diff changeset
241
17506
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
242 /* TODO: ADD STUFF HERE */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
243
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
244 /*@}*/
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
245
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
246
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
247 #ifdef __cplusplus
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
248 }
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
249 #endif /* __cplusplus */
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
250
eff6bdd382f3 - Added certificate.[ch] and got them integrated into the build
William Ehlhardt <williamehlhardt@gmail.com>
parents:
diff changeset
251 #endif /* _PURPLE_CERTIFICATE_H */

mercurial