certificate.h
Go to the documentation of this file.
1 
8 /*
9  *
10  * purple
11  *
12  * Purple is the legal property of its developers, whose names are too numerous
13  * to list here. Please refer to the COPYRIGHT file distributed with this
14  * source distribution.
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
29  */
30 
31 #ifndef _PURPLE_CERTIFICATE_H
32 #define _PURPLE_CERTIFICATE_H
33 
34 #include <time.h>
35 
36 #include <glib.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41 
42 
43 typedef enum
44 {
45  PURPLE_CERTIFICATE_INVALID = 0,
46  PURPLE_CERTIFICATE_VALID = 1
47 } PurpleCertificateVerificationStatus;
48 
49 /*
50  * TODO: Merge this with PurpleCertificateVerificationStatus for 3.0.0 */
51 typedef enum {
52  PURPLE_CERTIFICATE_UNKNOWN_ERROR = -1,
53 
54  /* Not an error */
55  PURPLE_CERTIFICATE_NO_PROBLEMS = 0,
56 
57  /* Non-fatal */
58  PURPLE_CERTIFICATE_NON_FATALS_MASK = 0x0000FFFF,
59 
60  /* The certificate is self-signed. */
61  PURPLE_CERTIFICATE_SELF_SIGNED = 0x01,
62 
63  /* The CA is not in libpurple's pool of certificates. */
64  PURPLE_CERTIFICATE_CA_UNKNOWN = 0x02,
65 
66  /* The current time is before the certificate's specified
67  * activation time.
68  */
69  PURPLE_CERTIFICATE_NOT_ACTIVATED = 0x04,
70 
71  /* The current time is after the certificate's specified expiration time */
72  PURPLE_CERTIFICATE_EXPIRED = 0x08,
73 
74  /* The certificate's subject name doesn't match the expected */
75  PURPLE_CERTIFICATE_NAME_MISMATCH = 0x10,
76 
77  /* No CA pool was found. This shouldn't happen... */
78  PURPLE_CERTIFICATE_NO_CA_POOL = 0x20,
79 
80  /* Fatal */
81  PURPLE_CERTIFICATE_FATALS_MASK = 0xFFFF0000,
82 
83  /* The signature chain could not be validated. Due to limitations in the
84  * the current API, this also indicates one of the CA certificates in the
85  * chain is expired (or not yet activated). FIXME 3.0.0 */
86  PURPLE_CERTIFICATE_INVALID_CHAIN = 0x10000,
87 
88  /* The signature has been revoked. */
89  PURPLE_CERTIFICATE_REVOKED = 0x20000,
90 
91  PURPLE_CERTIFICATE_LAST = 0x40000,
92 } PurpleCertificateInvalidityFlags;
93 
99 
105 typedef void (*PurpleCertificateVerifiedCallback)
106  (PurpleCertificateVerificationStatus st,
107  gpointer userdata);
108 
115 {
119  gpointer data;
120 };
121 
129 {
131  gchar *scheme_name;
133  gchar *name;
134 
140  gchar *fullname;
141 
143  gpointer data;
144 
152  gboolean (* init)(void);
153 
159  void (* uninit)(void);
160 
162  gboolean (* cert_in_pool)(const gchar *id);
164  PurpleCertificate * (* get_cert)(const gchar *id);
169  gboolean (* put_cert)(const gchar *id, PurpleCertificate *crt);
171  gboolean (* delete_cert)(const gchar *id);
172 
174  GList * (* get_idlist)(void);
175 
176  void (*_purple_reserved1)(void);
177  void (*_purple_reserved2)(void);
178  void (*_purple_reserved3)(void);
179  void (*_purple_reserved4)(void);
180 };
181 
191 {
197  gchar * name;
198 
204  gchar * fullname;
205 
212  PurpleCertificate * (* import_certificate)(const gchar * filename);
213 
222  gboolean (* export_certificate)(const gchar *filename, PurpleCertificate *crt);
223 
232  PurpleCertificate * (* copy_certificate)(PurpleCertificate *crt);
233 
244 
248  gboolean (*signed_by)(PurpleCertificate *crt, PurpleCertificate *issuer);
256  GByteArray * (* get_fingerprint_sha1)(PurpleCertificate *crt);
257 
265  gchar * (* get_unique_id)(PurpleCertificate *crt);
266 
274  gchar * (* get_issuer_unique_id)(PurpleCertificate *crt);
275 
287  gchar * (* get_subject_name)(PurpleCertificate *crt);
288 
294  gboolean (* check_subject_name)(PurpleCertificate *crt, const gchar *name);
295 
297  gboolean (* get_times)(PurpleCertificate *crt, time_t *activation, time_t *expiration);
298 
305  GSList * (* import_certificates)(const gchar * filename);
306 
310  gboolean (* register_trusted_tls_cert)(PurpleCertificate *crt, gboolean ca);
311 
316  void (* verify_cert)(PurpleCertificateVerificationRequest *vrq, PurpleCertificateInvalidityFlags *flags);
317 
318  void (*_purple_reserved3)(void);
319 };
320 
331 {
337  gchar *scheme_name;
338 
340  gchar *name;
341 
353 
363 
364  void (*_purple_reserved1)(void);
365  void (*_purple_reserved2)(void);
366  void (*_purple_reserved3)(void);
367  void (*_purple_reserved4)(void);
368 };
369 
376 {
384 
390  gchar *subject_name;
391 
397  GList *cert_chain;
398 
400  gpointer data;
401 
405  gpointer cb_data;
406 };
407 
408 /*****************************************************************************/
410 /*****************************************************************************/
436 void
438  const gchar *subject_name, GList *cert_chain,
440  gpointer cb_data);
441 
449 void
451  PurpleCertificateVerificationStatus st);
452 
455 /*****************************************************************************/
457 /*****************************************************************************/
468 
475 GList *
476 purple_certificate_copy_list(GList *crt_list);
477 
483 void
485 
491 void
492 purple_certificate_destroy_list (GList * crt_list);
493 
504 gboolean
506 
525 gboolean
527  PurpleCertificate **failing);
528 
543 gboolean
545 
554 purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename);
555 
563 GSList *
564 purple_certificates_import(PurpleCertificateScheme *scheme, const gchar *filename);
565 
573 gboolean
574 purple_certificate_export(const gchar *filename, PurpleCertificate *crt);
575 
576 
585 GByteArray *
587 
594 gchar *
596 
604 gchar *
606 
616 gchar *
618 
625 gboolean
627 
638 gboolean
639 purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration);
640 
643 /*****************************************************************************/
645 /*****************************************************************************/
658 gchar *
660 
670 gboolean
672 
683 
690 gboolean
692 
702 
713 gboolean
715 
723 gboolean
725 
733 GList *
735 
741 void
743 
746 /*****************************************************************************/
748 /*****************************************************************************/
754 void
756 
760 void
762 
766 gpointer
768 
774 purple_certificate_find_scheme(const gchar *name);
775 
782 GList *
784 
793 gboolean
795 
803 gboolean
805 
812 purple_certificate_find_verifier(const gchar *scheme_name, const gchar *ver_name);
813 
820 GList *
822 
829 gboolean
831 
838 gboolean
840 
847 purple_certificate_find_pool(const gchar *scheme_name, const gchar *pool_name);
848 
855 GList *
857 
864 gboolean
866 
873 gboolean
875 
885 void
887 
893 void purple_certificate_add_ca_search_path(const char *path);
894 
895 #ifdef __cplusplus
896 }
897 #endif /* __cplusplus */
898 
899 #endif /* _PURPLE_CERTIFICATE_H */