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.
- pkcs11/__init__.py +50 -0
- pkcs11/_pkcs11.cp315-win_amd64.pyd +0 -0
- pkcs11/_pkcs11.pxd +964 -0
- pkcs11/_pkcs11.pyi +35 -0
- pkcs11/_pkcs11.pyx +2327 -0
- pkcs11/attributes.py +272 -0
- pkcs11/constants.py +559 -0
- pkcs11/defaults.py +121 -0
- pkcs11/exceptions.py +410 -0
- pkcs11/mechanisms.py +862 -0
- pkcs11/py.typed +0 -0
- pkcs11/types.py +1457 -0
- pkcs11/util/__init__.py +17 -0
- pkcs11/util/dh.py +79 -0
- pkcs11/util/dsa.py +108 -0
- pkcs11/util/ec.py +143 -0
- pkcs11/util/rsa.py +95 -0
- pkcs11/util/x509.py +136 -0
- python_pkcs11-0.10.1.dist-info/METADATA +399 -0
- python_pkcs11-0.10.1.dist-info/RECORD +23 -0
- python_pkcs11-0.10.1.dist-info/WHEEL +5 -0
- python_pkcs11-0.10.1.dist-info/licenses/LICENSE +21 -0
- python_pkcs11-0.10.1.dist-info/top_level.txt +1 -0
pkcs11/exceptions.py
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PKCS#11 return codes are exposed as Python exceptions inheriting from
|
|
3
|
+
:class:`PKCS11Error`.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PKCS11Error(RuntimeError):
|
|
10
|
+
"""
|
|
11
|
+
Base exception for all PKCS#11 exceptions.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AnotherUserAlreadyLoggedIn(PKCS11Error):
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class AttributeTypeInvalid(PKCS11Error):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AttributeValueInvalid(PKCS11Error):
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AttributeReadOnly(PKCS11Error):
|
|
28
|
+
"""
|
|
29
|
+
An attempt was made to set a value for an attribute which may not be set by
|
|
30
|
+
the application, or which may not be modified by the application.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class AttributeSensitive(PKCS11Error):
|
|
35
|
+
"""
|
|
36
|
+
An attempt was made to obtain the value of an attribute of an object which
|
|
37
|
+
cannot be satisfied because the object is either sensitive or
|
|
38
|
+
un-extractable.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ArgumentsBad(PKCS11Error):
|
|
43
|
+
"""
|
|
44
|
+
Bad arguments were passed into PKCS#11.
|
|
45
|
+
|
|
46
|
+
This can indicate missing parameters to a mechanism or some other issue.
|
|
47
|
+
Consult your PKCS#11 vendor documentation.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class DataInvalid(PKCS11Error):
|
|
52
|
+
"""
|
|
53
|
+
The plaintext input data to a cryptographic operation is invalid.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class DataLenRange(PKCS11Error):
|
|
58
|
+
"""
|
|
59
|
+
The plaintext input data to a cryptographic operation has a bad length.
|
|
60
|
+
Depending on the operation's mechanism, this could mean that the plaintext
|
|
61
|
+
data is too short, too long, or is not a multiple of some particular block
|
|
62
|
+
size.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class DomainParamsInvalid(PKCS11Error):
|
|
67
|
+
"""
|
|
68
|
+
Invalid or unsupported domain parameters were supplied to the function.
|
|
69
|
+
Which representation methods of domain parameters are supported by a given
|
|
70
|
+
mechanism can vary from token to token.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class DeviceError(PKCS11Error):
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class DeviceMemory(PKCS11Error):
|
|
79
|
+
"""
|
|
80
|
+
The token does not have sufficient memory to perform the requested
|
|
81
|
+
function.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class DeviceRemoved(PKCS11Error):
|
|
86
|
+
"""
|
|
87
|
+
The token was removed from its slot during the execution of the function.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class EncryptedDataInvalid(PKCS11Error):
|
|
92
|
+
"""
|
|
93
|
+
The encrypted input to a decryption operation has been determined to be
|
|
94
|
+
invalid ciphertext.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class EncryptedDataLenRange(PKCS11Error):
|
|
99
|
+
"""
|
|
100
|
+
The ciphertext input to a decryption operation has been determined to be
|
|
101
|
+
invalid ciphertext solely on the basis of its length. Depending on the
|
|
102
|
+
operation's mechanism, this could mean that the ciphertext is too short,
|
|
103
|
+
too long, or is not a multiple of some particular block size.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class ExceededMaxIterations(PKCS11Error):
|
|
108
|
+
"""
|
|
109
|
+
An iterative algorithm (for key pair generation, domain parameter
|
|
110
|
+
generation etc.) failed because we have exceeded the maximum number of
|
|
111
|
+
iterations.
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class FunctionCancelled(PKCS11Error):
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class FunctionFailed(PKCS11Error):
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class FunctionRejected(PKCS11Error):
|
|
124
|
+
pass
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class FunctionNotSupported(PKCS11Error):
|
|
128
|
+
pass
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class KeyHandleInvalid(PKCS11Error):
|
|
132
|
+
pass
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class KeyIndigestible(PKCS11Error):
|
|
136
|
+
pass
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class KeyNeeded(PKCS11Error):
|
|
140
|
+
pass
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class KeyNotNeeded(PKCS11Error):
|
|
144
|
+
pass
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class KeyNotWrappable(PKCS11Error):
|
|
148
|
+
pass
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class KeySizeRange(PKCS11Error):
|
|
152
|
+
pass
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class KeyTypeInconsistent(PKCS11Error):
|
|
156
|
+
pass
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class KeyUnextractable(PKCS11Error):
|
|
160
|
+
pass
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class GeneralError(PKCS11Error):
|
|
164
|
+
"""
|
|
165
|
+
In unusual (and extremely unpleasant!) circumstances, a function can fail
|
|
166
|
+
with the return value CKR_GENERAL_ERROR. When this happens, the token
|
|
167
|
+
and/or host computer may be in an inconsistent state, and the goals of the
|
|
168
|
+
function may have been partially achieved.
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class HostMemory(PKCS11Error):
|
|
173
|
+
"""
|
|
174
|
+
The computer that the Cryptoki library is running on has insufficient
|
|
175
|
+
memory to perform the requested function.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class MechanismInvalid(PKCS11Error):
|
|
180
|
+
"""
|
|
181
|
+
Mechanism can not be used with requested operation.
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class MechanismParamInvalid(PKCS11Error):
|
|
186
|
+
pass
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class MultipleObjectsReturned(PKCS11Error):
|
|
190
|
+
"""
|
|
191
|
+
Multiple objects matched the search parameters.
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class MultipleTokensReturned(PKCS11Error):
|
|
196
|
+
"""
|
|
197
|
+
Multiple tokens matched the search parameters.
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class NoEvent(PKCS11Error):
|
|
202
|
+
"""
|
|
203
|
+
No slot events were detected.
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class NoSuchKey(PKCS11Error):
|
|
208
|
+
"""
|
|
209
|
+
No key matching the parameters was found.
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class NoSuchToken(PKCS11Error):
|
|
214
|
+
"""
|
|
215
|
+
No token matching the parameters was found.
|
|
216
|
+
"""
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class ObjectHandleInvalid(PKCS11Error):
|
|
220
|
+
pass
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class OperationActive(PKCS11Error):
|
|
224
|
+
"""
|
|
225
|
+
There is already an active operation (or combination of active operations)
|
|
226
|
+
which prevents Cryptoki from activating the specified operation. For
|
|
227
|
+
example, an active object-searching operation would prevent Cryptoki from
|
|
228
|
+
activating an encryption operation with C_EncryptInit. Or, an active
|
|
229
|
+
digesting operation and an active encryption operation would prevent
|
|
230
|
+
Cryptoki from activating a signature operation. Or, on a token which
|
|
231
|
+
doesn't support simultaneous dual cryptographic operations in a session
|
|
232
|
+
(see the description of the CKF_DUAL_CRYPTO_OPERATIONS flag in the
|
|
233
|
+
CK_TOKEN_INFO structure), an active signature operation would prevent
|
|
234
|
+
Cryptoki from activating an encryption operation.
|
|
235
|
+
"""
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class OperationNotInitialized(PKCS11Error):
|
|
239
|
+
pass
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class PinExpired(PKCS11Error):
|
|
243
|
+
pass
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class PinIncorrect(PKCS11Error):
|
|
247
|
+
pass
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class PinInvalid(PKCS11Error):
|
|
251
|
+
pass
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
class PinLenRange(PKCS11Error):
|
|
255
|
+
"""The specified PIN is too long or too short."""
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class PinLocked(PKCS11Error):
|
|
259
|
+
pass
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class PinTooWeak(PKCS11Error):
|
|
263
|
+
pass
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class PublicKeyInvalid(PKCS11Error):
|
|
267
|
+
pass
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class RandomNoRNG(PKCS11Error):
|
|
271
|
+
pass
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
class RandomSeedNotSupported(PKCS11Error):
|
|
275
|
+
pass
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
class SessionClosed(PKCS11Error):
|
|
279
|
+
"""
|
|
280
|
+
The session was closed during the execution of the function.
|
|
281
|
+
"""
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
class SessionCount(PKCS11Error):
|
|
285
|
+
"""
|
|
286
|
+
An attempt to open a session which does not succeed because there are too
|
|
287
|
+
many existing sessions.
|
|
288
|
+
"""
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
class SessionExists(PKCS11Error):
|
|
292
|
+
pass
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class SessionHandleInvalid(PKCS11Error):
|
|
296
|
+
"""
|
|
297
|
+
The session handle was invalid. This is usually caused by using an
|
|
298
|
+
old session object that is not known to PKCS#11.
|
|
299
|
+
"""
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class SessionReadOnly(PKCS11Error):
|
|
303
|
+
"""Attempted to write to a read-only session."""
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
class SessionReadOnlyExists(PKCS11Error):
|
|
307
|
+
pass
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class SessionReadWriteSOExists(PKCS11Error):
|
|
311
|
+
"""
|
|
312
|
+
If the application calling :meth:`Token.open` already has a R/W SO
|
|
313
|
+
session open with the token, then any attempt to open a R/O session with
|
|
314
|
+
the token fails with this exception.
|
|
315
|
+
"""
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
class SignatureLenRange(PKCS11Error):
|
|
319
|
+
pass
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class SignatureInvalid(PKCS11Error):
|
|
323
|
+
pass
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
class SlotIDInvalid(PKCS11Error):
|
|
327
|
+
pass
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
class TemplateIncomplete(PKCS11Error):
|
|
331
|
+
"""
|
|
332
|
+
Required attributes to create the object were missing.
|
|
333
|
+
"""
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
class TemplateInconsistent(PKCS11Error):
|
|
337
|
+
"""
|
|
338
|
+
Template values (including vendor defaults) are contradictory.
|
|
339
|
+
"""
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
class TokenNotPresent(PKCS11Error):
|
|
343
|
+
"""
|
|
344
|
+
The token was not present in its slot at the time that the function was
|
|
345
|
+
invoked.
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
class TokenNotRecognised(PKCS11Error):
|
|
350
|
+
pass
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
class TokenWriteProtected(PKCS11Error):
|
|
354
|
+
pass
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
class UnwrappingKeyHandleInvalid(PKCS11Error):
|
|
358
|
+
pass
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
class UnwrappingKeySizeRange(PKCS11Error):
|
|
362
|
+
pass
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
class UnwrappingKeyTypeInconsistent(PKCS11Error):
|
|
366
|
+
pass
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
class UserAlreadyLoggedIn(PKCS11Error):
|
|
370
|
+
pass
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
class UserNotLoggedIn(PKCS11Error):
|
|
374
|
+
pass
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
class UserPinNotInitialized(PKCS11Error):
|
|
378
|
+
pass
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
class UserTooManyTypes(PKCS11Error):
|
|
382
|
+
"""
|
|
383
|
+
An attempt was made to have more distinct users simultaneously logged into
|
|
384
|
+
the token than the token and/or library permits. For example, if some
|
|
385
|
+
application has an open SO session, and another application attempts to log
|
|
386
|
+
the normal user into a session, the attempt may return this error. It is
|
|
387
|
+
not required to, however. Only if the simultaneous distinct users cannot
|
|
388
|
+
be supported does C_Login have to return this value. Note that this error
|
|
389
|
+
code generalizes to true multi-user tokens.
|
|
390
|
+
"""
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
class WrappedKeyInvalid(PKCS11Error):
|
|
394
|
+
pass
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
class WrappedKeyLenRange(PKCS11Error):
|
|
398
|
+
pass
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
class WrappingKeyHandleInvalid(PKCS11Error):
|
|
402
|
+
pass
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
class WrappingKeySizeRange(PKCS11Error):
|
|
406
|
+
pass
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class WrappingKeyTypeInconsistent(PKCS11Error):
|
|
410
|
+
pass
|