Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/borg/crypto/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from ..repoobj import RepoObj


from .nonces import NonceManager
from .low_level import AES, bytes_to_int, num_cipher_blocks, hmac_sha256, blake2b_256, hkdf_hmac_sha512
from .low_level import AES256_CTR_HMAC_SHA256, AES256_CTR_BLAKE2b, AES256_OCB, CHACHA20_POLY1305
from . import low_level
Expand Down Expand Up @@ -372,7 +371,8 @@ class AESKeyBase(KeyBase):
logically_encrypted = True

def encrypt(self, id, data):
next_iv = self.nonce_manager.ensure_reservation(self.cipher.next_iv(), self.cipher.block_count(len(data)))
# legacy, this is only used by the tests.
next_iv = self.cipher.next_iv()
return self.cipher.encrypt(data, header=self.TYPE_STR, iv=next_iv)

def decrypt(self, id, data):
Expand Down Expand Up @@ -411,7 +411,6 @@ def init_ciphers(self, manifest_data=None):
manifest_blocks = num_cipher_blocks(len(manifest_data))
nonce = self.cipher.extract_iv(manifest_data) + manifest_blocks
self.cipher.set_iv(nonce)
self.nonce_manager = NonceManager(self.repository, nonce)


class FlexiKey:
Expand Down
91 changes: 0 additions & 91 deletions src/borg/crypto/nonces.py

This file was deleted.

12 changes: 0 additions & 12 deletions src/borg/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ def __init__(self, data):
"negotiate": ("client_data",),
"open": ("path", "create", "lock_wait", "lock", "exclusive", "append_only"),
"info": (),
"get_free_nonce": (),
"commit_nonce_reservation": ("next_unreserved", "start_nonce"),
}


Expand All @@ -159,8 +157,6 @@ class RepositoryServer: # pragma: no cover
"save_key",
"load_key",
"break_lock",
"get_free_nonce",
"commit_nonce_reservation",
"inject_exception",
)

Expand Down Expand Up @@ -1024,14 +1020,6 @@ def save_key(self, keydata):
def load_key(self):
"""actual remoting is done via self.call in the @api decorator"""

@api(since=parse_version("1.0.0"))
def get_free_nonce(self):
"""actual remoting is done via self.call in the @api decorator"""

@api(since=parse_version("1.0.0"))
def commit_nonce_reservation(self, next_unreserved, start_nonce):
"""actual remoting is done via self.call in the @api decorator"""

@api(since=parse_version("1.0.0"))
def break_lock(self):
"""actual remoting is done via self.call in the @api decorator"""
Expand Down
30 changes: 0 additions & 30 deletions src/borg/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,36 +369,6 @@ def load_key(self):
# note: if we return an empty string, it means there is no repo key
return keydata.encode("utf-8") # remote repo: msgpack issue #99, returning bytes

def get_free_nonce(self):
if self.do_lock and not self.lock.got_exclusive_lock():
raise AssertionError("bug in code, exclusive lock should exist here")

nonce_path = os.path.join(self.path, "nonce")
try:
with open(nonce_path) as fd:
return int.from_bytes(unhexlify(fd.read()), byteorder="big")
except FileNotFoundError:
return None

def commit_nonce_reservation(self, next_unreserved, start_nonce):
if self.do_lock and not self.lock.got_exclusive_lock():
raise AssertionError("bug in code, exclusive lock should exist here")

if self.get_free_nonce() != start_nonce:
raise Exception("nonce space reservation with mismatched previous state")
nonce_path = os.path.join(self.path, "nonce")
try:
with SaveFile(nonce_path, binary=False) as fd:
fd.write(bin_to_hex(next_unreserved.to_bytes(8, byteorder="big")))
except PermissionError as e:
# error is only a problem if we even had a lock
if self.do_lock:
raise
logger.warning(
"%s: Failed writing to '%s'. This is expected when working on "
"read-only repositories." % (e.strerror, e.filename)
)

def destroy(self):
"""Destroy the repository at `self.path`"""
if self.append_only:
Expand Down
6 changes: 0 additions & 6 deletions src/borg/testsuite/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ def canonical_path(self):
id = bytes(32)
id_str = bin_to_hex(id)

def get_free_nonce(self):
return None

def commit_nonce_reservation(self, next_unreserved, start_nonce):
pass

def save_key(self, data):
self.key_data = data

Expand Down
197 changes: 0 additions & 197 deletions src/borg/testsuite/nonces.py

This file was deleted.

Loading