summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Waldmann <tw@waldmann-edv.de>2017-07-26 04:34:02 +0200
committerThomas Waldmann <tw@waldmann-edv.de>2017-07-27 23:48:30 +0200
commitdc4abffbc04e82aa982677ed2ad949f8ccdbe072 (patch)
treef02389b47425febfdfe49910e7bfd2caf7a03485
parent63ebfc140b2831ea5bfaa2d34301f29e6115510b (diff)
remove unused bytes16 conversions
-rw-r--r--src/borg/crypto/low_level.pyx13
-rw-r--r--src/borg/selftest.py2
-rw-r--r--src/borg/testsuite/crypto.py8
3 files changed, 2 insertions, 21 deletions
diff --git a/src/borg/crypto/low_level.pyx b/src/borg/crypto/low_level.pyx
index 6db977800..da06c73e2 100644
--- a/src/borg/crypto/low_level.pyx
+++ b/src/borg/crypto/low_level.pyx
@@ -134,25 +134,12 @@ import struct
_int = struct.Struct('>I')
_long = struct.Struct('>Q')
-_2long = struct.Struct('>QQ')
bytes_to_int = lambda x, offset=0: _int.unpack_from(x, offset)[0]
bytes_to_long = lambda x, offset=0: _long.unpack_from(x, offset)[0]
long_to_bytes = lambda x: _long.pack(x)
-def bytes16_to_int(b, offset=0):
- h, l = _2long.unpack_from(b, offset)
- return (h << 64) + l
-
-
-def int_to_bytes16(i):
- max_uint64 = 0xffffffffffffffff
- l = i & max_uint64
- h = (i >> 64) & max_uint64
- return _2long.pack(h, l)
-
-
def num_cipher_blocks(length, blocksize=16):
"""Return the number of cipher blocks required to encrypt/decrypt <length> bytes of data.
diff --git a/src/borg/selftest.py b/src/borg/selftest.py
index 619edb8fe..e8605f7cb 100644
--- a/src/borg/selftest.py
+++ b/src/borg/selftest.py
@@ -30,7 +30,7 @@ SELFTEST_CASES = [
ChunkerTestCase,
]
-SELFTEST_COUNT = 38
+SELFTEST_COUNT = 37
class SelfTestResult(TestResult):
diff --git a/src/borg/testsuite/crypto.py b/src/borg/testsuite/crypto.py
index a60ab2fb3..a4e822c5d 100644
--- a/src/borg/testsuite/crypto.py
+++ b/src/borg/testsuite/crypto.py
@@ -2,7 +2,7 @@ from binascii import hexlify, unhexlify
from ..crypto.low_level import AES256_CTR_HMAC_SHA256, AES256_GCM, AES256_OCB, CHACHA20_POLY1305, UNENCRYPTED, \
IntegrityError, blake2b_256, hmac_sha256, openssl10
-from ..crypto.low_level import bytes_to_long, bytes_to_int, long_to_bytes, bytes16_to_int, int_to_bytes16
+from ..crypto.low_level import bytes_to_long, bytes_to_int, long_to_bytes
from ..crypto.low_level import hkdf_hmac_sha512
from . import BaseTestCase
@@ -20,12 +20,6 @@ class CryptoTestCase(BaseTestCase):
self.assert_equal(bytes_to_long(b'\0\0\0\0\0\0\0\1'), 1)
self.assert_equal(long_to_bytes(1), b'\0\0\0\0\0\0\0\1')
- def test_bytes16_to_int(self):
- self.assert_equal(bytes16_to_int(b'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1'), 1)
- self.assert_equal(int_to_bytes16(1), b'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1')
- self.assert_equal(bytes16_to_int(b'\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0'), 2 ** 64)
- self.assert_equal(int_to_bytes16(2 ** 64), b'\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\0')
-
def test_UNENCRYPTED(self):
iv = b'' # any IV is ok, it just must be set and not None
data = b'data'