Browse Source

move the function locally since it looks like this is the way forward..

tags/v0.1.0
John-Mark Gurney 5 years ago
parent
commit
05e577f738
2 changed files with 18 additions and 3 deletions
  1. +18
    -1
      ntunnel.py
  2. +0
    -2
      requirements.txt

+ 18
- 1
ntunnel.py View File

@@ -2,8 +2,9 @@ from noise.connection import NoiseConnection, Keypair
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import hashes
from twistednoise import genkeypair
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import x448
from cryptography.hazmat.primitives import serialization

import asyncio
import os.path
@@ -15,6 +16,22 @@ import unittest

_backend = default_backend()

def genkeypair():
'''Generates a keypair, and returns a tuple of (public, private).
They are encoded as raw bytes, and sutible for use w/ Noise.'''

key = x448.X448PrivateKey.generate()

enc = serialization.Encoding.Raw
pubformat = serialization.PublicFormat.Raw
privformat = serialization.PrivateFormat.Raw
encalgo = serialization.NoEncryption()

pub = key.public_key().public_bytes(encoding=enc, format=pubformat)
priv = key.private_bytes(encoding=enc, format=privformat, encryption_algorithm=encalgo)

return pub, priv

def _makefut(obj):
loop = asyncio.get_running_loop()
fut = loop.create_future()


+ 0
- 2
requirements.txt View File

@@ -1,4 +1,2 @@
coverage
-e git+https://github.com/jmgurney/noiseprotocol.git@ab6f8ebe0e28f5a4105928c13baddcfdc43b7e82#egg=noiseprotocol
twisted
mock

Loading…
Cancel
Save