diff options
author | Werner Koch <[email protected]> | 2013-02-06 11:42:07 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2013-02-06 11:56:19 +0000 |
commit | 4483a4f0ea030046137ba04905eb5220c14a2161 (patch) | |
tree | f092bc7079c528632f993c2072fe36197876e08e | |
parent | scd: Fix check_keypad_request. (diff) | |
download | gnupg-4483a4f0ea030046137ba04905eb5220c14a2161.tar.gz gnupg-4483a4f0ea030046137ba04905eb5220c14a2161.zip |
agent: Return a better error code if no passphrase was given.
* agent/protect.c (hash_passphrase): Handle an empty passphrase.
--
This is mostly useful in loopback pinentry-mode.
-rw-r--r-- | agent/protect.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/agent/protect.c b/agent/protect.c index d26573d11..3e2cbb94e 100644 --- a/agent/protect.c +++ b/agent/protect.c @@ -1075,7 +1075,11 @@ hash_passphrase (const char *passphrase, int hashalgo, unsigned long s2kcount, unsigned char *key, size_t keylen) { - + /* The key derive function does not support a zero length string for + the passphrase in the S2K modes. Return a better suited error + code than GPG_ERR_INV_DATA. */ + if (!passphrase || !*passphrase) + return gpg_error (GPG_ERR_NO_PASSPHRASE); return gcry_kdf_derive (passphrase, strlen (passphrase), s2kmode == 3? GCRY_KDF_ITERSALTED_S2K : s2kmode == 1? GCRY_KDF_SALTED_S2K : |