certificate.h

Go to the documentation of this file.
00001 
00006 /*
00007  *
00008  * purple
00009  *
00010  * Purple is the legal property of its developers, whose names are too numerous
00011  * to list here.  Please refer to the COPYRIGHT file distributed with this
00012  * source distribution.
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU General Public License as published by
00016  * the Free Software Foundation; either version 2 of the License, or
00017  * (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00027  */
00028 
00029 #ifndef _PURPLE_CERTIFICATE_H
00030 #define _PURPLE_CERTIFICATE_H
00031 
00032 #include <glib.h>
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif /* __cplusplus */
00037 
00038 
00039 typedef enum
00040 {
00041     PURPLE_CERTIFICATE_INVALID = 0,
00042     PURPLE_CERTIFICATE_VALID = 1
00043 } PurpleCertificateVerificationStatus;
00044 
00045 typedef struct _PurpleCertificate PurpleCertificate;
00046 typedef struct _PurpleCertificatePool PurpleCertificatePool;
00047 typedef struct _PurpleCertificateScheme PurpleCertificateScheme;
00048 typedef struct _PurpleCertificateVerifier PurpleCertificateVerifier;
00049 typedef struct _PurpleCertificateVerificationRequest PurpleCertificateVerificationRequest;
00050 
00056 typedef void (*PurpleCertificateVerifiedCallback)
00057         (PurpleCertificateVerificationStatus st,
00058          gpointer userdata);
00059                               
00065 struct _PurpleCertificate
00066 {
00068     PurpleCertificateScheme * scheme;
00070     gpointer data;
00071 };
00072 
00079 struct _PurpleCertificatePool
00080 {
00082     gchar *scheme_name;
00084     gchar *name;
00085 
00091     gchar *fullname;
00092 
00094     gpointer data;
00095     
00103     gboolean (* init)(void);
00104 
00110     void (* uninit)(void);
00111 
00113     gboolean (* cert_in_pool)(const gchar *id);
00115     PurpleCertificate * (* get_cert)(const gchar *id);
00120     gboolean (* put_cert)(const gchar *id, PurpleCertificate *crt);
00122     gboolean (* delete_cert)(const gchar *id);
00123 
00125     GList * (* get_idlist)(void);
00126 
00127     void (*_purple_reserved1)(void);
00128     void (*_purple_reserved2)(void);
00129     void (*_purple_reserved3)(void);
00130     void (*_purple_reserved4)(void);
00131 };
00132 
00141 struct _PurpleCertificateScheme
00142 {
00148     gchar * name;
00149 
00155     gchar * fullname;
00156 
00163     PurpleCertificate * (* import_certificate)(const gchar * filename);
00164 
00173     gboolean (* export_certificate)(const gchar *filename, PurpleCertificate *crt);
00174 
00183     PurpleCertificate * (* copy_certificate)(PurpleCertificate *crt);
00184 
00194     void (* destroy_certificate)(PurpleCertificate * crt);
00195 
00198     gboolean (*signed_by)(PurpleCertificate *crt, PurpleCertificate *issuer);
00206     GByteArray * (* get_fingerprint_sha1)(PurpleCertificate *crt);
00207 
00215     gchar * (* get_unique_id)(PurpleCertificate *crt);
00216 
00224     gchar * (* get_issuer_unique_id)(PurpleCertificate *crt);
00225 
00237     gchar * (* get_subject_name)(PurpleCertificate *crt);
00238 
00244     gboolean (* check_subject_name)(PurpleCertificate *crt, const gchar *name);
00245 
00247     gboolean (* get_times)(PurpleCertificate *crt, time_t *activation, time_t *expiration);
00248     
00249     void (*_purple_reserved1)(void);
00250     void (*_purple_reserved2)(void);
00251     void (*_purple_reserved3)(void);
00252     void (*_purple_reserved4)(void);
00253 };
00254 
00264 struct _PurpleCertificateVerifier
00265 {
00271     gchar *scheme_name;
00272 
00274     gchar *name;
00275     
00286     void (* start_verification)(PurpleCertificateVerificationRequest *vrq);
00287 
00296     void (* destroy_request)(PurpleCertificateVerificationRequest *vrq);
00297 
00298     void (*_purple_reserved1)(void);
00299     void (*_purple_reserved2)(void);
00300     void (*_purple_reserved3)(void);
00301     void (*_purple_reserved4)(void);
00302 };
00303 
00309 struct _PurpleCertificateVerificationRequest
00310 {
00312     PurpleCertificateVerifier *verifier;
00317     PurpleCertificateScheme *scheme;
00318 
00324     gchar *subject_name;
00325     
00331     GList *cert_chain;
00332     
00334     gpointer data;
00335 
00337     PurpleCertificateVerifiedCallback cb;
00339     gpointer cb_data;
00340 };
00341 
00342 /*****************************************************************************/
00344 /*****************************************************************************/
00370 void
00371 purple_certificate_verify (PurpleCertificateVerifier *verifier,
00372                const gchar *subject_name, GList *cert_chain,
00373                PurpleCertificateVerifiedCallback cb,
00374                gpointer cb_data);
00375 
00383 void
00384 purple_certificate_verify_complete(PurpleCertificateVerificationRequest *vrq,
00385                    PurpleCertificateVerificationStatus st);
00386 
00389 /*****************************************************************************/
00391 /*****************************************************************************/
00400 PurpleCertificate *
00401 purple_certificate_copy(PurpleCertificate *crt);
00402 
00409 GList *
00410 purple_certificate_copy_list(GList *crt_list);
00411 
00417 void
00418 purple_certificate_destroy (PurpleCertificate *crt);
00419 
00425 void
00426 purple_certificate_destroy_list (GList * crt_list);
00427 
00438 gboolean
00439 purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer);
00440 
00453 gboolean
00454 purple_certificate_check_signature_chain(GList *chain);
00455 
00463 PurpleCertificate *
00464 purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename);
00465 
00473 gboolean
00474 purple_certificate_export(const gchar *filename, PurpleCertificate *crt);
00475 
00476 
00485 GByteArray *
00486 purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt);
00487 
00494 gchar *
00495 purple_certificate_get_unique_id(PurpleCertificate *crt);
00496 
00504 gchar *
00505 purple_certificate_get_issuer_unique_id(PurpleCertificate *crt);
00506 
00516 gchar *
00517 purple_certificate_get_subject_name(PurpleCertificate *crt);
00518 
00525 gboolean
00526 purple_certificate_check_subject_name(PurpleCertificate *crt, const gchar *name);
00527 
00538 gboolean
00539 purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration);
00540 
00543 /*****************************************************************************/
00545 /*****************************************************************************/
00558 gchar *
00559 purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id);
00560 
00570 gboolean
00571 purple_certificate_pool_usable(PurpleCertificatePool *pool);
00572 
00581 PurpleCertificateScheme *
00582 purple_certificate_pool_get_scheme(PurpleCertificatePool *pool);
00583 
00590 gboolean
00591 purple_certificate_pool_contains(PurpleCertificatePool *pool, const gchar *id);
00592 
00599 PurpleCertificate *
00600 purple_certificate_pool_retrieve(PurpleCertificatePool *pool, const gchar *id);
00601 
00612 gboolean
00613 purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt);
00614 
00622 gboolean
00623 purple_certificate_pool_delete(PurpleCertificatePool *pool, const gchar *id);
00624 
00632 GList *
00633 purple_certificate_pool_get_idlist(PurpleCertificatePool *pool);
00634 
00640 void
00641 purple_certificate_pool_destroy_idlist(GList *idlist);
00642 
00645 /*****************************************************************************/
00647 /*****************************************************************************/
00653 void
00654 purple_certificate_init(void);
00655 
00659 void
00660 purple_certificate_uninit(void);
00661 
00665 gpointer
00666 purple_certificate_get_handle(void);
00667 
00672 PurpleCertificateScheme *
00673 purple_certificate_find_scheme(const gchar *name);
00674 
00681 GList *
00682 purple_certificate_get_schemes(void);
00683 
00692 gboolean
00693 purple_certificate_register_scheme(PurpleCertificateScheme *scheme);
00694 
00702 gboolean
00703 purple_certificate_unregister_scheme(PurpleCertificateScheme *scheme);
00704 
00710 PurpleCertificateVerifier *
00711 purple_certificate_find_verifier(const gchar *scheme_name, const gchar *ver_name);
00712 
00719 GList *
00720 purple_certificate_get_verifiers(void);
00721 
00728 gboolean
00729 purple_certificate_register_verifier(PurpleCertificateVerifier *vr);
00730 
00737 gboolean
00738 purple_certificate_unregister_verifier(PurpleCertificateVerifier *vr);
00739 
00745 PurpleCertificatePool *
00746 purple_certificate_find_pool(const gchar *scheme_name, const gchar *pool_name);
00747 
00754 GList *
00755 purple_certificate_get_pools(void);
00756 
00763 gboolean
00764 purple_certificate_register_pool(PurpleCertificatePool *pool);
00765 
00772 gboolean
00773 purple_certificate_unregister_pool(PurpleCertificatePool *pool);
00774 
00784 void
00785 purple_certificate_display_x509(PurpleCertificate *crt);
00786 
00787 
00788 #ifdef __cplusplus
00789 }
00790 #endif /* __cplusplus */
00791 
00792 #endif /* _PURPLE_CERTIFICATE_H */