python-pkcs11 0.8.1__tar.gz → 0.9.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. python_pkcs11-0.9.1/.github/actions/install-opencryptoki/action.yml +58 -0
  2. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/.github/actions/install-softhsm/action.yml +11 -12
  3. python_pkcs11-0.9.1/.github/actions/test-setup/action.yml +87 -0
  4. python_pkcs11-0.9.1/.github/workflows/coverage.yml +101 -0
  5. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/.github/workflows/release.yml +2 -2
  6. python_pkcs11-0.9.1/.github/workflows/tests.yml +87 -0
  7. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/.gitignore +4 -1
  8. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/PKG-INFO +4 -2
  9. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/README.rst +2 -1
  10. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/extern/pkcs11t.h +2 -0
  11. python_pkcs11-0.9.1/pkcs11/__init__.py +44 -0
  12. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/_pkcs11.pxd +198 -21
  13. python_pkcs11-0.9.1/pkcs11/_pkcs11.pyx +2194 -0
  14. python_pkcs11-0.9.1/pkcs11/attributes.py +240 -0
  15. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/constants.py +27 -0
  16. python_pkcs11-0.9.1/pkcs11/defaults.py +106 -0
  17. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/exceptions.py +0 -6
  18. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/mechanisms.py +21 -0
  19. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/types.py +217 -169
  20. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/util/dh.py +2 -2
  21. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/util/dsa.py +2 -2
  22. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/util/ec.py +2 -2
  23. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/util/rsa.py +4 -4
  24. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/util/x509.py +7 -2
  25. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pyproject.toml +25 -1
  26. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/python_pkcs11.egg-info/PKG-INFO +4 -2
  27. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/python_pkcs11.egg-info/SOURCES.txt +5 -1
  28. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_aes.py +358 -1
  29. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_digest.py +27 -0
  30. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_ecc.py +9 -29
  31. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_iterators.py +0 -5
  32. python_pkcs11-0.9.1/tests/test_multilib.py +26 -0
  33. python_pkcs11-0.9.1/tests/test_rsa.py +250 -0
  34. python_pkcs11-0.9.1/tests/test_sessions.py +343 -0
  35. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_slots_and_tokens.py +45 -4
  36. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_x509.py +17 -20
  37. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/uv.lock +109 -0
  38. python_pkcs11-0.8.1/.github/workflows/tests.yml +0 -45
  39. python_pkcs11-0.8.1/Dockerfile +0 -27
  40. python_pkcs11-0.8.1/pkcs11/__init__.py +0 -36
  41. python_pkcs11-0.8.1/pkcs11/_pkcs11.pyx +0 -1891
  42. python_pkcs11-0.8.1/pkcs11/defaults.py +0 -197
  43. python_pkcs11-0.8.1/tests/test_rsa.py +0 -120
  44. python_pkcs11-0.8.1/tests/test_sessions.py +0 -159
  45. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/.github/release-template.md +0 -0
  46. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/.github/workflows/quality.yml +0 -0
  47. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/.python-version +0 -0
  48. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/.readthedocs.yaml +0 -0
  49. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/LICENSE +0 -0
  50. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/MANIFEST.in +0 -0
  51. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/Makefile +0 -0
  52. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/api.rst +0 -0
  53. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/applied.rst +0 -0
  54. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/concurrency.rst +0 -0
  55. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/conf.py +0 -0
  56. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/index.rst +0 -0
  57. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/make.bat +0 -0
  58. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/docs/opensc.rst +0 -0
  59. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/extern/.gitignore +0 -0
  60. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/extern/cryptoki.h +0 -0
  61. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/extern/load_module.c +0 -0
  62. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/extern/load_module.h +0 -0
  63. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/extern/pkcs11.h +0 -0
  64. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/extern/pkcs11f.h +0 -0
  65. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/pkcs11/util/__init__.py +0 -0
  66. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/python_pkcs11.egg-info/dependency_links.txt +0 -0
  67. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/python_pkcs11.egg-info/requires.txt +0 -0
  68. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/python_pkcs11.egg-info/top_level.txt +0 -0
  69. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/setup.cfg +0 -0
  70. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/__init__.py +0 -0
  71. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_des.py +0 -0
  72. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_dh.py +0 -0
  73. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_dsa.py +0 -0
  74. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_public_key_external.py +0 -0
  75. {python_pkcs11-0.8.1 → python_pkcs11-0.9.1}/tests/test_threading.py +0 -0
