mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 01:37:20 +00:00
remove unused bytes16 conversions
This commit is contained in:
parent
63ebfc140b
commit
dc4abffbc0
3 changed files with 2 additions and 21 deletions
|
@ -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.
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
ChunkerTestCase,
|
||||
]
|
||||
|
||||
SELFTEST_COUNT = 38
|
||||
SELFTEST_COUNT = 37
|
||||
|
||||
|
||||
class SelfTestResult(TestResult):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
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 @@ def test_bytes_to_long(self):
|
|||
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'
|
||||
|
|
Loading…
Reference in a new issue