summaryrefslogtreecommitdiff
path: root/cipher/pubkey.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-07-26 19:22:36 +0200
committerWerner Koch <wk@gnupg.org>2013-07-26 19:22:36 +0200
commitb72d312ad11887fc416aa821786f6bdb663c0f4a (patch)
tree0f4707d16bef3ed4fb91864d689c8288d0c65198 /cipher/pubkey.c
parent287bf0e543f244d784cf8b58340bf0ab3c6aba97 (diff)
downloadlibgcrypt-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.c7
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. */