Frameworks/libpurple.framework/Versions/0.6.2/Headers/certificate.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2571 Frameworks/libpurple.framework/Versions/0.6.0/Headers/certificate.h@75fb8ee8f2e6
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /**
     2  * @file certificate.h Public-Key Certificate API
     3  * @ingroup core
     4  * @see @ref certificate-signals
     5  * @since 2.2.0
     6  */
     7 
     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 typedef struct _PurpleCertificate PurpleCertificate;
    50 typedef struct _PurpleCertificatePool PurpleCertificatePool;
    51 typedef struct _PurpleCertificateScheme PurpleCertificateScheme;
    52 typedef struct _PurpleCertificateVerifier PurpleCertificateVerifier;
    53 typedef struct _PurpleCertificateVerificationRequest PurpleCertificateVerificationRequest;
    54 
    55 /**
    56  * Callback function for the results of a verification check
    57  * @param st       Status code
    58  * @param userdata User-defined data
    59  */
    60 typedef void (*PurpleCertificateVerifiedCallback)
    61 		(PurpleCertificateVerificationStatus st,
    62 		 gpointer userdata);
    63 
    64 /** A certificate instance
    65  *
    66  *  An opaque data structure representing a single certificate under some
    67  *  CertificateScheme
    68  */
    69 struct _PurpleCertificate
    70 {
    71 	/** Scheme this certificate is under */
    72 	PurpleCertificateScheme * scheme;
    73 	/** Opaque pointer to internal data */
    74 	gpointer data;
    75 };
    76 
    77 /**
    78  * Database for retrieval or storage of Certificates
    79  *
    80  * More or less a hash table; all lookups and writes are controlled by a string
    81  * key.
    82  */
    83 struct _PurpleCertificatePool
    84 {
    85 	/** Scheme this Pool operates for */
    86 	gchar *scheme_name;
    87 	/** Internal name to refer to the pool by */
    88 	gchar *name;
    89 
    90 	/** User-friendly name for this type
    91 	 *  ex: N_("SSL Servers")
    92 	 *  When this is displayed anywhere, it should be i18ned
    93 	 *  ex: _(pool->fullname)
    94 	 */
    95 	gchar *fullname;
    96 
    97 	/** Internal pool data */
    98 	gpointer data;
    99 
   100 	/**
   101 	 * Set up the Pool's internal state
   102 	 *
   103 	 * Upon calling purple_certificate_register_pool() , this function will
   104 	 * be called. May be NULL.
   105 	 * @return TRUE if the initialization succeeded, otherwise FALSE
   106 	 */
   107 	gboolean (* init)(void);
   108 
   109 	/**
   110 	 * Uninit the Pool's internal state
   111 	 *
   112 	 * Will be called by purple_certificate_unregister_pool() . May be NULL
   113 	 */
   114 	void (* uninit)(void);
   115 
   116 	/** Check for presence of a certificate in the pool using unique ID */
   117 	gboolean (* cert_in_pool)(const gchar *id);
   118 	/** Retrieve a PurpleCertificate from the pool */
   119 	PurpleCertificate * (* get_cert)(const gchar *id);
   120 	/** Add a certificate to the pool. Must overwrite any other
   121 	 *  certificates sharing the same ID in the pool.
   122 	 *  @return TRUE if the operation succeeded, otherwise FALSE
   123 	 */
   124 	gboolean (* put_cert)(const gchar *id, PurpleCertificate *crt);
   125 	/** Delete a certificate from the pool */
   126 	gboolean (* delete_cert)(const gchar *id);
   127 
   128 	/** Returns a list of IDs stored in the pool */
   129 	GList * (* get_idlist)(void);
   130 
   131 	void (*_purple_reserved1)(void);
   132 	void (*_purple_reserved2)(void);
   133 	void (*_purple_reserved3)(void);
   134 	void (*_purple_reserved4)(void);
   135 };
   136 
   137 /** A certificate type
   138  *
   139  *  A CertificateScheme must implement all of the fields in the structure,
   140  *  and register it using purple_certificate_register_scheme()
   141  *
   142  *  There may be only ONE CertificateScheme provided for each certificate
   143  *  type, as specified by the "name" field.
   144  */
   145 struct _PurpleCertificateScheme
   146 {
   147 	/** Name of the certificate type
   148 	 *  ex: "x509", "pgp", etc.
   149 	 *  This must be globally unique - you may not register more than one
   150 	 *  CertificateScheme of the same name at a time.
   151 	 */
   152 	gchar * name;
   153 
   154 	/** User-friendly name for this type
   155 	 *  ex: N_("X.509 Certificates")
   156 	 *  When this is displayed anywhere, it should be i18ned
   157 	 *  ex: _(scheme->fullname)
   158 	 */
   159 	gchar * fullname;
   160 
   161 	/** Imports a certificate from a file
   162 	 *
   163 	 *  @param filename   File to import the certificate from
   164 	 *  @return           Pointer to the newly allocated Certificate struct
   165 	 *                    or NULL on failure.
   166 	 */
   167 	PurpleCertificate * (* import_certificate)(const gchar * filename);
   168 
   169 	/**
   170 	 * Exports a certificate to a file
   171 	 *
   172 	 * @param filename    File to export the certificate to
   173 	 * @param crt         Certificate to export
   174 	 * @return TRUE if the export succeeded, otherwise FALSE
   175 	 * @see purple_certificate_export()
   176 	 */
   177 	gboolean (* export_certificate)(const gchar *filename, PurpleCertificate *crt);
   178 
   179 	/**
   180 	 * Duplicates a certificate
   181 	 *
   182 	 * Certificates are generally assumed to be read-only, so feel free to
   183 	 * do any sort of reference-counting magic you want here. If this ever
   184 	 * changes, please remember to change the magic accordingly.
   185 	 * @return Reference to the new copy
   186 	 */
   187 	PurpleCertificate * (* copy_certificate)(PurpleCertificate *crt);
   188 
   189 	/** Destroys and frees a Certificate structure
   190 	 *
   191 	 *  Destroys a Certificate's internal data structures and calls
   192 	 *  free(crt)
   193 	 *
   194 	 *  @param crt  Certificate instance to be destroyed. It WILL NOT be
   195 	 *              destroyed if it is not of the correct
   196 	 *              CertificateScheme. Can be NULL
   197 	 */
   198 	void (* destroy_certificate)(PurpleCertificate * crt);
   199 
   200 	/** Find whether "crt" has a valid signature from issuer "issuer"
   201 	 *  @see purple_certificate_signed_by() */
   202 	gboolean (*signed_by)(PurpleCertificate *crt, PurpleCertificate *issuer);
   203 	/**
   204 	 * Retrieves the certificate public key fingerprint using SHA1
   205 	 *
   206 	 * @param crt   Certificate instance
   207 	 * @return Binary representation of SHA1 hash - must be freed using
   208 	 *         g_byte_array_free()
   209 	 */
   210 	GByteArray * (* get_fingerprint_sha1)(PurpleCertificate *crt);
   211 
   212 	/**
   213 	 * Retrieves a unique certificate identifier
   214 	 *
   215 	 * @param crt   Certificate instance
   216 	 * @return Newly allocated string that can be used to uniquely
   217 	 *         identify the certificate.
   218 	 */
   219 	gchar * (* get_unique_id)(PurpleCertificate *crt);
   220 
   221 	/**
   222 	 * Retrieves a unique identifier for the certificate's issuer
   223 	 *
   224 	 * @param crt   Certificate instance
   225 	 * @return Newly allocated string that can be used to uniquely
   226 	 *         identify the issuer's certificate.
   227 	 */
   228 	gchar * (* get_issuer_unique_id)(PurpleCertificate *crt);
   229 
   230 	/**
   231 	 * Gets the certificate subject's name
   232 	 *
   233 	 * For X.509, this is the "Common Name" field, as we're only using it
   234 	 * for hostname verification at the moment
   235 	 *
   236 	 * @see purple_certificate_get_subject_name()
   237 	 *
   238 	 * @param crt   Certificate instance
   239 	 * @return Newly allocated string with the certificate subject.
   240 	 */
   241 	gchar * (* get_subject_name)(PurpleCertificate *crt);
   242 
   243 	/**
   244 	 * Check the subject name against that on the certificate
   245 	 * @see purple_certificate_check_subject_name()
   246 	 * @return TRUE if it is a match, else FALSE
   247 	 */
   248 	gboolean (* check_subject_name)(PurpleCertificate *crt, const gchar *name);
   249 
   250 	/** Retrieve the certificate activation/expiration times */
   251 	gboolean (* get_times)(PurpleCertificate *crt, time_t *activation, time_t *expiration);
   252 
   253 	void (*_purple_reserved1)(void);
   254 	void (*_purple_reserved2)(void);
   255 	void (*_purple_reserved3)(void);
   256 	void (*_purple_reserved4)(void);
   257 };
   258 
   259 /** A set of operations used to provide logic for verifying a Certificate's
   260  *  authenticity.
   261  *
   262  * A Verifier provider must fill out these fields, then register it using
   263  * purple_certificate_register_verifier()
   264  *
   265  * The (scheme_name, name) value must be unique for each Verifier - you may not
   266  * register more than one Verifier of the same name for each Scheme
   267  */
   268 struct _PurpleCertificateVerifier
   269 {
   270 	/** Name of the scheme this Verifier operates on
   271 	 *
   272 	 * The scheme will be looked up by name when a Request is generated
   273 	 * using this Verifier
   274 	 */
   275 	gchar *scheme_name;
   276 
   277 	/** Name of the Verifier - case insensitive */
   278 	gchar *name;
   279 
   280 	/**
   281 	 * Start the verification process
   282 	 *
   283 	 * To be called from purple_certificate_verify once it has
   284 	 * constructed the request. This will use the information in the
   285 	 * given VerificationRequest to check the certificate and callback
   286 	 * the requester with the verification results.
   287 	 *
   288 	 * @param vrq      Request to process
   289 	 */
   290 	void (* start_verification)(PurpleCertificateVerificationRequest *vrq);
   291 
   292 	/**
   293 	 * Destroy a completed Request under this Verifier
   294 	 * The function pointed to here is only responsible for cleaning up
   295 	 * whatever PurpleCertificateVerificationRequest::data points to.
   296 	 * It should not call free(vrq)
   297 	 *
   298 	 * @param vrq       Request to destroy
   299 	 */
   300 	void (* destroy_request)(PurpleCertificateVerificationRequest *vrq);
   301 
   302 	void (*_purple_reserved1)(void);
   303 	void (*_purple_reserved2)(void);
   304 	void (*_purple_reserved3)(void);
   305 	void (*_purple_reserved4)(void);
   306 };
   307 
   308 /** Structure for a single certificate request
   309  *
   310  *  Useful for keeping track of the state of a verification that involves
   311  *  several steps
   312  */
   313 struct _PurpleCertificateVerificationRequest
   314 {
   315 	/** Reference to the verification logic used */
   316 	PurpleCertificateVerifier *verifier;
   317 	/** Reference to the scheme used.
   318 	 *
   319 	 * This is looked up from the Verifier when the Request is generated
   320 	 */
   321 	PurpleCertificateScheme *scheme;
   322 
   323 	/**
   324 	 * Name to check that the certificate is issued to
   325 	 *
   326 	 * For X.509 certificates, this is the Common Name
   327 	 */
   328 	gchar *subject_name;
   329 
   330 	/** List of certificates in the chain to be verified (such as that returned by purple_ssl_get_peer_certificates )
   331 	 *
   332 	 * This is most relevant for X.509 certificates used in SSL sessions.
   333 	 * The list order should be: certificate, issuer, issuer's issuer, etc.
   334 	 */
   335 	GList *cert_chain;
   336 
   337 	/** Internal data used by the Verifier code */
   338 	gpointer data;
   339 
   340 	/** Function to call with the verification result */
   341 	PurpleCertificateVerifiedCallback cb;
   342 	/** Data to pass to the post-verification callback */
   343 	gpointer cb_data;
   344 };
   345 
   346 /*****************************************************************************/
   347 /** @name Certificate Verification Functions                                 */
   348 /*****************************************************************************/
   349 /*@{*/
   350 
   351 /**
   352  * Constructs a verification request and passed control to the specified Verifier
   353  *
   354  * It is possible that the callback will be called immediately upon calling
   355  * this function. Plan accordingly.
   356  *
   357  * @param verifier      Verification logic to use.
   358  *                      @see purple_certificate_find_verifier()
   359  *
   360  * @param subject_name  Name that should match the first certificate in the
   361  *                      chain for the certificate to be valid. Will be strdup'd
   362  *                      into the Request struct
   363  *
   364  * @param cert_chain    Certificate chain to check. If there is more than one
   365  *                      certificate in the chain (X.509), the peer's
   366  *                      certificate comes first, then the issuer/signer's
   367  *                      certificate, etc. The whole list is duplicated into the
   368  *                      Request struct.
   369  *
   370  * @param cb            Callback function to be called with whether the
   371  *                      certificate was approved or not.
   372  * @param cb_data       User-defined data for the above.
   373  */
   374 void
   375 purple_certificate_verify (PurpleCertificateVerifier *verifier,
   376 			   const gchar *subject_name, GList *cert_chain,
   377 			   PurpleCertificateVerifiedCallback cb,
   378 			   gpointer cb_data);
   379 
   380 /**
   381  * Completes and destroys a VerificationRequest
   382  *
   383  * @param vrq           Request to conclude
   384  * @param st            Success/failure code to pass to the request's
   385  *                      completion callback.
   386  */
   387 void
   388 purple_certificate_verify_complete(PurpleCertificateVerificationRequest *vrq,
   389 				   PurpleCertificateVerificationStatus st);
   390 
   391 /*@}*/
   392 
   393 /*****************************************************************************/
   394 /** @name Certificate Functions                                              */
   395 /*****************************************************************************/
   396 /*@{*/
   397 
   398 /**
   399  * Makes a duplicate of a certificate
   400  *
   401  * @param crt        Instance to duplicate
   402  * @return Pointer to new instance
   403  */
   404 PurpleCertificate *
   405 purple_certificate_copy(PurpleCertificate *crt);
   406 
   407 /**
   408  * Duplicates an entire list of certificates
   409  *
   410  * @param crt_list   List to duplicate
   411  * @return New list copy
   412  */
   413 GList *
   414 purple_certificate_copy_list(GList *crt_list);
   415 
   416 /**
   417  * Destroys and free()'s a Certificate
   418  *
   419  * @param crt        Instance to destroy. May be NULL.
   420  */
   421 void
   422 purple_certificate_destroy (PurpleCertificate *crt);
   423 
   424 /**
   425  * Destroy an entire list of Certificate instances and the containing list
   426  *
   427  * @param crt_list   List of certificates to destroy. May be NULL.
   428  */
   429 void
   430 purple_certificate_destroy_list (GList * crt_list);
   431 
   432 /**
   433  * Check whether 'crt' has a valid signature made by 'issuer'
   434  *
   435  * @param crt        Certificate instance to check signature of
   436  * @param issuer     Certificate thought to have signed 'crt'
   437  *
   438  * @return TRUE if 'crt' has a valid signature made by 'issuer',
   439  *         otherwise FALSE
   440  * @todo Find a way to give the reason (bad signature, not the issuer, etc.)
   441  */
   442 gboolean
   443 purple_certificate_signed_by(PurpleCertificate *crt, PurpleCertificate *issuer);
   444 
   445 /**
   446  * Check that a certificate chain is valid and, if not, the failing certificate.
   447  *
   448  * Uses purple_certificate_signed_by() to verify that each PurpleCertificate
   449  * in the chain carries a valid signature from the next. A single-certificate
   450  * chain is considered to be valid.
   451  *
   452  * @param chain      List of PurpleCertificate instances comprising the chain,
   453  *                   in the order certificate, issuer, issuer's issuer, etc.
   454  * @param failing    A pointer to a PurpleCertificate*. If not NULL, if the
   455  *                   chain fails to validate, this will be set to the
   456  *                   certificate whose signature could not be validated.
   457  * @return TRUE if the chain is valid. See description.
   458  *
   459  * @since 2.6.0
   460  * @deprecated  This function will become
   461  *              purple_certificate_check_signature_chain in 3.0.0
   462  */
   463 gboolean
   464 purple_certificate_check_signature_chain_with_failing(GList *chain,
   465 		PurpleCertificate **failing);
   466 
   467 /**
   468  * Check that a certificate chain is valid
   469  *
   470  * Uses purple_certificate_signed_by() to verify that each PurpleCertificate
   471  * in the chain carries a valid signature from the next. A single-certificate
   472  * chain is considered to be valid.
   473  *
   474  * @param chain      List of PurpleCertificate instances comprising the chain,
   475  *                   in the order certificate, issuer, issuer's issuer, etc.
   476  * @return TRUE if the chain is valid. See description.
   477  * @todo Specify which certificate in the chain caused a failure
   478  * @deprecated  This function will be removed in 3.0.0 and replaced with
   479  *              purple_certificate_check_signature_chain_with_failing
   480  */
   481 gboolean
   482 purple_certificate_check_signature_chain(GList *chain);
   483 
   484 /**
   485  * Imports a PurpleCertificate from a file
   486  *
   487  * @param scheme      Scheme to import under
   488  * @param filename    File path to import from
   489  * @return Pointer to a new PurpleCertificate, or NULL on failure
   490  */
   491 PurpleCertificate *
   492 purple_certificate_import(PurpleCertificateScheme *scheme, const gchar *filename);
   493 
   494 /**
   495  * Exports a PurpleCertificate to a file
   496  *
   497  * @param filename    File to export the certificate to
   498  * @param crt         Certificate to export
   499  * @return TRUE if the export succeeded, otherwise FALSE
   500  */
   501 gboolean
   502 purple_certificate_export(const gchar *filename, PurpleCertificate *crt);
   503 
   504 
   505 /**
   506  * Retrieves the certificate public key fingerprint using SHA1.
   507  *
   508  * @param crt        Certificate instance
   509  * @return Binary representation of the hash. You are responsible for free()ing
   510  *         this.
   511  * @see purple_base16_encode_chunked()
   512  */
   513 GByteArray *
   514 purple_certificate_get_fingerprint_sha1(PurpleCertificate *crt);
   515 
   516 /**
   517  * Get a unique identifier for the certificate
   518  *
   519  * @param crt        Certificate instance
   520  * @return String representing the certificate uniquely. Must be g_free()'ed
   521  */
   522 gchar *
   523 purple_certificate_get_unique_id(PurpleCertificate *crt);
   524 
   525 /**
   526  * Get a unique identifier for the certificate's issuer
   527  *
   528  * @param crt        Certificate instance
   529  * @return String representing the certificate's issuer uniquely. Must be
   530  *         g_free()'ed
   531  */
   532 gchar *
   533 purple_certificate_get_issuer_unique_id(PurpleCertificate *crt);
   534 
   535 /**
   536  * Gets the certificate subject's name
   537  *
   538  * For X.509, this is the "Common Name" field, as we're only using it
   539  * for hostname verification at the moment
   540  *
   541  * @param crt   Certificate instance
   542  * @return Newly allocated string with the certificate subject.
   543  */
   544 gchar *
   545 purple_certificate_get_subject_name(PurpleCertificate *crt);
   546 
   547 /**
   548  * Check the subject name against that on the certificate
   549  * @param crt   Certificate instance
   550  * @param name  Name to check.
   551  * @return TRUE if it is a match, else FALSE
   552  */
   553 gboolean
   554 purple_certificate_check_subject_name(PurpleCertificate *crt, const gchar *name);
   555 
   556 /**
   557  * Get the expiration/activation times.
   558  *
   559  * @param crt          Certificate instance
   560  * @param activation   Reference to store the activation time at. May be NULL
   561  *                     if you don't actually want it.
   562  * @param expiration   Reference to store the expiration time at. May be NULL
   563  *                     if you don't actually want it.
   564  * @return TRUE if the requested values were obtained, otherwise FALSE.
   565  */
   566 gboolean
   567 purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration);
   568 
   569 /*@}*/
   570 
   571 /*****************************************************************************/
   572 /** @name Certificate Pool Functions                                         */
   573 /*****************************************************************************/
   574 /*@{*/
   575 /**
   576  * Helper function for generating file paths in ~/.purple/certificates for
   577  * CertificatePools that use them.
   578  *
   579  * All components will be escaped for filesystem friendliness.
   580  *
   581  * @param pool   CertificatePool to build a path for
   582  * @param id     Key to look up a Certificate by. May be NULL.
   583  * @return A newly allocated path of the form
   584  *         ~/.purple/certificates/scheme_name/pool_name/unique_id
   585  */
   586 gchar *
   587 purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id);
   588 
   589 /**
   590  * Determines whether a pool can be used.
   591  *
   592  * Checks whether the associated CertificateScheme is loaded.
   593  *
   594  * @param pool   Pool to check
   595  *
   596  * @return TRUE if the pool can be used, otherwise FALSE
   597  */
   598 gboolean
   599 purple_certificate_pool_usable(PurpleCertificatePool *pool);
   600 
   601 /**
   602  * Looks up the scheme the pool operates under
   603  *
   604  * @param pool   Pool to get the scheme of
   605  *
   606  * @return Pointer to the pool's scheme, or NULL if it isn't loaded.
   607  * @see purple_certificate_pool_usable()
   608  */
   609 PurpleCertificateScheme *
   610 purple_certificate_pool_get_scheme(PurpleCertificatePool *pool);
   611 
   612 /**
   613  * Check for presence of an ID in a pool.
   614  * @param pool   Pool to look in
   615  * @param id     ID to look for
   616  * @return TRUE if the ID is in the pool, else FALSE
   617  */
   618 gboolean
   619 purple_certificate_pool_contains(PurpleCertificatePool *pool, const gchar *id);
   620 
   621 /**
   622  * Retrieve a certificate from a pool.
   623  * @param pool   Pool to fish in
   624  * @param id     ID to look up
   625  * @return Retrieved certificate, or NULL if it wasn't there
   626  */
   627 PurpleCertificate *
   628 purple_certificate_pool_retrieve(PurpleCertificatePool *pool, const gchar *id);
   629 
   630 /**
   631  * Add a certificate to a pool
   632  *
   633  * Any pre-existing certificate of the same ID will be overwritten.
   634  *
   635  * @param pool   Pool to add to
   636  * @param id     ID to store the certificate with
   637  * @param crt    Certificate to store
   638  * @return TRUE if the operation succeeded, otherwise FALSE
   639  */
   640 gboolean
   641 purple_certificate_pool_store(PurpleCertificatePool *pool, const gchar *id, PurpleCertificate *crt);
   642 
   643 /**
   644  * Remove a certificate from a pool
   645  *
   646  * @param pool   Pool to remove from
   647  * @param id     ID to remove
   648  * @return TRUE if the operation succeeded, otherwise FALSE
   649  */
   650 gboolean
   651 purple_certificate_pool_delete(PurpleCertificatePool *pool, const gchar *id);
   652 
   653 /**
   654  * Get the list of IDs currently in the pool.
   655  *
   656  * @param pool   Pool to enumerate
   657  * @return GList pointing to newly-allocated id strings. Free using
   658  *         purple_certificate_pool_destroy_idlist()
   659  */
   660 GList *
   661 purple_certificate_pool_get_idlist(PurpleCertificatePool *pool);
   662 
   663 /**
   664  * Destroys the result given by purple_certificate_pool_get_idlist()
   665  *
   666  * @param idlist ID List to destroy
   667  */
   668 void
   669 purple_certificate_pool_destroy_idlist(GList *idlist);
   670 
   671 /*@}*/
   672 
   673 /*****************************************************************************/
   674 /** @name Certificate Subsystem API                                          */
   675 /*****************************************************************************/
   676 /*@{*/
   677 
   678 /**
   679  * Initialize the certificate system
   680  */
   681 void
   682 purple_certificate_init(void);
   683 
   684 /**
   685  * Un-initialize the certificate system
   686  */
   687 void
   688 purple_certificate_uninit(void);
   689 
   690 /**
   691  * Get the Certificate subsystem handle for signalling purposes
   692  */
   693 gpointer
   694 purple_certificate_get_handle(void);
   695 
   696 /** Look up a registered CertificateScheme by name
   697  * @param name   The scheme name. Case insensitive.
   698  * @return Pointer to the located Scheme, or NULL if it isn't found.
   699  */
   700 PurpleCertificateScheme *
   701 purple_certificate_find_scheme(const gchar *name);
   702 
   703 /**
   704  * Get all registered CertificateSchemes
   705  *
   706  * @return GList pointing to all registered CertificateSchemes . This value
   707  *         is owned by libpurple
   708  */
   709 GList *
   710 purple_certificate_get_schemes(void);
   711 
   712 /** Register a CertificateScheme with libpurple
   713  *
   714  * No two schemes can be registered with the same name; this function enforces
   715  * that.
   716  *
   717  * @param scheme  Pointer to the scheme to register.
   718  * @return TRUE if the scheme was successfully added, otherwise FALSE
   719  */
   720 gboolean
   721 purple_certificate_register_scheme(PurpleCertificateScheme *scheme);
   722 
   723 /** Unregister a CertificateScheme from libpurple
   724  *
   725  * @param scheme    Scheme to unregister.
   726  *                  If the scheme is not registered, this is a no-op.
   727  *
   728  * @return TRUE if the unregister completed successfully
   729  */
   730 gboolean
   731 purple_certificate_unregister_scheme(PurpleCertificateScheme *scheme);
   732 
   733 /** Look up a registered PurpleCertificateVerifier by scheme and name
   734  * @param scheme_name  Scheme name. Case insensitive.
   735  * @param ver_name     The verifier name. Case insensitive.
   736  * @return Pointer to the located Verifier, or NULL if it isn't found.
   737  */
   738 PurpleCertificateVerifier *
   739 purple_certificate_find_verifier(const gchar *scheme_name, const gchar *ver_name);
   740 
   741 /**
   742  * Get the list of registered CertificateVerifiers
   743  *
   744  * @return GList of all registered PurpleCertificateVerifier. This value
   745  *         is owned by libpurple
   746  */
   747 GList *
   748 purple_certificate_get_verifiers(void);
   749 
   750 /**
   751  * Register a CertificateVerifier with libpurple
   752  *
   753  * @param vr     Verifier to register.
   754  * @return TRUE if register succeeded, otherwise FALSE
   755  */
   756 gboolean
   757 purple_certificate_register_verifier(PurpleCertificateVerifier *vr);
   758 
   759 /**
   760  * Unregister a CertificateVerifier with libpurple
   761  *
   762  * @param vr     Verifier to unregister.
   763  * @return TRUE if unregister succeeded, otherwise FALSE
   764  */
   765 gboolean
   766 purple_certificate_unregister_verifier(PurpleCertificateVerifier *vr);
   767 
   768 /** Look up a registered PurpleCertificatePool by scheme and name
   769  * @param scheme_name  Scheme name. Case insensitive.
   770  * @param pool_name    Pool name. Case insensitive.
   771  * @return Pointer to the located Pool, or NULL if it isn't found.
   772  */
   773 PurpleCertificatePool *
   774 purple_certificate_find_pool(const gchar *scheme_name, const gchar *pool_name);
   775 
   776 /**
   777  * Get the list of registered Pools
   778  *
   779  * @return GList of all registered PurpleCertificatePool s. This value
   780  *         is owned by libpurple
   781  */
   782 GList *
   783 purple_certificate_get_pools(void);
   784 
   785 /**
   786  * Register a CertificatePool with libpurple and call its init function
   787  *
   788  * @param pool   Pool to register.
   789  * @return TRUE if the register succeeded, otherwise FALSE
   790  */
   791 gboolean
   792 purple_certificate_register_pool(PurpleCertificatePool *pool);
   793 
   794 /**
   795  * Unregister a CertificatePool with libpurple and call its uninit function
   796  *
   797  * @param pool   Pool to unregister.
   798  * @return TRUE if the unregister succeeded, otherwise FALSE
   799  */
   800 gboolean
   801 purple_certificate_unregister_pool(PurpleCertificatePool *pool);
   802 
   803 /*@}*/
   804 
   805 
   806 /**
   807  * Displays a window showing X.509 certificate information
   808  *
   809  * @param crt    Certificate under an "x509" Scheme
   810  * @todo Will break on CA certs, as they have no Common Name
   811  */
   812 void
   813 purple_certificate_display_x509(PurpleCertificate *crt);
   814 
   815 /**
   816  * Add a search path for certificates.
   817  *
   818  * @param path   Path to search for certificates.
   819  */
   820 void purple_certificate_add_ca_search_path(const char *path);
   821 
   822 #ifdef __cplusplus
   823 }
   824 #endif /* __cplusplus */
   825 
   826 #endif /* _PURPLE_CERTIFICATE_H */