mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gcc-4 defaults forced me to edit many many files to get rid of the
char * vs. unsigned char * warnings. The GNU coding standards used to say that these mismatches are okay and better than a bunch of casts. Obviously this has changed now.
This commit is contained in:
parent
3370164182
commit
deeba405a9
69 changed files with 558 additions and 348 deletions
|
@ -1,3 +1,49 @@
|
|||
2005-06-16 Werner Koch <wk@g10code.com>
|
||||
|
||||
* protect-tool.c (make_advanced): Makde RESULT a plain char.
|
||||
* call-scd.c (unescape_status_string): Need to cast unsigned char*
|
||||
for strcpy.
|
||||
(agent_card_pksign): Made arg R_BUF an unsigned char**.
|
||||
* divert-scd.c (divert_pksign): Made SIGVAL unsigned char*.
|
||||
(encode_md_for_card): Initialize R_VAL and R_LEN.
|
||||
* genkey.c (store_key): Made BUF unsigned.
|
||||
* protect.c (do_encryption): Ditto.
|
||||
(do_encryption): Made arg PROTBEGIN unsigned. Initialize RESULT
|
||||
and RESULTLEN even on error.
|
||||
(merge_lists): Need to cast unsigned char * for strcpy. Initialize
|
||||
RESULTand RESULTLEN even on error.
|
||||
(agent_unprotect): Likewise for strtoul.
|
||||
(make_shadow_info): Made P and INFO plain char.
|
||||
(agent_shadow_key): Made P plain char.
|
||||
|
||||
2005-06-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* query.c (agent_get_passphrase): Made HEXSTRING a char*.
|
||||
* command-ssh.c (ssh_key_grip): Made arg BUFFER unsigned.
|
||||
(ssh_key_grip): Simplified.
|
||||
(data_sign): Initialize variables with the definition.
|
||||
(ssh_convert_key_to_blob): Make sure that BLOB and BLOB_SIZE
|
||||
are set to NULL on error. Cool, gcc-4 detects uninitialized stuff
|
||||
beyond function boundaries; well it can't know that we do error
|
||||
proper error handling so that this was not a real error.
|
||||
(file_to_buffer): Likewise for BUFFER and BUFFER_N.
|
||||
(data_sign): Likewise for SIG and SIG_N.
|
||||
(stream_read_byte): Set B to a value even on error.
|
||||
* command.c (cmd_genkey): Changed VALUE to char.
|
||||
(cmd_readkey): Cast arg for gcry_sexp_sprint.
|
||||
* agent.h (struct server_control_s): Made KEYGRIP unsigned.
|
||||
|
||||
2005-06-13 Werner Koch <wk@g10code.com>
|
||||
|
||||
* command-ssh.c (start_command_handler_ssh): Reset the SCD.
|
||||
|
||||
2005-06-09 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpg-agent.c (create_socket_name): New option --max-cache-ttl-ssh.
|
||||
* cache.c (housekeeping): Use it.
|
||||
(agent_put_cache): Use a switch to get the default ttl so that it
|
||||
is easier to add more cases.
|
||||
|
||||
2005-06-06 Werner Koch <wk@g10code.com>
|
||||
|
||||
* gpg-agent.c: New option --default-cache-ttl-ssh.
|
||||
|
|
|
@ -71,9 +71,10 @@ struct {
|
|||
int no_grab; /* Don't let the pinentry grab the keyboard */
|
||||
|
||||
/* The default and maximum TTL of cache entries. */
|
||||
unsigned long def_cache_ttl; /* Normal. */
|
||||
unsigned long def_cache_ttl_ssh; /* SSH. */
|
||||
unsigned long max_cache_ttl;
|
||||
unsigned long def_cache_ttl; /* Default. */
|
||||
unsigned long def_cache_ttl_ssh; /* for SSH. */
|
||||
unsigned long max_cache_ttl; /* Default. */
|
||||
unsigned long max_cache_ttl_ssh; /* for SSH. */
|
||||
|
||||
|
||||
int running_detached; /* We are running detached from the tty. */
|
||||
|
@ -107,8 +108,8 @@ struct server_local_s;
|
|||
struct scd_local_s;
|
||||
|
||||
/* Collection of data per session (aka connection). */
|
||||
struct server_control_s {
|
||||
|
||||
struct server_control_s
|
||||
{
|
||||
/* Private data of the server (command.c). */
|
||||
struct server_local_s *server_local;
|
||||
|
||||
|
@ -128,7 +129,7 @@ struct server_control_s {
|
|||
int valuelen;
|
||||
int raw_value: 1;
|
||||
} digest;
|
||||
char keygrip[20];
|
||||
unsigned char keygrip[20];
|
||||
int have_keygrip;
|
||||
|
||||
int use_auth_call; /* Hack to send the PKAUTH command instead of the
|
||||
|
@ -289,7 +290,7 @@ int agent_card_pksign (ctrl_t ctrl,
|
|||
int (*getpin_cb)(void *, const char *, char*, size_t),
|
||||
void *getpin_cb_arg,
|
||||
const unsigned char *indata, size_t indatalen,
|
||||
char **r_buf, size_t *r_buflen);
|
||||
unsigned char **r_buf, size_t *r_buflen);
|
||||
int agent_card_pkdecrypt (ctrl_t ctrl,
|
||||
const char *keyid,
|
||||
int (*getpin_cb)(void *, const char *, char*,size_t),
|
||||
|
|
|
@ -103,10 +103,17 @@ housekeeping (void)
|
|||
}
|
||||
|
||||
/* Second, make sure that we also remove them based on the created stamp so
|
||||
that the user has to enter it from time to time. We do this every hour */
|
||||
that the user has to enter it from time to time. */
|
||||
for (r=thecache; r; r = r->next)
|
||||
{
|
||||
if (!r->lockcount && r->pw && r->created + opt.max_cache_ttl < current)
|
||||
unsigned long maxttl;
|
||||
|
||||
switch (r->cache_mode)
|
||||
{
|
||||
case CACHE_MODE_SSH: maxttl = opt.max_cache_ttl_ssh; break;
|
||||
default: maxttl = opt.max_cache_ttl; break;
|
||||
}
|
||||
if (!r->lockcount && r->pw && r->created + maxttl < current)
|
||||
{
|
||||
if (DBG_CACHE)
|
||||
log_debug (" expired `%s' (%lus after creation)\n",
|
||||
|
@ -203,10 +210,11 @@ agent_put_cache (const char *key, cache_mode_t cache_mode,
|
|||
|
||||
if (!ttl)
|
||||
{
|
||||
if (cache_mode == CACHE_MODE_SSH)
|
||||
ttl = opt.def_cache_ttl_ssh;
|
||||
else
|
||||
ttl = opt.def_cache_ttl;
|
||||
switch(cache_mode)
|
||||
{
|
||||
case CACHE_MODE_SSH: ttl = opt.def_cache_ttl_ssh; break;
|
||||
default: ttl = opt.def_cache_ttl; break;
|
||||
}
|
||||
}
|
||||
if (!ttl || cache_mode == CACHE_MODE_IGNORE)
|
||||
return 0;
|
||||
|
|
|
@ -465,7 +465,7 @@ unescape_status_string (const unsigned char *s)
|
|||
{
|
||||
char *buffer, *d;
|
||||
|
||||
buffer = d = xtrymalloc (strlen (s)+1);
|
||||
buffer = d = xtrymalloc (strlen ((const char*)s)+1);
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
while (*s)
|
||||
|
@ -666,7 +666,7 @@ agent_card_pksign (ctrl_t ctrl,
|
|||
int (*getpin_cb)(void *, const char *, char*, size_t),
|
||||
void *getpin_cb_arg,
|
||||
const unsigned char *indata, size_t indatalen,
|
||||
char **r_buf, size_t *r_buflen)
|
||||
unsigned char **r_buf, size_t *r_buflen)
|
||||
{
|
||||
int rc, i;
|
||||
char *p, line[ASSUAN_LINELENGTH];
|
||||
|
@ -714,14 +714,11 @@ agent_card_pksign (ctrl_t ctrl,
|
|||
/* Create an S-expression from it which is formatted like this:
|
||||
"(7:sig-val(3:rsa(1:sSIGBUFLEN:SIGBUF)))" */
|
||||
*r_buflen = 21 + 11 + sigbuflen + 4;
|
||||
*r_buf = xtrymalloc (*r_buflen);
|
||||
if (!*r_buf)
|
||||
{
|
||||
gpg_error_t tmperr = out_of_core ();
|
||||
xfree (*r_buf);
|
||||
return unlock_scd (ctrl, tmperr);
|
||||
}
|
||||
p = stpcpy (*r_buf, "(7:sig-val(3:rsa(1:s" );
|
||||
p = xtrymalloc (*r_buflen);
|
||||
*r_buf = (unsigned char*)p;
|
||||
if (!p)
|
||||
return unlock_scd (ctrl, out_of_core ());
|
||||
p = stpcpy (p, "(7:sig-val(3:rsa(1:s" );
|
||||
sprintf (p, "%u:", (unsigned int)sigbuflen);
|
||||
p += strlen (p);
|
||||
memcpy (p, sigbuf, sigbuflen);
|
||||
|
@ -895,7 +892,7 @@ card_getattr_cb (void *opaque, const char *line)
|
|||
if (keywordlen == parm->keywordlen
|
||||
&& !memcmp (keyword, parm->keyword, keywordlen))
|
||||
{
|
||||
parm->data = unescape_status_string (line);
|
||||
parm->data = unescape_status_string ((const unsigned char*)line);
|
||||
if (!parm->data)
|
||||
parm->error = errno;
|
||||
}
|
||||
|
|
|
@ -297,6 +297,7 @@ stream_read_byte (estream_t stream, unsigned char *b)
|
|||
err = gpg_error_from_errno (errno);
|
||||
else
|
||||
err = gpg_error (GPG_ERR_EOF);
|
||||
*b = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -604,6 +605,9 @@ file_to_buffer (const char *filename, unsigned char **buffer, size_t *buffer_n)
|
|||
gpg_error_t err;
|
||||
int ret;
|
||||
|
||||
*buffer = NULL;
|
||||
*buffer_n = 0;
|
||||
|
||||
buffer_new = NULL;
|
||||
err = 0;
|
||||
|
||||
|
@ -1381,6 +1385,9 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
|
|||
gpg_error_t err;
|
||||
unsigned int i;
|
||||
|
||||
*blob = NULL;
|
||||
*blob_size = 0;
|
||||
|
||||
blob_new = NULL;
|
||||
stream = NULL;
|
||||
err = 0;
|
||||
|
@ -1535,20 +1542,12 @@ ssh_read_key_public_from_blob (unsigned char *blob, size_t blob_size,
|
|||
S-Expression KEY and writes it to BUFFER, which must be large
|
||||
enough to hold it. Returns usual error code. */
|
||||
static gpg_error_t
|
||||
ssh_key_grip (gcry_sexp_t key, char *buffer)
|
||||
ssh_key_grip (gcry_sexp_t key, unsigned char *buffer)
|
||||
{
|
||||
gpg_error_t err;
|
||||
char *p;
|
||||
if (!gcry_pk_get_keygrip (key, buffer))
|
||||
return gpg_error (GPG_ERR_INTERNAL);
|
||||
|
||||
/* FIXME: unsigned vs. signed. */
|
||||
|
||||
p = gcry_pk_get_keygrip (key, buffer);
|
||||
if (! p)
|
||||
err = gpg_error (GPG_ERR_INTERNAL); /* FIXME? */
|
||||
else
|
||||
err = 0;
|
||||
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Converts the secret key KEY_SECRET into a public key, storing it in
|
||||
|
@ -1654,7 +1653,7 @@ card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn)
|
|||
}
|
||||
|
||||
pkbuflen = gcry_sexp_canon_len (pkbuf, 0, NULL, NULL);
|
||||
err = gcry_sexp_sscan (&s_pk, NULL, pkbuf, pkbuflen);
|
||||
err = gcry_sexp_sscan (&s_pk, NULL, (char*)pkbuf, pkbuflen);
|
||||
if (err)
|
||||
{
|
||||
log_error ("failed to build S-Exp from received card key: %s\n",
|
||||
|
@ -1877,7 +1876,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
err = gcry_sexp_sscan (&key_secret, NULL, buffer, buffer_n);
|
||||
err = gcry_sexp_sscan (&key_secret, NULL, (char*)buffer, buffer_n);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
|
@ -1984,14 +1983,14 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
|
|||
unsigned char **sig, size_t *sig_n)
|
||||
{
|
||||
gpg_error_t err;
|
||||
gcry_sexp_t signature_sexp;
|
||||
estream_t stream;
|
||||
gcry_sexp_t valuelist;
|
||||
gcry_sexp_t sublist;
|
||||
gcry_mpi_t sig_value;
|
||||
unsigned char *sig_blob;
|
||||
size_t sig_blob_n;
|
||||
char *identifier;
|
||||
gcry_sexp_t signature_sexp = NULL;
|
||||
estream_t stream = NULL;
|
||||
gcry_sexp_t valuelist = NULL;
|
||||
gcry_sexp_t sublist = NULL;
|
||||
gcry_mpi_t sig_value = NULL;
|
||||
unsigned char *sig_blob = NULL;;
|
||||
size_t sig_blob_n = 0;
|
||||
char *identifier = NULL;
|
||||
const char *identifier_raw;
|
||||
size_t identifier_n;
|
||||
ssh_key_type_spec_t spec;
|
||||
|
@ -1999,17 +1998,10 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
|
|||
unsigned int i;
|
||||
const char *elems;
|
||||
size_t elems_n;
|
||||
gcry_mpi_t *mpis;
|
||||
gcry_mpi_t *mpis = NULL;
|
||||
|
||||
signature_sexp = NULL;
|
||||
identifier = NULL;
|
||||
valuelist = NULL;
|
||||
sublist = NULL;
|
||||
sig_blob = NULL;
|
||||
sig_blob_n = 0;
|
||||
stream = NULL;
|
||||
sig_value = NULL;
|
||||
mpis = NULL;
|
||||
*sig = NULL;
|
||||
*sig_n = 0;
|
||||
|
||||
ctrl->use_auth_call = 1;
|
||||
err = agent_pksign_do (ctrl,
|
||||
|
@ -2119,7 +2111,7 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
*sig = (char *) sig_blob;
|
||||
*sig = sig_blob;
|
||||
*sig_n = sig_blob_n;
|
||||
|
||||
out:
|
||||
|
@ -2684,7 +2676,7 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
|
|||
secure memory, since we never give out secret keys.
|
||||
|
||||
FIXME: This is a pretty good DoS. We only have a limited amount
|
||||
of secure memory, we can't trhow hin everything we get from a
|
||||
of secure memory, we can't throw in everything we get from a
|
||||
client -wk */
|
||||
|
||||
/* Retrieve request. */
|
||||
|
@ -2824,7 +2816,6 @@ start_command_handler_ssh (int sock_client)
|
|||
struct server_control_s ctrl;
|
||||
estream_t stream_sock;
|
||||
gpg_error_t err;
|
||||
int bad;
|
||||
int ret;
|
||||
|
||||
/* Setup control structure. */
|
||||
|
@ -2868,15 +2859,15 @@ start_command_handler_ssh (int sock_client)
|
|||
goto out;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
bad = ssh_request_process (&ctrl, stream_sock);
|
||||
if (bad)
|
||||
break;
|
||||
};
|
||||
/* Main processing loop. */
|
||||
while ( !ssh_request_process (&ctrl, stream_sock) )
|
||||
;
|
||||
|
||||
/* Reset the SCD in case it has been used. */
|
||||
agent_reset_scd (&ctrl);
|
||||
|
||||
|
||||
out:
|
||||
|
||||
if (stream_sock)
|
||||
es_fclose (stream_sock);
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ parse_keygrip (ASSUAN_CONTEXT ctx, const char *string, unsigned char *buf)
|
|||
if (n != 20)
|
||||
return set_error (Parameter_Error, "invalid length of keygrip");
|
||||
|
||||
for (p=string, n=0; n < 20; p += 2, n++)
|
||||
for (p=(const unsigned char*)string, n=0; n < 20; p += 2, n++)
|
||||
buf[n] = xtoi_2 (p);
|
||||
|
||||
return 0;
|
||||
|
@ -494,7 +494,7 @@ cmd_genkey (ASSUAN_CONTEXT ctx, char *line)
|
|||
|
||||
init_membuf (&outbuf, 512);
|
||||
|
||||
rc = agent_genkey (ctrl, value, valuelen, &outbuf);
|
||||
rc = agent_genkey (ctrl, (char*)value, valuelen, &outbuf);
|
||||
xfree (value);
|
||||
if (rc)
|
||||
clear_outbuf (&outbuf);
|
||||
|
|
|
@ -139,10 +139,13 @@ static int
|
|||
encode_md_for_card (const unsigned char *digest, size_t digestlen, int algo,
|
||||
unsigned char **r_val, size_t *r_len)
|
||||
{
|
||||
byte *frame;
|
||||
byte asn[100];
|
||||
unsigned char *frame;
|
||||
unsigned char asn[100];
|
||||
size_t asnlen;
|
||||
|
||||
*r_val = NULL;
|
||||
*r_len = 0;
|
||||
|
||||
asnlen = DIM(asn);
|
||||
if (gcry_md_algo_info (algo, GCRYCTL_GET_ASNOID, asn, &asnlen))
|
||||
{
|
||||
|
@ -295,7 +298,7 @@ divert_pksign (CTRL ctrl,
|
|||
int rc;
|
||||
char *kid;
|
||||
size_t siglen;
|
||||
char *sigval;
|
||||
unsigned char *sigval;
|
||||
unsigned char *data;
|
||||
size_t ndata;
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
|
|||
}
|
||||
|
||||
/* Convert the file into a gcrypt S-expression object. */
|
||||
rc = gcry_sexp_sscan (&s_skey, &erroff, buf, buflen);
|
||||
rc = gcry_sexp_sscan (&s_skey, &erroff, (char*)buf, buflen);
|
||||
xfree (fname);
|
||||
fclose (fp);
|
||||
xfree (buf);
|
||||
|
@ -500,7 +500,7 @@ agent_key_from_file (ctrl_t ctrl, const char *desc_text,
|
|||
}
|
||||
|
||||
buflen = gcry_sexp_canon_len (buf, 0, NULL, NULL);
|
||||
rc = gcry_sexp_sscan (&s_skey, &erroff, buf, buflen);
|
||||
rc = gcry_sexp_sscan (&s_skey, &erroff, (char*)buf, buflen);
|
||||
wipememory (buf, buflen);
|
||||
xfree (buf);
|
||||
if (rc)
|
||||
|
|
|
@ -33,7 +33,7 @@ static int
|
|||
store_key (gcry_sexp_t private, const char *passphrase, int force)
|
||||
{
|
||||
int rc;
|
||||
char *buf;
|
||||
unsigned char *buf;
|
||||
size_t len;
|
||||
unsigned char grip[20];
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ enum cmd_and_opt_values
|
|||
oDefCacheTTL,
|
||||
oDefCacheTTLSSH,
|
||||
oMaxCacheTTL,
|
||||
oMaxCacheTTLSSH,
|
||||
oUseStandardSocket,
|
||||
oNoUseStandardSocket,
|
||||
|
||||
|
@ -143,6 +144,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||
N_("|N|expire cached PINs after N seconds")},
|
||||
{ oDefCacheTTLSSH, "default-cache-ttl-ssh", 4, "@" },
|
||||
{ oMaxCacheTTL, "max-cache-ttl", 4, "@" },
|
||||
{ oMaxCacheTTLSSH, "max-cache-ttl-ssh", 4, "@" },
|
||||
{ oIgnoreCacheForSigning, "ignore-cache-for-signing", 0,
|
||||
N_("do not use the PIN cache when signing")},
|
||||
{ oAllowMarkTrusted, "allow-mark-trusted", 0,
|
||||
|
@ -156,8 +158,9 @@ static ARGPARSE_OPTS opts[] = {
|
|||
};
|
||||
|
||||
|
||||
#define DEFAULT_CACHE_TTL (10*60) /* 10 minutes */
|
||||
#define MAX_CACHE_TTL (120*60) /* 2 hours */
|
||||
#define DEFAULT_CACHE_TTL (10*60) /* 10 minutes */
|
||||
#define DEFAULT_CACHE_TTL_SSH (30*60) /* 30 minutes */
|
||||
#define MAX_CACHE_TTL (120*60) /* 2 hours */
|
||||
|
||||
|
||||
/* flag to indicate that a shutdown was requested */
|
||||
|
@ -369,8 +372,9 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
|
|||
opt.pinentry_program = NULL;
|
||||
opt.scdaemon_program = NULL;
|
||||
opt.def_cache_ttl = DEFAULT_CACHE_TTL;
|
||||
opt.def_cache_ttl_ssh = DEFAULT_CACHE_TTL;
|
||||
opt.def_cache_ttl_ssh = DEFAULT_CACHE_TTL_SSH;
|
||||
opt.max_cache_ttl = MAX_CACHE_TTL;
|
||||
opt.max_cache_ttl_ssh = MAX_CACHE_TTL;
|
||||
opt.ignore_cache_for_signing = 0;
|
||||
opt.allow_mark_trusted = 0;
|
||||
opt.disable_scdaemon = 0;
|
||||
|
@ -407,6 +411,7 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
|
|||
case oDefCacheTTL: opt.def_cache_ttl = pargs->r.ret_ulong; break;
|
||||
case oDefCacheTTLSSH: opt.def_cache_ttl_ssh = pargs->r.ret_ulong; break;
|
||||
case oMaxCacheTTL: opt.max_cache_ttl = pargs->r.ret_ulong; break;
|
||||
case oMaxCacheTTLSSH: opt.max_cache_ttl_ssh = pargs->r.ret_ulong; break;
|
||||
|
||||
case oIgnoreCacheForSigning: opt.ignore_cache_for_signing = 1; break;
|
||||
|
||||
|
|
|
@ -1552,6 +1552,8 @@ p12_build (gcry_mpi_t *kparms, unsigned char *cert, size_t certlen,
|
|||
struct buffer_s seqlist[2];
|
||||
int seqlistidx = 0;
|
||||
|
||||
n = buflen = 0; /* (avoid compiler warning). */
|
||||
|
||||
if (cert && certlen)
|
||||
{
|
||||
/* Encode the certificate. */
|
||||
|
|
|
@ -52,7 +52,7 @@ agent_pkdecrypt (CTRL ctrl, const char *desc_text,
|
|||
goto leave;
|
||||
}
|
||||
|
||||
rc = gcry_sexp_sscan (&s_cipher, NULL, ciphertext, ciphertextlen);
|
||||
rc = gcry_sexp_sscan (&s_cipher, NULL, (char*)ciphertext, ciphertextlen);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("failed to convert ciphertext: %s\n", gpg_strerror (rc));
|
||||
|
|
|
@ -117,7 +117,7 @@ agent_pksign_do (ctrl_t ctrl, const char *desc_text,
|
|||
len = gcry_sexp_canon_len (buf, 0, NULL, NULL);
|
||||
assert (len);
|
||||
|
||||
rc = gcry_sexp_sscan (&s_sig, NULL, buf, len);
|
||||
rc = gcry_sexp_sscan (&s_sig, NULL, (char*)buf, len);
|
||||
xfree (buf);
|
||||
if (rc)
|
||||
{
|
||||
|
|
|
@ -239,9 +239,9 @@ make_advanced (const unsigned char *buf, size_t buflen)
|
|||
int rc;
|
||||
size_t erroff, len;
|
||||
gcry_sexp_t sexp;
|
||||
unsigned char *result;
|
||||
char *result;
|
||||
|
||||
rc = gcry_sexp_sscan (&sexp, &erroff, buf, buflen);
|
||||
rc = gcry_sexp_sscan (&sexp, &erroff, (const char*)buf, buflen);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("invalid canonical S-Expression (off=%u): %s\n",
|
||||
|
@ -378,7 +378,7 @@ read_and_protect (const char *fname)
|
|||
xfree (result);
|
||||
if (!p)
|
||||
return;
|
||||
result = p;
|
||||
result = (unsigned char*)p;
|
||||
resultlen = strlen (p);
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ read_and_unprotect (const char *fname)
|
|||
xfree (result);
|
||||
if (!p)
|
||||
return;
|
||||
result = p;
|
||||
result = (unsigned char*)p;
|
||||
resultlen = strlen (p);
|
||||
}
|
||||
|
||||
|
@ -434,12 +434,13 @@ read_and_shadow (const char *fname)
|
|||
unsigned char *key;
|
||||
unsigned char *result;
|
||||
size_t resultlen;
|
||||
unsigned char dummy_info[] = "(8:313233342:43)";
|
||||
|
||||
key = read_key (fname);
|
||||
if (!key)
|
||||
return;
|
||||
|
||||
rc = agent_shadow_key (key, "(8:313233342:43)", &result);
|
||||
rc = agent_shadow_key (key, dummy_info, &result);
|
||||
xfree (key);
|
||||
if (rc)
|
||||
{
|
||||
|
@ -455,7 +456,7 @@ read_and_shadow (const char *fname)
|
|||
xfree (result);
|
||||
if (!p)
|
||||
return;
|
||||
result = p;
|
||||
result = (unsigned char*)p;
|
||||
resultlen = strlen (p);
|
||||
}
|
||||
|
||||
|
@ -682,7 +683,7 @@ import_p12_file (const char *fname)
|
|||
if (!buf)
|
||||
return;
|
||||
|
||||
kparms = p12_parse (buf, buflen, (pw=get_passphrase (2)),
|
||||
kparms = p12_parse ((unsigned char*)buf, buflen, (pw=get_passphrase (2)),
|
||||
import_p12_cert_cb, NULL);
|
||||
release_passphrase (pw);
|
||||
xfree (buf);
|
||||
|
@ -773,7 +774,7 @@ import_p12_file (const char *fname)
|
|||
xfree (result);
|
||||
if (!p)
|
||||
return;
|
||||
result = p;
|
||||
result = (unsigned char*)p;
|
||||
resultlen = strlen (p);
|
||||
}
|
||||
|
||||
|
@ -932,7 +933,7 @@ export_p12_file (const char *fname)
|
|||
|
||||
if (opt_have_cert)
|
||||
{
|
||||
cert = read_file ("-", &certlen);
|
||||
cert = (unsigned char*)read_file ("-", &certlen);
|
||||
if (!cert)
|
||||
{
|
||||
wipememory (key, keylen_for_wipe);
|
||||
|
@ -1040,7 +1041,7 @@ percent_plus_unescape (unsigned char *string)
|
|||
static char *
|
||||
percent_plus_unescape_string (char *string)
|
||||
{
|
||||
unsigned char *p = string;
|
||||
unsigned char *p = (unsigned char*)string;
|
||||
size_t n;
|
||||
|
||||
n = percent_plus_unescape (p);
|
||||
|
|
|
@ -134,19 +134,22 @@ calculate_mic (const unsigned char *plainkey, unsigned char *sha1hash)
|
|||
|
||||
*/
|
||||
static int
|
||||
do_encryption (const char *protbegin, size_t protlen,
|
||||
do_encryption (const unsigned char *protbegin, size_t protlen,
|
||||
const char *passphrase, const unsigned char *sha1hash,
|
||||
unsigned char **result, size_t *resultlen)
|
||||
{
|
||||
gcry_cipher_hd_t hd;
|
||||
const char *modestr = "openpgp-s2k3-sha1-" PROT_CIPHER_STRING "-cbc";
|
||||
int blklen, enclen, outlen;
|
||||
char *iv = NULL;
|
||||
unsigned char *iv = NULL;
|
||||
int rc;
|
||||
char *outbuf = NULL;
|
||||
char *p;
|
||||
int saltpos, ivpos, encpos;
|
||||
|
||||
*resultlen = 0;
|
||||
*result = NULL;
|
||||
|
||||
rc = gcry_cipher_open (&hd, PROT_CIPHER, GCRY_CIPHER_MODE_CBC,
|
||||
GCRY_CIPHER_SECURE);
|
||||
if (rc)
|
||||
|
@ -250,7 +253,7 @@ do_encryption (const char *protbegin, size_t protlen,
|
|||
return tmperr;
|
||||
}
|
||||
*resultlen = strlen (p);
|
||||
*result = p;
|
||||
*result = (unsigned char*)p;
|
||||
memcpy (p+saltpos, iv+2*blklen, 8);
|
||||
memcpy (p+ivpos, iv, blklen);
|
||||
memcpy (p+encpos, outbuf, enclen);
|
||||
|
@ -261,7 +264,7 @@ do_encryption (const char *protbegin, size_t protlen,
|
|||
|
||||
|
||||
|
||||
/* Protect the key encoded in canonical format in plainkey. We assume
|
||||
/* Protect the key encoded in canonical format in PLAINKEY. We assume
|
||||
a valid S-Exp here. */
|
||||
int
|
||||
agent_protect (const unsigned char *plainkey, const char *passphrase,
|
||||
|
@ -469,6 +472,9 @@ merge_lists (const unsigned char *protectedkey,
|
|||
const unsigned char *startpos, *endpos;
|
||||
int i, rc;
|
||||
|
||||
*result = NULL;
|
||||
*resultlen = 0;
|
||||
|
||||
if (replacepos < 26)
|
||||
return gpg_error (GPG_ERR_BUG);
|
||||
|
||||
|
@ -487,7 +493,7 @@ merge_lists (const unsigned char *protectedkey,
|
|||
return out_of_core ();
|
||||
|
||||
/* Copy the initial segment */
|
||||
strcpy (newlist, "(11:private-key");
|
||||
strcpy ((char*)newlist, "(11:private-key");
|
||||
p = newlist + 15;
|
||||
memcpy (p, protectedkey+15+10, replacepos-15-10);
|
||||
p += replacepos-15-10;
|
||||
|
@ -669,7 +675,7 @@ agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
|
|||
is nothing we should worry about */
|
||||
if (s[n] != ')' )
|
||||
return gpg_error (GPG_ERR_INV_SEXP);
|
||||
s2kcount = strtoul (s, NULL, 10);
|
||||
s2kcount = strtoul ((const char*)s, NULL, 10);
|
||||
if (!s2kcount)
|
||||
return gpg_error (GPG_ERR_CORRUPTED_PROTECTION);
|
||||
s += n;
|
||||
|
@ -838,7 +844,7 @@ unsigned char *
|
|||
make_shadow_info (const char *serialno, const char *idstring)
|
||||
{
|
||||
const char *s;
|
||||
unsigned char *info, *p;
|
||||
char *info, *p;
|
||||
char numbuf[21];
|
||||
int n;
|
||||
|
||||
|
@ -853,13 +859,13 @@ make_shadow_info (const char *serialno, const char *idstring)
|
|||
sprintf (numbuf, "%d:", n);
|
||||
p = stpcpy (p, numbuf);
|
||||
for (s=serialno; *s && s[1]; s += 2)
|
||||
*p++ = xtoi_2 (s);
|
||||
*(unsigned char *)p++ = xtoi_2 (s);
|
||||
sprintf (numbuf, "%d:", strlen (idstring));
|
||||
p = stpcpy (p, numbuf);
|
||||
p = stpcpy (p, idstring);
|
||||
*p++ = ')';
|
||||
*p = 0;
|
||||
return info;
|
||||
return (unsigned char *)info;
|
||||
}
|
||||
|
||||
|
||||
|
@ -878,7 +884,7 @@ agent_shadow_key (const unsigned char *pubkey,
|
|||
const unsigned char *point;
|
||||
size_t n;
|
||||
int depth = 0;
|
||||
unsigned char *p;
|
||||
char *p;
|
||||
size_t pubkey_len = gcry_sexp_canon_len (pubkey, 0, NULL,NULL);
|
||||
size_t shadow_info_len = gcry_sexp_canon_len (shadow_info, 0, NULL,NULL);
|
||||
|
||||
|
@ -930,7 +936,8 @@ agent_shadow_key (const unsigned char *pubkey,
|
|||
/* Calculate required length by taking in account: the "shadowed-"
|
||||
prefix, the "shadowed", "t1-v1" as well as some parenthesis */
|
||||
n = 12 + pubkey_len + 1 + 3+8 + 2+5 + shadow_info_len + 1;
|
||||
*result = p = xtrymalloc (n);
|
||||
*result = xtrymalloc (n);
|
||||
p = (char*)*result;
|
||||
if (!p)
|
||||
return out_of_core ();
|
||||
p = stpcpy (p, "(20:shadowed-private-key");
|
||||
|
|
|
@ -58,7 +58,7 @@ static pth_mutex_t entry_lock;
|
|||
struct entry_parm_s {
|
||||
int lines;
|
||||
size_t size;
|
||||
char *buffer;
|
||||
unsigned char *buffer;
|
||||
};
|
||||
|
||||
|
||||
|
@ -372,7 +372,7 @@ agent_askpin (ctrl_t ctrl,
|
|||
{
|
||||
memset (&parm, 0, sizeof parm);
|
||||
parm.size = pininfo->max_length;
|
||||
parm.buffer = pininfo->pin;
|
||||
parm.buffer = (unsigned char*)pininfo->pin;
|
||||
|
||||
if (errtext)
|
||||
{
|
||||
|
@ -444,7 +444,8 @@ agent_get_passphrase (CTRL ctrl,
|
|||
int rc;
|
||||
char line[ASSUAN_LINELENGTH];
|
||||
struct entry_parm_s parm;
|
||||
unsigned char *p, *hexstring;
|
||||
unsigned char *p;
|
||||
char *hexstring;
|
||||
int i;
|
||||
|
||||
*retpass = NULL;
|
||||
|
@ -497,7 +498,7 @@ agent_get_passphrase (CTRL ctrl,
|
|||
return unlock_pinentry (map_assuan_err (rc));
|
||||
}
|
||||
|
||||
hexstring = gcry_malloc_secure (strlen (parm.buffer)*2+1);
|
||||
hexstring = gcry_malloc_secure (strlen ((char*)parm.buffer)*2+1);
|
||||
if (!hexstring)
|
||||
{
|
||||
gpg_error_t tmperr = out_of_core ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue