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
-
Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
-
Install Rust (if not already installed):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Quick Start
-
Setup development environment:
cd pyrsca uv sync --dev
-
Activate virtual environment:
source .venv/bin/activate
-
Build the extension:
uv run maturin develop
-
Run tests:
uv run pytest
Development Workflow
-
Install dependencies:
uv add --dev <package-name>
-
Build for development:
uv run maturin develop --release
-
Build wheels:
uv run maturin build --release
-
Publish (when ready):
uv run maturin publish
Project Structure
src/lib.rs- Rust source code with Python bindingspyrsca/- Python package sourcetests/- Python testspyproject.toml- Project configuration and dependenciesCargo.toml- Rust dependencies and build configuration
Available Commands
Using uv directly:
uv sync- Install all dependenciesuv run pytest- Run testsuv run maturin develop- Build and install in development modeuv run maturin build- Build distribution wheelsuv add <package>- Add a new dependencyuv 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:
-
Update
.python-version:echo "3.12" > .python-version
-
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}")
Metadata
Release files for pyrsca 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyrsca-0.4.0.tar.gz | 31.9 kB | Details |
Built distributions (wheels)
Total release size: 17.9 MB
Release files / pyrsca-0.4.0.tar.gz
| Download URL | pyrsca-0.4.0.tar.gz |
|---|---|
| Size | 31.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0608ef8fdfc18123efcdaa180bea35d587f59892a574badca88f6be862f5870
|
|
BLAKE2b-256 checksum How to use checksums |
24459fa67d8e175b5014b7fe9e10b368cde91651bc84f59fd902e471474251bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp314-cp314t-win_amd64.whl
| Download URL | pyrsca-0.4.0-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9ceb96ecb2953b81de368c132ef88729d9e738fdee8aed55faa53d3226c53b72
|
|
BLAKE2b-256 checksum How to use checksums |
0e9f6c10fbc50f1a2c4f9702d746d0c502b6b03abf5a211e2d846dda237616c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e37622bb7479500eb412bb55e7f0839bb983edcd1e52145f5c3576f274c3d9ed
|
|
BLAKE2b-256 checksum How to use checksums |
e213f0085114d3d324ed6559a13378eaa3b40f84191752e4c35c2014cdf452b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARMv7l |
|
SHA-256 checksum How to use checksums |
8240cd44f6afff7adb7fc5c10022ef99ff1ce21218fb66ad51eb58c8d3fabb71
|
|
BLAKE2b-256 checksum How to use checksums |
7d2684c4dcaca9d720ecb17935b50d2fac0e9cf54b14494f27bb75a3b199ba15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pyrsca-0.4.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
21e6a598e33f382ad23a878136fa744f329e097b487d940c8c3b340b4c9509a1
|
|
BLAKE2b-256 checksum How to use checksums |
9883aa293c853a6f9bc2412a7ec19e31a9f4c3d35be3486f92dacd2047b45ce6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | pyrsca-0.4.0-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
302e1780fa0e903f1018f0be720e4dbc64396d55f08529bd120057661fcd0ee9
|
|
BLAKE2b-256 checksum How to use checksums |
f3e1bcb63e29ca967ce19bbc7602c096b522c9f563c991ad4b741fdff83c2a48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | pyrsca-0.4.0-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
89d660251ea24e29cf33dd2fcc5a4d6290ec2eb630fb1d0efddfcb6f94d3125c
|
|
BLAKE2b-256 checksum How to use checksums |
6b08267897d171e075ee4a76aca461c26b2102e86e6585dfe5a407a19c01df6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-win_amd64.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.7 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5b97035473a06531c5f05833b37911dc095425abae35b7209c22b5d41ff5c09c
|
|
BLAKE2b-256 checksum How to use checksums |
37030db75110607053d2626ff52c9a0ceeda9119f08499a1a9c5cd51ec0a33e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-win32.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-win32.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.7 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
4aeb63fa35bd656b383b47f71472b95d52dc527f433ca31ce02697fe7ade39c7
|
|
BLAKE2b-256 checksum How to use checksums |
5c714472263d8705c09481967dca6856f1c4063e270045b10e4b6b7070d792b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
811afeb8707b7cebb0179acf68d19a64bc293310bb414badde7293ec2d5da694
|
|
BLAKE2b-256 checksum How to use checksums |
9ecb7c7c3418e4553d63ef5f3eb6cccb222b9a97c3459665a225f06839f29704
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
be6ccdbe328302b0ab3134c4b41097b5e032a2ce95a0a307c0af31d98905ceec
|
|
BLAKE2b-256 checksum How to use checksums |
67d9a9867005f3ddaa1f76210fe311b813048ac74a57ee5a36fc03a7981708ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
d404dc69be0c28cec7a66ee9842833d80ddd4e5af662532c51a596b0089f4ee2
|
|
BLAKE2b-256 checksum How to use checksums |
2ad6b8a3a77cb8eeacf887517ae6697d35c92a137cd577e4116180136f4b8001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
02c03f1fd809b2e7720e4e549ff493bba8793a491644513efa5582a3c77615b9
|
|
BLAKE2b-256 checksum How to use checksums |
1a8e93b11d3c299e3ffaac35257fe7db81ea180056c52371a959743ed0ac9a68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.7 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
3843ef87f5808d256ce78ea676255aa97dc788a7b2ccb39970b7be0be553b2b5
|
|
BLAKE2b-256 checksum How to use checksums |
a6f3c160bb8b5d76e981525b5d8ca0b71021f096ad4f446f9a4c4d7ed7a9a4ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-macosx_11_0_arm64.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.7 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2dc266566e87968b880810bc7e581487d02d01034577adca434a37a195e7b0f0
|
|
BLAKE2b-256 checksum How to use checksums |
d358a36e77522b4babc5a41253d70b7c954d428ccb0dd1041cbbeb3d09d64ea7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|
Release files / pyrsca-0.4.0-cp37-abi3-macosx_10_12_x86_64.whl
| Download URL | pyrsca-0.4.0-cp37-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.7 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
ccb6913cc7c16f2576aa3366cef83106725879bf237c263a6e690a2f2879c82e
|
|
BLAKE2b-256 checksum How to use checksums |
352754eb2d023f7db4a780af8e6f1856143d0e21cd3340c9602f7d6dbf5bc748
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.4
|