From 7949cba7d779148821808b8671eddabe7155239c Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Sun, 4 Feb 2018 15:50:56 +0100 Subject: [PATCH] Fix import order --- examples/test_client.py | 4 +--- examples/test_server.py | 4 +--- secret_handshake/boxstream.py | 3 +-- secret_handshake/crypto.py | 3 ++- secret_handshake/test_boxstream.py | 5 +++-- secret_handshake/util.py | 1 - 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/examples/test_client.py b/examples/test_client.py index 852541d..1fbdff5 100644 --- a/examples/test_client.py +++ b/examples/test_client.py @@ -1,14 +1,12 @@ import os -import yaml - from asyncio import get_event_loop from base64 import b64decode +import yaml from nacl.signing import SigningKey from secret_handshake import SHSClient - with open(os.path.expanduser('~/.ssb/secret')) as f: config = yaml.load(f) diff --git a/examples/test_server.py b/examples/test_server.py index 1d0399e..cc9c616 100644 --- a/examples/test_server.py +++ b/examples/test_server.py @@ -1,14 +1,12 @@ import os -import yaml - from asyncio import get_event_loop from base64 import b64decode +import yaml from nacl.signing import SigningKey from secret_handshake import SHSServer - with open(os.path.expanduser('~/.ssb/secret')) as f: config = yaml.load(f) diff --git a/secret_handshake/boxstream.py b/secret_handshake/boxstream.py index af948cf..04a42a1 100644 --- a/secret_handshake/boxstream.py +++ b/secret_handshake/boxstream.py @@ -2,10 +2,9 @@ import struct from asyncio import IncompleteReadError from async_generator import async_generator, yield_ - from nacl.secret import SecretBox -from .util import split_chunks, inc_nonce +from .util import inc_nonce, split_chunks HEADER_LENGTH = 2 + 16 + 16 MAX_SEGMENT_SIZE = 4 * 1024 diff --git a/secret_handshake/crypto.py b/secret_handshake/crypto.py index dc8f2db..05b1315 100644 --- a/secret_handshake/crypto.py +++ b/secret_handshake/crypto.py @@ -23,7 +23,8 @@ import hashlib import hmac from base64 import b64decode -from nacl.bindings import crypto_scalarmult, crypto_box_afternm, crypto_box_open_afternm +from nacl.bindings import (crypto_box_afternm, crypto_box_open_afternm, + crypto_scalarmult) from nacl.exceptions import CryptoError from nacl.public import PrivateKey from nacl.signing import VerifyKey diff --git a/secret_handshake/test_boxstream.py b/secret_handshake/test_boxstream.py index fc0ad98..d035b58 100644 --- a/secret_handshake/test_boxstream.py +++ b/secret_handshake/test_boxstream.py @@ -21,10 +21,11 @@ import pytest -from .test_crypto import (CLIENT_ENCRYPT_KEY, CLIENT_ENCRYPT_NONCE) -from secret_handshake.boxstream import BoxStream, UnboxStream, HEADER_LENGTH +from secret_handshake.boxstream import HEADER_LENGTH, BoxStream, UnboxStream from secret_handshake.util import AsyncBuffer, async_comprehend +from .test_crypto import CLIENT_ENCRYPT_KEY, CLIENT_ENCRYPT_NONCE + MESSAGE_1 = (b'\xcev\xedE\x06l\x02\x13\xc8\x17V\xfa\x8bZ?\x88B%O\xb0L\x9f\x8e\x8c0y\x1dv\xc0\xc9\xf6\x9d\xc2\xdf\xdb' b'\xee\x9d') MESSAGE_2 = b"\x141\xd63\x13d\xd1\xecZ\x9b\xd0\xd4\x03\xcdR?'\xaa.\x89I\x92I\xf9guL\xaa\x06?\xea\xca/}\x88*\xb2" diff --git a/secret_handshake/util.py b/secret_handshake/util.py index d0df4bd..0b4667e 100644 --- a/secret_handshake/util.py +++ b/secret_handshake/util.py @@ -22,7 +22,6 @@ import struct from io import BytesIO - NONCE_SIZE = 24 MAX_NONCE = (8 * NONCE_SIZE)