Comments (2)
Dear Piotr,
I am trying to create a server according your main example. However, I believe my code is missing something:
#!/usr/bin/env python
import socket
from noise.builder import NoiseBuilder
host = '127.0.1.1'
port = 8888
payload = 1500
server_address = (host, port)
def start_TCP_server():
proto = NoiseBuilder.from_name(b'Noise_NN_25519_ChaChaPoly_SHA256')
proto.get_handshake_hash()
proto.set_as_responder()
proto.start_handshake()
message = proto.write_message()
socket_Noise = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket_Noise.bind(server_address)
socket_Noise.listen(1)
print("Noise server is running...")
while True:
client, client_address = socket_Noise.accept()
print(client_address)
while True:
data = client.recv(payload)
if not data:
break
client.sendall(data)
if __name__ == "__main__":
start_TCP_server()
May you help me out?
Thank you.
from noiseprotocol.
Hello Andrey,
I've updated the readme in trunk branch of the repository: https://github.com/plizonczyk/noiseprotocol/tree/trunk
Regarding the code snippet you've pasted:
- proto.get_handshake_hash() statement has no effect
- you can't write message before reading a message from initiator if in the responder role - NoiseBuilder would raise a NoiseHandshakeError in this case.
Traceback (most recent call last):
...
noise.exceptions.NoiseHandshakeError: NoiseBuilder.read_message has to be called now
- you need to use proto you've created to encrypt data sent to the other party. So, instead of
client.sendall(data)
you should useclient.sendall(proto.write_message(data))
. By the way, you need to feed the data received from the initiator into proto first in order to decrypt it - so afterdata = client.recv(payload)
you should doplaintext = proto.read_message(data)
. - after finishing handshake (in case of this pattern (NN) - after one cycle of read/write) - you should use proto.encrypt and proto.decrypt.
If you won't be able to figure it out based on the updated readme - please let me know and we'll fix up your code.
Kind regards,
Piotr
from noiseprotocol.
Related Issues (20)
- Do not reinitialise AESGCM every time
- Support non-default crypto backends
- Provision documentation for readthedocs
- Upgrade Cryptography version and support Python 3.5
- Experimental support for Windows and OS X
- Feature request: Support for Noise_XK_secp256k1_ChaChaPoly_SHA256 HOT 3
- why pin cryptography==2.1.4? HOT 3
- Remove custom curve448 implementation HOT 5
- Support fallback patterns
- deprecation warning in use of x25519 HOT 2
- Error in Base Usage HOT 1
- installed on python 3.4, but fails to run HOT 3
- Serious lack of documentation HOT 1
- Deferred handshake patterns (enhancement)
- Tags for newest versions missing HOT 1
- why no tar.gz/source distributable for 0.3.1 ? HOT 1
- Testing aditional mcginty/snow test vectors results in a failure HOT 1
- MAX_MESSAGE_LEN HOT 1
- Library name noise conflicts with the existing noise PyPi module
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from noiseprotocol.