mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
common: Add constant KEYGRIP_LEN.
* common/util.h (KEYGRIP_LEN): New. * g10/call-agent.c (agent_probe_any_secret_key): Use that constant. * g10/keyid.c (keygrip_from_pk): Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
6aa4478c78
commit
76c80021d4
@ -59,6 +59,11 @@
|
|||||||
/* Hash function used with libksba. */
|
/* Hash function used with libksba. */
|
||||||
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
|
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
|
||||||
|
|
||||||
|
/* The length of the keygrip. This is a SHA-1 hash of the key
|
||||||
|
* parameters as generated by gcry_pk_get_keygrip. */
|
||||||
|
#define KEYGRIP_LEN 20
|
||||||
|
|
||||||
|
|
||||||
/* Get all the stuff from jnlib. */
|
/* Get all the stuff from jnlib. */
|
||||||
#include "../common/logging.h"
|
#include "../common/logging.h"
|
||||||
#include "../common/argparse.h"
|
#include "../common/argparse.h"
|
||||||
|
@ -1474,7 +1474,7 @@ agent_probe_any_secret_key (ctrl_t ctrl, kbnode_t keyblock)
|
|||||||
char *p;
|
char *p;
|
||||||
kbnode_t kbctx, node;
|
kbnode_t kbctx, node;
|
||||||
int nkeys;
|
int nkeys;
|
||||||
unsigned char grip[20];
|
unsigned char grip[KEYGRIP_LEN];
|
||||||
|
|
||||||
err = start_agent (ctrl, 0);
|
err = start_agent (ctrl, 0);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -959,18 +959,18 @@ gpg_error_t
|
|||||||
hexkeygrip_from_pk (PKT_public_key *pk, char **r_grip)
|
hexkeygrip_from_pk (PKT_public_key *pk, char **r_grip)
|
||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
unsigned char grip[20];
|
unsigned char grip[KEYGRIP_LEN];
|
||||||
|
|
||||||
*r_grip = NULL;
|
*r_grip = NULL;
|
||||||
err = keygrip_from_pk (pk, grip);
|
err = keygrip_from_pk (pk, grip);
|
||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
char * buf = xtrymalloc (20*2+1);
|
char * buf = xtrymalloc (KEYGRIP_LEN * 2 + 1);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bin2hex (grip, 20, buf);
|
bin2hex (grip, KEYGRIP_LEN, buf);
|
||||||
*r_grip = buf;
|
*r_grip = buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user