@@ -0,0 +1,58 @@
1
+ name: install-opencryptoki
2
+ author: Matthias Valvekens
3
+ description: Install opencryptoki and configure an empty token
4
+ inputs:
5
+ os:
6
+ description: OS to target
7
+ required: true
8
+ token-label:
9
+ description: Label assigned to the token
10
+ required: true
11
+ token-user-pin:
12
+ description: User PIN to configure on the token
13
+ required: true
14
+ token-so-pin:
15
+ description: Security officer PIN to configure on the token
16
+ required: true
17
+ outputs:
18
+ module:
19
+ description: Path to PKCS#11 module
20
+ value: ${{ steps.install.outputs.module }}
21
+ runs:
22
+ using: "composite"
23
+ steps:
24
+ - name: Install opencryptoki
25
+ id: install
26
+ shell: bash
27
+ run: |
28
+ if [[ "${OS_NAME:0:6}" == 'ubuntu' ]]; then
29
+ sudo apt install libcap-dev libldap-dev
30
+ git clone https://github.com/opencryptoki/opencryptoki
31
+ cd opencryptoki
32
+ ./bootstrap.sh
33
+ ./configure --prefix=/usr --sysconfdir=/etc \
34
+ --with-pkcs-group=users \
35
+ --disable-tpmtok --disable-ccatok --disable-ep11tok --disable-icsftok \
36
+ --disable-p11sak --disable-pkcstok_migrate --disable-pkcsstats
37
+ make
38
+ sudo make install
39
+ sudo ldconfig
40
+ echo -e "slot 0\n{\nstdll = libpkcs11_sw.so\ntokversion = 3.12\n}" > /tmp/opencryptoki.conf
41
+ sudo cp /tmp/opencryptoki.conf /etc/opencryptoki/
42
+ sudo chown root:root /etc/opencryptoki/opencryptoki.conf
43
+ echo "module=/usr/lib/opencryptoki/libopencryptoki.so" >> "$GITHUB_OUTPUT"
44
+ else
45
+ echo "$OS_NAME is not a supported target system"
46
+ exit 1
47
+ fi
48
+ env:
49
+ OS_NAME: ${{ inputs.os }}
50
+ - name: Run opencryptoki daemon
51
+ shell: bash
52
+ run: sudo -u pkcsslotd pkcsslotd
53
+ - name: Initialize token
54
+ shell: bash
55
+ run: |
56
+ echo "${{ inputs.token-label }}" | pkcsconf -I -c 0 -S 87654321
57
+ pkcsconf -P -c 0 -S 87654321 -n "${{ inputs.token-so-pin }}"
58
+ pkcsconf -u -c 0 -S "${{ inputs.token-so-pin }}" -n "${{ inputs.token-user-pin }}"
@@ -7,20 +7,22 @@ inputs:
7
7
  required: true
8
8
  token-label:
9
9
  description: Label assigned to the token
10
- required: false
11
- default: TEST
10
+ required: true
12
11
  token-user-pin:
13
12
  description: User PIN to configure on the token
14
- required: false
15
- default: "1234"
13
+ required: true
16
14
  token-so-pin:
17
15
  description: Security officer PIN to configure on the token
18
- required: false
19
- default: "5678"
16
+ required: true
17
+ outputs:
18
+ module:
19
+ description: Path to PKCS#11 module
20
+ value: ${{ steps.install.outputs.module }}
20
21
  runs:
