python-pkcs11 0.7.0__tar.gz → 0.8.0__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 (86) hide show
  1. python_pkcs11-0.8.0/.github/actions/install-softhsm/action.yml +54 -0
  2. python_pkcs11-0.8.0/.github/release-template.md +1 -0
  3. python_pkcs11-0.8.0/.github/workflows/quality.yml +33 -0
  4. python_pkcs11-0.8.0/.github/workflows/release.yml +144 -0
  5. python_pkcs11-0.8.0/.github/workflows/tests.yml +47 -0
  6. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/.gitignore +1 -1
  7. python_pkcs11-0.8.0/.python-version +1 -0
  8. python_pkcs11-0.8.0/.readthedocs.yaml +16 -0
  9. python_pkcs11-0.8.0/Dockerfile +27 -0
  10. python_pkcs11-0.8.0/LICENSE +21 -0
  11. python_pkcs11-0.8.0/MANIFEST.in +2 -0
  12. python_pkcs11-0.8.0/PKG-INFO +392 -0
  13. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/README.rst +21 -11
  14. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/Makefile +4 -4
  15. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/api.rst +11 -0
  16. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/conf.py +37 -34
  17. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/opensc.rst +1 -1
  18. python_pkcs11-0.8.0/extern/.gitignore +1 -0
  19. python_pkcs11-0.8.0/extern/load_module.c +99 -0
  20. python_pkcs11-0.8.0/extern/load_module.h +21 -0
  21. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/extern/pkcs11.h +33 -49
  22. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/extern/pkcs11f.h +266 -6
  23. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/extern/pkcs11t.h +535 -19
  24. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/__init__.py +3 -2
  25. python-pkcs11-0.7.0/pkcs11/_pkcs11_defn.pxd → python_pkcs11-0.8.0/pkcs11/_pkcs11.pxd +55 -0
  26. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/_pkcs11.pyx +521 -194
  27. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/constants.py +11 -11
  28. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/defaults.py +10 -9
  29. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/exceptions.py +14 -8
  30. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/mechanisms.py +56 -5
  31. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/types.py +148 -114
  32. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/util/__init__.py +1 -2
  33. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/util/dh.py +10 -9
  34. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/util/dsa.py +13 -11
  35. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/util/ec.py +18 -16
  36. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/util/rsa.py +19 -18
  37. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/pkcs11/util/x509.py +32 -28
  38. python_pkcs11-0.8.0/pyproject.toml +99 -0
  39. python_pkcs11-0.8.0/python_pkcs11.egg-info/PKG-INFO +392 -0
  40. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/python_pkcs11.egg-info/SOURCES.txt +17 -17
  41. python_pkcs11-0.8.0/python_pkcs11.egg-info/requires.txt +1 -0
  42. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/__init__.py +28 -21
  43. python_pkcs11-0.8.0/tests/test_aes.py +389 -0
  44. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_des.py +4 -4
  45. python_pkcs11-0.8.0/tests/test_dh.py +387 -0
  46. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_digest.py +25 -22
  47. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_dsa.py +14 -13
  48. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_ecc.py +62 -31
  49. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_iterators.py +8 -11
  50. python_pkcs11-0.8.0/tests/test_public_key_external.py +170 -0
  51. python_pkcs11-0.8.0/tests/test_rsa.py +120 -0
  52. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_sessions.py +42 -43
  53. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_slots_and_tokens.py +2 -3
  54. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_threading.py +5 -9
  55. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/tests/test_x509.py +135 -122
  56. python_pkcs11-0.8.0/uv.lock +932 -0
  57. python-pkcs11-0.7.0/.travis.yml +0 -45
  58. python-pkcs11-0.7.0/PKG-INFO +0 -375
  59. python-pkcs11-0.7.0/dev-requirements.in +0 -11
  60. python-pkcs11-0.7.0/dev-requirements.txt +0 -46
  61. python-pkcs11-0.7.0/pkcs11/_errors.pyx +0 -89
  62. python-pkcs11-0.7.0/pkcs11/_mswin.pxd +0 -109
  63. python-pkcs11-0.7.0/pkcs11/_utils.pyx +0 -38
  64. python-pkcs11-0.7.0/python_pkcs11.egg-info/PKG-INFO +0 -375
  65. python-pkcs11-0.7.0/python_pkcs11.egg-info/requires.txt +0 -5
  66. python-pkcs11-0.7.0/requirements.in +0 -3
  67. python-pkcs11-0.7.0/requirements.txt +0 -9
  68. python-pkcs11-0.7.0/setup.py +0 -61
  69. python-pkcs11-0.7.0/tests/test_aes.py +0 -125
  70. python-pkcs11-0.7.0/tests/test_dh.py +0 -125
  71. python-pkcs11-0.7.0/tests/test_public_key_external.py +0 -167
  72. python-pkcs11-0.7.0/tests/test_rsa.py +0 -120
  73. python-pkcs11-0.7.0/tools/buildbot/build.sh +0 -11
  74. python-pkcs11-0.7.0/tools/buildbot/install.sh +0 -16
  75. python-pkcs11-0.7.0/tools/buildbot/test.sh +0 -16
  76. python-pkcs11-0.7.0/tools/nfast/build.sh +0 -14
  77. python-pkcs11-0.7.0/tools/nfast/install.sh +0 -19
  78. python-pkcs11-0.7.0/tools/nfast/test.sh +0 -22
  79. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/applied.rst +0 -0
  80. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/concurrency.rst +0 -0
  81. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/index.rst +0 -0
  82. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/docs/make.bat +0 -0
  83. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/extern/cryptoki.h +0 -0
  84. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/python_pkcs11.egg-info/dependency_links.txt +0 -0
  85. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/python_pkcs11.egg-info/top_level.txt +0 -0
  86. {python-pkcs11-0.7.0 → python_pkcs11-0.8.0}/setup.cfg +0 -0
