Removing old echo example

This commit is contained in:
Piotr Lizonczyk
2017-09-03 19:42:14 +02:00
parent 57a64fc05e
commit d0899c6871
4 changed files with 0 additions and 110 deletions

View File

@@ -1,9 +0,0 @@
### Important notes
This example should be able to work with noise-c echo example.
Echo constants required for proper encoding of Noise Protocol name were ported directly from noise-c.
More info on noise-c echo: https://rweather.github.io/noise-c/example_echo.html
### Usage
TBD

View File

@@ -1,52 +0,0 @@
import logging
import socket
import struct
from examples.echo.echo_constants import PSK, PATTERN, CIPHER, DH, HASH
logger = logging.getLogger(__name__)
with open('../noise-keys/psk') as fd:
psk = fd.readline()
# psk = base64.b64decode(fd.readline())
protocol_id = struct.Struct('BBBBB')
noise_name = 'NoisePSK_NN_448_ChaChaPoly_BLAKE2b'
s = socket.socket()
s.connect(('localhost', 2000))
def get_packed_protocol_id(name):
if not name.startswith('Noise'):
logger.info('Wrong pattern: does not begin with "Noise"')
name = name[5:]
if name.startswith('PSK'):
psk_byte = PSK.PSK_ENABLED.value
name = name[3:]
else:
psk_byte = PSK.PSK_DISABLED.value
name = name.lstrip('_')
pattern = name[:2]
pattern_byte = getattr(PATTERN, 'PATTERN_' + pattern).value
name = name[2:].lstrip('_')
dh = name.split('_')[0]
dh_byte = getattr(DH, 'DH_' + dh).value
name = name.lstrip(dh).lstrip('_')
cipher = name.split('_')[0]
cipher_byte = getattr(CIPHER, 'CIPHER_' + cipher.upper()).value
name = name.lstrip(cipher).lstrip('_')
hashing = name.split('_')[0]
hashing_byte = getattr(HASH, 'HASH_' + hashing).value
return protocol_id.pack(psk_byte, pattern_byte, cipher_byte, dh_byte, hashing_byte)
s.send(get_packed_protocol_id(noise_name))
# s.send.
# import ipdb; ipdb.set_trace()

View File

@@ -1,49 +0,0 @@
from enum import Enum
class PSK(Enum):
PSK_DISABLED = 0x00
PSK_ENABLED = 0x01
class PATTERN(Enum):
PATTERN_NN = 0x00
PATTERN_KN = 0x01
PATTERN_NK = 0x02
PATTERN_KK = 0x03
PATTERN_NX = 0x04
PATTERN_KX = 0x05
PATTERN_XN = 0x06
PATTERN_IN = 0x07
PATTERN_XK = 0x08
PATTERN_IK = 0x09
PATTERN_XX = 0x0A
PATTERN_IX = 0x0B
PATTERN_HFS = 0x80
class CIPHER(Enum):
CIPHER_CHACHAPOLY = 0x00
CIPHER_AESGCM = 0x01
class DH(Enum):
DH_25519 = 0x00
DH_448 = 0x01
DH_NEWHOPE = 0x02
DH_MASK = 0x0F
class HYBRID(Enum):
HYBRID_NONE = 0x00
HYBRID_25519 = 0x10
HYBRID_448 = 0x20
HYBRID_NEWHOPE = 0x30
HYBRID_MASK = 0xF0
class HASH(Enum):
HASH_SHA256 = 0x00
HASH_SHA512 = 0x01
HASH_BLAKE2s = 0x02
HASH_BLAKE2b = 0x03