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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file pkstl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pkstl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for pkstl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d9600828ada744ebb87c4a0fa89396783c20e921a6e2a1af64b31b932450257
MD5 d4b74da25ddf6c3e9f2f56b2cd7e36fc
BLAKE2b-256 fe20abc21126fe06ef1a58028b5484a1e463ae9acc3ab89b2eb57091f6e22bdf

See more details on using hashes here.

Supported by

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