diff options
author | lv-426 <oxcafebaby@yahoo.com> | 2008-07-07 02:39:48 +0000 |
---|---|---|
committer | lv-426 <oxcafebaby@yahoo.com> | 2008-07-07 02:39:48 +0000 |
commit | 6d57794092b3a43cf74626e16cec2913c845c3a9 (patch) | |
tree | e3831206f47321091d34187e71441c9ffe2f4a1b /src/daemon/https/openpgp/pgp.c | |
parent | b9f09651e6217396171d0ee25eb3f1a5087a3ad6 (diff) | |
download | libmicrohttpd-6d57794092b3a43cf74626e16cec2913c845c3a9.tar.gz libmicrohttpd-6d57794092b3a43cf74626e16cec2913c845c3a9.zip |
formating
Diffstat (limited to 'src/daemon/https/openpgp/pgp.c')
-rw-r--r-- | src/daemon/https/openpgp/pgp.c | 169 |
1 files changed, 89 insertions, 80 deletions
diff --git a/src/daemon/https/openpgp/pgp.c b/src/daemon/https/openpgp/pgp.c index fca307f5..d5e6ce09 100644 --- a/src/daemon/https/openpgp/pgp.c +++ b/src/daemon/https/openpgp/pgp.c | |||
@@ -39,12 +39,13 @@ | |||
39 | * Returns 0 on success. | 39 | * Returns 0 on success. |
40 | * | 40 | * |
41 | **/ | 41 | **/ |
42 | int gnutls_openpgp_crt_init(gnutls_openpgp_crt_t * key) | 42 | int |
43 | gnutls_openpgp_crt_init (gnutls_openpgp_crt_t * key) | ||
43 | { | 44 | { |
44 | *key = gnutls_calloc(1, sizeof(gnutls_openpgp_crt_int)); | 45 | *key = gnutls_calloc (1, sizeof (gnutls_openpgp_crt_int)); |
45 | 46 | ||
46 | if (*key) | 47 | if (*key) |
47 | return 0; /* success */ | 48 | return 0; /* success */ |
48 | return GNUTLS_E_MEMORY_ERROR; | 49 | return GNUTLS_E_MEMORY_ERROR; |
49 | } | 50 | } |
50 | 51 | ||
@@ -54,18 +55,19 @@ int gnutls_openpgp_crt_init(gnutls_openpgp_crt_t * key) | |||
54 | * | 55 | * |
55 | * This function will deinitialize a key structure. | 56 | * This function will deinitialize a key structure. |
56 | **/ | 57 | **/ |
57 | void gnutls_openpgp_crt_deinit(gnutls_openpgp_crt_t key) | 58 | void |
59 | gnutls_openpgp_crt_deinit (gnutls_openpgp_crt_t key) | ||
58 | { | 60 | { |
59 | if (!key) | 61 | if (!key) |
60 | return; | 62 | return; |
61 | 63 | ||
62 | if (key->knode) | 64 | if (key->knode) |
63 | { | 65 | { |
64 | cdk_kbnode_release(key->knode); | 66 | cdk_kbnode_release (key->knode); |
65 | key->knode = NULL; | 67 | key->knode = NULL; |
66 | } | 68 | } |
67 | 69 | ||
68 | gnutls_free(key); | 70 | gnutls_free (key); |
69 | } | 71 | } |
70 | 72 | ||
71 | /** | 73 | /** |
@@ -79,32 +81,33 @@ void gnutls_openpgp_crt_deinit(gnutls_openpgp_crt_t key) | |||
79 | * | 81 | * |
80 | * Returns 0 on success. | 82 | * Returns 0 on success. |
81 | **/ | 83 | **/ |
82 | int gnutls_openpgp_crt_import(gnutls_openpgp_crt_t key, | 84 | int |
83 | const gnutls_datum_t * data, | 85 | gnutls_openpgp_crt_import (gnutls_openpgp_crt_t key, |
84 | gnutls_openpgp_crt_fmt_t format) | 86 | const gnutls_datum_t * data, |
87 | gnutls_openpgp_crt_fmt_t format) | ||
85 | { | 88 | { |
86 | cdk_stream_t inp; | 89 | cdk_stream_t inp; |
87 | int rc; | 90 | int rc; |
88 | 91 | ||
89 | if (format == GNUTLS_OPENPGP_FMT_RAW) | 92 | if (format == GNUTLS_OPENPGP_FMT_RAW) |
90 | rc = cdk_kbnode_read_from_mem(&key->knode, data->data, data->size); | 93 | rc = cdk_kbnode_read_from_mem (&key->knode, data->data, data->size); |
91 | else | 94 | else |
92 | { | 95 | { |
93 | rc = cdk_stream_tmp_from_mem(data->data, data->size, &inp); | 96 | rc = cdk_stream_tmp_from_mem (data->data, data->size, &inp); |
94 | if (rc) | 97 | if (rc) |
95 | { | 98 | { |
96 | rc = _gnutls_map_cdk_rc(rc); | 99 | rc = _gnutls_map_cdk_rc (rc); |
97 | gnutls_assert (); | 100 | gnutls_assert (); |
98 | return rc; | 101 | return rc; |
99 | } | 102 | } |
100 | if (cdk_armor_filter_use(inp)) | 103 | if (cdk_armor_filter_use (inp)) |
101 | rc = cdk_stream_set_armor_flag(inp, 0); | 104 | rc = cdk_stream_set_armor_flag (inp, 0); |
102 | if (!rc) | 105 | if (!rc) |
103 | rc = cdk_keydb_get_keyblock(inp, &key->knode); | 106 | rc = cdk_keydb_get_keyblock (inp, &key->knode); |
104 | cdk_stream_close(inp); | 107 | cdk_stream_close (inp); |
105 | if (rc) | 108 | if (rc) |
106 | { | 109 | { |
107 | rc = _gnutls_map_cdk_rc(rc); | 110 | rc = _gnutls_map_cdk_rc (rc); |
108 | gnutls_assert (); | 111 | gnutls_assert (); |
109 | return rc; | 112 | return rc; |
110 | } | 113 | } |
@@ -127,50 +130,50 @@ int gnutls_openpgp_crt_import(gnutls_openpgp_crt_t key, | |||
127 | * Returns 0 on success. | 130 | * Returns 0 on success. |
128 | * | 131 | * |
129 | **/ | 132 | **/ |
130 | int gnutls_openpgp_crt_export(gnutls_openpgp_crt_t key, | 133 | int |
131 | gnutls_openpgp_crt_fmt_t format, | 134 | gnutls_openpgp_crt_export (gnutls_openpgp_crt_t key, |
132 | void *output_data, | 135 | gnutls_openpgp_crt_fmt_t format, |
133 | size_t * output_data_size) | 136 | void *output_data, size_t * output_data_size) |
134 | { | 137 | { |
135 | size_t input_data_size = *output_data_size; | 138 | size_t input_data_size = *output_data_size; |
136 | size_t calc_size; | 139 | size_t calc_size; |
137 | int rc; | 140 | int rc; |
138 | 141 | ||
139 | rc = cdk_kbnode_write_to_mem(key->knode, output_data, output_data_size); | 142 | rc = cdk_kbnode_write_to_mem (key->knode, output_data, output_data_size); |
140 | if (rc) | 143 | if (rc) |
141 | { | 144 | { |
142 | rc = _gnutls_map_cdk_rc(rc); | 145 | rc = _gnutls_map_cdk_rc (rc); |
143 | gnutls_assert (); | 146 | gnutls_assert (); |
144 | return rc; | 147 | return rc; |
145 | } | 148 | } |
146 | 149 | ||
147 | /* FIXME: The first call of this function is with output_data == NULL | 150 | /* FIXME: The first call of this function is with output_data == NULL |
148 | to figure out the size and the caller expects this error here. */ | 151 | to figure out the size and the caller expects this error here. */ |
149 | if (!output_data) | 152 | if (!output_data) |
150 | return GNUTLS_E_SHORT_MEMORY_BUFFER; | 153 | return GNUTLS_E_SHORT_MEMORY_BUFFER; |
151 | 154 | ||
152 | if (format == GNUTLS_OPENPGP_FMT_BASE64) | 155 | if (format == GNUTLS_OPENPGP_FMT_BASE64) |
153 | { | 156 | { |
154 | unsigned char *in = cdk_calloc(1, *output_data_size); | 157 | unsigned char *in = cdk_calloc (1, *output_data_size); |
155 | memcpy(in, output_data, *output_data_size); | 158 | memcpy (in, output_data, *output_data_size); |
156 | 159 | ||
157 | /* Calculate the size of the encoded data and check if the provided | 160 | /* Calculate the size of the encoded data and check if the provided |
158 | buffer is large enough. */ | 161 | buffer is large enough. */ |
159 | rc = cdk_armor_encode_buffer(in, input_data_size, | 162 | rc = cdk_armor_encode_buffer (in, input_data_size, |
160 | NULL, 0, &calc_size, CDK_ARMOR_PUBKEY); | 163 | NULL, 0, &calc_size, CDK_ARMOR_PUBKEY); |
161 | if (rc || calc_size > input_data_size) | 164 | if (rc || calc_size > input_data_size) |
162 | { | 165 | { |
163 | cdk_free(in); | 166 | cdk_free (in); |
164 | *output_data_size = calc_size; | 167 | *output_data_size = calc_size; |
165 | rc = _gnutls_map_cdk_rc(CDK_Too_Short); | 168 | rc = _gnutls_map_cdk_rc (CDK_Too_Short); |
166 | gnutls_assert (); | 169 | gnutls_assert (); |
167 | return rc; | 170 | return rc; |
168 | } | 171 | } |
169 | 172 | ||
170 | rc = cdk_armor_encode_buffer(in, input_data_size, output_data, | 173 | rc = cdk_armor_encode_buffer (in, input_data_size, output_data, |
171 | input_data_size, &calc_size, | 174 | input_data_size, &calc_size, |
172 | CDK_ARMOR_PUBKEY); | 175 | CDK_ARMOR_PUBKEY); |
173 | cdk_free(in); | 176 | cdk_free (in); |
174 | *output_data_size = calc_size; | 177 | *output_data_size = calc_size; |
175 | } | 178 | } |
176 | 179 | ||
@@ -186,12 +189,12 @@ int gnutls_openpgp_crt_export(gnutls_openpgp_crt_t key, | |||
186 | * Returns the fingerprint of the OpenPGP key. Depends on the algorithm, | 189 | * Returns the fingerprint of the OpenPGP key. Depends on the algorithm, |
187 | * the fingerprint can be 16 or 20 bytes. | 190 | * the fingerprint can be 16 or 20 bytes. |
188 | **/ | 191 | **/ |
189 | int gnutls_openpgp_crt_get_fingerprint(gnutls_openpgp_crt_t key, | 192 | int |
190 | void *fpr, | 193 | gnutls_openpgp_crt_get_fingerprint (gnutls_openpgp_crt_t key, |
191 | size_t * fprlen) | 194 | void *fpr, size_t * fprlen) |
192 | { | 195 | { |
193 | cdk_packet_t pkt; | 196 | cdk_packet_t pkt; |
194 | cdk_pkt_pubkey_t pk= NULL; | 197 | cdk_pkt_pubkey_t pk = NULL; |
195 | 198 | ||
196 | if (!fpr || !fprlen) | 199 | if (!fpr || !fprlen) |
197 | { | 200 | { |
@@ -201,7 +204,7 @@ int gnutls_openpgp_crt_get_fingerprint(gnutls_openpgp_crt_t key, | |||
201 | 204 | ||
202 | *fprlen = 0; | 205 | *fprlen = 0; |
203 | 206 | ||
204 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_PUBLIC_KEY); | 207 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); |
205 | if (!pkt) | 208 | if (!pkt) |
206 | return GNUTLS_E_OPENPGP_GETKEY_FAILED; | 209 | return GNUTLS_E_OPENPGP_GETKEY_FAILED; |
207 | 210 | ||
@@ -211,12 +214,13 @@ int gnutls_openpgp_crt_get_fingerprint(gnutls_openpgp_crt_t key, | |||
211 | /* FIXME: Check if the draft allows old PGP keys. */ | 214 | /* FIXME: Check if the draft allows old PGP keys. */ |
212 | if (is_RSA (pk->pubkey_algo) && pk->version < 4) | 215 | if (is_RSA (pk->pubkey_algo) && pk->version < 4) |
213 | *fprlen = 16; | 216 | *fprlen = 16; |
214 | cdk_pk_get_fingerprint(pk, fpr); | 217 | cdk_pk_get_fingerprint (pk, fpr); |
215 | 218 | ||
216 | return 0; | 219 | return 0; |
217 | } | 220 | } |
218 | 221 | ||
219 | int _gnutls_openpgp_count_key_names(gnutls_openpgp_crt_t key) | 222 | int |
223 | _gnutls_openpgp_count_key_names (gnutls_openpgp_crt_t key) | ||
220 | { | 224 | { |
221 | cdk_kbnode_t p, ctx; | 225 | cdk_kbnode_t p, ctx; |
222 | cdk_packet_t pkt; | 226 | cdk_packet_t pkt; |
@@ -230,9 +234,9 @@ int _gnutls_openpgp_count_key_names(gnutls_openpgp_crt_t key) | |||
230 | 234 | ||
231 | ctx = NULL; | 235 | ctx = NULL; |
232 | nuids = 0; | 236 | nuids = 0; |
233 | while ((p = cdk_kbnode_walk(key->knode, &ctx, 0))) | 237 | while ((p = cdk_kbnode_walk (key->knode, &ctx, 0))) |
234 | { | 238 | { |
235 | pkt = cdk_kbnode_get_packet(p); | 239 | pkt = cdk_kbnode_get_packet (p); |
236 | if (pkt->pkttype == CDK_PKT_USER_ID) | 240 | if (pkt->pkttype == CDK_PKT_USER_ID) |
237 | nuids++; | 241 | nuids++; |
238 | } | 242 | } |
@@ -254,14 +258,13 @@ int _gnutls_openpgp_count_key_names(gnutls_openpgp_crt_t key) | |||
254 | * if the index of the ID does not exist. | 258 | * if the index of the ID does not exist. |
255 | * | 259 | * |
256 | **/ | 260 | **/ |
257 | int gnutls_openpgp_crt_get_name(gnutls_openpgp_crt_t key, | 261 | int |
258 | int idx, | 262 | gnutls_openpgp_crt_get_name (gnutls_openpgp_crt_t key, |
259 | char *buf, | 263 | int idx, char *buf, size_t * sizeof_buf) |
260 | size_t * sizeof_buf) | ||
261 | { | 264 | { |
262 | cdk_kbnode_t ctx= NULL, p; | 265 | cdk_kbnode_t ctx = NULL, p; |
263 | cdk_packet_t pkt= NULL; | 266 | cdk_packet_t pkt = NULL; |
264 | cdk_pkt_userid_t uid= NULL; | 267 | cdk_pkt_userid_t uid = NULL; |
265 | int pos = 0; | 268 | int pos = 0; |
266 | 269 | ||
267 | if (!key || !buf) | 270 | if (!key || !buf) |
@@ -270,17 +273,17 @@ int gnutls_openpgp_crt_get_name(gnutls_openpgp_crt_t key, | |||
270 | return GNUTLS_E_INVALID_REQUEST; | 273 | return GNUTLS_E_INVALID_REQUEST; |
271 | } | 274 | } |
272 | 275 | ||
273 | if (idx < 0 || idx > _gnutls_openpgp_count_key_names(key)) | 276 | if (idx < 0 || idx > _gnutls_openpgp_count_key_names (key)) |
274 | return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; | 277 | return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; |
275 | 278 | ||
276 | if (!idx) | 279 | if (!idx) |
277 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_USER_ID); | 280 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_USER_ID); |
278 | else | 281 | else |
279 | { | 282 | { |
280 | pos = 0; | 283 | pos = 0; |
281 | while ((p = cdk_kbnode_walk(key->knode, &ctx, 0))) | 284 | while ((p = cdk_kbnode_walk (key->knode, &ctx, 0))) |
282 | { | 285 | { |
283 | pkt = cdk_kbnode_get_packet(p); | 286 | pkt = cdk_kbnode_get_packet (p); |
284 | if (pkt->pkttype == CDK_PKT_USER_ID && ++pos == idx) | 287 | if (pkt->pkttype == CDK_PKT_USER_ID && ++pos == idx) |
285 | break; | 288 | break; |
286 | } | 289 | } |
@@ -300,8 +303,8 @@ int gnutls_openpgp_crt_get_name(gnutls_openpgp_crt_t key, | |||
300 | return GNUTLS_E_SHORT_MEMORY_BUFFER; | 303 | return GNUTLS_E_SHORT_MEMORY_BUFFER; |
301 | } | 304 | } |
302 | 305 | ||
303 | memcpy(buf, uid->name, uid->len); | 306 | memcpy (buf, uid->name, uid->len); |
304 | buf[uid->len] = '\0'; /* make sure it's a string */ | 307 | buf[uid->len] = '\0'; /* make sure it's a string */ |
305 | *sizeof_buf = uid->len + 1; | 308 | *sizeof_buf = uid->len + 1; |
306 | 309 | ||
307 | if (uid->is_revoked) | 310 | if (uid->is_revoked) |
@@ -326,8 +329,9 @@ int gnutls_openpgp_crt_get_name(gnutls_openpgp_crt_t key, | |||
326 | * or a negative value on error. | 329 | * or a negative value on error. |
327 | * | 330 | * |
328 | **/ | 331 | **/ |
329 | gnutls_pk_algorithm_t gnutls_openpgp_crt_get_pk_algorithm(gnutls_openpgp_crt_t key, | 332 | gnutls_pk_algorithm_t |
330 | unsigned int *bits) | 333 | gnutls_openpgp_crt_get_pk_algorithm (gnutls_openpgp_crt_t key, |
334 | unsigned int *bits) | ||
331 | { | 335 | { |
332 | cdk_packet_t pkt; | 336 | cdk_packet_t pkt; |
333 | int algo; | 337 | int algo; |
@@ -336,11 +340,11 @@ gnutls_pk_algorithm_t gnutls_openpgp_crt_get_pk_algorithm(gnutls_openpgp_crt_t k | |||
336 | return GNUTLS_PK_UNKNOWN; | 340 | return GNUTLS_PK_UNKNOWN; |
337 | 341 | ||
338 | algo = 0; | 342 | algo = 0; |
339 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_PUBLIC_KEY); | 343 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); |
340 | if (pkt && pkt->pkttype == CDK_PKT_PUBLIC_KEY) | 344 | if (pkt && pkt->pkttype == CDK_PKT_PUBLIC_KEY) |
341 | { | 345 | { |
342 | if (bits) | 346 | if (bits) |
343 | *bits = cdk_pk_get_nbits(pkt->pkt.public_key); | 347 | *bits = cdk_pk_get_nbits (pkt->pkt.public_key); |
344 | algo = pkt->pkt.public_key->pubkey_algo; | 348 | algo = pkt->pkt.public_key->pubkey_algo; |
345 | if (is_RSA (algo)) | 349 | if (is_RSA (algo)) |
346 | algo = GNUTLS_PK_RSA; | 350 | algo = GNUTLS_PK_RSA; |
@@ -357,7 +361,8 @@ gnutls_pk_algorithm_t gnutls_openpgp_crt_get_pk_algorithm(gnutls_openpgp_crt_t k | |||
357 | * | 361 | * |
358 | * Extract the version of the OpenPGP key. | 362 | * Extract the version of the OpenPGP key. |
359 | **/ | 363 | **/ |
360 | int gnutls_openpgp_crt_get_version(gnutls_openpgp_crt_t key) | 364 | int |
365 | gnutls_openpgp_crt_get_version (gnutls_openpgp_crt_t key) | ||
361 | { | 366 | { |
362 | cdk_packet_t pkt; | 367 | cdk_packet_t pkt; |
363 | int version; | 368 | int version; |
@@ -365,7 +370,7 @@ int gnutls_openpgp_crt_get_version(gnutls_openpgp_crt_t key) | |||
365 | if (!key) | 370 | if (!key) |
366 | return -1; | 371 | return -1; |
367 | 372 | ||
368 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_PUBLIC_KEY); | 373 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); |
369 | if (pkt) | 374 | if (pkt) |
370 | version = pkt->pkt.public_key->version; | 375 | version = pkt->pkt.public_key->version; |
371 | else | 376 | else |
@@ -380,7 +385,8 @@ int gnutls_openpgp_crt_get_version(gnutls_openpgp_crt_t key) | |||
380 | * | 385 | * |
381 | * Returns the timestamp when the OpenPGP key was created. | 386 | * Returns the timestamp when the OpenPGP key was created. |
382 | **/ | 387 | **/ |
383 | time_t gnutls_openpgp_crt_get_creation_time(gnutls_openpgp_crt_t key) | 388 | time_t |
389 | gnutls_openpgp_crt_get_creation_time (gnutls_openpgp_crt_t key) | ||
384 | { | 390 | { |
385 | cdk_packet_t pkt; | 391 | cdk_packet_t pkt; |
386 | time_t timestamp; | 392 | time_t timestamp; |
@@ -388,7 +394,7 @@ time_t gnutls_openpgp_crt_get_creation_time(gnutls_openpgp_crt_t key) | |||
388 | if (!key) | 394 | if (!key) |
389 | return (time_t) - 1; | 395 | return (time_t) - 1; |
390 | 396 | ||
391 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_PUBLIC_KEY); | 397 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); |
392 | if (pkt) | 398 | if (pkt) |
393 | timestamp = pkt->pkt.public_key->timestamp; | 399 | timestamp = pkt->pkt.public_key->timestamp; |
394 | else | 400 | else |
@@ -404,7 +410,8 @@ time_t gnutls_openpgp_crt_get_creation_time(gnutls_openpgp_crt_t key) | |||
404 | * Returns the time when the OpenPGP key expires. A value of '0' means | 410 | * Returns the time when the OpenPGP key expires. A value of '0' means |
405 | * that the key doesn't expire at all. | 411 | * that the key doesn't expire at all. |
406 | **/ | 412 | **/ |
407 | time_t gnutls_openpgp_crt_get_expiration_time(gnutls_openpgp_crt_t key) | 413 | time_t |
414 | gnutls_openpgp_crt_get_expiration_time (gnutls_openpgp_crt_t key) | ||
408 | { | 415 | { |
409 | cdk_packet_t pkt; | 416 | cdk_packet_t pkt; |
410 | time_t expiredate; | 417 | time_t expiredate; |
@@ -412,7 +419,7 @@ time_t gnutls_openpgp_crt_get_expiration_time(gnutls_openpgp_crt_t key) | |||
412 | if (!key) | 419 | if (!key) |
413 | return (time_t) - 1; | 420 | return (time_t) - 1; |
414 | 421 | ||
415 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_PUBLIC_KEY); | 422 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); |
416 | if (pkt) | 423 | if (pkt) |
417 | expiredate = pkt->pkt.public_key->expiredate; | 424 | expiredate = pkt->pkt.public_key->expiredate; |
418 | else | 425 | else |
@@ -428,8 +435,8 @@ time_t gnutls_openpgp_crt_get_expiration_time(gnutls_openpgp_crt_t key) | |||
428 | * | 435 | * |
429 | * Returns the 64-bit keyID of the OpenPGP key. | 436 | * Returns the 64-bit keyID of the OpenPGP key. |
430 | **/ | 437 | **/ |
431 | int gnutls_openpgp_crt_get_id(gnutls_openpgp_crt_t key, | 438 | int |
432 | unsigned char keyid[8]) | 439 | gnutls_openpgp_crt_get_id (gnutls_openpgp_crt_t key, unsigned char keyid[8]) |
433 | { | 440 | { |
434 | cdk_packet_t pkt; | 441 | cdk_packet_t pkt; |
435 | uint32_t kid[2]; | 442 | uint32_t kid[2]; |
@@ -440,11 +447,11 @@ int gnutls_openpgp_crt_get_id(gnutls_openpgp_crt_t key, | |||
440 | return GNUTLS_E_INVALID_REQUEST; | 447 | return GNUTLS_E_INVALID_REQUEST; |
441 | } | 448 | } |
442 | 449 | ||
443 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_PUBLIC_KEY); | 450 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); |
444 | if (!pkt) | 451 | if (!pkt) |
445 | return GNUTLS_E_OPENPGP_GETKEY_FAILED; | 452 | return GNUTLS_E_OPENPGP_GETKEY_FAILED; |
446 | 453 | ||
447 | cdk_pk_get_keyid(pkt->pkt.public_key, kid); | 454 | cdk_pk_get_keyid (pkt->pkt.public_key, kid); |
448 | keyid[0] = kid[0] >> 24; | 455 | keyid[0] = kid[0] >> 24; |
449 | keyid[1] = kid[0] >> 16; | 456 | keyid[1] = kid[0] >> 16; |
450 | keyid[2] = kid[0] >> 8; | 457 | keyid[2] = kid[0] >> 8; |
@@ -469,8 +476,9 @@ int gnutls_openpgp_crt_get_id(gnutls_openpgp_crt_t key, | |||
469 | * Returns non zero on success, and zero on failure. | 476 | * Returns non zero on success, and zero on failure. |
470 | * | 477 | * |
471 | **/ | 478 | **/ |
472 | int gnutls_openpgp_crt_check_hostname(gnutls_openpgp_crt_t key, | 479 | int |
473 | const char *hostname) | 480 | gnutls_openpgp_crt_check_hostname (gnutls_openpgp_crt_t key, |
481 | const char *hostname) | ||
474 | { | 482 | { |
475 | char dnsname[MAX_CN]; | 483 | char dnsname[MAX_CN]; |
476 | size_t dnsnamesize; | 484 | size_t dnsnamesize; |
@@ -481,9 +489,9 @@ int gnutls_openpgp_crt_check_hostname(gnutls_openpgp_crt_t key, | |||
481 | for (i = 0; !(ret < 0); i++) | 489 | for (i = 0; !(ret < 0); i++) |
482 | { | 490 | { |
483 | dnsnamesize = sizeof (dnsname); | 491 | dnsnamesize = sizeof (dnsname); |
484 | ret = gnutls_openpgp_crt_get_name(key, i, dnsname, &dnsnamesize); | 492 | ret = gnutls_openpgp_crt_get_name (key, i, dnsname, &dnsnamesize); |
485 | /* FIXME: ret is not used */ | 493 | /* FIXME: ret is not used */ |
486 | if (_gnutls_hostname_compare(dnsname, hostname)) | 494 | if (_gnutls_hostname_compare (dnsname, hostname)) |
487 | return 1; | 495 | return 1; |
488 | } | 496 | } |
489 | 497 | ||
@@ -503,8 +511,9 @@ int gnutls_openpgp_crt_check_hostname(gnutls_openpgp_crt_t key, | |||
503 | * A negative value may be returned in case of parsing error. | 511 | * A negative value may be returned in case of parsing error. |
504 | * | 512 | * |
505 | */ | 513 | */ |
506 | int gnutls_openpgp_crt_get_key_usage(gnutls_openpgp_crt_t key, | 514 | int |
507 | unsigned int *key_usage) | 515 | gnutls_openpgp_crt_get_key_usage (gnutls_openpgp_crt_t key, |
516 | unsigned int *key_usage) | ||
508 | { | 517 | { |
509 | cdk_packet_t pkt; | 518 | cdk_packet_t pkt; |
510 | int algo = 0; | 519 | int algo = 0; |
@@ -514,14 +523,14 @@ int gnutls_openpgp_crt_get_key_usage(gnutls_openpgp_crt_t key, | |||
514 | 523 | ||
515 | *key_usage = 0; | 524 | *key_usage = 0; |
516 | 525 | ||
517 | pkt = cdk_kbnode_find_packet(key->knode, CDK_PKT_PUBLIC_KEY); | 526 | pkt = cdk_kbnode_find_packet (key->knode, CDK_PKT_PUBLIC_KEY); |
518 | if (pkt && pkt->pkttype == CDK_PKT_PUBLIC_KEY) | 527 | if (pkt && pkt->pkttype == CDK_PKT_PUBLIC_KEY) |
519 | { | 528 | { |
520 | algo = pkt->pkt.public_key->pubkey_algo; | 529 | algo = pkt->pkt.public_key->pubkey_algo; |
521 | 530 | ||
522 | /* FIXME: We need to take a look at the key flags because | 531 | /* FIXME: We need to take a look at the key flags because |
523 | RSA-E and RSA-S are obsolete. Only RSA is used | 532 | RSA-E and RSA-S are obsolete. Only RSA is used |
524 | and the flags are used to set the capabilities. */ | 533 | and the flags are used to set the capabilities. */ |
525 | if (is_DSA (algo) || algo == GCRY_PK_RSA_S) | 534 | if (is_DSA (algo) || algo == GCRY_PK_RSA_S) |
526 | *key_usage |= KEY_DIGITAL_SIGNATURE; | 535 | *key_usage |= KEY_DIGITAL_SIGNATURE; |
527 | else if (algo == GCRY_PK_RSA_E) | 536 | else if (algo == GCRY_PK_RSA_E) |