Skip to main content

Public key secure transport layer

Project description

Py-PKSTL

Python 3 bindings for Rust PKSTL. PKSTL is a security layer for network connections (public key cryptography & Diffie-Hellman secret generation).

Install

sudo pip3 install pkstl

Build & install

sudo pip3 install --upgrade setuptools wheel
sh build_wheel.sh
sudo pip3 install target/wheel/dist/pkstl-*-py3-none-any.whl

Example

Run an example (client-server echo):

python3 py/example_echo.py server
python3 py/example_echo.py client
# and type some text into the client!

Minimal example code: (Bob knows Alice's public key and contacts her)

import pkstl

# Generate keypairs
alice_seed = pkstl.Seed32.random() # Alice's permanent private key
alice_pubkey = pkstl.Ed25519KeyPair.from_seed_unchecked(alice_seed.bytes).pubkey
bob_seed = pkstl.Seed32.random() # Bob's ephemeral private key
alice_msl = pkstl.SecureLayer.create(pkstl.SecureLayerConfig.default(), alice_seed)
bob_msl = pkstl.SecureLayer.create(pkstl.SecureLayerConfig.default(), bob_seed, alice_pubkey)

# Establish connection
msg = bob_msl.write_connect_msg_bin(b"Hello Alice!")
alice_msl.read_bin(msg)

msg = alice_msl.write_connect_msg_bin(b"Hello Bob!")
bob_msl.read_bin(msg)

msg = alice_msl.write_ack_msg_bin(b"Nice to meet you Bob!")
bob_msl.read_bin(msg)

msg = bob_msl.write_ack_msg_bin(b"Nice to meet you Alice!")
alice_msl.read_bin(msg)

# Send messages
msg = alice_msl.write_bin(b"Is this channel encrypted?")
print(bob_msl.read_bin(msg)[0].data[0])

msg = bob_msl.write_bin(b"Yes it is.")
print(alice_msl.read_bin(msg)[0].data[0])

Project details


Release history Release notifications

This version

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pkstl, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pkstl-0.1.0-py3-none-any.whl (1.0 MB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page