SF.net SVN: mahogany:[7552] trunk/M/src/modules/crypt/PGPEngine.cpp
[email protected] Thu, 06 Nov 2008 16:34:55 +0000
| Newsgroups | gmane.mail.mahogany.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 7552
http://mahogany.svn.sourceforge.net/mahogany/?rev=7552&view=rev
Author: vadz
Date: 2008-11-06 16:34:55 +0000 (Thu, 06 Nov 2008)
Log Message:
-----------
don't give spurious errors for messages encrypted with more than one key, it's enough to have private key for one of them in this case, not all of them
Modified Paths:
--------------
trunk/M/src/modules/crypt/PGPEngine.cpp
Modified: trunk/M/src/modules/crypt/PGPEngine.cpp
===================================================================
--- trunk/M/src/modules/crypt/PGPEngine.cpp 2008-11-06 13:48:09 UTC (rev 7551)
+++ trunk/M/src/modules/crypt/PGPEngine.cpp 2008-11-06 16:34:55 UTC (rev 7552)
@@ -308,6 +308,12 @@
String user,
pass;
+ // the arrays of keys for which this message is encrypted and the number of
+ // them for which we do _not_ have the private key -- if this number is
+ // equal to the number of array elements it means that we have none of them
+ wxArrayString keysEnc;
+ size_t keysNoPrivate = 0;
+
messageOut.clear();
char bufOut[4096];
@@ -370,6 +376,31 @@
if ( log )
log->AddMessage(line);
+ /*
+ Some typical message sequences:
+
+ + For signed messages:
+ - SIG_ID
+ - GOODSIG
+ - VALIDSIG
+ - TRUST_UNDEFINED
+
+ + For encrypted messages:
+ - ENC_TO
+ - USERID_HINT
+ - NEED_PASSPHRASE (only if the key needs it, of course, this
+ will be the last message if the user doesn't enter a valid
+ pass phrase)
+ - GET_HIDDEN
+ - GOT_IT
+ - GOOD_PASSPHRASE
+ - BEGIN_DECRYPTION
+ - PLAINTEXT
+ - DECRYPTION_OKAY
+ - GOODMDC
+ - END_DECRYPTION
+
+ */
if ( line.StartsWith(_T("[GNUPG:] "), &line) )
{
String code;
@@ -540,8 +571,12 @@
}
else if ( code == _T("NO_SECKEY") )
{
- wxLogWarning(_("Secret key needed to decrypt this message is "
- "not available"));
+ // it's ok if we have no private key for some of the keys used
+ // to encrypt this message, we need to have only one private key
+ // to be able to decrypt it, so just remember the keys which we
+ // may use to decrypt this message for now and only log an error
+ // if we don't have any of them when decryption starts
+ keysNoPrivate++;
}
else if ( code == _T("SIG_CREATED") )
{
@@ -642,9 +677,26 @@
// GPG, check that we did send everything
ASSERT_MSG( !lenIn, "should have sent everything by now" );
}
- else if ( code == _T("ENC_TO") ||
- code == _T("BEGIN_DECRYPTION") ||
- code == _T("END_DECRYPTION") ||
+ else if ( code == _T("ENC_TO") )
+ {
+ keysEnc.push_back(pc);
+ }
+ else if ( code == _T("BEGIN_DECRYPTION") )
+ {
+ if ( !keysEnc.empty() &&
+ keysNoPrivate == keysEnc.size() )
+ {
+ wxString keys = keysEnc.front();
+ for ( size_t n = 1; n < keysNoPrivate - 1; n++ )
+ keys << _(" or ") << keysEnc[n];
+ if ( keysNoPrivate > 1 )
+ keys += keysEnc[keysNoPrivate - 1];
+
+ wxLogWarning(_("No secret key which can decrypt this message "
+ "(%s) is available."), keys.c_str());
+ }
+ }
+ else if ( code == _T("END_DECRYPTION") ||
code == _T("GOODMDC") || // what does it mean?
code == _T("GOT_IT") ||
code == _T("SIGEXPIRED") || // we will give a warning
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/