21
22
  using: "composite"
22
23
  steps:
23
24
  - name: Install SoftHSM
25
+ id: install
24
26
  shell: bash
25
27
  run: |
26
28
  if [[ "${OS_NAME:0:6}" == 'ubuntu' ]]; then
@@ -28,14 +30,14 @@ runs:
28
30
  mkdir softhsm_tokens
29
31
  echo "directories.tokendir = $(pwd)/softhsm_tokens" > /tmp/softhsm2.conf
30
32
  echo "SOFTHSM2_CONF=/tmp/softhsm2.conf" >> "$GITHUB_ENV"
31
- echo "PKCS11_MODULE=/usr/lib/softhsm/libsofthsm2.so" >> "$GITHUB_ENV"
33
+ echo "module=/usr/lib/softhsm/libsofthsm2.so" >> "$GITHUB_OUTPUT"
32
34
  elif [[ "${OS_NAME:0:5}" == 'macos' ]]; then
33
35
  brew install softhsm
34
- echo "PKCS11_MODULE=/opt/homebrew/lib/softhsm/libsofthsm2.so" >> "$GITHUB_ENV"
36
+ echo "module=/opt/homebrew/lib/softhsm/libsofthsm2.so" >> "$GITHUB_OUTPUT"
35
37
  elif [[ "${OS_NAME:0:7}" == 'windows' ]]; then
36
38
  choco install softhsm.install
37
39
  echo "SOFTHSM2_CONF=D:/SoftHSM2/etc/softhsm2.conf" >> "$GITHUB_ENV"
38
- echo "PKCS11_MODULE=D:/SoftHSM2/lib/softhsm2-x64.dll" >> "$GITHUB_ENV"
40
+ echo "module=D:/SoftHSM2/lib/softhsm2-x64.dll" >> "$GITHUB_OUTPUT"
39
41
  echo "D:/SoftHSM2/bin" >> "$GITHUB_PATH"
40
42
  echo "D:/SoftHSM2/lib" >> "$GITHUB_PATH"
41
43
  else
@@ -49,6 +51,3 @@ runs:
49
51
  run: |
50
52
  softhsm2-util --init-token --free --label "${{ inputs.token-label }}" \
51
53
  --pin "${{ inputs.token-user-pin }}" --so-pin "${{ inputs.token-so-pin }}"