@@ -0,0 +1,54 @@
1
+ name: install-softhsm
2
+ author: Matthias Valvekens
3
+ description: Install SoftHSM 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: false
11
+ default: TEST
12
+ token-user-pin:
13
+ description: User PIN to configure on the token
14
+ required: false
15
+ default: "1234"
16
+ token-so-pin:
17
+ description: Security officer PIN to configure on the token
18
+ required: false
19
+ default: "5678"
20
+ runs:
21
+ using: "composite"
22
+ steps:
23
+ - name: Install SoftHSM
24
+ shell: bash
25
+ run: |
26
+ if [[ "${OS_NAME:0:6}" == 'ubuntu' ]]; then
27
+ sudo apt-get install softhsm2
28
+ mkdir softhsm_tokens
29
+ echo "directories.tokendir = $(pwd)/softhsm_tokens" > /tmp/softhsm2.conf
30
+ echo "SOFTHSM2_CONF=/tmp/softhsm2.conf" >> "$GITHUB_ENV"
31
+ echo "PKCS11_MODULE=/usr/lib/softhsm/libsofthsm2.so" >> "$GITHUB_ENV"
32
+ elif [[ "${OS_NAME:0:5}" == 'macos' ]]; then
33
+ brew install softhsm
34
+ echo "PKCS11_MODULE=/opt/homebrew/lib/softhsm/libsofthsm2.so" >> "$GITHUB_ENV"
35
+ elif [[ "${OS_NAME:0:7}" == 'windows' ]]; then
36
+ choco install softhsm.install
37
+ echo "SOFTHSM2_CONF=D:/SoftHSM2/etc/softhsm2.conf" >> "$GITHUB_ENV"
38
+ echo "PKCS11_MODULE=D:/SoftHSM2/lib/softhsm2-x64.dll" >> "$GITHUB_ENV"
39
+ echo "D:/SoftHSM2/bin" >> "$GITHUB_PATH"
40
+ echo "D:/SoftHSM2/lib" >> "$GITHUB_PATH"
41
+ else
42
+ echo "$OS_NAME is not a supported target system"
43
+ exit 1
44
+ fi
45
+ env:
46
+ OS_NAME: ${{ inputs.os }}
47
+ - name: Initialize SoftHSM token
48
+ shell: bash
49
+ run: |
50
+ softhsm2-util --init-token --free --label "${{ inputs.token-label }}" \
51
+ --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 @@
1
+ A source distribution and wheels for common platforms have been published to [PyPI](https://pypi.org/project/python-pkcs11/:VERSION).
@@ -0,0 +1,33 @@
1
+ name: Code quality
2
+ on:
3
+ push: {}
4
+ pull_request: {}
5
+ env:
6
+ UV_PYTHON_PREFERENCE: only-system
7
+ UV_NO_SYNC: "1"
8
+ jobs:
9
+ run:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Acquire sources
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v4
17
+ with:
18
+ enable-cache: true
19
+
20
+ - name: Setup Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.13"
24
+ architecture: x64
25
+
26
+ - name: Install lint dependencies
27
+ run: uv sync --no-dev --exact --group lint
28
+
29
+ - name: ruff format
30
+ run: uv run ruff format --diff .
31
+
32
+ - name: ruff check
33
+ run: uv run ruff check --diff .
@@ -0,0 +1,144 @@
1
+ name: Publish release to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v[0-9]+.[0-9]+.[0-9]+'
7
+ workflow_dispatch:
8
+ inputs:
9
+ environment:
10
+ type: environment
11
+ description: "Environment in which to execute the release process"
12
+ env:
13
+ UV_PYTHON_PREFERENCE: only-system
14
+ # we do all UV syncing explicitly
15
+ UV_NO_SYNC: "1"
16
+ jobs:
17
+ extract-params:
18
+ name: Determine release parameters
19
+ runs-on: ubuntu-latest
20
+ permissions: {}
21
+ outputs:
22
+ publish-env: ${{ steps.setenv.outputs.envname }}
23
+ version: ${{ steps.getrelease.outputs.version }}
24
+ steps:
25
+ - id: setenv
26
+ run: |
27
+ if [[ $GITHUB_EVENT_NAME == 'workflow_dispatch' ]]; then
28
+ echo "envname=${{ inputs.environment }}" >> "$GITHUB_OUTPUT"
29
+ elif [[ $GITHUB_EVENT_NAME == 'push' ]]; then
30
+ echo "envname=pypi" >> "$GITHUB_OUTPUT"
31
+ else
32
+ echo "Cannot run release workflow for trigger event $GITHUB_EVENT_NAME"
33
+ exit 1
34
+ fi
35
+ cat "$GITHUB_OUTPUT"
36
+ - name: Get version information
37
+ id: getrelease
38
+ run: |
39
+ set -eo pipefail
40
+
41
+ VER_REGEX="v[0-9]\+\.[0-9]\+\..\+"
42
+ if [[ "${GITHUB_REF:0:11}" != 'refs/tags/v' ]]; then
43
+ echo "Cannot run release workflow for ref $GITHUB_REF, must be a tag starting with 'v'"
44
+ exit 1
45
+ fi
46
+ VERSION=${GITHUB_REF:10}
47
+
48
+ if echo $VERSION | grep -q "$VER_REGEX"; then
49
+ echo "version=${VERSION:1}" >> "$GITHUB_OUTPUT"
50
+ else
51
+ echo "Tag $VERSION does not follow v<version> naming scheme"
52
+ exit 1
53
+ fi
54
+ - uses: actions/checkout@v4
55
+ - name: Generate release body
56
+ run: |
57
+ sed "s/:VERSION/$VERSION/g" < .github/release-template.md > release.md
58
+ cat release.md
59
+ env:
60
+ VERSION: ${{ steps.getrelease.outputs.version }}
61
+ - name: Upload release body
62
+ uses: actions/upload-artifact@v4
63
+ with:
64
+ name: release-body
65
+ path: release.md
66
+ build-wheels:
67
+ runs-on: ${{ matrix.os }}
68
+ needs: [extract-params]
69
+ strategy:
70
+ fail-fast: false
71
+ matrix:
72
+ os:
73
+ - ubuntu-latest
74
+ - ubuntu-24.04-arm
75
+ - windows-latest
76
+ - macos-latest
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+ - name: Setup Python
80
+ uses: actions/setup-python@v5
81
+ - name: Build wheels
82
+ uses: pypa/cibuildwheel@v3.0.0
83
+ - uses: actions/upload-artifact@v4
84
+ with:
85
+ name: wheels-${{ matrix.os }}-${{ strategy.job-index }}
86
+ path: ./wheelhouse/*.whl
87
+ build-sdist:
88
+ runs-on: ubuntu-latest
89
+ needs: [extract-params]
90
+ steps:
91
+ - uses: actions/checkout@v4
92
+ - name: Setup Python
93
+ uses: actions/setup-python@v5
94
+ - name: Install uv
95
+ uses: astral-sh/setup-uv@v4
96
+ with:
97
+ enable-cache: true
98
+ - name: Build source distribution
99
+ run: uv build --sdist
100
+ - uses: actions/upload-artifact@v4
101
+ with:
102
+ name: sdist
103
+ path: ./dist/*.tar.gz
104
+ publish:
105
+ name: Publish release artifacts
106
+ needs: [extract-params, build-sdist, build-wheels]
107
+ runs-on: ubuntu-latest
108
+ environment: ${{ needs.extract-params.outputs.publish-env }}
109
+ permissions:
110
+ # we use PyPI's trusted publisher model -> expose identity token
111
+ id-token: write
112
+ # Needed to create GitHub releases
113
+ contents: write
114
+ steps:
115
+ - name: Download wheels
116
+ uses: actions/download-artifact@v4
117
+ with:
118
+ pattern: wheels-*
119
+ path: dist/
120
+ merge-multiple: 'true'
121
+ - name: Download source distribution
122
+ uses: actions/download-artifact@v4
123
+ with:
124
+ name: sdist
125
+ path: dist/
126
+ - name: Download release body
127
+ uses: actions/download-artifact@v4
128
+ with:
129
+ name: release-body
130
+ path: release-body
131
+ - name: Upload to PyPI
132
+ uses: pypa/gh-action-pypi-publish@release/v1
133
+ with:
134
+ repository-url: ${{ vars.REPOSITORY_URL }}
135
+ - name: Create GitHub release
136
+ if: needs.extract-params.outputs.publish-env == 'pypi' && startsWith(github.ref, 'refs/tags/')
137
+ uses: softprops/action-gh-release@v2
138
+ with:
139
+ files: |
140
+ dist/*.whl
141
+ dist/*.tar.gz
142
+ body_path: release-body/release.md
143
+ fail_on_unmatched_files: true
144
+ name: python-pkcs11 ${{ needs.extract-params.outputs.version }}
@@ -0,0 +1,47 @@
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
+ jobs:
11
+ run:
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ matrix:
15
+ os:
16
+ - ubuntu-latest
17
+ - windows-latest
18
+ - macos-latest
19
+ python-version:
20
+ - "3.9"
21
+ - "3.10"
22
+ - "3.11"
23
+ - "3.12"
24
+ # 3.13.4 has a regression in C extension builds,
25
+ # need to stick to 3.13.3 until 3.13.5 is available on runners
26
+ - "3.13.3"
27
+
28
+ steps:
29
+ - name: Acquire sources
30
+ uses: actions/checkout@v4
31
+
32
+ - name: Setup Python
33
+ uses: actions/setup-python@v5
34
+ with:
35
+ python-version: ${{ matrix.python-version }}
36
+ - uses: ./.github/actions/install-softhsm
37
+ with:
38
+ os: ${{ matrix.os }}
39
+ - name: Install uv
40
+ uses: astral-sh/setup-uv@v4
41
+ with:
42
+ enable-cache: true
43
+ python-version: ${{ matrix.python-version }}
44
+ - name: Install testing dependencies
45
+ run: uv sync --no-dev --exact --group testing
46
+ - name: Run tests
47
+ run: uv run pytest -v
@@ -1,7 +1,7 @@
1
1
  *.so
2
2
  *.c
3
3
  __pycache__
4
-
4
+ .idea/
5
5
  /build
6
6
  /dist/
7
7
  /docs/_build
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,16 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-24.04
5
+ tools:
6
+ python: "3.12"
7
+ # readthedocs does not support [dependency-groups] directly
8
+ jobs:
9
+ create_environment:
10
+ - asdf plugin add uv
11
+ - asdf install uv latest
12
+ - asdf global uv latest
13
+ build:
14
+ html:
15
+ - make -C docs html BUILDDIR=$READTHEDOCS_OUTPUT
16
+ formats: all
@@ -0,0 +1,27 @@
1
+ ARG IMAGE=debian:stable
2
+ FROM $IMAGE
3
+
4
+ RUN apt-get update && \
5
+ DEBIAN_FRONTEND="noninteractive" apt-get install -y gcc python3 python3-dev softhsm2 openssl && \
6
+ rm -rf /var/lib/apt/lists/*
7
+
8
+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
9
+
10
+ WORKDIR /test
11
+
12
+ ADD uv.lock pyproject.toml setup.py .
13
+ ADD pkcs11/ pkcs11/
14
+ ADD extern/ extern/
15
+
16
+ ENV UV_LINK_MODE=copy
17
+ RUN --mount=type=cache,target=/root/.cache/uv \
18
+ uv sync --all-extras
19
+
20
+ ENV PKCS11_MODULE=/usr/lib/softhsm/libsofthsm2.so
21
+ ENV PKCS11_TOKEN_LABEL=TEST
22
+ ENV PKCS11_TOKEN_PIN=1234
23
+ ENV PKCS11_TOKEN_SO_PIN=5678
24
+ RUN softhsm2-util --init-token --free --label TEST --pin 1234 --so-pin 5678
25
+
26
+ ADD tests/ tests/
27
+ CMD ["uv", "run", "pytest", "-v"]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Danielle Madeley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ graft extern/
2
+ include pkcs11/*.pxd