Skip to main content

Python bindings for libcdoc - read and write encrypted CDOC containers

Project description

pycdoc

Python bindings for libcdoc - a library for reading and writing encrypted CDOC containers.

CDOC is a file format for encrypting documents, used primarily in Estonia for secure document exchange with the Estonian ID-card ecosystem.

Installation

uv add pycdoc

Requirements

Runtime

  • Python 3.10+
  • OpenSSL 3.5+ (usually pre-installed on modern systems)

Building from Source

Building from source requires:

  • Python 3.10+
  • CMake 3.20+
  • SWIG 4.0+
  • OpenSSL 3.5+
  • libxml2
  • zlib
  • FlatBuffers
  • C++23 compatible compiler

macOS:

brew install cmake swig openssl@3 libxml2 flatbuffers

Ubuntu/Debian:

sudo apt install cmake swig libssl-dev libxml2-dev zlib1g-dev libflatbuffers-dev

Fedora/RHEL:

sudo dnf install cmake swig openssl-devel libxml2-devel zlib-devel flatbuffers-devel

Quick Start

Install with LDAP support for certificate lookup:

uv add "pycdoc[ldap]"

Encrypting Files

import pycdoc

# Encrypt a file for an Estonian ID card holder
pycdoc.encrypt("document.pdf", "38607080247", output="encrypted.cdoc")

# Get CDOC as bytes instead of writing to file
cdoc_bytes = pycdoc.encrypt("document.pdf", "38607080247")

# Encrypt raw bytes
pycdoc.encrypt(b"secret content", "38607080247", filename="secret.txt", output="encrypted.cdoc")

# Encrypt multiple files into one container
pycdoc.encrypt(["file1.pdf", "file2.docx"], "38607080247", output="bundle.cdoc")

The recipient can decrypt with DigiDoc4 Client or cdoc-tool.

API Overview

Core Classes

  • CDocReader - Read and decrypt CDOC containers
  • CDocWriter - Create and encrypt CDOC containers

Configuration

  • Configuration - Base configuration class (can be subclassed)
  • JSONConfiguration - JSON file-based configuration

Backends

  • CryptoBackend - Cryptographic operations backend (can be subclassed)
  • NetworkBackend - Network operations backend for key servers
  • PKCS11Backend - PKCS#11 hardware token backend (smart cards, HSMs)

Data Types

  • Recipient - Encryption recipient information
  • Lock - Decryption lock information
  • FileInfo - File metadata (name, size)
  • DataSource - Abstract data source for streaming
  • DataConsumer - Abstract data consumer for streaming

Result Codes

  • OK - Operation successful
  • WRONG_KEY - Incorrect decryption key
  • DATA_FORMAT_ERROR - Invalid container format
  • CRYPTO_ERROR - Cryptographic operation failed
  • PKCS11_ERROR - PKCS#11/smart card error

Use pycdoc.get_error_str(code) to get human-readable error descriptions.

Building from Source

  1. Clone the repository with submodules:
git clone --recurse-submodules https://github.com/namespace-ee/pycdoc.git
cd pycdoc
  1. Build the wheel:
uv build --wheel
  1. Install the wheel:
uv pip install dist/pycdoc-*.whl

Development

# Build wheel
uv build --wheel

# Install in development mode (rebuild required after changes)
uv pip install --force-reinstall dist/pycdoc-*.whl

# Run tests
uv run pytest tests/ -v

License

This library is licensed under the GNU Lesser General Public License v2.1 or later (LGPL-2.1-or-later).

See LICENSE for the full license text.

Links

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

pycdoc-0.1.2.tar.gz (460.3 kB view details)

Uploaded Source

Built Distributions

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

pycdoc-0.1.2-cp314-cp314-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.14Windows x86-64

pycdoc-0.1.2-cp314-cp314-manylinux_2_28_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

pycdoc-0.1.2-cp314-cp314-macosx_15_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

pycdoc-0.1.2-cp313-cp313-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.13Windows x86-64

pycdoc-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pycdoc-0.1.2-cp313-cp313-macosx_15_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pycdoc-0.1.2-cp312-cp312-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.12Windows x86-64

pycdoc-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pycdoc-0.1.2-cp312-cp312-macosx_15_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pycdoc-0.1.2-cp311-cp311-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.11Windows x86-64

pycdoc-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pycdoc-0.1.2-cp311-cp311-macosx_15_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pycdoc-0.1.2-cp310-cp310-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.10Windows x86-64

