Skip to main content

Python bindings for rsca library

Project description

PyRSCA

Python bindings for the RSCA (Rust Signature and Certificate Authority) library.

Development with uv

This project is managed using uv, a fast Python package manager.

Prerequisites

  1. Install uv:

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. Install Rust (if not already installed):

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    

Quick Start

  1. Setup development environment:

    cd pyrsca
    uv sync --dev
    
  2. Activate virtual environment:

    source .venv/bin/activate
    
  3. Build the extension:

    uv run maturin develop
    
  4. Run tests:

    uv run pytest
    

Development Workflow

  1. Install dependencies:

    uv add --dev <package-name>
    
  2. Build for development:

    uv run maturin develop --release
    
  3. Build wheels:

    uv run maturin build --release
    
  4. Publish (when ready):

    uv run maturin publish
    

Project Structure

  • src/lib.rs - Rust source code with Python bindings
  • pyrsca/ - Python package source
  • tests/ - Python tests
  • pyproject.toml - Project configuration and dependencies
  • Cargo.toml - Rust dependencies and build configuration

Available Commands

Using uv directly:

  • uv sync - Install all dependencies
  • uv run pytest - Run tests
  • uv run maturin develop - Build and install in development mode
  • uv run maturin build - Build distribution wheels
  • uv add <package> - Add a new dependency
  • uv remove <package> - Remove a dependency

Using the development script (recommended):

The dev.sh script handles environment conflicts and provides convenient commands:

  • ./dev.sh sync - Install/update dependencies
  • ./dev.sh dev - Build in development mode
  • ./dev.sh build - Build release mode
  • ./dev.sh test - Run tests
  • ./dev.sh clean - Clean build artifacts
  • ./dev.sh install - Install package in editable mode
  • ./dev.sh help - Show help

Note: The development script automatically handles conda/uv environment conflicts.

Python Version Management

This project supports Python 3.7+ and uses Python 3.11 by default. You can change this by:

  1. Update .python-version:

    echo "3.12" > .python-version
    
  2. Recreate virtual environment:

    uv sync --reinstall
    

Features

  • PyTWCA: Python wrapper for TWCA certificate operations
  • uni_sign: Unified signature function supporting both PKCS1 and PKCS7 formats
  • PKCS7 Signature: PKCS7 signature with unified output format
  • PKCS1 Signature: PKCS1 signature with base64 encoded data and certificate
  • PySignType: Enum for selecting signature type (Pkcs1, Pkcs7)
  • Certificate operations: Extract certificate information and base64 encoding

Signature Output Format

Both PKCS1 and PKCS7 signatures use a unified output format:

{type}.{signature_base64}.{data_base64}.{cert_base64}
  • PKCS1: pkcs1.{signature_base64}.{data_base64}.{cert_base64}
  • PKCS7: pkcs7.{signature_base64}.{data_base64}.{cert_base64}

Usage Example

from pyrsca import PyTWCA, PySignType

# Initialize TWCA instance
twca = PyTWCA("/path/to/cert.pfx", "password", "192.168.1.1")

# Get certificate person ID
person_id = twca.get_cert_person_id()
print(f"Certificate Person ID: {person_id}")

# Unified signature function (recommended)
pkcs1_result = twca.uni_sign("data to sign", PySignType.Pkcs1)
pkcs7_result = twca.uni_sign("data to sign", PySignType.Pkcs7)
print(f"PKCS1 Result: {pkcs1_result}")
print(f"PKCS7 Result: {pkcs7_result}")

# Direct signature methods
pkcs1_result = twca.sign_pkcs1("data to sign")
pkcs7_result = twca.sign_pkcs7("data to sign")

# Legacy PKCS7 signature (URL encoded, different format)
legacy_signature = twca.sign("data to sign")

# Get base64 encoded certificate
cert_base64 = twca.get_cert_base64()
print(f"Certificate Base64: {cert_base64}")

# Check expiration
expire_timestamp = twca.get_expire_timestamp()
print(f"Certificate expires at: {expire_timestamp}")

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

pyrsca-0.4.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distributions

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

pyrsca-0.4.0-cp314-cp314t-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.14tWindows x86-64

pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARMv7l

pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

pyrsca-0.4.0-cp314-cp314t-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

pyrsca-0.4.0-cp314-cp314t-macosx_10_12_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

pyrsca-0.4.0-cp37-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.7+Windows x86-64

pyrsca-0.4.0-cp37-abi3-win32.whl (1.2 MB view details)

Uploaded CPython 3.7+Windows x86

pyrsca-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

pyrsca-0.4.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

pyrsca-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ i686

pyrsca-0.4.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.1 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

pyrsca-0.4.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

pyrsca-0.4.0-cp37-abi3-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

pyrsca-0.4.0-cp37-abi3-macosx_10_12_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file pyrsca-0.4.0.tar.gz.

File metadata

  • Download URL: pyrsca-0.4.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.4

File hashes

Hashes for pyrsca-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c0608ef8fdfc18123efcdaa180bea35d587f59892a574badca88f6be862f5870
MD5 93cb5e4a6334eba6cd77fdf0cddd0185
BLAKE2b-256 24459fa67d8e175b5014b7fe9e10b368cde91651bc84f59fd902e471474251bd

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp314-cp314t-win_amd64.whl.

