diff options
author | Emanoil Kotsev <[email protected]> | 2018-05-05 19:29:46 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2018-05-05 19:29:46 +0200 |
commit | f09192b22acd8e7719f8eb31a2348a40f944df25 (patch) | |
tree | 0a118db21d0ad806b29cd8d9663505b7b39ef7e0 /libkpgp/kpgpbaseG.cpp | |
parent | e0c1fe7ab9a5b12b51201a50610fe871429206dc (diff) | |
download | tdepim-f09192b22acd8e7719f8eb31a2348a40f944df25.tar.gz tdepim-f09192b22acd8e7719f8eb31a2348a40f944df25.zip |
libkpgp: Fix signature key exctraction for GnuPG 2.1
This resolves bug 2883
Signed-off-by: Emanoil Kotsev <[email protected]>
Diffstat (limited to 'libkpgp/kpgpbaseG.cpp')
-rw-r--r-- | libkpgp/kpgpbaseG.cpp | 24 |
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 <[email protected]>" [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 ) { |