52
- echo "PKCS11_TOKEN_LABEL=${{ inputs.token-label }}" >> "$GITHUB_ENV"
53
- echo "PKCS11_TOKEN_PIN=${{ inputs.token-user-pin }}" >> "$GITHUB_ENV"
54
- echo "PKCS11_TOKEN_SO_PIN=${{ inputs.token-so-pin }}" >> "$GITHUB_ENV"
@@ -0,0 +1,87 @@
1
+ name: test-setup
2
+ author: Matthias Valvekens
3
+ description: Perform set-up for python-pkcs11 CI
4
+ inputs:
5
+ os:
6
+ description: OS to target
7
+ required: true
8
+ python-version:
9
+ description: Python version to target
10
+ required: true
11
+ dependency-group:
12
+ description: UV dependency group to install
13
+ required: true
14
+ pkcs11-platform:
15
+ description: PKCS#11 platform to target
16
+ required: true
17
+ token-label:
18
+ description: Label assigned to the token
19
+ required: true
20
+ token-user-pin:
21
+ description: User PIN to configure on the token
22
+ required: true
23
+ token-so-pin:
24
+ description: Security officer PIN to configure on the token
25
+ required: true
26
+ outputs:
27
+ module:
28
+ description: Path to PKCS#11 module
29
+ value: ${{ steps.install-result.outputs.module }}
30
+ module2:
31
+ description: Path to alternative PKCS#11 module ('multi' only)
32
+ value: ${{ steps.install-result.outputs.module2 }}
33
+ runs:
34
+ using: "composite"
35
+ steps:
36
+ - name: Setup Python
37
+ uses: actions/setup-python@v5
38
+ with:
39
+ python-version: ${{ inputs.python-version }}
40
+ - uses: ./.github/actions/install-softhsm
41
+ if: inputs.pkcs11-platform == 'softhsm' || inputs.pkcs11-platform == 'multi'
42
+ id: softhsm
43
+ with:
44
+ os: ${{ inputs.os }}
45
+ token-label: ${{ inputs.token-label }}
46
+ token-so-pin: ${{ inputs.token-so-pin }}
47
+ token-user-pin: ${{ inputs.token-user-pin }}
48
+ - uses: ./.github/actions/install-opencryptoki
49
+ # only run opencryptoki tests on ubuntu
50
+ # (macos and windows don't seem to be supported)
51
+ if: inputs.pkcs11-platform == 'opencryptoki' || inputs.pkcs11-platform == 'multi'
52
+ id: opencryptoki
53
+ with:
54
+ os: ${{ inputs.os }}
55
+ token-label: ${{ inputs.token-label }}
56
+ token-so-pin: ${{ inputs.token-so-pin }}
57
+ token-user-pin: ${{ inputs.token-user-pin }}
58
+ - name: Set module path
59
+ id: install-result
60
+ shell: bash
61
+ run: |
62
+ if [[ "$PLATFORM" == 'opencryptoki' ]]; then
63
+ echo "module=${{ steps.opencryptoki.outputs.module }}" >> "$GITHUB_OUTPUT"
64
+ elif [[ "$PLATFORM" == 'softhsm' ]]; then
65
+ echo "module=${{ steps.softhsm.outputs.module }}" >> "$GITHUB_OUTPUT"
66
+ elif [[ "$PLATFORM" == 'multi' ]]; then
67
+ # NOTE: the 'multi' platform is only used for testing the code that
68
+ # swaps between multiple PKCS#11 implementations. As such, any two
69
+ # PKCS#11 implementations will do. If we add a 3rd platform
70
+ # to the CI at a later stage that is faster to install than opencryptoki,
71
+ # switching is an option.
72
+ echo "module=${{ steps.softhsm.outputs.module }}" >> "$GITHUB_OUTPUT"
73
+ echo "module2=${{ steps.opencryptoki.outputs.module }}" >> "$GITHUB_OUTPUT"
74
+ else
75
+ echo "$PLATFORM is not a valid PKCS#11 platform choice"
76
+ exit 1
77
+ fi
78
+ env:
79
+ PLATFORM: ${{ inputs.pkcs11-platform }}
80
+ - name: Install uv
81
+ uses: astral-sh/setup-uv@v4
82
+ with:
83
+ enable-cache: true
84
+ python-version: ${{ inputs.python-version }}
85
+ - name: Install testing dependencies
86
+ shell: bash
87
+ run: uv sync --no-dev --exact --group "${{ inputs.dependency-group }}"
@@ -0,0 +1,101 @@
1
+ name: Coverage
2
+ on:
3
+ pull_request: {}
4
+ push:
5
+ branches: ["master"]
6
+ workflow_dispatch: {}
7
+ env:
8
+ UV_PYTHON_PREFERENCE: only-system
9
+ UV_NO_SYNC: "1"
10
+ PKCS11_TOKEN_LABEL: "TEST"
11
+ PKCS11_TOKEN_PIN: "1234"
12
+ PKCS11_TOKEN_SO_PIN: "5678"
13
+ jobs:
14
+ # For now, we run the coverage as a separate job.
15
+ # At the time of writing, the latest version of Cython's line tracing
16
+ # seems to lead to segfaults in Python 3.13 -> TODO: investigate
17
+ pytest-coverage:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ pkcs11-platform:
22
+ - softhsm
23
+ - opencryptoki
24
+ steps:
25
+ - name: Acquire sources
26
+ uses: actions/checkout@v4
27
+ - name: Arm coverage-only compiler directives
28
+ # Unfortunately, it doesn't seem to be possible to pass directives
29
+ # to Cython through environment variables: https://github.com/cython/cython/issues/3930
30
+ # Doing it here is still better than introducing a non-declarative setup.py into the
31
+ # build again.
32
+ run: sed -i 's/#coverage#cython/#cython/g' pkcs11/*.pyx
33
+ - uses: ./.github/actions/test-setup
34
+ id: setup
35
+ with:
36
+ os: ubuntu-latest
37
+ python-version: "3.12"
38
+ dependency-group: coverage
39
+ token-label: ${{ env.PKCS11_TOKEN_LABEL }}
40
+ token-so-pin: ${{ env.PKCS11_TOKEN_SO_PIN }}
41
+ token-user-pin: ${{ env.PKCS11_TOKEN_PIN }}
42
+ pkcs11-platform: ${{ matrix.pkcs11-platform }}
43
+ env:
44
+ CFLAGS: "-DCYTHON_TRACE_NOGIL=1"
45
+ EXT_BUILD_DEBUG: "1"
46
+ - name: Run tests
47
+ run: uv run pytest -v --cov=pkcs11 --cov-branch --cov-report=xml:${{ matrix.pkcs11-platform }}-coverage.xml
48
+ env:
49
+ PKCS11_MODULE: ${{ steps.setup.outputs.module }}
50
+ - name: Stash coverage report
51
+ uses: actions/upload-artifact@v4
52
+ with:
53
+ name: coverage-${{ strategy.job-index }}
54
+ path: "*-coverage.xml"
55
+ pytest-coverage-multilib:
56
+ runs-on: ubuntu-latest
57
+ steps:
58
+ - name: Acquire sources
59
+ uses: actions/checkout@v4
60
+ - uses: ./.github/actions/test-setup
61
+ id: setup
62
+ with:
63
+ os: ubuntu-latest
64
+ pkcs11-platform: multi
65
+ token-label: ${{ env.PKCS11_TOKEN_LABEL }}
66
+ token-so-pin: ${{ env.PKCS11_TOKEN_SO_PIN }}
67
+ token-user-pin: ${{ env.PKCS11_TOKEN_PIN }}
68
+ python-version: "3.12"
69
+ dependency-group: coverage
70
+ - name: Run tests
71
+ run: uv run pytest -v --cov=pkcs11 --cov-branch --cov-report=xml:multilib-coverage.xml tests/test_multilib.py
72
+ env:
73
+ PKCS11_MODULE: ${{ steps.setup.outputs.module }}
74
+ PKCS11_MODULE2: ${{ steps.setup.outputs.module2 }}
75
+ - name: Stash coverage report
76
+ uses: actions/upload-artifact@v4
77
+ with:
78
+ name: coverage-multilib
79
+ path: "*-coverage.xml"
80
+ codecov-upload:
81
+ permissions:
82
+ actions: write
83
+ contents: read
84
+ runs-on: ubuntu-latest
85
+ needs: [pytest-coverage,pytest-coverage-multilib]
86
+ steps:
87
+ # checkout necessary to ensure the uploaded report contains the correct paths
88
+ - uses: actions/checkout@v4
89
+ - name: Retrieve coverage reports
90
+ uses: actions/download-artifact@v4
91
+ with:
92
+ pattern: coverage-*
93
+ path: ./reports/
94
+ - name: Upload all coverage reports to Codecov
95
+ uses: codecov/codecov-action@v5
96
+ with:
97
+ token: ${{ secrets.CODECOV_TOKEN }}
98
+ directory: ./reports/
99
+ flags: unittests
100
+ env_vars: OS,PYTHON
101
+ name: codecov-umbrella
@@ -73,7 +73,7 @@ jobs:
73
73
  - ubuntu-latest
74
74
  - ubuntu-24.04-arm
75
75
  - windows-latest
76
- - macos-latest
76
+ - macos-14
77
77
  steps:
78
78
  - uses: actions/checkout@v4
79
79
  - name: Setup Python
@@ -141,4 +141,4 @@ jobs:
141
141
  dist/*.tar.gz
142
142
  body_path: release-body/release.md
143
143
  fail_on_unmatched_files: true
144
- name: python-pkcs11 ${{ needs.extract-params.outputs.version }}
144
+ name: v${{ needs.extract-params.outputs.version }}
@@ -0,0 +1,87 @@
1
+ name: Tests
2
+ on:
3
+ push:
4
+ branches: ["**"]
5
+ pull_request: {}
6
+ workflow_dispatch: {}
7
+ env:
8
+ UV_PYTHON_PREFERENCE: only-system
9
+ UV_NO_SYNC: "1"
10
+ PKCS11_TOKEN_LABEL: "TEST"
11
+ PKCS11_TOKEN_PIN: "1234"
12
+ PKCS11_TOKEN_SO_PIN: "5678"
13
+ jobs:
14
+ tests:
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ # Our test suite is pretty fast, so fail-fast: false allows for better troubleshooting.
18
+ fail-fast: false
19
+ matrix:
20
+ os:
21
+ - ubuntu-latest
22
+ - windows-latest
23
+ - macos-14
24
+ python-version:
25
+ - "3.9"
26
+ - "3.10"
27
+ - "3.11"
28
+ - "3.12"
29
+ - "3.13"
30
+ - "3.14"
31
+ pkcs11-platform:
32
+ - softhsm
33
+ - opencryptoki
34
+ exclude:
35
+ # only run opencryptoki tests on ubuntu
36
+ # (macos and windows don't seem to be supported)
37
+ - pkcs11-platform: opencryptoki
38
+ os: windows-latest
39
+ - pkcs11-platform: opencryptoki
40
+ os: macos-14
41
+ steps:
42
+ - name: Acquire sources
43
+ uses: actions/checkout@v4
44
+ - uses: ./.github/actions/test-setup
45
+ id: setup
46
+ with:
47
+ os: ${{ matrix.os }}
48
+ token-label: ${{ env.PKCS11_TOKEN_LABEL }}
49
+ token-so-pin: ${{ env.PKCS11_TOKEN_SO_PIN }}
50
+ token-user-pin: ${{ env.PKCS11_TOKEN_PIN }}
51
+ python-version: ${{ matrix.python-version }}
52
+ pkcs11-platform: ${{ matrix.pkcs11-platform }}
53
+ dependency-group: testing
54
+ - name: Run tests
55
+ run: uv run pytest -v
56
+ env:
57
+ PKCS11_MODULE: ${{ steps.setup.outputs.module }}
58
+ multilib-tests:
59
+ runs-on: ubuntu-latest
60
+ strategy:
61
+ fail-fast: false
62
+ matrix:
63
+ python-version:
64
+ - "3.9"
65
+ - "3.10"
66
+ - "3.11"
67
+ - "3.12"
68
+ - "3.13"
69
+ - "3.14"
70
+ steps:
71
+ - name: Acquire sources
72
+ uses: actions/checkout@v4
73
+ - uses: ./.github/actions/test-setup
74
+ id: setup
75
+ with:
76
+ os: ubuntu-latest
77
+ pkcs11-platform: multi
78
+ token-label: ${{ env.PKCS11_TOKEN_LABEL }}
79
+ token-so-pin: ${{ env.PKCS11_TOKEN_SO_PIN }}
80
+ token-user-pin: ${{ env.PKCS11_TOKEN_PIN }}
81
+ python-version: ${{ matrix.python-version }}
82
+ dependency-group: testing
83
+ - name: Run tests
84
+ run: uv run pytest -v tests/test_multilib.py
85
+ env:
86
+ PKCS11_MODULE: ${{ steps.setup.outputs.module }}
87
+ PKCS11_MODULE2: ${{ steps.setup.outputs.module2 }}
@@ -6,4 +6,7 @@ __pycache__
6
6
  /dist/
7
7
  /docs/_build
8
8
  /python_pkcs11.egg-info/
9
- /.eggs/
9
+ /.eggs/
10
+ .coverage
11
+ *coverage.xml
12
+ *.html
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-pkcs11
3
- Version: 0.8.1
3
+ Version: 0.9.1
4
4
  Summary: PKCS#11 support for Python
5
5
  Author-email: Andrey Kislyuk <kislyuk@gmail.com>, Danielle Madeley <danielle@madeley.id.au>
6
6
  Maintainer-email: Andrey Kislyuk <kislyuk@gmail.com>
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
19
20
  Classifier: Topic :: Security :: Cryptography
20
21
  Requires-Python: >=3.9
21
22
  Description-Content-Type: text/x-rst
@@ -45,7 +46,8 @@ features.
45
46
 
46
47
  Historically, this project used to run continuous integration tests against several
47
48
  HSM platforms, but this test setup has not been maintained over time. Currently,
48
- the integration tests in GitHub Actions use SoftHSMv2 as a baseline. If you would like
49
+ the integration tests in GitHub Actions use SoftHSMv2 as a baseline.
50
+ We also test against ``opencryptoki`` in CI. If you would like
49
51
  to contribute some CI setup with additional PKCS#11 implementations or actual HSMs,
50
52
  let's chat!
51
53
 
@@ -20,7 +20,8 @@ features.
20
20
 
21
21
  Historically, this project used to run continuous integration tests against several
22
22
  HSM platforms, but this test setup has not been maintained over time. Currently,
23
- the integration tests in GitHub Actions use SoftHSMv2 as a baseline. If you would like
23
+ the integration tests in GitHub Actions use SoftHSMv2 as a baseline.
24
+ We also test against ``opencryptoki`` in CI. If you would like
24
25
  to contribute some CI setup with additional PKCS#11 implementations or actual HSMs,
25
26
  let's chat!
26
27
 
@@ -270,6 +270,8 @@ typedef CK_ULONG CK_USER_TYPE;
270
270
  #define CKU_USER 1UL
271
271
  /* Context specific */
