Skip to main content

A package to interact with the PC Bio Unlock credentials module.

Project description

py-pcbu

This library simplifies interactions with PC Bio Unlock by implementing its protocol.

Usage

Pairing

  1. First, install PC Bio Unlock normally. Currently, versions >2.0.0 are supported, probably lower versions too.
  2. In the desktop app, click on Pair device. Go through the wizard steps, until you reach the QR Code.
  3. Get the JSON string out of the QR Code. On Android, I can only recommend using the FOSS app https://gitlab.com/Atharok/BarcodeScanner
  4. Write a TCPPairClient as follows:
from pcbu.tcp.pair_client import TCPPairClient
from pcbu.models import PairingQRData

pairing_data = PairingQRData.from_json(your_qr_json_string_here)

client = TCPPairClient(pairing_qr_data=pairing_data, device_name="The name of the device authorizing unlocks")
pair_response = client.pair()
print(pair_response)

This snippet prints in plaintext the payload received from the desktop. It contains sensitive informations such as your account password! So make sure to store it somewhere safe

Unlocking

py-pcbu gives you a base class to create a server listening for TCP unlock requests. Here is a minimalistic code to get it up and running:

from pcbu.models import PCPairing, PCPairingSecret
from pcbu.tcp.unlock_server import TCPUnlockServerBase

pairings_dicts =   [
    {
        "server_ip_address": "192.168.1.Y",
        "server_port": 43296,
        "pairing_id": "abcdef",
        "desktop_ip_address": "192.168.1.X",
        "encryption_key": "some_super_long_key",
        "username": "user1@desktop",
        "password": "pwd1"
    },
    {
        "server_ip_address": "192.168.2.Z",
        "server_port": 43296,
        "pairing_id": "ghijk",
        "desktop_ip_address": "192.168.1.X",
        "encryption_key": "another_super_long_key",
        "username": "user2@desktop",
        "password": "pwd2"
    }
]
pc_pairings = [PCPairingSecret.from_dict(d) for d in pairing_dicts]

class TCPUnlockServer(TCPUnlockServerBase):

    def on_valid_unlock_request(self, pairing: PCPairing) -> bool:
        print(f"Accepting unlock request from {pairing.desktop_ip_address}!")
        return True

with TCPUnlockServer(pc_pairings) as server:
    server.listen()

This snippet will start a TCPUnlockServer listening on each of the server_ip_address from the PCPairingSecret list, using port 43298 by default (same as PC Bio Unlock's default). When the server receivces an unlocking request, it will validate that the requestee's ip addres matches one of the PCPairingSecret instances, decrypt the unlock request, and call on_valid_unlock_request which you have to implement. In this snippet, the implementation of on_valid_unlock_request automatically accepts the unlocking request, but you could add more external conditions to allow it.

Development

For easier development, we include two scripts with VSCode launch configuration:

  • scripts/test_pair.py
  • scripts/test_unlock.py

Both scripts expect a gitignored conf.local.json file at the root of the repository. You can cp conf.template.json conf.local.json to get a base file to start from.

Releasing

Releases are automatically created when a change to version in pyproject.toml is detected. The new files are automatically uploaded to PyPI and the signed release is uploaded to GitHub Releases. The current steps to release are:

  1. Make sure pyproject.toml is updated with the new version
  2. Using cucumber/changelog, add the changes and update CHANGELOG.md with the new version
./changelog -o CHANGELOG.md added "Add this and that"
./changelog -o CHANGELOG.md release 0.1.2
  1. Commit the pyproject.toml and CHANGELOG.md changes
  2. Push the changes to GitHub
  3. Wait for the release to be published on PyPI
  4. Wait for the release to be published on GitHub Releases

Project details


Download files

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

Source Distribution

py_pcbu-0.2.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

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

py_pcbu-0.2.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file py_pcbu-0.2.0.tar.gz.

File metadata

  • Download URL: py_pcbu-0.2.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for py_pcbu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ff564bea7605032b94c04eeea37a335a1b80a6ce3843679938e77d93dfd1aafc
MD5 f3159a0a139260ce95bfe4f3910f6f07
BLAKE2b-256 1543b4dd1d6b5eefe9f4ca21f0c0bf993d3f1a20fb39729918030adbd9904f83

See more details on using hashes here.

File details

Details for the file py_pcbu-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: py_pcbu-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for py_pcbu-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5f4b3133897636411c98b193a29b77444d784a01b574d33303ce6d989cb15ef
MD5 04d21503298723923f12c3db3831cd15
BLAKE2b-256 55125ff1732d45b19b43557c2a071de9a6b426d9867740c6a7398bae6e8d0ad2

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