diff options
author | Werner Koch <wk@gnupg.org> | 2013-07-26 19:22:36 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2013-07-26 19:22:36 +0200 |
commit | b72d312ad11887fc416aa821786f6bdb663c0f4a (patch) | |
tree | 0f4707d16bef3ed4fb91864d689c8288d0c65198 /cipher/pubkey.c | |
parent | 287bf0e543f244d784cf8b58340bf0ab3c6aba97 (diff) | |
download | libgcrypt-b72d312ad11887fc416aa821786f6bdb663c0f4a.tar.gz |
Allow the use of a private-key s-expression with gcry_pk_verify.
* cipher/pubkey.c (sexp_to_key): Fallback to private key.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'cipher/pubkey.c')
-rw-r--r-- | cipher/pubkey.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cipher/pubkey.c b/cipher/pubkey.c index 606cedf8..b540bd5a 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -2022,9 +2022,14 @@ sexp_to_key (gcry_sexp_t sexp, int want_private, int use, pk_extra_spec_t *extraspec; int is_ecc; - /* Check that the first element is valid. */ + /* Check that the first element is valid. If we are looking for a + public key but a private key was supplied, we allow the use of + the private key anyway. The rationale for this is that the + private key is a superset of the public key. */ list = gcry_sexp_find_token (sexp, want_private? "private-key":"public-key", 0); + if (!list && !want_private) + list = gcry_sexp_find_token (sexp, "private-key", 0); if (!list) return GPG_ERR_INV_OBJ; /* Does not contain a key object. */ |