From 008825b0fdd8543bc66f334a6b4ee3b36d2a8d86 Mon Sep 17 00:00:00 2001 From: heartsucker Date: Thu, 16 May 2019 14:32:39 +0200 Subject: [PATCH] replaced referecnes to pycryptopp AES with own wrapper --- src/allmydata/dirnode.py | 2 +- src/allmydata/immutable/filenode.py | 2 +- src/allmydata/immutable/upload.py | 6 +++--- src/allmydata/mutable/filenode.py | 5 ++--- src/allmydata/mutable/publish.py | 4 ++-- src/allmydata/mutable/retrieve.py | 5 +++-- src/allmydata/test/test_helper.py | 2 +- src/allmydata/util/fileutil.py | 3 +-- 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/allmydata/dirnode.py b/src/allmydata/dirnode.py index 0811abc99..a0620016d 100644 --- a/src/allmydata/dirnode.py +++ b/src/allmydata/dirnode.py @@ -6,6 +6,7 @@ from twisted.internet import defer from foolscap.api import fireEventually import json +from allmydata.crypto.aes import AES from allmydata.deep_stats import DeepStats from allmydata.mutable.common import NotWriteableError from allmydata.mutable.filenode import MutableFileNode @@ -22,7 +23,6 @@ from allmydata.util.assertutil import precondition from allmydata.util.netstring import netstring, split_netstring from allmydata.util.consumer import download_to_data from allmydata.uri import wrap_dirnode_cap -from pycryptopp.cipher.aes import AES from allmydata.util.dictutil import AuxValueDict from eliot import ( diff --git a/src/allmydata/immutable/filenode.py b/src/allmydata/immutable/filenode.py index e8e4851bb..28e027cb5 100644 --- a/src/allmydata/immutable/filenode.py +++ b/src/allmydata/immutable/filenode.py @@ -7,12 +7,12 @@ from twisted.internet import defer from allmydata import uri from twisted.internet.interfaces import IConsumer +from allmydata.crypto.aes import AES from allmydata.interfaces import IImmutableFileNode, IUploadResults from allmydata.util import consumer from allmydata.check_results import CheckResults, CheckAndRepairResults from allmydata.util.dictutil import DictOfSets from allmydata.util.happinessutil import servers_of_happiness -from pycryptopp.cipher.aes import AES # local imports from allmydata.immutable.checker import Checker diff --git a/src/allmydata/immutable/upload.py b/src/allmydata/immutable/upload.py index 7a683f317..53dd0389b 100644 --- a/src/allmydata/immutable/upload.py +++ b/src/allmydata/immutable/upload.py @@ -5,6 +5,7 @@ from twisted.internet import defer from twisted.application import service from foolscap.api import Referenceable, Copyable, RemoteCopy, fireEventually +from allmydata.crypto.aes import AES from allmydata.util.hashutil import file_renewal_secret_hash, \ file_cancel_secret_hash, bucket_renewal_secret_hash, \ bucket_cancel_secret_hash, plaintext_hasher, \ @@ -23,7 +24,6 @@ from allmydata.interfaces import IUploadable, IUploader, IUploadResults, \ NoServersError, InsufficientVersionError, UploadUnhappinessError, \ DEFAULT_MAX_SEGMENT_SIZE, IProgress, IPeerSelector from allmydata.immutable import layout -from pycryptopp.cipher.aes import AES from six.moves import cStringIO as StringIO from happiness_upload import share_placement, calculate_happiness @@ -1064,8 +1064,8 @@ class EncryptAnUploadable(object): self._plaintext_hasher.update(chunk) self._update_segment_hash(chunk) # TODO: we have to encrypt the data (even if hash_only==True) - # because pycryptopp's AES-CTR implementation doesn't offer a - # way to change the counter value. Once pycryptopp acquires + # because the AES-CTR implementation doesn't offer a + # way to change the counter value. Once it acquires # this ability, change this to simply update the counter # before each call to (hash_only==False) _encryptor.process() ciphertext = self._encryptor.process(chunk) diff --git a/src/allmydata/mutable/filenode.py b/src/allmydata/mutable/filenode.py index 4065c25ba..7e814367d 100644 --- a/src/allmydata/mutable/filenode.py +++ b/src/allmydata/mutable/filenode.py @@ -1,9 +1,10 @@ - import random from zope.interface import implementer from twisted.internet import defer, reactor from foolscap.api import eventually + +from allmydata.crypto.aes import AES from allmydata.interfaces import IMutableFileNode, ICheckable, ICheckResults, \ NotEnoughSharesError, MDMF_VERSION, SDMF_VERSION, IMutableUploadable, \ IMutableFileVersion, IWriteable @@ -12,8 +13,6 @@ from allmydata.util.assertutil import precondition from allmydata.uri import WriteableSSKFileURI, ReadonlySSKFileURI, \ WriteableMDMFFileURI, ReadonlyMDMFFileURI from allmydata.monitor import Monitor -from pycryptopp.cipher.aes import AES - from allmydata.mutable.publish import Publish, MutableData,\ TransformingUploadable from allmydata.mutable.common import MODE_READ, MODE_WRITE, MODE_CHECK, UnrecoverableFileError, \ diff --git a/src/allmydata/mutable/publish.py b/src/allmydata/mutable/publish.py index 7f0dad180..b5067d7f5 100644 --- a/src/allmydata/mutable/publish.py +++ b/src/allmydata/mutable/publish.py @@ -4,15 +4,15 @@ from itertools import count from zope.interface import implementer from twisted.internet import defer from twisted.python import failure + +from allmydata.crypto.aes import AES from allmydata.interfaces import IPublishStatus, SDMF_VERSION, MDMF_VERSION, \ IMutableUploadable from allmydata.util import base32, hashutil, mathutil, log from allmydata.util.dictutil import DictOfSets from allmydata import hashtree, codec from allmydata.storage.server import si_b2a -from pycryptopp.cipher.aes import AES from foolscap.api import eventually, fireEventually - from allmydata.mutable.common import MODE_WRITE, MODE_CHECK, MODE_REPAIR, \ UncoordinatedWriteError, NotEnoughServersError from allmydata.mutable.servermap import ServerMap diff --git a/src/allmydata/mutable/retrieve.py b/src/allmydata/mutable/retrieve.py index 1e5d51497..a163c8ddc 100644 --- a/src/allmydata/mutable/retrieve.py +++ b/src/allmydata/mutable/retrieve.py @@ -1,5 +1,5 @@ - import time + from itertools import count from zope.interface import implementer from twisted.internet import defer @@ -8,6 +8,7 @@ from twisted.internet.interfaces import IPushProducer, IConsumer from foolscap.api import eventually, fireEventually, DeadReferenceError, \ RemoteException +from allmydata.crypto.aes import AES from allmydata.interfaces import IRetrieveStatus, NotEnoughSharesError, \ DownloadStopped, MDMF_VERSION, SDMF_VERSION from allmydata.util.assertutil import _assert, precondition @@ -15,7 +16,7 @@ from allmydata.util import hashutil, log, mathutil, deferredutil from allmydata.util.dictutil import DictOfSets from allmydata import hashtree, codec from allmydata.storage.server import si_b2a -from pycryptopp.cipher.aes import AES + from pycryptopp.publickey import rsa from allmydata.mutable.common import CorruptShareError, BadShareError, \ diff --git a/src/allmydata/test/test_helper.py b/src/allmydata/test/test_helper.py index 471c8bb87..a1ce4b064 100644 --- a/src/allmydata/test/test_helper.py +++ b/src/allmydata/test/test_helper.py @@ -5,12 +5,12 @@ from twisted.application import service from foolscap.api import Tub, fireEventually, flushEventualQueue +from allmydata.crypto.aes import AES from allmydata.storage.server import si_b2a from allmydata.storage_client import StorageFarmBroker from allmydata.immutable import offloaded, upload from allmydata import uri, client from allmydata.util import hashutil, fileutil, mathutil -from pycryptopp.cipher.aes import AES MiB = 1024*1024 diff --git a/src/allmydata/util/fileutil.py b/src/allmydata/util/fileutil.py index da1696f1b..30a495e53 100644 --- a/src/allmydata/util/fileutil.py +++ b/src/allmydata/util/fileutil.py @@ -16,8 +16,7 @@ if sys.platform == "win32": from twisted.python import log -from pycryptopp.cipher.aes import AES - +from allmydata.crypto.aes import AES from allmydata.util.assertutil import _assert