From 9c2ce310f3b80ff0728800e484dbff84ce17276c Mon Sep 17 00:00:00 2001 From: Artem Polishchuk Date: Jun 06 2023 12:06:35 +0000 Subject: chore: Update to 4.0.5 (close RHBZ#2212566) --- diff --git a/.gitignore b/.gitignore index 0d6e512..a3d87a4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /pykeepass-4.0.2.tar.gz /pykeepass-4.0.3.tar.gz /pykeepass-4.0.4.tar.gz +/pykeepass-4.0.5.tar.gz diff --git a/336.patch b/336.patch deleted file mode 100644 index 578ef10..0000000 --- a/336.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 0983dabb43f3b1a1d83f21e1192e6d01f0764c6e Mon Sep 17 00:00:00 2001 -From: "Benjamin A. Beasley" -Date: Sun, 5 Mar 2023 09:35:32 -0500 -Subject: [PATCH] Remove excessive byte-swapping in pytwofish.py - -Since the explicitly little-endian struct format strings are already -handling byte-swapping, remove the WORD_BIGENDIAN flag and all of the -excessive byte-swapping it enables. - -Fixes #332. ---- - pykeepass/kdbx_parsing/pytwofish.py | 77 ++++++++--------------------- - 1 file changed, 20 insertions(+), 57 deletions(-) - -diff --git a/pykeepass/kdbx_parsing/pytwofish.py b/pykeepass/kdbx_parsing/pytwofish.py -index 7cea4191..44671867 100644 ---- a/pykeepass/kdbx_parsing/pytwofish.py -+++ b/pykeepass/kdbx_parsing/pytwofish.py -@@ -137,11 +137,6 @@ def get_key_size(self): - # - - import struct --import sys -- --WORD_BIGENDIAN = 0 --if sys.byteorder == 'big': -- WORD_BIGENDIAN = 1 - - def rotr32(x, n): - return (x >> n) | ((x << (32 - n)) & 0xFFFFFFFF) -@@ -149,10 +144,6 @@ def rotr32(x, n): - def rotl32(x, n): - return ((x << n) & 0xFFFFFFFF) | (x >> (32 - n)) - --def byteswap32(x): -- return ((x & 0xff) << 24) | (((x >> 8) & 0xff) << 16) | \ -- (((x >> 16) & 0xff) << 8) | ((x >> 24) & 0xff) -- - class TWI: - def __init__(self): - self.k_len = 0 # word32 -@@ -292,14 +283,9 @@ def set_key(pkey, in_key, key_len): - me_key = [0,0,0,0] - mo_key = [0,0,0,0] - for i in range(pkey.k_len): -- if WORD_BIGENDIAN: -- a = byteswap32(in_key[i + 1]) -- me_key[i] = a -- b = byteswap32(in_key[i + i + 1]) -- else: -- a = in_key[i + i] -- me_key[i] = a -- b = in_key[i + i + 1] -+ a = in_key[i + i] -+ me_key[i] = a -+ b = in_key[i + i + 1] - mo_key[i] = b - pkey.s_key[pkey.k_len - i - 1] = mds_rem(a, b); - for i in range(0, 40, 2): -@@ -314,16 +300,10 @@ def set_key(pkey, in_key, key_len): - def encrypt(pkey, in_blk): - blk = [0, 0, 0, 0] - -- if WORD_BIGENDIAN: -- blk[0] = byteswap32(in_blk[0]) ^ pkey.l_key[0]; -- blk[1] = byteswap32(in_blk[1]) ^ pkey.l_key[1]; -- blk[2] = byteswap32(in_blk[2]) ^ pkey.l_key[2]; -- blk[3] = byteswap32(in_blk[3]) ^ pkey.l_key[3]; -- else: -- blk[0] = in_blk[0] ^ pkey.l_key[0]; -- blk[1] = in_blk[1] ^ pkey.l_key[1]; -- blk[2] = in_blk[2] ^ pkey.l_key[2]; -- blk[3] = in_blk[3] ^ pkey.l_key[3]; -+ blk[0] = in_blk[0] ^ pkey.l_key[0]; -+ blk[1] = in_blk[1] ^ pkey.l_key[1]; -+ blk[2] = in_blk[2] ^ pkey.l_key[2]; -+ blk[3] = in_blk[3] ^ pkey.l_key[3]; - - for i in range(8): - t1 = ( pkey.mk_tab[0][byte(blk[1],3)] ^ pkey.mk_tab[1][byte(blk[1],0)] ^ pkey.mk_tab[2][byte(blk[1],1)] ^ pkey.mk_tab[3][byte(blk[1],2)] ); -@@ -338,32 +318,20 @@ def encrypt(pkey, in_blk): - blk[0] = rotr32(blk[0] ^ ((t0 + t1 + pkey.l_key[4 * (i) + 10]) % 0x100000000), 1); - blk[1] = rotl32(blk[1], 1) ^ ((t0 + 2 * t1 + pkey.l_key[4 * (i) + 11]) % 0x100000000); - -- if WORD_BIGENDIAN: -- in_blk[0] = byteswap32(blk[2] ^ pkey.l_key[4]); -- in_blk[1] = byteswap32(blk[3] ^ pkey.l_key[5]); -- in_blk[2] = byteswap32(blk[0] ^ pkey.l_key[6]); -- in_blk[3] = byteswap32(blk[1] ^ pkey.l_key[7]); -- else: -- in_blk[0] = blk[2] ^ pkey.l_key[4]; -- in_blk[1] = blk[3] ^ pkey.l_key[5]; -- in_blk[2] = blk[0] ^ pkey.l_key[6]; -- in_blk[3] = blk[1] ^ pkey.l_key[7]; -+ in_blk[0] = blk[2] ^ pkey.l_key[4]; -+ in_blk[1] = blk[3] ^ pkey.l_key[5]; -+ in_blk[2] = blk[0] ^ pkey.l_key[6]; -+ in_blk[3] = blk[1] ^ pkey.l_key[7]; - - return - - def decrypt(pkey, in_blk): - blk = [0, 0, 0, 0] - -- if WORD_BIGENDIAN: -- blk[0] = byteswap32(in_blk[0]) ^ pkey.l_key[4]; -- blk[1] = byteswap32(in_blk[1]) ^ pkey.l_key[5]; -- blk[2] = byteswap32(in_blk[2]) ^ pkey.l_key[6]; -- blk[3] = byteswap32(in_blk[3]) ^ pkey.l_key[7]; -- else: -- blk[0] = in_blk[0] ^ pkey.l_key[4]; -- blk[1] = in_blk[1] ^ pkey.l_key[5]; -- blk[2] = in_blk[2] ^ pkey.l_key[6]; -- blk[3] = in_blk[3] ^ pkey.l_key[7]; -+ blk[0] = in_blk[0] ^ pkey.l_key[4]; -+ blk[1] = in_blk[1] ^ pkey.l_key[5]; -+ blk[2] = in_blk[2] ^ pkey.l_key[6]; -+ blk[3] = in_blk[3] ^ pkey.l_key[7]; - - for i in range(7, -1, -1): - t1 = ( pkey.mk_tab[0][byte(blk[1],3)] ^ pkey.mk_tab[1][byte(blk[1],0)] ^ pkey.mk_tab[2][byte(blk[1],1)] ^ pkey.mk_tab[3][byte(blk[1],2)] ) -@@ -378,16 +346,11 @@ def decrypt(pkey, in_blk): - blk[0] = rotl32(blk[0], 1) ^ ((t0 + t1 + pkey.l_key[4 * (i) + 8]) % 0x100000000) - blk[1] = rotr32(blk[1] ^ ((t0 + 2 * t1 + pkey.l_key[4 * (i) + 9]) % 0x100000000), 1) - -- if WORD_BIGENDIAN: -- in_blk[0] = byteswap32(blk[2] ^ pkey.l_key[0]); -- in_blk[1] = byteswap32(blk[3] ^ pkey.l_key[1]); -- in_blk[2] = byteswap32(blk[0] ^ pkey.l_key[2]); -- in_blk[3] = byteswap32(blk[1] ^ pkey.l_key[3]); -- else: -- in_blk[0] = blk[2] ^ pkey.l_key[0]; -- in_blk[1] = blk[3] ^ pkey.l_key[1]; -- in_blk[2] = blk[0] ^ pkey.l_key[2]; -- in_blk[3] = blk[1] ^ pkey.l_key[3]; -+ in_blk[0] = blk[2] ^ pkey.l_key[0]; -+ in_blk[1] = blk[3] ^ pkey.l_key[1]; -+ in_blk[2] = blk[0] ^ pkey.l_key[2]; -+ in_blk[3] = blk[1] ^ pkey.l_key[3]; -+ - return - - __testkey = b'\xD4\x3B\xB7\x55\x6E\xA3\x2E\x46\xF2\xA2\x82\xB7\xD4\x5B\x4E\x0D\x57\xFF\x73\x9D\x4D\xC9\x2C\x1B\xD7\xFC\x01\x70\x0C\xC8\x21\x6F' diff --git a/python-pykeepass.spec b/python-pykeepass.spec index 470df49..898e0bd 100644 --- a/python-pykeepass.spec +++ b/python-pykeepass.spec @@ -1,5 +1,5 @@ Name: python-pykeepass -Version: 4.0.4 +Version: 4.0.5 Release: %autorelease Epoch: 1 Summary: Python library to interact with keepass databases @@ -13,15 +13,6 @@ URL: https://github.com/libkeepass/pykeepass # The GitHub archive has tests; the PyPI sdist does not. Source: %{url}/archive/v%{version}/pykeepass-%{version}.tar.gz -# Remove excessive byte-swapping in pytwofish.py -# https://github.com/libkeepass/pykeepass/pull/336 -# -# Fixes: -# -# Tests fail on big-endian platform (s390x) -# https://github.com/libkeepass/pykeepass/issues/332 -Patch: %{url}/pull/336.patch - BuildArch: noarch BuildRequires: python3-devel diff --git a/sources b/sources index cba963e..f1ba190 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (pykeepass-4.0.4.tar.gz) = 49b806133ce92177225c49d82b4e3e3c994f6f4184049a2e1ed7d5afd52f46ce631f7da27289cb59bdc3fe2a89a03c9a3027fb8e8052e98772b16197e88b300c +SHA512 (pykeepass-4.0.5.tar.gz) = d3c079c631fd91a06e376c29a771f2c28a776206ef01c89043b9d5fe2b8cbe071da32a6ae2cb68f8beede4110717cfef63ecc49313ca023c2d79a235b0e0b273