Initialize the gmime for upstream
[platform/upstream/gmime.git] / gmime / gmime-certificate.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*  GMime
3  *  Copyright (C) 2000-2012 Jeffrey Stedfast
4  *
5  *  This library is free software; you can redistribute it and/or
6  *  modify it under the terms of the GNU Lesser General Public License
7  *  as published by the Free Software Foundation; either version 2.1
8  *  of the License, or (at your option) any later version.
9  *
10  *  This library is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *  Lesser General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Lesser General Public
16  *  License along with this library; if not, write to the Free
17  *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
18  *  02110-1301, USA.
19  */
20
21
22 #ifndef __GMIME_CERTIFICATE_H__
23 #define __GMIME_CERTIFICATE_H__
24
25 #include <glib.h>
26 #include <glib-object.h>
27
28 #include <time.h>
29
30 G_BEGIN_DECLS
31
32 #define GMIME_TYPE_CERTIFICATE                  (g_mime_certificate_get_type ())
33 #define GMIME_CERTIFICATE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_CERTIFICATE, GMimeCertificate))
34 #define GMIME_CERTIFICATE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_CERTIFICATE, GMimeCertificateClass))
35 #define GMIME_IS_CERTIFICATE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_CERTIFICATE))
36 #define GMIME_IS_CERTIFICATE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_CERTIFICATE))
37 #define GMIME_CERTIFICATE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_CERTIFICATE, GMimeCertificateClass))
38
39 #define GMIME_TYPE_CERTIFICATE_LIST             (g_mime_certificate_list_get_type ())
40 #define GMIME_CERTIFICATE_LIST(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMIME_TYPE_CERTIFICATE_LIST, GMimeCertificateList))
41 #define GMIME_CERTIFICATE_LIST_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GMIME_TYPE_CERTIFICATE_LIST, GMimeCertificateListClass))
42 #define GMIME_IS_CERTIFICATE_LIST(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMIME_TYPE_CERTIFICATE_LIST))
43 #define GMIME_IS_CERTIFICATE_LIST_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GMIME_TYPE_CERTIFICATE_LIST))
44 #define GMIME_CERTIFICATE_LIST_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GMIME_TYPE_CERTIFICATE_LIST, GMimeCertificateListClass))
45
46
47 typedef struct _GMimeCertificate GMimeCertificate;
48 typedef struct _GMimeCertificateClass GMimeCertificateClass;
49
50 typedef struct _GMimeCertificateList GMimeCertificateList;
51 typedef struct _GMimeCertificateListClass GMimeCertificateListClass;
52
53
54 /**
55  * GMimeDigestAlgo:
56  * @GMIME_DIGEST_ALGO_DEFAULT: The default hash algorithm.
57  * @GMIME_DIGEST_ALGO_MD5: The MD5 hash algorithm.
58  * @GMIME_DIGEST_ALGO_SHA1: The SHA-1 hash algorithm.
59  * @GMIME_DIGEST_ALGO_RIPEMD160: The RIPEMD-160 hash algorithm.
60  * @GMIME_DIGEST_ALGO_MD2: The MD2 hash algorithm.
61  * @GMIME_DIGEST_ALGO_TIGER192: The TIGER-192 hash algorithm.
62  * @GMIME_DIGEST_ALGO_HAVAL5160: The HAVAL-5-160 hash algorithm.
63  * @GMIME_DIGEST_ALGO_SHA256: The SHA-256 hash algorithm.
64  * @GMIME_DIGEST_ALGO_SHA384: The SHA-384 hash algorithm.
65  * @GMIME_DIGEST_ALGO_SHA512: The SHA-512 hash algorithm.
66  * @GMIME_DIGEST_ALGO_SHA224: The SHA-224 hash algorithm.
67  * @GMIME_DIGEST_ALGO_MD4: The MD4 hash algorithm.
68  *
69  * A hash algorithm.
70  **/
71 typedef enum {
72         GMIME_DIGEST_ALGO_DEFAULT     = 0,
73         GMIME_DIGEST_ALGO_MD5         = 1,
74         GMIME_DIGEST_ALGO_SHA1        = 2,
75         GMIME_DIGEST_ALGO_RIPEMD160   = 3,
76         GMIME_DIGEST_ALGO_MD2         = 5,
77         GMIME_DIGEST_ALGO_TIGER192    = 6,
78         GMIME_DIGEST_ALGO_HAVAL5160   = 7,
79         GMIME_DIGEST_ALGO_SHA256      = 8,
80         GMIME_DIGEST_ALGO_SHA384      = 9,
81         GMIME_DIGEST_ALGO_SHA512      = 10,
82         GMIME_DIGEST_ALGO_SHA224      = 11,
83         GMIME_DIGEST_ALGO_MD4         = 301
84 } GMimeDigestAlgo;
85
86 /**
87  * GMimePubKeyAlgo:
88  * @GMIME_PUBKEY_ALGO_DEFAULT: The default public-key algorithm.
89  * @GMIME_PUBKEY_ALGO_RSA: The RSA algorithm.
90  * @GMIME_PUBKEY_ALGO_RSA_E: An encryption-only RSA algorithm.
91  * @GMIME_PUBKEY_ALGO_RSA_S: A signature-only RSA algorithm.
92  * @GMIME_PUBKEY_ALGO_ELG_E: An encryption-only ElGamal algorithm.
93  * @GMIME_PUBKEY_ALGO_DSA: The DSA algorithm.
94  * @GMIME_PUBKEY_ALGO_ELG: The ElGamal algorithm.
95  *
96  * A public-key algorithm.
97  **/
98 typedef enum {
99         GMIME_PUBKEY_ALGO_DEFAULT  = 0,
100         GMIME_PUBKEY_ALGO_RSA      = 1,
101         GMIME_PUBKEY_ALGO_RSA_E    = 2,
102         GMIME_PUBKEY_ALGO_RSA_S    = 3,
103         GMIME_PUBKEY_ALGO_ELG_E    = 16,
104         GMIME_PUBKEY_ALGO_DSA      = 17,
105         GMIME_PUBKEY_ALGO_ELG      = 20
106 } GMimePubKeyAlgo;
107
108 /**
109  * GMimeCertificateTrust:
110  * @GMIME_CERTIFICATE_TRUST_NONE: No trust assigned.
111  * @GMIME_CERTIFICATE_TRUST_NEVER: Never trust this certificate.
112  * @GMIME_CERTIFICATE_TRUST_UNDEFINED: Undefined trust for this certificate.
113  * @GMIME_CERTIFICATE_TRUST_MARGINAL: Trust this certificate maginally.
114  * @GMIME_CERTIFICATE_TRUST_FULLY: Trust this certificate fully.
115  * @GMIME_CERTIFICATE_TRUST_ULTIMATE: Trust this certificate ultimately.
116  *
117  * The trust value of a certificate.
118  **/
119 typedef enum {
120         GMIME_CERTIFICATE_TRUST_NONE,
121         GMIME_CERTIFICATE_TRUST_NEVER,
122         GMIME_CERTIFICATE_TRUST_UNDEFINED,
123         GMIME_CERTIFICATE_TRUST_MARGINAL,
124         GMIME_CERTIFICATE_TRUST_FULLY,
125         GMIME_CERTIFICATE_TRUST_ULTIMATE
126 } GMimeCertificateTrust;
127
128 /**
129  * GMimeCertificate:
130  * @parent_object: parent #GObject
131  * @pubkey_algo: The public-key algorithm used by the certificate, if known.
132  * @digest_algo: The digest algorithm used by the certificate, if known.
133  * @trust: The level of trust assigned to this certificate.
134  * @issuer_serial: The issuer of the certificate, if known.
135  * @issuer_name: The issuer of the certificate, if known.
136  * @fingerprint: A hex string representing the certificate's fingerprint.
137  * @created: The creation date of the certificate.
138  * @expires: The expiration date of the certificate.
139  * @keyid: The certificate's key id.
140  * @email: The email address of the person or entity.
141  * @name: The name of the person or entity.
142  *
143  * An object containing useful information about a certificate.
144  **/
145 struct _GMimeCertificate {
146         GObject parent_object;
147         
148         GMimePubKeyAlgo pubkey_algo;
149         GMimeDigestAlgo digest_algo;
150         GMimeCertificateTrust trust;
151         char *issuer_serial;
152         char *issuer_name;
153         char *fingerprint;
154         time_t created;
155         time_t expires;
156         char *keyid;
157         char *email;
158         char *name;
159 };
160
161 struct _GMimeCertificateClass {
162         GObjectClass parent_class;
163         
164 };
165
166
167 GType g_mime_certificate_get_type (void);
168
169 GMimeCertificate *g_mime_certificate_new (void);
170
171 void g_mime_certificate_set_trust (GMimeCertificate *cert, GMimeCertificateTrust trust);
172 GMimeCertificateTrust g_mime_certificate_get_trust (GMimeCertificate *cert);
173
174 void g_mime_certificate_set_pubkey_algo (GMimeCertificate *cert, GMimePubKeyAlgo algo);
175 GMimePubKeyAlgo g_mime_certificate_get_pubkey_algo (GMimeCertificate *cert);
176
177 void g_mime_certificate_set_digest_algo (GMimeCertificate *cert, GMimeDigestAlgo algo);
178 GMimeDigestAlgo g_mime_certificate_get_digest_algo (GMimeCertificate *cert);
179
180 void g_mime_certificate_set_issuer_serial (GMimeCertificate *cert, const char *issuer_serial);
181 const char *g_mime_certificate_get_issuer_serial (GMimeCertificate *cert);
182
183 void g_mime_certificate_set_issuer_name (GMimeCertificate *cert, const char *issuer_name);
184 const char *g_mime_certificate_get_issuer_name (GMimeCertificate *cert);
185
186 void g_mime_certificate_set_fingerprint (GMimeCertificate *cert, const char *fingerprint);
187 const char *g_mime_certificate_get_fingerprint (GMimeCertificate *cert);
188
189 void g_mime_certificate_set_key_id (GMimeCertificate *cert, const char *key_id);
190 const char *g_mime_certificate_get_key_id (GMimeCertificate *cert);
191
192 void g_mime_certificate_set_email (GMimeCertificate *cert, const char *email);
193 const char *g_mime_certificate_get_email (GMimeCertificate *cert);
194
195 void g_mime_certificate_set_name (GMimeCertificate *cert, const char *name);
196 const char *g_mime_certificate_get_name (GMimeCertificate *cert);
197
198 void g_mime_certificate_set_created (GMimeCertificate *cert, time_t created);
199 time_t g_mime_certificate_get_created (GMimeCertificate *cert);
200
201 void g_mime_certificate_set_expires (GMimeCertificate *cert, time_t expires);
202 time_t g_mime_certificate_get_expires (GMimeCertificate *cert);
203
204
205 /**
206  * GMimeCertificateList:
207  * @parent_object: parent #GObject
208  * @array: An array of #GMimeCertificate objects.
209  *
210  * A collection of #GMimeCertificate objects.
211  **/
212 struct _GMimeCertificateList {
213         GObject parent_object;
214         GPtrArray *array;
215 };
216
217 struct _GMimeCertificateListClass {
218         GObjectClass parent_class;
219         
220 };
221
222
223 GType g_mime_certificate_list_get_type (void);
224
225 GMimeCertificateList *g_mime_certificate_list_new (void);
226
227 int g_mime_certificate_list_length (GMimeCertificateList *list);
228
229 void g_mime_certificate_list_clear (GMimeCertificateList *list);
230
231 int g_mime_certificate_list_add (GMimeCertificateList *list, GMimeCertificate *cert);
232 void g_mime_certificate_list_insert (GMimeCertificateList *list, int index, GMimeCertificate *cert);
233 gboolean g_mime_certificate_list_remove (GMimeCertificateList *list, GMimeCertificate *cert);
234 gboolean g_mime_certificate_list_remove_at (GMimeCertificateList *list, int index);
235
236 gboolean g_mime_certificate_list_contains (GMimeCertificateList *list, GMimeCertificate *cert);
237 int g_mime_certificate_list_index_of (GMimeCertificateList *list, GMimeCertificate *cert);
238
239 GMimeCertificate *g_mime_certificate_list_get_certificate (GMimeCertificateList *list, int index);
240 void g_mime_certificate_list_set_certificate (GMimeCertificateList *list, int index, GMimeCertificate *cert);
241
242 G_END_DECLS
243
244 #endif /* __GMIME_CERTIFICATE_H__ */