synta 0.2.3

ASN.1 parser, decoder, and encoder library with DER/BER support and C FFI
Documentation
# Installation and Building


## Prerequisites

- Rust toolchain (1.70 or later)
- Python 3.8 or later (abi3 stable ABI; compatible with CPython 3.8–3.14+)
- maturin 1.x

## Build Instructions

The `synta` package consists of three native extension modules.  The primary
module (`_synta`) is built by maturin; the subsystem modules (`_krb5`, `_mtc`)
are built with cargo and copied alongside it.

```bash
# Install maturin
pip install maturin

# Build _synta.abi3.so (release mode) — maturin reads pyproject.toml automatically
maturin build --release

# Build the subsystem extension modules
cargo build --release -p synta-python-krb5 --features openssl
cargo build --release -p synta-python-mtc  --features openssl
```

The maturin wheel is created in `target/wheels/`.  The subsystem `.so` files
must be placed inside the `synta/` directory within the wheel or, for
development installs, inside `python/synta/`.

For a development install with all three modules in one step, use the CI helper:

```bash
./contrib/ci/local-ci.sh python-test
```

Or build manually:

```bash
# Build in development mode (with a virtualenv active)
maturin develop

# Determine the platform extension suffix (e.g. .cpython-312-x86_64-linux-gnu.so)
EXT=$(python3 -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")

# Build and install subsystem modules
cargo build --release -p synta-python-krb5 --features openssl
cp target/release/lib_krb5.so "python/synta/_krb5${EXT}"

cargo build --release -p synta-python-mtc --features openssl
cp target/release/lib_mtc.so "python/synta/_mtc${EXT}"
```

Maturin is configured in `pyproject.toml` to build the `synta-python` crate:

```toml
[tool.maturin]
manifest-path = "synta-python/Cargo.toml"
module-name = "synta._synta"
bindings = "pyo3"
python-source = "python"
```

To enable OpenSSL-backed features (PKCS#12 encryption, CMS EnvelopedData
construction, X.509 chain verification):

```bash
maturin develop --features openssl
maturin build --release --features openssl
```

To additionally enable legacy PKCS#12 decryption algorithms (3DES, RC2):

```bash
maturin develop --features openssl,deprecated-pkcs12-algorithms
```

## Installation

```bash
# Install the built wheel
pip install target/wheels/synta-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
```

The wheel produced by maturin includes `_synta.abi3.so`.  When packaging for a
distribution, `_krb5.abi3.so` and `_mtc.abi3.so` are typically installed as
separate sub-packages alongside the main wheel; see
[`contrib/packages/`](../../../../contrib/packages/) for RPM spec examples.

## Running tests

```bash
# Build in development mode first
python -m venv venv
source venv/bin/activate
maturin develop

# Run the Python test suite
python -m pytest tests/python/
```

> **Note on PYTHONPATH:** When running scripts directly (not via `pytest`),
> use `PYTHONPATH=python python3 script.py` so Python can find the `synta`
> package in `python/synta/`.