mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
agent,ssh: Support "Use-for-ssh" flag in private key.
* agent/findkey.c (public_key_from_file): Support "Use-for-ssh" when it's in extended format. -- GnuPG-bug-id: 5985 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
193fcc2f7a
commit
d86b6c28fc
@ -1384,26 +1384,38 @@ public_key_from_file (ctrl_t ctrl, const unsigned char *grip,
|
|||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (keymeta)
|
if (for_ssh)
|
||||||
{
|
{
|
||||||
|
/* Use-for-ssh: yes */
|
||||||
/* Token: <SERIALNO> <IDSTR> */
|
/* Token: <SERIALNO> <IDSTR> */
|
||||||
const char *p = nvc_get_string (keymeta, "Token:");
|
const char *p;
|
||||||
|
int is_ssh = 0;
|
||||||
|
|
||||||
if (!p)
|
if (keymeta == NULL)
|
||||||
return gpg_error (GPG_ERR_WRONG_KEY_USAGE);
|
return gpg_error (GPG_ERR_WRONG_KEY_USAGE);
|
||||||
|
|
||||||
|
if ((p = nvc_get_string (keymeta, "Use-for-ssh:"))
|
||||||
|
&& !strcmp (p, "yes"))
|
||||||
|
is_ssh = 1;
|
||||||
|
|
||||||
|
if ((p = nvc_get_string (keymeta, "Token:")))
|
||||||
|
{
|
||||||
while (*p && !spacep (p))
|
while (*p && !spacep (p))
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if (!*p)
|
if (*p)
|
||||||
return gpg_error (GPG_ERR_WRONG_KEY_USAGE);
|
{
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
if (strcmp (p, "OPENPGP.3"))
|
if (!strcmp (p, "OPENPGP.3"))
|
||||||
return gpg_error (GPG_ERR_WRONG_KEY_USAGE);
|
is_ssh = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nvc_release (keymeta);
|
nvc_release (keymeta);
|
||||||
keymeta = NULL;
|
keymeta = NULL;
|
||||||
|
|
||||||
|
if (!is_ssh)
|
||||||
|
return gpg_error (GPG_ERR_WRONG_KEY_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i < DIM (array); i++)
|
for (i=0; i < DIM (array); i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user