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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pkstl-0.1.0-py3-none-any.whl (1.0 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page