python-pkcs11 0.10.1__cp315-cp315-win_amd64.whl

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.
@@ -0,0 +1,399 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-pkcs11
3
+ Version: 0.10.1
4
+ Summary: PKCS#11 support for Python
5
+ Author-email: Andrey Kislyuk <kislyuk@gmail.com>, Danielle Madeley <danielle@madeley.id.au>
6
+ Maintainer-email: Andrey Kislyuk <kislyuk@gmail.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://python-pkcs11.readthedocs.io/en/latest/
9
+ Project-URL: Documentation, https://python-pkcs11.readthedocs.io/en/latest/
10
+ Project-URL: Issues, https://github.com/pyauth/python-pkcs11/issues
11
+ Project-URL: Repository, https://github.com/pyauth/python-pkcs11
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
20
+ Classifier: Topic :: Security :: Cryptography
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/x-rst
23
+ License-File: LICENSE
24
+ Requires-Dist: asn1crypto>=1.5.1
25
+ Dynamic: license-file
26
+
27
+ .. image:: https://travis-ci.org/danni/python-pkcs11.svg?branch=master
28
+ :target: https://travis-ci.org/danni/python-pkcs11
29
+
30
+ Python PKCS#11 - High Level Wrapper API
31
+ =======================================
32
+
33
+ A high level, "more Pythonic" interface to the PKCS#11 (Cryptoki) standard
34
+ to support HSM and Smartcard devices in Python.
35
+
36
+ The interface is designed to follow the logical structure of a HSM, with
37
+ useful defaults for obscurely documented parameters. Many APIs will optionally
38
+ accept iterables and act as generators, allowing you to stream large data
39
+ blocks for symmetric encryption.
40
+
41
+ python-pkcs11 also includes numerous utility functions to convert between PKCS
42
+ #11 data structures and common interchange formats including PKCS #1 and X.509.
43
+
44
+ python-pkcs11 is fully documented and has a full integration test suite for all
45
+ features.
46
+
47
+ Historically, this project used to run continuous integration tests against several
48
+ HSM platforms, but this test setup has not been maintained over time. Currently,
49
+ the integration tests in GitHub Actions use SoftHSMv2 as a baseline.
50
+ We also test against ``opencryptoki`` in CI. If you would like
51
+ to contribute some CI setup with additional PKCS#11 implementations or actual HSMs,
52
+ let's chat!
53
+
54
+ Source: https://github.com/pyauth/python-pkcs11
55
+
56
+ Documentation: http://python-pkcs11.readthedocs.io/en/latest/
57
+
58
+ Getting Started
59
+ ---------------
60
+
61
+ Install from Pip:
62
+
63
+ ::
64
+
65
+ pip install python-pkcs11
66
+
67
+
68
+ Or build from source:
69
+
70
+ ::
71
+
72
+ python -m build .
73
+
74
+ Or using ``uv``:
75
+
76
+ ::
77
+
78
+ uv build
79
+
80
+ Assuming your PKCS#11 library is set as `PKCS11_MODULE` and contains a
81
+ token named `DEMO`:
82
+
83
+ AES
84
+ ~~~
85
+
86
+ ::
87
+
88
+ import pkcs11
89
+
90
+ # Initialise our PKCS#11 library
91
+ lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
92
+ token = lib.get_token(token_label='DEMO')
93
+
94
+ data = b'INPUT DATA'
95
+
96
+ # Open a session on our token
97
+ with token.open(user_pin='1234') as session:
98
+ # Generate an AES key in this session
99
+ key = session.generate_key(pkcs11.KeyType.AES, 256)
100
+
101
+ # Get an initialisation vector
102
+ iv = session.generate_random(128) # AES blocks are fixed at 128 bits
103
+ # Encrypt our data
104
+ crypttext = key.encrypt(data, mechanism_param=iv)
105
+
106
+ 3DES
107
+ ~~~~
108
+
109
+ ::
110
+
111
+ import pkcs11
112
+
113
+ # Initialise our PKCS#11 library
114
+ lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
115
+ token = lib.get_token(token_label='DEMO')
116
+
117
+ data = b'INPUT DATA'
118
+
119
+ # Open a session on our token
120
+ with token.open(user_pin='1234') as session:
121
+ # Generate a DES key in this session
122
+ key = session.generate_key(pkcs11.KeyType.DES3)
123
+
124
+ # Get an initialisation vector
125
+ iv = session.generate_random(64) # DES blocks are fixed at 64 bits
126
+ # Encrypt our data
127
+ crypttext = key.encrypt(data, mechanism_param=iv)
128
+
129
+ RSA
130
+ ~~~
131
+
132
+ ::
133
+
134
+ import pkcs11
135
+
136
+ lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
137
+ token = lib.get_token(token_label='DEMO')
138
+
139
+ data = b'INPUT DATA'
140
+
141
+ # Open a session on our token
142
+ with token.open(user_pin='1234') as session:
143
+ # Generate an RSA keypair in this session
144
+ pub, priv = session.generate_keypair(pkcs11.KeyType.RSA, 2048)
145
+
146
+ # Encrypt as one block
147
+ crypttext = pub.encrypt(data)
148
+
149
+ DSA
150
+ ~~~
151
+
152
+ ::
153
+
154
+ import pkcs11
155
+
156
+ lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
157
+ token = lib.get_token(token_label='DEMO')
158
+
159
+ data = b'INPUT DATA'
160
+
161
+ # Open a session on our token
162
+ with token.open(user_pin='1234') as session:
163
+ # Generate an DSA keypair in this session
164
+ pub, priv = session.generate_keypair(pkcs11.KeyType.DSA, 1024)
165
+
166
+ # Sign
167
+ signature = priv.sign(data)
168
+
169
+ ECDSA
170
+ ~~~~~
171
+
172
+ ::
173
+
174
+ import pkcs11
175
+
176
+ lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
177
+ token = lib.get_token(token_label='DEMO')
178
+
179
+ data = b'INPUT DATA'
180
+
181
+ # Open a session on our token
182
+ with token.open(user_pin='1234') as session:
183
+ # Generate an EC keypair in this session from a named curve
184
+ ecparams = session.create_domain_parameters(
185
+ pkcs11.KeyType.EC, {
186
+ pkcs11.Attribute.EC_PARAMS: pkcs11.util.ec.encode_named_curve_parameters('secp256r1'),
187
+ }, local=True)
188
+ pub, priv = ecparams.generate_keypair()
189
+
190
+ # Sign
191
+ signature = priv.sign(data)
192
+
193
+ Diffie-Hellman
194
+ ~~~~~~~~~~~~~~
195
+
196
+ ::
197
+
198
+ import pkcs11
199
+
200
+ lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
201
+ token = lib.get_token(token_label='DEMO')
202
+
203
+ with token.open() as session:
204
+ # Given shared Diffie-Hellman parameters
205
+ parameters = session.create_domain_parameters(pkcs11.KeyType.DH, {
206
+ pkcs11.Attribute.PRIME: prime, # Diffie-Hellman parameters
207
+ pkcs11.Attribute.BASE: base,
208
+ })
209
+
210
+ # Generate a DH key pair from the public parameters
211
+ public, private = parameters.generate_keypair()
212
+
213
+ # Share the public half of it with our other party.
214
+ _network_.write(public[Attribute.VALUE])
215
+ # And get their shared value
216
+ other_value = _network_.read()
217
+
218
+ # Derive a shared session key with perfect forward secrecy
219
+ session_key = private.derive_key(
220
+ pkcs11.KeyType.AES, 128,
221
+ mechanism_param=other_value)
222
+
223
+
224
+ Elliptic-Curve Diffie-Hellman
225
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
226
+
227
+ ::
228
+
229
+ import pkcs11
230
+
231
+ lib = pkcs11.lib(os.environ['PKCS11_MODULE'])
232
+ token = lib.get_token(token_label='DEMO')
233
+
234
+ with token.open() as session:
235
+ # Given DER encocded EC parameters, e.g. from
236
+ # openssl ecparam -outform der -name <named curve>
237
+ parameters = session.create_domain_parameters(pkcs11.KeyType.EC, {
238
+ pkcs11.Attribute.EC_PARAMS: ecparams,
239
+ })
240
+
241
+ # Generate a DH key pair from the public parameters
242
+ public, private = parameters.generate_keypair()
243
+
244
+ # Share the public half of it with our other party.
245
+ _network_.write(public[pkcs11.Attribute.EC_POINT])
246
+ # And get their shared value
247
+ other_value = _network_.read()
248
+
249
+ # Derive a shared session key
250
+ session_key = private.derive_key(
251
+ pkcs11.KeyType.AES, 128,
252
+ mechanism_param=(pkcs11.KDF.NULL, None, other_value))
253
+
254
+ Tested Compatibility
255
+ --------------------
256
+
257
+ +------------------------------+--------------+-----------------+--------------+-------------------+
258
+ | Functionality | SoftHSMv2 | Thales nCipher | Opencryptoki | OpenSC (Nitrokey) |
259
+ +==============================+==============+=================+==============+===================+
260
+ | Get Slots/Tokens | Works | Works | Works | Works |
261
+ +------------------------------+--------------+-----------------+--------------+-------------------+
262
+ | Get Mechanisms | Works | Works | Works | Works |
263
+ +------------------------------+--------------+-----------------+--------------+-------------------+
264
+ | Initialize token | Not implemented |
265
+ +------------------------------+-------------------------------------------------------------------+
266
+ | Slot events | Not implemented |
267
+ +------------------------------+-------------------------------------------------------------------+
268
+ | Alternative authentication | Not implemented |
269
+ | path | |
270
+ +------------------------------+-------------------------------------------------------------------+
271
+ | `Always authenticate` keys | Not implemented |
272
+ +-------------+----------------+--------------+-----------------+--------------+-------------------+
273
+ | Create/Copy | Keys | Works | Works | Errors | Create |
274
+ | +----------------+--------------+-----------------+--------------+-------------------+
275
+ | | Certificates | Caveats [1]_ | Caveats [1]_ | Caveats [1]_ | ? |
276
+ | +----------------+--------------+-----------------+--------------+-------------------+
277
+ | | Domain Params | Caveats [1]_ | Caveats [1]_ | ? | N/A |
278
+ +-------------+----------------+--------------+-----------------+--------------+-------------------+
279
+ | Destroy Object | Works | N/A | Works | Works |
280
+ +------------------------------+--------------+-----------------+--------------+-------------------+
281
+ | Generate Random | Works | Works | Works | Works |
282
+ +------------------------------+--------------+-----------------+--------------+-------------------+
283
+ | Seed Random | Works | N/A | N/A | N/A |
284
+ +------------------------------+--------------+-----------------+--------------+-------------------+
285
+ | Digest (Data & Keys) | Works | Caveats [2]_ | Works | Works |
286
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
287
+ | AES | Generate key | Works | Works | Works | N/A |
288
+ | +---------------------+--------------+-----------------+--------------+ |
289
+ | | Encrypt/Decrypt | Works | Works | Works | |
290
+ | +---------------------+--------------+-----------------+--------------+ |
291
+ | | Wrap/Unwrap | ? [3]_ | Works | Errors | |
292
+ | +---------------------+--------------+-----------------+--------------+ |
293
+ | | Sign/Verify | Works | Works [4]_ | N/A | |
294
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
295
+ | DES2/ | Generate key | Works | Works | Works | N/A |
296
+ | DES3 +---------------------+--------------+-----------------+--------------+ |
297
+ | | Encrypt/Decrypt | Works | Works | Works | |
298
+ | +---------------------+--------------+-----------------+--------------+ |
299
+ | | Wrap/Unwrap | ? | ? | ? | |
300
+ | +---------------------+--------------+-----------------+--------------+ |
301
+ | | Sign/Verify | ? | ? | ? | |
302
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
303
+ | RSA | Generate key pair | Works | Works | Works | Works [4]_ [8]_ |
304
+ | +---------------------+--------------+-----------------+--------------+-------------------+
305
+ | | Encrypt/Decrypt | Works | Works | Works | Decrypt only [9]_ |
306
+ | +---------------------+--------------+-----------------+--------------+-------------------+
307
+ | | Wrap/Unwrap | Works | Works | Works | N/A |
308
+ | +---------------------+--------------+-----------------+--------------+-------------------+
309
+ | | Sign/Verify | Works | Works | Works | Works |
310
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
311
+ | DSA | Generate parameters | Works | Error | N/A | N/A |
312
+ | +---------------------+--------------+-----------------+ | |
313
+ | | Generate key pair | Works | Caveats [5]_ | | |
314
+ | +---------------------+--------------+-----------------+ | |
315
+ | | Sign/Verify | Works | Works [4]_ | | |
316
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
317
+ | DH | Generate parameters | Works | N/A | N/A | N/A |
318
+ | +---------------------+--------------+-----------------+ | |
319
+ | | Generate key pair | Works | Caveats [6]_ | | |
320
+ | +---------------------+--------------+-----------------+ | |
321
+ | | Derive Key | Works | Caveats [7]_ | | |
322
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
323
+ | EC | Generate key pair | Caveats [6]_ | ? [3]_ | Works | Works |
324
+ | +---------------------+--------------+-----------------+--------------+-------------------+
325
+ | | Sign/Verify (ECDSA) | Works [4]_ | ? [3]_ | Works | Sign only [9]_ |
326
+ | +---------------------+--------------+-----------------+--------------+-------------------+
327
+ | | Derive key (ECDH) | Works | ? [3]_ | Works | ? |
328
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
329
+ | ML-DSA | Generate key pair | Works | ? [3]_ | Works | N/A |
330
+ | +---------------------+--------------+-----------------+--------------+ |
331
+ | | Sign/Verify | Works | ? [3]_ | Works | |
332
+ +--------+---------------------+--------------+-----------------+--------------+-------------------+
333
+ | Proprietary extensions | N/A | Not implemented | N/A | N/A |
334
+ +------------------------------+--------------+-----------------+--------------+-------------------+
335
+
336
+ .. [1] Device supports limited set of attributes.
337
+ .. [2] Digesting keys is not supported.
338
+ .. [3] Untested: requires support in device.
339
+ .. [4] Default mechanism not supported, must specify a mechanism.
340
+ .. [5] From existing domain parameters.
341
+ .. [6] Local domain parameters only.
342
+ .. [7] Generates security warnings about the derived key.
343
+ .. [8] `store` parameter is ignored, all keys are stored.
344
+ .. [9] Encryption/verify not supported, extract the public key
345
+
346
+ Python version:
347
+
348
+ * >= 3.10
349
+
350
+ PKCS#11 versions:
351
+
352
+ * 2.11
353
+ * 2.20
354
+ * 2.40
355
+ * 3.1
356
+ * 3.2
357
+
358
+ Feel free to send pull requests for any functionality that's not exposed. The
359
+ code is designed to be readable and expose the PKCS #11 spec in a
360
+ straight-forward way.
361
+
362
+ If you want your device supported, get in touch!
363
+
364
+ More info on PKCS #11
365
+ ---------------------
366
+
367
+ The latest version of the PKCS #11 spec is available from OASIS:
368
+
369
+ http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/pkcs11-base-v2.40.html
370
+
371
+ You should also consult the documentation for your PKCS #11 implementation.
372
+ Many implementations expose additional vendor options configurable in your
373
+ environment, including alternative features, modes and debugging
374
+ information.
375
+
376
+ License
377
+ -------
378
+
379
+ MIT License
380
+
381
+ Copyright (c) 2017 Danielle Madeley and contributors
382
+
383
+ Permission is hereby granted, free of charge, to any person obtaining a copy
384
+ of this software and associated documentation files (the "Software"), to deal
385
+ in the Software without restriction, including without limitation the rights
386
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
387
+ copies of the Software, and to permit persons to whom the Software is
388
+ furnished to do so, subject to the following conditions:
389
+
390
+ The above copyright notice and this permission notice shall be included in all
391
+ copies or substantial portions of the Software.
392
+
393
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
394
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
395
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
396
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
397
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
398
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
399
+ SOFTWARE.
@@ -0,0 +1,23 @@
1
+ pkcs11/__init__.py,sha256=UNOMqyFSptUerGagly_LWE796AHCNtzUXiqL9Rx3p_Y,1080
2
+ pkcs11/_pkcs11.cp315-win_amd64.pyd,sha256=eYwRYuxzri8pVdaTpfjT4DFpKT0_hL2FlU9t33F1w9M,550912
3
+ pkcs11/_pkcs11.pxd,sha256=JDS5VYMBRzNR0RO1vNZmWDlmX4sVlOp-Vi3POBZQbPo,35829
4
+ pkcs11/_pkcs11.pyi,sha256=dW3JSLLRl1RoLIBpKSJVXhok1IDJGaGf6Gtt0XBmFGU,1132
5
+ pkcs11/_pkcs11.pyx,sha256=hKp8vW5cMnz8e36HC2r6heyMIPIYX_dUFMOhaRwtma8,82872
6
+ pkcs11/attributes.py,sha256=1tqfg39yTQ12mH_GhQyG2iH0JWgLu_6sojcttRSZNDQ,9268
7
+ pkcs11/constants.py,sha256=xWyOBjzLk4BEocifgPyN_C4POX1s5DKtx2t363SmOnY,16656
8
+ pkcs11/defaults.py,sha256=Bt9_Jj0EpcbkR96g4g9tyNzmS0M9vl6tdCJlsTuLt1o,3992
9
+ pkcs11/exceptions.py,sha256=pelfs2By1kncNtEJ0WRNmIbDbL5SY9eZTRUYy7GCwA0,8917
10
+ pkcs11/mechanisms.py,sha256=28HAMCzGKcOwVwkMD0fahX0-JCK8Cu37aLOg-6cTuT0,24984
11
+ pkcs11/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ pkcs11/types.py,sha256=0JNfNkVg7UZLUWEQKQDtctg-tHDqmHDKzFPcbKiDhbU,48194
13
+ pkcs11/util/__init__.py,sha256=q90T0GbuxtsIYKxhyXTX9WL4xiGCOC3UvGaF-g5X_zY,471
14
+ pkcs11/util/dh.py,sha256=P2thmqoT7njSw3Ara3NKbd2LeBL89byvulw9Su6v1gA,1874
15
+ pkcs11/util/dsa.py,sha256=43TgrtIe2yq0Zlo_amH1pg8zkOAnmeScYv9A3AfmQHQ,2648
16
+ pkcs11/util/ec.py,sha256=Okc_NOOoMh6jyRitol8L6EuM3eMQ3ltJd-SNACc2ST0,3996
17
+ pkcs11/util/rsa.py,sha256=KTrfx1aUxreAELkIPAkeE7jIEWBob_SDZy7gOKSvov8,3331
18
+ pkcs11/util/x509.py,sha256=1wA671iXZYuFO-sfj1AlBJpWShRVXP9m_pgOo779DCY,4099
19
+ python_pkcs11-0.10.1.dist-info/licenses/LICENSE,sha256=_MQXAG7rWQ5-aJCEtiFxPMrUNaRrR68AsJZYOb3ZMr0,1094
20
+ python_pkcs11-0.10.1.dist-info/METADATA,sha256=3-JWDJO1_0OBkNA_D46Uh10Zb9HPVe46hajE6VQUpEE,17865
21
+ python_pkcs11-0.10.1.dist-info/WHEEL,sha256=0gLwYZa0C2fhgCxWR2c8HahwUiopqonVCV0wVwEg6fE,101
22
+ python_pkcs11-0.10.1.dist-info/top_level.txt,sha256=QXuJ7iSMaVyTfyYhAivm5m835NHoayh_MrtE-mxVwwc,7
23
+ python_pkcs11-0.10.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp315-cp315-win_amd64
5
+
@@ -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 @@
1
+ pkcs11