17 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
20 |
|
|
21 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
22 |
#include <config.h> |
#include <config.h> |
23 |
#endif |
#endif |
24 |
|
|
25 |
#include <windows.h> |
#include <windows.h> |
|
#include <windows.h> |
|
26 |
#include <stdio.h> |
#include <stdio.h> |
27 |
#include <string.h> |
#include <string.h> |
28 |
#include <malloc.h> |
#include <malloc.h> |
29 |
#include <ctype.h> |
#include <ctype.h> |
30 |
#include <assert.h> |
#include <assert.h> |
31 |
|
#include <gpgme.h> |
32 |
|
|
|
#include "w32gpgme.h" |
|
33 |
#include "wptKeyCache.h" |
#include "wptKeyCache.h" |
34 |
#include "openpgp.h" |
#include "openpgp.h" |
35 |
#include "wptNLS.h" |
#include "wptNLS.h" |
37 |
#include "wptW32API.h" |
#include "wptW32API.h" |
38 |
|
|
39 |
|
|
40 |
|
#if 0 |
41 |
/* convert a binary buffer into its hex representation. */ |
/* convert a binary buffer into its hex representation. */ |
42 |
static void |
static void |
43 |
buffer_to_string (char *dst, size_t dlen, const byte *buf, size_t nbytes) |
buffer_to_string (char *dst, size_t dlen, const byte *buf, size_t nbytes) |
52 |
dlen -= 2; |
dlen -= 2; |
53 |
} |
} |
54 |
} |
} |
55 |
|
#endif |
56 |
|
|
57 |
|
|
58 |
/* Parse the secret keyring and retrieve some additional information |
/* Parse the secret keyring and retrieve some additional information |
107 |
keycache_prepare2 (gpg_keycache_t ctx, const char *kid, |
keycache_prepare2 (gpg_keycache_t ctx, const char *kid, |
108 |
const char *pubring, const char *secring) |
const char *pubring, const char *secring) |
109 |
{ |
{ |
110 |
gpgme_error_t err; |
gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR); |
111 |
gpgme_key_t key = NULL; |
gpgme_key_t key = NULL; |
112 |
gpg_iobuf_t inp; |
gpg_iobuf_t inp; |
113 |
PACKET *pkt = (PACKET*)calloc (1, sizeof * pkt); |
PACKET *pkt = (PACKET*)calloc (1, sizeof * pkt); |
115 |
const byte *sym_prefs; |
const byte *sym_prefs; |
116 |
char keyid[16+1], *id = NULL; |
char keyid[16+1], *id = NULL; |
117 |
int key_seen = 0; |
int key_seen = 0; |
118 |
size_t nbytes = 0, nsym =0; |
size_t nsym =0; |
119 |
|
|
120 |
if (secring) { |
if (secring) { |
121 |
parse_secring (ctx, kid, secring); |
parse_secring (ctx, kid, secring); |
178 |
} |
} |
179 |
if ((pkt->pkttype == PKT_USER_ID || pkt->pkttype == PKT_ATTRIBUTE) |
if ((pkt->pkttype == PKT_USER_ID || pkt->pkttype == PKT_ATTRIBUTE) |
180 |
&& pkt->pkt.user_id->attrib_data && key) { |
&& pkt->pkt.user_id->attrib_data && key) { |
181 |
PKT_user_id *id = pkt->pkt.user_id; |
PKT_user_id *uid = pkt->pkt.user_id; |
182 |
c->attrib.used = 1; |
c->attrib.used = 1; |
183 |
c->attrib.len = id->attrib_len; |
c->attrib.len = uid->attrib_len; |
184 |
c->attrib.d = (unsigned char*)calloc (1, id->attrib_len + 1); |
c->attrib.d = (unsigned char*)calloc (1, uid->attrib_len + 1); |
185 |
if (!c->attrib.d) { |
if (!c->attrib.d) { |
186 |
err = gpg_error (GPG_ERR_ENOMEM); |
err = gpg_error (GPG_ERR_ENOMEM); |
187 |
goto fail; |
goto fail; |
188 |
} |
} |
189 |
memcpy (c->attrib.d, id->attrib_data, id->attrib_len); |
memcpy (c->attrib.d, uid->attrib_data, uid->attrib_len); |
190 |
key = NULL; |
key = NULL; |
191 |
c = NULL; |
c = NULL; |
192 |
} |
} |
289 |
gpgme_error_t |
gpgme_error_t |
290 |
gpg_keycache_add_key (gpg_keycache_t ctx, gpgme_key_t key, void **opaque) |
gpg_keycache_add_key (gpg_keycache_t ctx, gpgme_key_t key, void **opaque) |
291 |
{ |
{ |
292 |
struct keycache_s * c, * n1; |
struct keycache_s *c, *n1; |
293 |
|
|
294 |
if (!ctx) |
if (!ctx) |
295 |
return gpg_error (GPG_ERR_INV_ARG); |
return gpg_error (GPG_ERR_INV_ARG); |