diff options
author | David Shaw <[email protected]> | 2006-01-17 20:55:53 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2006-01-17 20:55:53 +0000 |
commit | dbe415ea61569fd7b0ad4a2fd56fe948c4bdbdca (patch) | |
tree | b85cc7a86b9f1f6ecea878b137084facdc7d0407 /g10/passphrase.c | |
parent | * libcurl.m4: Add IDN, SSPI, NTLM, and TFTP defines. (diff) | |
download | gnupg-dbe415ea61569fd7b0ad4a2fd56fe948c4bdbdca.tar.gz gnupg-dbe415ea61569fd7b0ad4a2fd56fe948c4bdbdca.zip |
* keydb.h, passphrase.c (next_to_last_passphrase): New. "Touch" a
passphrase as if it was used (move from next_pw to last_pw).
* pubkey-enc.c (get_session_key): Use it here to handle the case where a
passphrase happens to be correct for a secret key, but yet that key isn't
the anonymous recipient (i.e. the secret key could be decrypted, but not
the session key). This also handles the case where a secret key is
located on a card and a secret key with no passphrase. Note this does not
fix bug 594 (anonymous recipients on smartcard do not work) - it just
prevents the anonymous search from stopping when the card is encountered.
Diffstat (limited to '')
-rw-r--r-- | g10/passphrase.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c index d0a19d25d..944c52325 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -55,24 +55,6 @@ #include "assuan.h" #endif /*ENABLE_AGENT_SUPPORT*/ - -#define buftou32( p ) ((*(byte*)(p) << 24) | (*((byte*)(p)+1)<< 16) | \ - (*((byte*)(p)+2) << 8) | (*((byte*)(p)+3))) -#define u32tobuf( p, a ) do { \ - ((byte*)p)[0] = (byte)((a) >> 24); \ - ((byte*)p)[1] = (byte)((a) >> 16); \ - ((byte*)p)[2] = (byte)((a) >> 8); \ - ((byte*)p)[3] = (byte)((a) ); \ - } while(0) - -#define digitp(p) (*(p) >= '0' && *(p) <= '9') -#define hexdigitp(a) (digitp (a) \ - || (*(a) >= 'A' && *(a) <= 'F') \ - || (*(a) >= 'a' && *(a) <= 'f')) -#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ - *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) -#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) - static char *fd_passwd = NULL; static char *next_pw = NULL; static char *last_pw = NULL; @@ -115,6 +97,17 @@ get_last_passphrase() return p; } +/* As if we had used the passphrase - make it the last_pw. */ +void +next_to_last_passphrase(void) +{ + if(next_pw) + { + last_pw=next_pw; + next_pw=NULL; + } +} + /* Here's an interesting question: since this passphrase was passed in on the command line, is there really any point in using secure memory for it? I'm going with 'yes', since it doesn't hurt, and |