272
272
  #define CKU_CONTEXT_SPECIFIC 2UL
273
+ /* Value used in python-pkcs11 as a sentinel value for non-logged in sessions */
274
+ #define CKU_USER_NOBODY 999UL
273
275
 
274
276
  /* CK_STATE enumerates the session states */
275
277
  typedef CK_ULONG CK_STATE;
@@ -0,0 +1,44 @@
1
+ """
2
+ :mod:`pkcs11` defines a high-level, "Pythonic" interface to PKCS#11.
3
+ """
4
+
5
+ from pkcs11.constants import * # noqa: F403
6
+ from pkcs11.exceptions import * # noqa: F403
7
+ from pkcs11.mechanisms import * # noqa: F403
8
+ from pkcs11.types import * # noqa: F403
9
+ from pkcs11.util import dh, dsa, ec, rsa, x509 # noqa: F401
10
+
11
+ _loaded = {}
12
+
13
+
14
+ def lib(so):
15
+ """
16
+ Wrap the main library call coming from Cython with a preemptive
17
+ dynamic loading.
18
+ """
19
+ global _loaded
20
+
21
+ try:
22
+ _lib = _loaded[so]
23
+ if not _lib.initialized:
24
+ _lib.initialize()
25
+ return _lib
26
+ except KeyError:
27
+ pass
28
+
29
+ from . import _pkcs11
30
+
31
+ _lib = _pkcs11.lib(so)
32
+ _loaded[so] = _lib
33
+
34
+ return _lib
35
+
36
+
37
+ def unload(so):
38
+ global _loaded
39
+ try:
40
+ loaded_lib = _loaded[so]
41
+ except KeyError:
42
+ return
43
+ del _loaded[so]
44
+ loaded_lib.unload()