comparison libpurple/certificate.h @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents 32642aa8dbe5
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
1 /** 1 /**
2 * @file certificate.h Public-Key Certificate API 2 * @file certificate.h Public-Key Certificate API
3 * @ingroup core 3 * @ingroup core
4 * @see @ref certificate-signals 4 * @see @ref certificate-signals
5 * @since 2.2.0
6 */ 5 */
7 6
8 /* 7 /*
9 * 8 *
10 * purple 9 * purple
32 #define _PURPLE_CERTIFICATE_H 31 #define _PURPLE_CERTIFICATE_H
33 32
34 #include <time.h> 33 #include <time.h>
35 34
36 #include <glib.h> 35 #include <glib.h>
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif /* __cplusplus */
41
42 36
43 typedef enum 37 typedef enum
44 { 38 {
45 PURPLE_CERTIFICATE_INVALID = 0, 39 PURPLE_CERTIFICATE_INVALID = 0,
46 PURPLE_CERTIFICATE_VALID = 1 40 PURPLE_CERTIFICATE_VALID = 1
256 * @return GSList of pointers to the newly allocated Certificate structs 250 * @return GSList of pointers to the newly allocated Certificate structs
257 * or NULL on failure. 251 * or NULL on failure.
258 */ 252 */
259 GSList * (* import_certificates)(const gchar * filename); 253 GSList * (* import_certificates)(const gchar * filename);
260 254
255 /**
256 * Retrieves the certificate data in DER form
257 *
258 * @param crt Certificate instance
259 * @return Binary DER representation of certificate - must be freed using
260 * g_byte_array_free()
261 */
262 GByteArray * (* get_der_data)(PurpleCertificate *crt);
263
264 /**
265 * Retrieves a string representation of the certificate suitable for display
266 *
267 * @param crt Certificate instance
268 * @return User-displayable string representation of certificate - must be
269 * freed using g_free().
270 */
271 gchar * (* get_display_string)(PurpleCertificate *crt);
272
261 void (*_purple_reserved1)(void); 273 void (*_purple_reserved1)(void);
262 void (*_purple_reserved2)(void);
263 void (*_purple_reserved3)(void);
264 }; 274 };
265 275
266 /** A set of operations used to provide logic for verifying a Certificate's 276 /** A set of operations used to provide logic for verifying a Certificate's
267 * authenticity. 277 * authenticity.
268 * 278 *
347 /** Function to call with the verification result */ 357 /** Function to call with the verification result */
348 PurpleCertificateVerifiedCallback cb; 358 PurpleCertificateVerifiedCallback cb;
349 /** Data to pass to the post-verification callback */ 359 /** Data to pass to the post-verification callback */
350 gpointer cb_data; 360 gpointer cb_data;
351 }; 361 };
362
363 G_BEGIN_DECLS
352 364
353 /*****************************************************************************/ 365 /*****************************************************************************/
354 /** @name Certificate Verification Functions */ 366 /** @name Certificate Verification Functions */
355 /*****************************************************************************/ 367 /*****************************************************************************/
356 /*@{*/ 368 /*@{*/
460 * in the order certificate, issuer, issuer's issuer, etc. 472 * in the order certificate, issuer, issuer's issuer, etc.
461 * @param failing A pointer to a PurpleCertificate*. If not NULL, if the 473 * @param failing A pointer to a PurpleCertificate*. If not NULL, if the
462 * chain fails to validate, this will be set to the 474 * chain fails to validate, this will be set to the
463 * certificate whose signature could not be validated. 475 * certificate whose signature could not be validated.
464 * @return TRUE if the chain is valid. See description. 476 * @return TRUE if the chain is valid. See description.
465 * 477 */
466 * @since 2.6.0 478 gboolean
467 * @deprecated This function will become 479 purple_certificate_check_signature_chain(GList *chain,
468 * purple_certificate_check_signature_chain in 3.0.0
469 */
470 gboolean
471 purple_certificate_check_signature_chain_with_failing(GList *chain,
472 PurpleCertificate **failing); 480 PurpleCertificate **failing);
473
474 /**
475 * Check that a certificate chain is valid
476 *
477 * Uses purple_certificate_signed_by() to verify that each PurpleCertificate
478 * in the chain carries a valid signature from the next. A single-certificate
479 * chain is considered to be valid.
480 *
481 * @param chain List of PurpleCertificate instances comprising the chain,
482 * in the order certificate, issuer, issuer's issuer, etc.
483 * @return TRUE if the chain is valid. See description.
484 * @todo Specify which certificate in the chain caused a failure
485 * @deprecated This function will be removed in 3.0.0 and replaced with
486 * purple_certificate_check_signature_chain_with_failing
487 */
488 gboolean
489 purple_certificate_check_signature_chain(GList *chain);
490 481
491 /** 482 /**
492 * Imports a PurpleCertificate from a file 483 * Imports a PurpleCertificate from a file
493 * 484 *
494 * @param scheme Scheme to import under 485 * @param scheme Scheme to import under
581 * @return TRUE if the requested values were obtained, otherwise FALSE. 572 * @return TRUE if the requested values were obtained, otherwise FALSE.
582 */ 573 */
583 gboolean 574 gboolean
584 purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration); 575 purple_certificate_get_times(PurpleCertificate *crt, time_t *activation, time_t *expiration);
585 576
577 /**
578 * Retrieves the certificate data in DER form.
579 *
580 * @param crt Certificate instance
581 *
582 * @return Binary DER representation of the certificate - must be freed using
583 * g_byte_array_free().
584 */
585 GByteArray *
586 purple_certificate_get_der_data(PurpleCertificate *crt);
587
588 /**
589 * Retrieves a string suitable for displaying a certificate to the user.
590 *
591 * @param crt Certificate instance
592 *
593 * @return String representing the certificate that may be displayed to the user
594 * - must be freed using g_free().
595 */
596 char *
597 purple_certificate_get_display_string(PurpleCertificate *crt);
598
586 /*@}*/ 599 /*@}*/
587 600
588 /*****************************************************************************/ 601 /*****************************************************************************/
589 /** @name Certificate Pool Functions */ 602 /** @name Certificate Pool Functions */
590 /*****************************************************************************/ 603 /*****************************************************************************/
819 832
820 /*@}*/ 833 /*@}*/
821 834
822 835
823 /** 836 /**
824 * Displays a window showing X.509 certificate information
825 *
826 * @param crt Certificate under an "x509" Scheme
827 * @todo Will break on CA certs, as they have no Common Name
828 */
829 void
830 purple_certificate_display_x509(PurpleCertificate *crt);
831
832 /**
833 * Add a search path for certificates. 837 * Add a search path for certificates.
834 * 838 *
835 * @param path Path to search for certificates. 839 * @param path Path to search for certificates.
836 */ 840 */
837 void purple_certificate_add_ca_search_path(const char *path); 841 void purple_certificate_add_ca_search_path(const char *path);
838 842
839 #ifdef __cplusplus 843 G_END_DECLS
840 }
841 #endif /* __cplusplus */
842 844
843 #endif /* _PURPLE_CERTIFICATE_H */ 845 #endif /* _PURPLE_CERTIFICATE_H */