File metadata

  • Download URL: pyrsca-0.4.0-cp314-cp314t-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.14t, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.4

File hashes

Hashes for pyrsca-0.4.0-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 9ceb96ecb2953b81de368c132ef88729d9e738fdee8aed55faa53d3226c53b72
MD5 8a4038063d2e01d16306acbaa0405781
BLAKE2b-256 0e9f6c10fbc50f1a2c4f9702d746d0c502b6b03abf5a211e2d846dda237616c8

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e37622bb7479500eb412bb55e7f0839bb983edcd1e52145f5c3576f274c3d9ed
MD5 c79d86900c501dbcffa3a232117076f8
BLAKE2b-256 e213f0085114d3d324ed6559a13378eaa3b40f84191752e4c35c2014cdf452b2

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8240cd44f6afff7adb7fc5c10022ef99ff1ce21218fb66ad51eb58c8d3fabb71
MD5 723c1dec0afd2c867c9be5fd4e834196
BLAKE2b-256 7d2684c4dcaca9d720ecb17935b50d2fac0e9cf54b14494f27bb75a3b199ba15

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 21e6a598e33f382ad23a878136fa744f329e097b487d940c8c3b340b4c9509a1
MD5 8ddfb280ae1e8ada72ce92948fcd7fa3
BLAKE2b-256 9883aa293c853a6f9bc2412a7ec19e31a9f4c3d35be3486f92dacd2047b45ce6

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 302e1780fa0e903f1018f0be720e4dbc64396d55f08529bd120057661fcd0ee9
MD5 54dcd8772c463ad8c9f4d627e2a4a740
BLAKE2b-256 f3e1bcb63e29ca967ce19bbc7602c096b522c9f563c991ad4b741fdff83c2a48

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp314-cp314t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 89d660251ea24e29cf33dd2fcc5a4d6290ec2eb630fb1d0efddfcb6f94d3125c
MD5 dd0cdd671fae8b924a5d1a887a6231bb
BLAKE2b-256 6b08267897d171e075ee4a76aca461c26b2102e86e6585dfe5a407a19c01df6a

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: pyrsca-0.4.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.4

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5b97035473a06531c5f05833b37911dc095425abae35b7209c22b5d41ff5c09c
MD5 24a1688731c0d070399990995a54ddcb
BLAKE2b-256 37030db75110607053d2626ff52c9a0ceeda9119f08499a1a9c5cd51ec0a33e6

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-win32.whl.

File metadata

  • Download URL: pyrsca-0.4.0-cp37-abi3-win32.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.4

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 4aeb63fa35bd656b383b47f71472b95d52dc527f433ca31ce02697fe7ade39c7
MD5 3b849a5559dd3e347ecf72cff6b0c494
BLAKE2b-256 5c714472263d8705c09481967dca6856f1c4063e270045b10e4b6b7070d792b1

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 811afeb8707b7cebb0179acf68d19a64bc293310bb414badde7293ec2d5da694
MD5 21729379132849e456f825b2f0c1d657
BLAKE2b-256 9ecb7c7c3418e4553d63ef5f3eb6cccb222b9a97c3459665a225f06839f29704

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 be6ccdbe328302b0ab3134c4b41097b5e032a2ce95a0a307c0af31d98905ceec
MD5 60befd4dedb57aa242bcbf107050bcdb
BLAKE2b-256 67d9a9867005f3ddaa1f76210fe311b813048ac74a57ee5a36fc03a7981708ae

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 d404dc69be0c28cec7a66ee9842833d80ddd4e5af662532c51a596b0089f4ee2
MD5 0e8e1bf388c04976838221a4189301c3
BLAKE2b-256 2ad6b8a3a77cb8eeacf887517ae6697d35c92a137cd577e4116180136f4b8001

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 02c03f1fd809b2e7720e4e549ff493bba8793a491644513efa5582a3c77615b9
MD5 1bac31c3db919e18fd05bd34187de4b9
BLAKE2b-256 1a8e93b11d3c299e3ffaac35257fe7db81ea180056c52371a959743ed0ac9a68

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3843ef87f5808d256ce78ea676255aa97dc788a7b2ccb39970b7be0be553b2b5
MD5 72c4240fed93ffbf06221cd1eb4b5964
BLAKE2b-256 a6f3c160bb8b5d76e981525b5d8ca0b71021f096ad4f446f9a4c4d7ed7a9a4ed

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2dc266566e87968b880810bc7e581487d02d01034577adca434a37a195e7b0f0
MD5 3c301b4255c35e944f1378c1a726e308
BLAKE2b-256 d358a36e77522b4babc5a41253d70b7c954d428ccb0dd1041cbbeb3d09d64ea7

See more details on using hashes here.

File details

Details for the file pyrsca-0.4.0-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyrsca-0.4.0-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ccb6913cc7c16f2576aa3366cef83106725879bf237c263a6e690a2f2879c82e
MD5 613a72dea0dda0579c6c6ad06bbfd422
BLAKE2b-256 352754eb2d023f7db4a780af8e6f1856143d0e21cd3340c9602f7d6dbf5bc748

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