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