certificate.h

Go to the documentation of this file.
00001 
00008 /*
00009  *
00010  * purple
00011  *
00012  * Purple is the legal property of its developers, whose names are too numerous
00013  * to list here.  Please refer to the COPYRIGHT file distributed with this
00014  * source distribution.
00015  *
00016  * This program is free software; you can redistribute it and/or modify
00017  * it under the terms of the GNU General Public License as published by
00018  * the Free Software Foundation; either version 2 of the License, or
00019  * (at your option) any later version.
00020  *
00021  * This program is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License
00027  * along with this program; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00029  */
00030 
00031 #ifndef _PURPLE_CERTIFICATE_H
00032 #define _PURPLE_CERTIFICATE_H
00033 
00034 #include <time.h>
00035 
00036 #include <glib.h>
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif /* __cplusplus */
00041 
00042 
00043 typedef enum
00044 {
00045     PURPLE_CERTIFICATE_INVALID = 0,
00046     PURPLE_CERTIFICATE_VALID = 1
00047 } PurpleCertificateVerificationStatus;
00048 
00049 typedef struct _PurpleCertificate PurpleCertificate;
00050 typedef struct _PurpleCertificatePool PurpleCertificatePool;
00051 typedef struct _PurpleCertificateScheme PurpleCertificateScheme;
00052 typedef struct _PurpleCertificateVerifier PurpleCertificateVerifier;
00053 typedef struct _PurpleCertificateVerificationRequest PurpleCertificateVerificationRequest;
00054 
00060 typedef void (*PurpleCertificateVerifiedCallback)
00061         (PurpleCertificateVerificationStatus st,
00062          gpointer userdata);
00063 
00069 struct _PurpleCertificate
00070 {
00072     PurpleCertificateScheme * scheme;
00074     gpointer data;
00075 };
00076 
00083 struct _PurpleCertificatePool
00084 {
00086     gchar *scheme_name;
00088     gchar *name;
00089 
00095     gchar *fullname;
00096 
00098     gpointer data;
00099 
00107     gboolean (* init)(void);
00108 
00114     void (* uninit)(void);
00115 
00117     gboolean (* cert_in_pool)(const gchar *id);
00119     PurpleCertificate * (* get_cert)(const gchar *id);
00124     gboolean (* put_cert)(const gchar *id, PurpleCertificate *crt);
00126     gboolean (* delete_cert)(const gchar *id);
00127 
00129     GList * (* get_idlist)(void);
00130 
00131     void (*_purple_reserved1)(void);
00132     void (*_purple_reserved2)(void);
00133     void (*_purple_reserved3)(void);
00134     void (*_purple_reserved4)(void);
00135 };
00136 
00145 struct _PurpleCertificateScheme
00146 {
00152     gchar * name;
00153 
00159     gchar * fullname;
00160 
00167     PurpleCertificate * (* import_certificate)(const gchar * filename);
00168 
00177     gboolean (* export_certificate)(const gchar *filename, PurpleCertificate *crt);
00178 
00187     PurpleCertificate * (* copy_certificate)(PurpleCertificate *crt);
00188 
00198     void (* destroy_certificate)(PurpleCertificate * crt);
00199 
00202     gboolean (*signed_by)(PurpleCertificate *crt, PurpleCertificate *issuer);
00210     GByteArray * (* get_fingerprint_sha1)(PurpleCertificate *crt);
00211 
00219     gchar * (* get_unique_id)(PurpleCertificate *crt);
00220 
00228     gchar * (* get_issuer_unique_id)(PurpleCertificate *crt);
00229 
00241     gchar * (* get_subject_name)(PurpleCertificate *crt);
00242 
00248     gboolean (* check_subject_name)(PurpleCertificate *crt, const gchar *name);
00249 
00251     gboolean (* get_times)(PurpleCertificate *crt, time_t *activation, time_t *expiration);
00252 
00253     void (*_purple_reserved1)(void);
00254     void (*_purple_reserved2)(void);
00255     void (*_purple_reserved3)(void);
00256     void (*_purple_reserved4)(void);
00257 };
00258 
00268 struct _PurpleCertificateVerifier
00269 {
00275     gchar *scheme_name;
00276 
00278     gchar *name;
00279 
00290     void (* start_verification)(PurpleCertificateVerificationRequest *vrq);
00291 
00300     void (* destroy_request)(PurpleCertificateVerificationRequest *vrq);
00301 
00302     void (*_purple_reserved1)(void);
00303     void (*_purple_reserved2)(void);
00304     void (*_purple_reserved3)(void);
00305     void (*_purple_reserved4)(void);
00306 };
00307 
00313 struct _PurpleCertificateVerificationRequest
00314 {
00316     PurpleCertificateVerifier *verifier;
00321     PurpleCertificateScheme *scheme;
00322 
00328     gchar *subject_name;
00329 
00335     GList *cert_chain;
00336 
00338     gpointer data;
00339 
00341     PurpleCertificateVerifiedCallback cb;
00343     gpointer cb_data;
00344 };
00345 
00346 /*****************************************************************************/
00348 /*****************************************************************************/
00374 void
00375 purple_certificate_verify (PurpleCertificateVerifier *verifier,
00376                const gchar *subject_name, GList *cert_chain,
00377                PurpleCertificateVerifiedCallback cb,
00378                gpointer cb_data);
00379 
00387 void
00388 purple_certificate_verify_complete(PurpleCertificateVerificationRequest *vrq,
00389                    PurpleCertificateVerificationStatus st);
00390 
00393 /*****************************************************************************/
00395 /*****************************************************************************/
00404 PurpleCertificate *
00405 purple_certificate_copy(PurpleCertificate *crt);
00406 
00413 GList *
00414 purple_certificate_copy_list(GList *crt_list);
00415 
00421 void
00422 purple_certificate_destroy (PurpleCertificate *crt);
00423 
00429 void
00430 purple_certificate_destroy_list (GList * crt_list);
00431 
00442 gboolean
00443 purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer);
00444 
00463 gboolean
00464 purple_certificate_check_signature_chain_with_failing(GList *chain,
00465         PurpleCertificate **failing);
00466 
00481 gboolean
00482 purple_certificate_check_signature_chain(GList *chain);
00483 
00491 PurpleCertificate *
00492 purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename);
00493 
00501 gboolean
00502 purple_certificate_export(const gchar *filename, PurpleCertificate *crt);
00503 
00504 
00513 GByteArray *
00514 purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt);
00515 
00522 gchar *
00523 purple_certificate_get_unique_id(PurpleCertificate *crt);
00524 
00532 gchar *
00533 purple_certificate_get_issuer_unique_id(PurpleCertificate *crt);
00534 
00544 gchar *
00545 purple_certificate_get_subject_name(PurpleCertificate *crt);
00546 
00553 gboolean
00554 purple_certificate_check_subject_name(PurpleCertificate *crt, const gchar *name);
00555 
00566 gboolean
00567 purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration);
00568 
00571 /*****************************************************************************/
00573 /*****************************************************************************/
00586 gchar *
00587 purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id);
00588 
00598 gboolean
00599 purple_certificate_pool_usable(PurpleCertificatePool *pool);
00600 
00609 PurpleCertificateScheme *
00610 purple_certificate_pool_get_scheme(PurpleCertificatePool *pool);
00611 
00618 gboolean
00619 purple_certificate_pool_contains(PurpleCertificatePool *pool, const gchar *id);
00620 
00627 PurpleCertificate *
00628 purple_certificate_pool_retrieve(PurpleCertificatePool *pool, const gchar *id);
00629 
00640 gboolean
00641 purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt);
00642 
00650 gboolean
00651 purple_certificate_pool_delete(PurpleCertificatePool *pool, const gchar *id);
00652 
00660 GList *
00661 purple_certificate_pool_get_idlist(PurpleCertificatePool *pool);
00662 
00668 void
00669 purple_certificate_pool_destroy_idlist(GList *idlist);
00670 
00673 /*****************************************************************************/
00675 /*****************************************************************************/
00681 void
00682 purple_certificate_init(void);
00683 
00687 void
00688 purple_certificate_uninit(void);
00689 
00693 gpointer
00694 purple_certificate_get_handle(void);
00695 
00700 PurpleCertificateScheme *
00701 purple_certificate_find_scheme(const gchar *name);
00702 
00709 GList *
00710 purple_certificate_get_schemes(void);
00711 
00720 gboolean
00721 purple_certificate_register_scheme(PurpleCertificateScheme *scheme);
00722 
00730 gboolean
00731 purple_certificate_unregister_scheme(PurpleCertificateScheme *scheme);
00732 
00738 PurpleCertificateVerifier *
00739 purple_certificate_find_verifier(const gchar *scheme_name, const gchar *ver_name);
00740 
00747 GList *
00748 purple_certificate_get_verifiers(void);
00749 
00756 gboolean
00757 purple_certificate_register_verifier(PurpleCertificateVerifier *vr);
00758 
00765 gboolean
00766 purple_certificate_unregister_verifier(PurpleCertificateVerifier *vr);
00767 
00773 PurpleCertificatePool *
00774 purple_certificate_find_pool(const gchar *scheme_name, const gchar *pool_name);
00775 
00782 GList *
00783 purple_certificate_get_pools(void);
00784 
00791 gboolean
00792 purple_certificate_register_pool(PurpleCertificatePool *pool);
00793 
00800 gboolean
00801 purple_certificate_unregister_pool(PurpleCertificatePool *pool);
00802 
00812 void
00813 purple_certificate_display_x509(PurpleCertificate *crt);
00814 
00820 void purple_certificate_add_ca_search_path(const char *path);
00821 
00822 #ifdef __cplusplus
00823 }
00824 #endif /* __cplusplus */
00825 
00826 #endif /* _PURPLE_CERTIFICATE_H */