pycdoc-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pycdoc-0.1.2-cp310-cp310-macosx_15_0_arm64.whl (3.2 MB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file pycdoc-0.1.2.tar.gz.

File metadata

  • Download URL: pycdoc-0.1.2.tar.gz
  • Upload date:
  • Size: 460.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycdoc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 be4fcd6c8febfe8d8455d62519391d70c49f719a6fefd6fd505431057f3b30bc
MD5 902fc6e88b294ddabe63f8da9195c47d
BLAKE2b-256 09d8d764a2533b10272379866e2faff68e533c6cc7d5934d53f295e791e71347

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2.tar.gz:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: pycdoc-0.1.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycdoc-0.1.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1cd52958b5c05952dc2f2d6a6a7ef25f43da8698802dcf0120c9ae27ec467f58
MD5 a4f23f91a64b5840b640a4028a804d4e
BLAKE2b-256 32362f2a7f51d1a281b2fd04be98f16b8e8a7d76549a757c3d77abadbfdd394b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp314-cp314-win_amd64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bfe34f1733632e065edaf01f0e44d6c84e1821848588bca9f0d39640cc599133
MD5 483a1b7e980822646cd6ab370935ebbb
BLAKE2b-256 f6256dd6bb295c75aad6c3c4d805982be1cca747a2f216a4acbfe58b10381265

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp314-cp314-manylinux_2_28_x86_64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 43e518a2774cd19fb8f512c45fc5fb88565a9510a9b87e06f2457c32dbff76f0
MD5 7a0d3ff6255365dd9af4f1628e99b5a5
BLAKE2b-256 2f9a2226673e7dbde42dad8e5575e8ab5254c2cba8ecba237ef149f544d1d3d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp314-cp314-macosx_15_0_arm64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pycdoc-0.1.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycdoc-0.1.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 87bacbe921edb66a6967238e523be9579c086aac9bc417589a54002fc7b6ced0
MD5 6e9b8c8153e2bc7480bcec5deb65a692
BLAKE2b-256 9eb510299f16c56882efcfe2dc7093c7142ac76c2c2e0ad80c7b3b8fc91d9ed6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp313-cp313-win_amd64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a267858e3eb0e4e0e89b00933f8c5455dc7a7fb116d0cbd29fd989d8af002f1
MD5 2405827197fbbfc2d99eaecc4f32d879
BLAKE2b-256 062fa63c6c228211de065430639cc32fe3a9232f7c4524f4e1a238d96cc6a9df

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 546710d584d83fa688aa4c6b907be22e2058d9ad5b30bf2a4b4776d8e38acf56
MD5 cf1859869bdc314e9c83456b8a5acdf6
BLAKE2b-256 b008404913ecc0f39cc6d8c22e2c69fbe96e71c3c0896bb24a6a5dcec53b1449

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pycdoc-0.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycdoc-0.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 82b0d1191cb7ad1f0ff211ef06901e85c36714d5c212c5f7c42943430bf8c51e
MD5 0bb718d6962df2a1166ead18726ba27a
BLAKE2b-256 335891e77c8b6feea468527cf1a051a8e0330bc5c16e8211363f6ee5d1e7914d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp312-cp312-win_amd64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd36c51f695e1a00af14f0d3718b8773e1edd68e2f35c2d510e12e698fafad8d
MD5 267dff0937ad9bef81c4e42286a041f5
BLAKE2b-256 727073fac0bf26193f2bb63c3ae6887e1b660caf0426e99e5cbd24d47ec93b20

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2a4e12ac2c5f8daa440f95271fc63985c27cb106990c80923a29080f8f404611
MD5 0ea299d8145673279ad8866c49c7faf6
BLAKE2b-256 2ceb9a0686f3e2516c454f0e8163530b2bc7ddc026854bd4da3ad382e46cac1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pycdoc-0.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycdoc-0.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3111697576a5f2f9f000f55684b345e51d2e332bb9ce20ae61882e5aeee6b8f4
MD5 426fe877d9048490ee847f476c052328
BLAKE2b-256 b1973379e307a33a8f6493d3b5dd8c3eb70c9af40c43461540fe2ffa232a929d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp311-cp311-win_amd64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4e3265011527df2bf58ae52ceee1668b2a5ca403931643327982237da5c1f4a7
MD5 c64ea22a9d49204f758ecca30c853bb2
BLAKE2b-256 a9d91686208b60ced21f675cc0d066d716217395862b3830f37f50ed3b661bb0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d6d120fdfd9483cdca3ffbdb8125c4a53a10bd967cb97ecce9df2f241720c5c0
MD5 c72878d7a0a09759c79fcf1e75a1ad98
BLAKE2b-256 f951d261a761db11eeb7cbca669a8fa4c53e9126941612956e734978dbf7e6dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pycdoc-0.1.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycdoc-0.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cafc77a40904d840b5b79af0d3e82cee58e03a4b56137dadc2bd2696d6ecdada
MD5 1ade1555aa2670c617142d0078118821
BLAKE2b-256 95f5dbfcde1ad09bb7cbd7bf42030a7184420870d76b236544733869aafe8e12

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp310-cp310-win_amd64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ceb565fd1956d94979e8cc90fe8e03e4470bc9a05719f24835f4e70a6e167843
MD5 988f7c366c2a85416744d1eb377f8c3a
BLAKE2b-256 d5194f1aa4f65b0bcd6843bf86c09a3a80e1323ad05560688312ff953cf2924e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycdoc-0.1.2-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pycdoc-0.1.2-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 efbd6b644f3302f47aeb8e288a6f160faa84fbf2430ca0be5a04de838b01b7e8
MD5 7302f0c32faa5e50f9c2cc8ba114aa74
BLAKE2b-256 ad8c41959051d5308d7e0c0590f923a6b6b3cbd90c2aa84500c3743f954e7ab6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycdoc-0.1.2-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: build.yml on namespace-ee/pycdoc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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