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