diff options
| author | Victor Shyba <victor1984@riseup.net> | 2017-07-08 03:00:11 -0300 | 
|---|---|---|
| committer | drebs <drebs@leap.se> | 2017-07-18 15:22:37 -0300 | 
| commit | 1b71b5c3f5df1c88f61ac2c57abe791f47027143 (patch) | |
| tree | f2f23bd1cf27e44a8a766cb2e884346c9eb4af66 /src | |
| parent | 361eb8d7121cc8abb94d9fef784d5ff2b27722d0 (diff) | |
[style] fix naming from review
Diffstat (limited to 'src')
| -rw-r--r-- | src/leap/soledad/client/_crypto.py | 6 | ||||
| -rw-r--r-- | src/leap/soledad/common/preamble.py | 12 | 
2 files changed, 9 insertions, 9 deletions
| diff --git a/src/leap/soledad/client/_crypto.py b/src/leap/soledad/client/_crypto.py index 998b70fa..c0d9dde9 100644 --- a/src/leap/soledad/client/_crypto.py +++ b/src/leap/soledad/client/_crypto.py @@ -33,7 +33,7 @@ Encryption  ----------  IV = os.urandom(16) -PREAMBLE = BLOB_SIGNATURE_MAGIC, ENC_SCHEME, ENC_METHOD, time, IV, doc_id, rev, +PREAMBLE = MAGIC, ENC_SCHEME, ENC_METHOD, time, IV, doc_id, rev,  and size.  PREAMBLE = base64_encoded(PREAMBLE) @@ -90,7 +90,7 @@ from leap.soledad.common.preamble import InvalidPreambleException  from leap.soledad.common.preamble import decode_preamble  from leap.soledad.common.preamble import Preamble  from leap.soledad.common.preamble import ENC_SCHEME, ENC_METHOD -from leap.soledad.common.preamble import BLOB_SIGNATURE_MAGIC +from leap.soledad.common.preamble import MAGIC  SECRET_LENGTH = 64 @@ -383,7 +383,7 @@ class BlobDecryptor(object):          except InvalidPreambleException as e:              raise InvalidBlob(e) -        if preamble.magic != BLOB_SIGNATURE_MAGIC: +        if preamble.magic != MAGIC:              raise InvalidBlob          # TODO check timestamp. Just as a sanity check, but for instance          # we can refuse to process something that is in the future or diff --git a/src/leap/soledad/common/preamble.py b/src/leap/soledad/common/preamble.py index 72549031..d4065c38 100644 --- a/src/leap/soledad/common/preamble.py +++ b/src/leap/soledad/common/preamble.py @@ -15,9 +15,9 @@  # You should have received a copy of the GNU General Public License  # along with this program. If not, see <http://www.gnu.org/licenses/>.  """ -Preamble is a metadata payload present on encrypted documents. It holds data -about encryption scheme, iv, document id and sync related data. -   BLOB_SIGNATURE_MAGIC, -> used to differentiate from other data formats +Preamble is a binary packed metadata payload present on encrypted documents. It +holds data about encryption scheme, iv, document id and sync related data. +   MAGIC, -> used to differentiate from other data formats     ENC_SCHEME, -> cryptographic scheme (symmetric or asymmetric)     ENC_METHOD, -> cipher used, such as AES-GCM or AES-CTR or GPG     current_time, -> time.time() @@ -32,7 +32,7 @@ import time  from collections import namedtuple  PACMAN = struct.Struct('2sbbQ16s255p255pQ')  LEGACY_PACMAN = struct.Struct('2sbbQ16s255p255p')  # DEPRECATED -BLOB_SIGNATURE_MAGIC = '\x13\x37' +MAGIC = '\x13\x37'  ENC_SCHEME = namedtuple('SCHEME', 'symkey external')(1, 2)  ENC_METHOD = namedtuple('METHOD', 'aes_256_ctr aes_256_gcm pgp')(1, 2, 3) @@ -41,7 +41,7 @@ class InvalidPreambleException(Exception):      pass -class Preamble: +class Preamble(object):      def __init__(self, doc_id, rev, scheme, method,                   timestamp=0, iv='', magic=None, content_size=0): @@ -51,7 +51,7 @@ class Preamble:          self.method = method          self.iv = iv          self.timestamp = int(timestamp) or int(time.time()) -        self.magic = magic or BLOB_SIGNATURE_MAGIC +        self.magic = magic or MAGIC          self.content_size = int(content_size)      def encode(self): | 
