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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* egg-oid.c - OID helper routines
Copyright (C) 2007 Stefan Walter
The Gnome Keyring Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Keyring Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
<http://www.gnu.org/licenses/>.
Author: Stef Walter <stef@memberwebs.com>
*/
#include "config.h"
#include "egg-oid.h"
#include <string.h>
#include <glib/gi18n-lib.h>
typedef struct _OidInfo {
GQuark oid;
const gchar *oidstr;
const gchar *attr;
const gchar *description;
guint flags;
} OidInfo;
static OidInfo oid_info[] = {
{ 0, "0.9.2342.19200300.100.1.25", "DC", N_("Domain Component"),
EGG_OID_PRINTABLE },
{ 0, "0.9.2342.19200300.100.1.1", "UID", N_("User ID"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "1.2.840.113549.1.9.1", "EMAIL", N_("Email Address"),
EGG_OID_PRINTABLE },
{ 0, "1.2.840.113549.1.9.7", NULL, NULL,
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "1.2.840.113549.1.9.20", NULL, NULL,
EGG_OID_PRINTABLE },
{ 0, "1.3.6.1.5.5.7.9.1", "dateOfBirth", N_("Date of Birth"),
EGG_OID_PRINTABLE },
{ 0, "1.3.6.1.5.5.7.9.2", "placeOfBirth", N_("Place of Birth"),
EGG_OID_PRINTABLE },
{ 0, "1.3.6.1.5.5.7.9.3", "gender", N_("Gender"),
EGG_OID_PRINTABLE },
{ 0, "1.3.6.1.5.5.7.9.4", "countryOfCitizenship", N_("Country of Citizenship"),
EGG_OID_PRINTABLE },
{ 0, "1.3.6.1.5.5.7.9.5", "countryOfResidence", N_("Country of Residence"),
EGG_OID_PRINTABLE },
{ 0, "2.5.4.3", "CN", N_("Common Name"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.4", "surName", N_("Surname"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.5", "serialNumber", N_("Serial Number"),
EGG_OID_PRINTABLE },
{ 0, "2.5.4.6", "C", N_("Country"),
EGG_OID_PRINTABLE, },
{ 0, "2.5.4.7", "L", N_("Locality"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.8", "ST", N_("State"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.9", "STREET", N_("Street"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.10", "O", N_("Organization"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.11", "OU", N_("Organizational Unit"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.12", "T", N_("Title"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.20", "telephoneNumber", N_("Telephone Number"),
EGG_OID_PRINTABLE },
{ 0, "2.5.4.42", "givenName", N_("Given Name"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.43", "initials", N_("Initials"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.44", "generationQualifier", N_("Generation Qualifier"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "2.5.4.46", "dnQualifier", N_("DN Qualifier"),
EGG_OID_PRINTABLE },
{ 0, "2.5.4.65", "pseudonym", N_("Pseudonym"),
EGG_OID_PRINTABLE | EGG_OID_IS_CHOICE },
{ 0, "1.2.840.113549.1.1.1", "rsaEncryption", N_("RSA"), 0 },
{ 0, "1.2.840.113549.1.1.2", "md2WithRSAEncryption", N_("MD2 with RSA"), 0 },
{ 0, "1.2.840.113549.1.1.4", "md5WithRSAEncryption", N_("MD5 with RSA"), 0 },
{ 0, "1.2.840.113549.1.1.5", "sha1WithRSAEncryption", N_("SHA1 with RSA"), 0 },
{ 0, "1.2.840.10040.4.1", "dsa", N_("DSA"), 0 },
{ 0, "1.2.840.10040.4.3", "sha1WithDSA", N_("SHA1 with DSA"), 0 },
/* Extended Key Usages */
{ 0, "1.3.6.1.5.5.7.3.1", NULL, N_("Server Authentication"), 0 },
{ 0, "1.3.6.1.5.5.7.3.2", NULL, N_("Client Authentication"), 0 },
{ 0, "1.3.6.1.5.5.7.3.3", NULL, N_("Code Signing"), 0 },
{ 0, "1.3.6.1.5.5.7.3.4", NULL, N_("Email Protection"), 0 },
{ 0, "1.3.6.1.5.5.7.3.8", NULL, N_("Time Stamping"), 0 },
{ 0, NULL, NULL, NULL, FALSE }
};
static OidInfo*
find_oid_info (GQuark oid)
{
static volatile gsize inited_oids = 0;
int i;
g_return_val_if_fail (oid != 0, NULL);
/* Initialize first time around */
if (g_once_init_enter (&inited_oids)) {
for (i = 0; oid_info[i].oidstr != NULL; ++i)
oid_info[i].oid = g_quark_from_static_string (oid_info[i].oidstr);
g_once_init_leave (&inited_oids, 1);
}
for (i = 0; oid_info[i].oidstr != NULL; ++i) {
if (oid_info[i].oid == oid)
return &oid_info[i];
}
return NULL;
}
const gchar*
egg_oid_get_name (GQuark oid)
{
OidInfo *info;
g_return_val_if_fail (oid, NULL);
info = find_oid_info (oid);
if (info == NULL)
return g_quark_to_string (oid);
return info->attr;
}
const gchar*
egg_oid_get_description (GQuark oid)
{
OidInfo *info;
g_return_val_if_fail (oid, NULL);
info = find_oid_info (oid);
if (info == NULL)
return g_quark_to_string (oid);
return gettext (info->description);
}
guint
egg_oid_get_flags (GQuark oid)
{
OidInfo *info;
g_return_val_if_fail (oid, 0);
info = find_oid_info (oid);
if (info == NULL)
return 0;
return info->flags;
}
|