summaryrefslogtreecommitdiff
path: root/gcr/gcr-certificate.h
blob: 05946a4ea113fbbd6db5b680e60a7801017753a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * gnome-keyring
 *
 * Copyright (C) 2008 Stefan Walter
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#if !defined (__GCR_INSIDE_HEADER__) && !defined (GCR_COMPILATION)
#error "Only <gcr/gcr.h> or <gcr/gcr-base.h> can be included directly."
#endif

#ifndef __GCR_CERTIFICATE_H__
#define __GCR_CERTIFICATE_H__

#include "gcr-types.h"
#include "gcr-column.h"
#include "gcr-comparable.h"

#include <glib-object.h>
#include <gio/gio.h>

G_BEGIN_DECLS

#define GCR_CERTIFICATE_COLUMNS                 (gcr_certificate_get_columns ())
#define GCR_TYPE_CERTIFICATE                    (gcr_certificate_get_type ())
#define GCR_CERTIFICATE(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCR_TYPE_CERTIFICATE, GcrCertificate))
#define GCR_IS_CERTIFICATE(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCR_TYPE_CERTIFICATE))
#define GCR_CERTIFICATE_GET_INTERFACE(inst)     (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GCR_TYPE_CERTIFICATE, GcrCertificateIface))

typedef struct _GcrCertificate          GcrCertificate;
typedef struct _GcrCertificateIface     GcrCertificateIface;

struct _GcrCertificateIface {
	GTypeInterface parent;


	/*
	 * g-ir-scanner cannot comprehend this yet ...
	 * See: https://bugzilla.gnome.org/show_bug.cgi?id=725501
	 *
	 * GcrCertificate.get_der_data:
	 * @self: a #GcrCertificate
	 * @n_data: a pointer to a location to store the size of the resulting DER data.
	 *
	 * Implemented to return the raw DER data for an X.509 certificate. The data
	 * should be owned by the #GcrCertificate object.
	 *
	 * Returns: (array length=n_data): raw DER data of the X.509 certificate
	 */
	const guint8 * (* get_der_data) (GcrCertificate *self,
	                                 gsize *n_data);

	/*< private >*/
	gpointer dummy1;
	gpointer dummy2;
	gpointer dummy3;
	gpointer dummy5;
	gpointer dummy6;
	gpointer dummy7;
	gpointer dummy8;
};

GType               gcr_certificate_get_type               (void);

const guint8 *      gcr_certificate_get_der_data           (GcrCertificate *self,
                                                            gsize *n_data);

const GcrColumn*    gcr_certificate_get_columns            (void);

gint                gcr_certificate_compare                (GcrComparable *first,
                                                            GcrComparable *other);

gchar *             gcr_certificate_get_issuer_name        (GcrCertificate *self);

gchar*              gcr_certificate_get_issuer_cn          (GcrCertificate *self);

gchar*              gcr_certificate_get_issuer_dn          (GcrCertificate *self);

gchar*              gcr_certificate_get_issuer_part        (GcrCertificate *self,
                                                            const gchar *part);

guchar *            gcr_certificate_get_issuer_raw         (GcrCertificate *self,
                                                            gsize *n_data);

gboolean            gcr_certificate_is_issuer              (GcrCertificate *self,
                                                            GcrCertificate *issuer);

gchar *             gcr_certificate_get_subject_name       (GcrCertificate *self);

gchar*              gcr_certificate_get_subject_cn         (GcrCertificate *self);

gchar*              gcr_certificate_get_subject_dn         (GcrCertificate *self);

gchar*              gcr_certificate_get_subject_part       (GcrCertificate *self,
                                                            const gchar *part);

guchar *            gcr_certificate_get_subject_raw        (GcrCertificate *self,
                                                            gsize *n_data);

GDate*              gcr_certificate_get_issued_date        (GcrCertificate *self);

GDate*              gcr_certificate_get_expiry_date        (GcrCertificate *self);

guchar*             gcr_certificate_get_serial_number      (GcrCertificate *self,
                                                            gsize *n_length);

gchar*              gcr_certificate_get_serial_number_hex  (GcrCertificate *self);

guint               gcr_certificate_get_key_size           (GcrCertificate *self);

guchar*             gcr_certificate_get_fingerprint        (GcrCertificate *self,
                                                            GChecksumType type,
                                                            gsize *n_length);

gchar*              gcr_certificate_get_fingerprint_hex    (GcrCertificate *self,
                                                            GChecksumType type);

gchar *             gcr_certificate_get_markup_text        (GcrCertificate *self);

GIcon*              gcr_certificate_get_icon               (GcrCertificate *self);

gboolean            gcr_certificate_get_basic_constraints  (GcrCertificate *self,
                                                            gboolean *is_ca,
                                                            gint *path_len);

#define GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE() \
	G_IMPLEMENT_INTERFACE (GCR_TYPE_COMPARABLE, gcr_certificate_mixin_comparable_init)

void                gcr_certificate_mixin_emit_notify      (GcrCertificate *self);

void                gcr_certificate_mixin_comparable_init  (GcrComparableIface *iface);

void                gcr_certificate_mixin_class_init       (GObjectClass *object_class);

void                gcr_certificate_mixin_get_property     (GObject *obj,
                                                            guint prop_id,
                                                            GValue *value,
                                                            GParamSpec *pspec);

G_END_DECLS

#endif /* __GCR_CERTIFICATE_H__ */