1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

agent: Fix for suggested Libgcrypt use.

* agent/divert-scd.c (divert_pkdecrypt): Skip a flags parameter.
--

The libgcrypt docs say that a "flags" parameter should always be used
in the input of pkdecrypt.  Thus we should allow that parameter also
when parsing an s-expression to figure out the algorithm for use with
scdaemon.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-02-22 14:09:02 +01:00
parent e140c6d4f5
commit a12c3a566e
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -498,6 +498,7 @@ divert_pkdecrypt (ctrl_t ctrl, const char *desc_text,
char *kid; char *kid;
const unsigned char *s; const unsigned char *s;
size_t n; size_t n;
int depth;
const unsigned char *ciphertext; const unsigned char *ciphertext;
size_t ciphertextlen; size_t ciphertextlen;
char *plaintext; char *plaintext;
@ -506,7 +507,6 @@ divert_pkdecrypt (ctrl_t ctrl, const char *desc_text,
(void)desc_text; (void)desc_text;
*r_padding = -1; *r_padding = -1;
s = cipher; s = cipher;
if (*s != '(') if (*s != '(')
return gpg_error (GPG_ERR_INV_SEXP); return gpg_error (GPG_ERR_INV_SEXP);
@ -522,6 +522,21 @@ divert_pkdecrypt (ctrl_t ctrl, const char *desc_text,
n = snext (&s); n = snext (&s);
if (!n) if (!n)
return gpg_error (GPG_ERR_INV_SEXP); return gpg_error (GPG_ERR_INV_SEXP);
/* First check whether we have a flags parameter and skip it. */
if (smatch (&s, n, "flags"))
{
depth = 1;
if (sskip (&s, &depth) || depth)
return gpg_error (GPG_ERR_INV_SEXP);
if (*s != '(')
return gpg_error (GPG_ERR_INV_SEXP);
s++;
n = snext (&s);
if (!n)
return gpg_error (GPG_ERR_INV_SEXP);
}
if (smatch (&s, n, "rsa")) if (smatch (&s, n, "rsa"))
{ {
if (*s != '(') if (*s != '(')