summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmanoil Kotsev <deloptes@gmail.com>2018-05-05 19:29:46 +0200
committerSlávek Banko <slavek.banko@axis.cz>2018-05-05 19:29:57 +0200
commit724a547c5610c19a412a7c5a30ea64e527fdb246 (patch)
tree11d6eaa0b2919ece68ea1c168b8cbeb9a8d7f53f
parent2478a9b568acc260bebfbd03d25f9c339c5a3e40 (diff)
downloadtdepim-724a547c5610c19a412a7c5a30ea64e527fdb246.tar.gz
tdepim-724a547c5610c19a412a7c5a30ea64e527fdb246.zip
libkpgp: Fix signature key exctraction for GnuPG 2.1
This resolves bug 2883 Signed-off-by: Emanoil Kotsev <deloptes@gmail.com> (cherry picked from commit f09192b22acd8e7719f8eb31a2348a40f944df25)
-rw-r--r--libkpgp/kpgpbaseG.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/libkpgp/kpgpbaseG.cpp b/libkpgp/kpgpbaseG.cpp
index 7e96b4e93..cd6eaf41c 100644
--- a/libkpgp/kpgpbaseG.cpp
+++ b/libkpgp/kpgpbaseG.cpp
@@ -313,8 +313,24 @@ BaseG::decrypt( Block& block, const char *passphrase )
index2 = error.find("using", index+15);
block.setSignatureDate( error.mid(index+15, index2-(index+15)-1) );
kdDebug(5100) << "Message was signed on '" << block.signatureDate() << "'\n";
- index2 = error.find("key ID ", index2) + 7;
- block.setSignatureKeyId( error.mid(index2,8) );
+ // To handle gnupg > 2.1
+ // gpg: Signature made Thu 05 Apr 2018 10:02:50 PM CEST
+ // gpg: using DSA key A0CF1DC09533E5E87F54DB40F1EEB8CD9FB16A50
+ // gpg: Good signature from "deloptes <deloptes@gmail.com>" [ultimate]
+ // so we need extra check
+ if (error.contains("key ID") > 0) {
+ index2 = error.find("key ID ", index2) + 7;
+ block.setSignatureKeyId( error.mid(index2,8) );
+ }
+ else {
+ index2 = error.find("key ", index2) + 4;
+ // handle variable key size
+ // gpg: Signature made Mon 02 Apr 2018 03:15:08 PM CEST
+ // gpg: using DSA key 05C82CF57AD1DA46
+ // gpg: Can't check signature: No public key
+ int end = error.find("\n", index2);
+ block.setSignatureKeyId( error.mid(index2,end-index2) );
+ }
kdDebug(5100) << "Message was signed with key '" << block.signatureKeyId() << "'\n";
// move index to start of next line
index = error.find('\n', index2)+1;
@@ -333,7 +349,7 @@ BaseG::decrypt( Block& block, const char *passphrase )
index = error.find('"',index);
index2 = error.find('\n',index+1);
index2 = error.findRev('"', index2-1);
- block.setSignatureUserId( error.mid( index+1, index2-index-1 ) );
+ block.setSignatureUserId( TQString::fromLocal8Bit( error.mid( index+1, index2-index-1 ) ) );
}
else if( error.find("BAD signature", index) != -1 )
{
@@ -343,7 +359,7 @@ BaseG::decrypt( Block& block, const char *passphrase )
index = error.find('"',index);
index2 = error.find('\n',index+1);
index2 = error.findRev('"', index2-1);
- block.setSignatureUserId( error.mid( index+1, index2-index-1 ) );
+ block.setSignatureUserId( TQString::fromLocal8Bit( error.mid( index+1, index2-index-1 ) ) );
}
else if( error.find("Can't find the right public key", index) != -1 )
{