changeset 7da647dc8429 in /home/hg/repos/gajim
author: Yann Leboulanger asterix@lagaule.org branches: gtk3 details:http://hg.gajim.org/gajim?cmd=changeset;node=7da647dc8429 description: [fedor] fix gpg signature when hash algo is not SHA-1. Fixes #7569
diffstat:
src/common/gpg.py | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-)
diffs (32 lines):
diff -r 905df90efb40 -r 7da647dc8429 src/common/gpg.py --- a/src/common/gpg.py Sat Nov 30 10:04:50 2013 +0100 +++ b/src/common/gpg.py Sat Nov 30 10:10:39 2013 +0100 @@ -80,14 +80,21 @@ def verify(self, str_, sign): if str_ is None: return '' - data = '-----BEGIN PGP SIGNED MESSAGE-----' + os.linesep - data = data + 'Hash: SHA1' + os.linesep + os.linesep - data = data + str_ + os.linesep - data = data + self._addHeaderFooter(sign, 'SIGNATURE') - result = super(GnuPG, self).verify(data) + # Hash algorithm is not transfered in the signed presence stanza so try + # all algorithms. Text name for hash algorithms from RFC 4880 - section 9.4 + hash_algorithms = ['SHA512', 'SHA384', 'SHA256', 'SHA224', 'SHA1', 'RIPEMD160'] + for algo in hash_algorithms: + data = os.linesep.join( + ['-----BEGIN PGP SIGNED MESSAGE-----', + 'Hash: ' + algo, + '', + str_, + self._addHeaderFooter(sign, 'SIGNATURE')] + ) + result = super(GnuPG, self).verify(data) + if result.valid: + return result.key_id
- if result.valid: - return result.key_id return ''
def get_keys(self, secret=False):