summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Schulte <mo@g10code.com>2005-05-05 16:57:59 +0200
committerMoritz Schulte <mo@g10code.com>2005-05-05 16:57:59 +0200
commit2fb1abb84906d37eef459fd70d014c3c5e93294d (patch)
tree6d8d8497039cbac623fbc1157983b81ca451c4d8
parent2005-05-05 Moritz Schulte <moritz@g10code.com> (diff)
downloadgnupg2-2fb1abb84906d37eef459fd70d014c3c5e93294d.tar.xz
gnupg2-2fb1abb84906d37eef459fd70d014c3c5e93294d.zip
2005-05-05 Moritz Schulte <moritz@g10code.com>
* command-ssh.c: Use ssh_key_grip(), where gcry_pk_get_keygrip() has been used before. (ssh_handler_sign_request): Removed unusued variable P.
-rw-r--r--agent/ChangeLog3
-rw-r--r--agent/command-ssh.c60
2 files changed, 32 insertions, 31 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog
index 940294c52..f5dbeb9e3 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -3,6 +3,9 @@
* command-ssh.c (ssh_key_to_buffer): Rename to ...
(ssh_key_to_protected_buffer): ... this; change callers.
Improved documentation.
+ Use ssh_key_grip(), where gcry_pk_get_keygrip() has been used
+ before.
+ (ssh_handler_sign_request): Removed unusued variable P.
2005-04-20 Moritz Schulte <moritz@g10code.com>
diff --git a/agent/command-ssh.c b/agent/command-ssh.c
index 0b6769209..92a84c662 100644
--- a/agent/command-ssh.c
+++ b/agent/command-ssh.c
@@ -1531,6 +1531,26 @@ ssh_read_key_public_from_blob (unsigned char *blob, size_t blob_size,
+/* This function calculates the key grip for the key contained in the
+ 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)
+{
+ gpg_error_t err;
+ char *p;
+
+ /* 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;
+}
+
/* Converts the secret key KEY_SECRET into a public key, storing it in
KEY_PUBLIC. SPEC is the according key specification. Returns zero
on success or an error code. */
@@ -1643,14 +1663,16 @@ card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn)
xfree (serialno);
return err;
}
-
- if ( !gcry_pk_get_keygrip (s_pk, grip) )
+
+ err = ssh_key_grip (s_pk, grip);
+ if (err)
{
- log_debug ("error computing keygrip from received card key\n");
+ log_debug ("error computing keygrip from received card key: %s\n",
+ gcry_strerror (err));
xfree (pkbuf);
gcry_sexp_release (s_pk);
xfree (serialno);
- return gpg_error (GPG_ERR_INTERNAL);
+ return err;
}
if ( agent_key_available (grip) )
@@ -1941,26 +1963,6 @@ ssh_handler_request_identities (ctrl_t ctrl,
return ret_err;
}
-/* This function calculates the key grip for the key contained in the
- 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)
-{
- gpg_error_t err;
- char *p;
-
- /* 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;
-}
-
/* This function hashes the data contained in DATA of size DATA_N
according to the message digest algorithm specified by MD_ALGORITHM
and writes the message digest to HASH, which needs to large enough
@@ -2151,7 +2153,6 @@ ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response)
size_t sig_n;
u32 data_size;
u32 flags;
- void *p;
gpg_error_t err;
gpg_error_t ret_err;
@@ -2192,12 +2193,9 @@ ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response)
goto out;
/* Calculate key grip. */
- p = gcry_pk_get_keygrip (key, key_grip);
- if (! p)
- {
- err = gpg_error (GPG_ERR_INTERNAL); /* FIXME? */
- goto out;
- }
+ err = ssh_key_grip (key, key_grip);
+ if (err)
+ goto out;
/* Sign data. */