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/constants.py ADDED
@@ -0,0 +1,541 @@
1
+ """
2
+ PKCS#11 constants.
3
+
4
+ See the Python :mod:`enum` documentation for more information on how to
5
+ use these classes.
6
+ """
7
+
8
+ from enum import IntEnum, IntFlag, unique
9
+
10
+ DEFAULT = object()
11
+ """Sentinel value used in templates.
12
+
13
+ Not all pkcs11 attribute sets are accepted by HSMs.
14
+ Use this value to remove the attribute from the template
15
+ sent to the HSM or to use the HSM default value.
16
+ """
17
+
18
+
19
+ @unique
20
+ class UserType(IntEnum):
21
+ """PKCS#11 user types."""
22
+
23
+ NOBODY = 999
24
+ """
25
+ Not officially in the PKCS#11 spec. Used to represent a session that is not
26
+ logged in.
27
+ """
28
+ SO = 0
29
+ """Security officer."""
30
+ USER = 1
31
+
32
+
33
+ class ObjectClass(IntEnum):
34
+ """
35
+ PKCS#11 :class:`Object` class.
36
+
37
+ This is the type of object we have.
38
+ """
39
+
40
+ DATA = 0x00000000
41
+ CERTIFICATE = 0x00000001
42
+ """See :class:`pkcs11.Certificate`."""
43
+ PUBLIC_KEY = 0x00000002
44
+ """See :class:`pkcs11.PublicKey`."""
45
+ PRIVATE_KEY = 0x00000003
46
+ """See :class:`pkcs11.PrivateKey`."""
47
+ SECRET_KEY = 0x00000004
48
+ """See :class:`pkcs11.SecretKey`."""
49
+ HW_FEATURE = 0x00000005
50
+ DOMAIN_PARAMETERS = 0x00000006
51
+ """See :class:`pkcs11.DomainParameters`."""
52
+ MECHANISM = 0x00000007
53
+ OTP_KEY = 0x00000008
54
+ PROFILE = 0x00000009
55
+
56
+ _VENDOR_DEFINED = 0x80000000
57
+
58
+ def __repr__(self):
59
+ return "<ObjectClass.%s>" % self.name
60
+
61
+
62
+ _ARRAY_ATTRIBUTE = 0x40000000
63
+ """Attribute consists of an array of values."""
64
+
65
+
66
+ class Attribute(IntEnum):
67
+ """
68
+ PKCS#11 object attributes.
69
+
70
+ Not all attributes are relevant to all objects.
71
+ Relevant attributes for each object type are given in `PKCS #11
72
+ <http://docs.oasis-open.org/pkcs11/pkcs11-curr/v2.40/pkcs11-curr-v2.40.html>`_.
73
+ """
74
+
75
+ CLASS = 0x00000000
76
+ """Object type (:class:`ObjectClass`)."""
77
+ TOKEN = 0x00000001
78
+ """
79
+ If True object will be stored to token.
80
+ Otherwise has session lifetime (:class:`bool`).
81
+ """
82
+ PRIVATE = 0x00000002
83
+ """
84
+ True if user must be authenticated to access this object (:class:`bool`).
85
+ """
86
+ LABEL = 0x00000003
87
+ """Object label (:class:`str`)."""
88
+ UNIQUE_ID = 0x00000004
89
+ """Unique identifier (:class:`str`)."""
90
+ APPLICATION = 0x00000010
91
+ VALUE = 0x00000011
92
+ """
93
+ Object value. Usually represents a secret or private key.
94
+ For certificates this is the complete certificate in the certificate's
95
+ native format (e.g. BER-encoded X.509 or WTLS encoding).
96
+
97
+ May be `SENSITIVE` (:class:`bytes`).
98
+ """
99
+ OBJECT_ID = 0x00000012
100
+ CERTIFICATE_TYPE = 0x00000080
101
+ """
102
+ Certificate type (:class:`CertificateType`).
103
+ """
104
+ ISSUER = 0x00000081
105
+ """
106
+ Certificate issuer in certificate's native format
107
+ (e.g. X.509 DER-encoding or WTLS encoding) (:class:`bytes`).
108
+ """
109
+ SERIAL_NUMBER = 0x00000082
110
+ """
111
+ Certificate serial number in certificate's native format
112
+ (e.g. X.509 DER-encoding) (:class:`bytes`).
113
+ """
114
+ AC_ISSUER = 0x00000083
115
+ """
116
+ Attribute Certificate Issuer. Different from `ISSUER` because the
117
+ encoding is different (:class:`bytes`).
118
+ """
119
+ OWNER = 0x00000084
120
+ """
121
+ Attribute Certificate Owner. Different from `SUBJECT` because the
122
+ encoding is different (:class:`bytes`).
123
+ """
124
+ ATTR_TYPES = 0x00000085
125
+ """
126
+ BER-encoding of a sequence of object identifier values corresponding to the
127
+ attribute types contained in the certificate. When present, this field
128
+ offers an opportunity for applications to search for a particular attribute
129
+ certificate without fetching and parsing the certificate itself.
130
+ """
131
+ TRUSTED = 0x00000086
132
+ """
133
+ This key can be used to wrap keys with `WRAP_WITH_TRUSTED` set;
134
+ or this certificate can be trusted.
135
+ (:class:`bool`).
136
+ """
137
+ CERTIFICATE_CATEGORY = 0x00000087
138
+ """
139
+ Certificate category (:class:`CertificateCategory`).
140
+ """
141
+ JAVA_MIDP_SECURITY_DOMAIN = 0x00000088
142
+ URL = 0x00000089
143
+ """URL where the complete certificate can be obtained."""
144
+ HASH_OF_SUBJECT_PUBLIC_KEY = 0x0000008A
145
+ """Hash of the certificate subject's public key."""
146
+ HASH_OF_ISSUER_PUBLIC_KEY = 0x0000008B
147
+ """Hash of the certificate issuer's public key."""
148
+ CHECK_VALUE = 0x00000090
149
+ """`VALUE` checksum. Key Check Value (:class:`bytes`)."""
150
+
151
+ KEY_TYPE = 0x00000100
152
+ """Key type (:class:`KeyType`)."""
153
+ SUBJECT = 0x00000101
154
+ """
155
+ Certificate subject in certificate's native format
156
+ (e.g. X.509 DER-encoding or WTLS encoding) (:class:`bytes`).
157
+ """
158
+ ID = 0x00000102
159
+ """Key ID (bytes)."""
160
+ SENSITIVE = 0x00000103
161
+ """
162
+ Sensitive attributes cannot be retrieved from the HSM
163
+ (e.g. `VALUE` or `PRIVATE_EXPONENT`) (:class:`bool`).
164
+ """
165
+ ENCRYPT = 0x00000104
166
+ """Key supports encryption (:class:`bool`)."""
167
+ DECRYPT = 0x00000105
168
+ """Key supports decryption (:class:`bool`)."""
169
+ WRAP = 0x00000106
170
+ """Key supports wrapping (:class:`bool`)."""
171
+ UNWRAP = 0x00000107
172
+ """Key supports unwrapping (:class:`bool`)."""
173
+ SIGN = 0x00000108
174
+ """Key supports signing (:class:`bool`)."""
175
+ SIGN_RECOVER = 0x00000109
176
+ VERIFY = 0x0000010A
177
+ """Key supports signature verification (:class:`bool`)."""
178
+ VERIFY_RECOVER = 0x0000010B
179
+ DERIVE = 0x0000010C
180
+ """Key supports key derivation (:class:`bool`)."""
181
+ START_DATE = 0x00000110
182
+ """Start date for the object's validity (:class:`datetime.date`)."""
183
+ END_DATE = 0x00000111
184
+ """End date for the object's validity (:class:`datetime.date`)."""
185
+ MODULUS = 0x00000120
186
+ """RSA private key modulus (n) (`biginteger` as :class:`bytes`)."""
187
+ MODULUS_BITS = 0x00000121
188
+ """
189
+ RSA private key modulus length. Use this for private key generation
190
+ (:class:`int`).
191
+ """
192
+ PUBLIC_EXPONENT = 0x00000122
193
+ """
194
+ RSA public exponent (e) (`biginteger` as :class:`bytes`).
195
+
196
+ Default is b'\1\0\1' (65537).
197
+ """
198
+ PRIVATE_EXPONENT = 0x00000123
199
+ """RSA private exponent (d) (`biginteger` as :class:`bytes`)."""
200
+ PRIME_1 = 0x00000124
201
+ """
202
+ RSA private key prime #1 (p). May not be stored.
203
+ (`biginteger` as :class:`bytes`).
204
+ """
205
+ PRIME_2 = 0x00000125
206
+ """
207
+ RSA private key prime #2 (q). May not be stored.
208
+ (`biginteger` as :class:`bytes`).
209
+ """
210
+ EXPONENT_1 = 0x00000126
211
+ """
212
+ RSA private key exponent #1 (d mod p-1). May not be stored.
213
+ (`biginteger` as :class:`bytes`).
214
+ """
215
+ EXPONENT_2 = 0x00000127
216
+ """
217
+ RSA private key exponent #2 (d mod q-1). May not be stored.
218
+ (`biginteger` as :class:`bytes`).
219
+ """
220
+ COEFFICIENT = 0x00000128
221
+ """
222
+ RSA private key CRT coefficient (q^-1 mod p). May not be stored.
223
+ (`biginteger` as :class:`bytes`).
224
+ """
225
+ PRIME = 0x00000130
226
+ """
227
+ Prime number 'q' (used for DH).
228
+ (`biginteger` as :class:`bytes`).
229
+ """
230
+ SUBPRIME = 0x00000131
231
+ """
232
+ Subprime number 'q' (used for DH).
233
+ (`biginteger` as :class:`bytes`).
234
+ """
235
+ BASE = 0x00000132
236
+ """
237
+ Base number 'g' (used for DH).
238
+ (`biginteger` as :class:`bytes`).
239
+ """
240
+
241
+ PRIME_BITS = 0x00000133
242
+ SUBPRIME_BITS = 0x00000134
243
+
244
+ VALUE_BITS = 0x00000160
245
+ VALUE_LEN = 0x00000161
246
+ """
247
+ `VALUE` length in bytes. Use this for secret key generation
248
+ (:class:`int`).
249
+ """
250
+ EXTRACTABLE = 0x00000162
251
+ """Key can be extracted wrapped."""
252
+ LOCAL = 0x00000163
253
+ """True if generated on the token, False if imported."""
254
+ NEVER_EXTRACTABLE = 0x00000164
255
+ """`EXTRACTABLE` has always been False."""
256
+ ALWAYS_SENSITIVE = 0x00000165
257
+ """`SENSITIVE` has always been True."""
258
+ KEY_GEN_MECHANISM = 0x00000166
259
+ """Key generation mechanism (:class:`pkcs11.mechanisms.Mechanism`)."""
260
+
261
+ MODIFIABLE = 0x00000170
262
+ """Object can be modified (:class:`bool`)."""
263
+ COPYABLE = 0x00000171
264
+ """Object can be copied (:class:`bool`)."""
265
+
266
+ EC_PARAMS = 0x00000180
267
+ """
268
+ DER-encoded ANSI X9.62 Elliptic-Curve domain parameters (:class:`bytes`).
269
+
270
+ These can packed using :mod:`pkcs11.util.ec.encode_named_curve_parameters`:
271
+
272
+ ::
273
+
274
+ from pkcs11.util.ec import encode_named_curve_parameters
275
+
276
+ ecParams = encode_named_curve_parameters('secp256r1')
277
+
278
+ Or output by OpenSSL:
279
+
280
+ ::
281
+
282
+ openssl ecparam -outform der -name <curve name> | base64
283
+
284
+ """
285
+
286
+ EC_POINT = 0x00000181
287
+ """
288
+ DER-encoded ANSI X9.62 Public key for :attr:`KeyType.EC` (:class:`bytes`).
289
+ """
290
+
291
+ SECONDARY_AUTH = 0x00000200
292
+ AUTH_PIN_FLAGS = 0x00000201
293
+
294
+ ALWAYS_AUTHENTICATE = 0x00000202
295
+ """
296
+ User has to provide pin with each use (sign or decrypt) (:class:`bool`).
297
+ """
298
+
299
+ WRAP_WITH_TRUSTED = 0x00000210
300
+ """Key can only be wrapped with a `TRUSTED` key."""
301
+ WRAP_TEMPLATE = _ARRAY_ATTRIBUTE | 0x00000211
302
+ UNWRAP_TEMPLATE = _ARRAY_ATTRIBUTE | 0x00000212
303
+ DERIVE_TEMPLATE = _ARRAY_ATTRIBUTE | 0x00000213
304
+
305
+ OTP_FORMAT = 0x00000220
306
+ OTP_LENGTH = 0x00000221
307
+ OTP_TIME_INTERVAL = 0x00000222
308
+ OTP_USER_FRIENDLY_MODE = 0x00000223
309
+ OTP_CHALLENGE_REQUIREMENT = 0x00000224
310
+ OTP_TIME_REQUIREMENT = 0x00000225
311
+ OTP_COUNTER_REQUIREMENT = 0x00000226
312
+ OTP_PIN_REQUIREMENT = 0x00000227
313
+ OTP_COUNTER = 0x0000022E
314
+ OTP_TIME = 0x0000022F
315
+ OTP_USER_IDENTIFIER = 0x0000022A
316
+ OTP_SERVICE_IDENTIFIER = 0x0000022B
317
+ OTP_SERVICE_LOGO = 0x0000022C
318
+ OTP_SERVICE_LOGO_TYPE = 0x0000022D
319
+
320
+ GOSTR3410_PARAMS = 0x00000250
321
+ GOSTR3411_PARAMS = 0x00000251
322
+ GOST28147_PARAMS = 0x00000252
323
+
324
+ HW_FEATURE_TYPE = 0x00000300
325
+ RESET_ON_INIT = 0x00000301
326
+ HAS_RESET = 0x00000302
327
+
328
+ PIXEL_X = 0x00000400
329
+ PIXEL_Y = 0x00000401
330
+ RESOLUTION = 0x00000402
331
+ CHAR_ROWS = 0x00000403
332
+ CHAR_COLUMNS = 0x00000404
333
+ COLOR = 0x00000405
334
+ BITS_PER_PIXEL = 0x00000406
335
+ CHAR_SETS = 0x00000480
336
+ ENCODING_METHODS = 0x00000481
337
+ MIME_TYPES = 0x00000482
338
+ MECHANISM_TYPE = 0x00000500
339
+ REQUIRED_CMS_ATTRIBUTES = 0x00000501
340
+ DEFAULT_CMS_ATTRIBUTES = 0x00000502
341
+ SUPPORTED_CMS_ATTRIBUTES = 0x00000503
342
+ ALLOWED_MECHANISMS = _ARRAY_ATTRIBUTE | 0x00000600
343
+
344
+ _VENDOR_DEFINED = 0x80000000
345
+
346
+ def __repr__(self):
347
+ return "<Attribute.%s>" % self.name
348
+
349
+
350
+ class CertificateType(IntEnum):
351
+ """
352
+ Certificate type of a :class:`pkcs11.Certificate`.
353
+ """
354
+
355
+ X_509 = 0x00000000
356
+ X_509_ATTR_CERT = 0x00000001
357
+ WTLS = 0x00000002
358
+ _VENDOR_DEFINED = 0x80000000
359
+
360
+
361
+ @unique
362
+ class MechanismFlag(IntFlag):
363
+ """
364
+ Describes the capabilities of a :class:`pkcs11.mechanisms.Mechanism`
365
+ or :class:`pkcs11.Object`.
366
+
367
+ Some objects and mechanisms are symmetric (i.e. can be used for encryption
368
+ and decryption), some are asymmetric (e.g. public key cryptography).
369
+ """
370
+
371
+ HW = 0x00000001
372
+ """Mechanism is performed in hardware."""
373
+
374
+ ENCRYPT = 0x00000100
375
+ """Can be used for encryption."""
376
+ DECRYPT = 0x00000200
377
+ """Can be used for decryption."""
378
+ DIGEST = 0x00000400
379
+ """Can make a message digest (hash)."""
380
+ SIGN = 0x00000800
381
+ """Can calculate digital signature."""
382
+ SIGN_RECOVER = 0x00001000
383
+ VERIFY = 0x00002000
384
+ """Can verify digital signature."""
385
+ VERIFY_RECOVER = 0x00004000
386
+ GENERATE = 0x00008000
387
+ """Can generate key/object."""
388
+ GENERATE_KEY_PAIR = 0x00010000
389
+ """Can generate key pair."""
390
+ WRAP = 0x00020000
391
+ """Can wrap a key for export."""
392
+ UNWRAP = 0x00040000
393
+ """Can unwrap a key for import."""
394
+ DERIVE = 0x00080000
395
+ """Can derive a key from another key."""
396
+
397
+ EC_F_P = 0x00100000
398
+ EC_F_2M = 0x00200000
399
+ EC_ECPARAMETERS = 0x00400000
400
+ EC_NAMEDCURVE = 0x00800000
401
+ EC_UNCOMPRESS = 0x01000000
402
+ EC_COMPRESS = 0x02000000
403
+
404
+ EXTENSION = 0x80000000
405
+
406
+
407
+ @unique
408
+ class SlotFlag(IntFlag):
409
+ """:class:`pkcs11.Slot` flags."""
410
+
411
+ TOKEN_PRESENT = 0x00000001
412
+ """
413
+ A token is present in the slot
414
+ (N.B. some hardware known not to set this for soft-tokens.)
415
+ """
416
+ REMOVABLE_DEVICE = 0x00000002
417
+ """Removable devices."""
418
+ HW_SLOT = 0x00000004
419
+ """Hardware slot."""
420
+
421
+
422
+ @unique
423
+ class TokenFlag(IntFlag):
424
+ """:class:`pkcs11.Token` flags."""
425
+
426
+ RNG = 0x00000001
427
+ """Has random number generator."""
428
+ WRITE_PROTECTED = 0x00000002
429
+ """Token is write protected."""
430
+ LOGIN_REQUIRED = 0x00000004
431
+ """User must login."""
432
+ USER_PIN_INITIALIZED = 0x00000008
433
+ """Normal user's pin is set."""
434
+
435
+ RESTORE_KEY_NOT_NEEDED = 0x00000020
436
+ """
437
+ If it is set, that means that *every* time the state of cryptographic
438
+ operations of a session is successfully saved, all keys needed to continue
439
+ those operations are stored in the state.
440
+ """
441
+
442
+ CLOCK_ON_TOKEN = 0x00000040
443
+ """
444
+ If it is set, that means that the token has some sort of clock. The time
445
+ on that clock is returned in the token info structure.
446
+ """
447
+
448
+ PROTECTED_AUTHENTICATION_PATH = 0x00000100
449
+ """
450
+ If it is set, that means that there is some way for the user to login
451
+ without sending a PIN through the Cryptoki library itself.
452
+ """
453
+
454
+ DUAL_CRYPTO_OPERATIONS = 0x00000200
455
+ """
456
+ If it is true, that means that a single session with the token can perform
457
+ dual simultaneous cryptographic operations (digest and encrypt; decrypt and
458
+ digest; sign and encrypt; and decrypt and sign).
459
+ """
460
+
461
+ TOKEN_INITIALIZED = 0x00000400
462
+ """
463
+ If it is true, the token has been initialized using C_InitializeToken or an
464
+ equivalent mechanism outside the scope of PKCS #11. Calling
465
+ C_InitializeToken when this flag is set will cause the token to be
466
+ reinitialized.
467
+ """
468
+
469
+ USER_PIN_COUNT_LOW = 0x00010000
470
+ """
471
+ If it is true, an incorrect user login PIN has been entered at least once
472
+ since the last successful authentication.
473
+ """
474
+
475
+ USER_PIN_FINAL_TRY = 0x00020000
476
+ """
477
+ If it is true, supplying an incorrect user PIN will it to become locked.
478
+ """
479
+
480
+ USER_PIN_LOCKED = 0x00040000
481
+ """
482
+ If it is true, the user PIN has been locked. User login to the token is not
483
+ possible.
484
+ """
485
+
486
+ USER_PIN_TO_BE_CHANGED = 0x00080000
487
+ """
488
+ If it is true, the user PIN value is the default value set by token
489
+ initialization or manufacturing, or the PIN has been expired by the card.
490
+ """
491
+
492
+ SO_PIN_COUNT_LOW = 0x00100000
493
+ """
494
+ If it is true, an incorrect SO (security officer) login PIN has been
495
+ entered at least once since the last successful authentication.
496
+ """
497
+
498
+ SO_PIN_FINAL_TRY = 0x00200000
499
+ """
500
+ If it is true, supplying an incorrect SO (security officer) PIN will it to
501
+ become locked.
502
+ """
503
+
504
+ SO_PIN_LOCKED = 0x00400000
505
+ """
506
+ If it is true, the SO (security officer) PIN has been locked. SO login to
507
+ the token is not possible.
508
+ """
509
+
510
+ SO_PIN_TO_BE_CHANGED = 0x00800000
511
+ """
512
+ If it is true, the SO PIN value is the default value set by token
513
+ initialization or manufacturing, or the PIN has been expired by the card.
514
+ """
515
+
516
+ ERROR_STATE = 0x01000000
517
+
518
+
519
+ @unique
520
+ class CancelStrategy(IntEnum):
521
+ """
522
+ Strategy to cancel cryptographic operations
523
+ """
524
+
525
+ DEFAULT = 0
526
+ """
527
+ Default strategy: attempt to cancel by finalising the operation using dummy data,
528
+ regardless of whether the operation is successful or not.
529
+ This approach should work universally, but is semantically difficult to identify
530
+ as a cancellation.
531
+ """
532
+
533
+ CANCEL_WITH_INIT = 1
534
+ """
535
+ Attempt to cancel by calling the ``C_XYZInit`` function of the running operation
536
+ with a ``NULL`` mechanism.
537
+
538
+ This usage is defined in PKCS#11 3.0 but not universally implemented.
539
+ """
540
+
541
+ # TODO support cancelling with C_SessionCancel on PKCS#11 3.0 and up
pkcs11/defaults.py ADDED
@@ -0,0 +1,106 @@
1
+ """
2
+ Default mappings for various key types and mechanisms.
3
+
4
+ None of this is provided for in PKCS#11 and its correctness should not be
5
+ assumed.
6
+ """
7
+
8
+ from pkcs11.constants import (
9
+ MechanismFlag,
10
+ )
11
+ from pkcs11.mechanisms import MGF, KeyType, Mechanism
12
+
13
+ DEFAULT_GENERATE_MECHANISMS = {
14
+ KeyType.AES: Mechanism.AES_KEY_GEN,
15
+ KeyType.DES2: Mechanism.DES2_KEY_GEN,
16
+ KeyType.DES3: Mechanism.DES3_KEY_GEN,
17
+ KeyType.DH: Mechanism.DH_PKCS_KEY_PAIR_GEN,
18
+ KeyType.DSA: Mechanism.DSA_KEY_PAIR_GEN,
19
+ KeyType.EC: Mechanism.EC_KEY_PAIR_GEN,
20
+ KeyType.RSA: Mechanism.RSA_PKCS_KEY_PAIR_GEN,
21
+ KeyType.X9_42_DH: Mechanism.X9_42_DH_KEY_PAIR_GEN,
22
+ KeyType.EC_EDWARDS: Mechanism.EC_EDWARDS_KEY_PAIR_GEN,
23
+ KeyType.GENERIC_SECRET: Mechanism.GENERIC_SECRET_KEY_GEN,
24
+ }
25
+ """
26
+ Default mechanisms for generating keys.
27
+ """
28
+
29
+ _ENCRYPTION = MechanismFlag.ENCRYPT | MechanismFlag.DECRYPT
30
+ _SIGNING = MechanismFlag.SIGN | MechanismFlag.VERIFY
31
+ _WRAPPING = MechanismFlag.WRAP | MechanismFlag.UNWRAP
32
+
33
+ DEFAULT_KEY_CAPABILITIES = {
34
+ KeyType.AES: _ENCRYPTION | _SIGNING | _WRAPPING,
35
+ KeyType.DES2: _ENCRYPTION | _SIGNING | _WRAPPING,
36
+ KeyType.DES3: _ENCRYPTION | _SIGNING | _WRAPPING,
37
+ KeyType.DH: MechanismFlag.DERIVE,
38
+ KeyType.DSA: _SIGNING,
39
+ KeyType.EC: _SIGNING | MechanismFlag.DERIVE,
40
+ KeyType.RSA: _ENCRYPTION | _SIGNING | _WRAPPING,
41
+ KeyType.GENERIC_SECRET: 0,
42
+ KeyType.EC_EDWARDS: _SIGNING,
43
+ }
44
+ """
45
+ Default capabilities for generating keys.
46
+ """
47
+
48
+ DEFAULT_ENCRYPT_MECHANISMS = {
49
+ KeyType.AES: Mechanism.AES_CBC_PAD,
50
+ KeyType.DES2: Mechanism.DES3_CBC_PAD,
51
+ KeyType.DES3: Mechanism.DES3_CBC_PAD,
52
+ KeyType.RSA: Mechanism.RSA_PKCS_OAEP,
53
+ }
54
+ """
55
+ Default mechanisms for encrypt/decrypt.
56
+ """
57
+
58
+ DEFAULT_SIGN_MECHANISMS = {
59
+ KeyType.AES: Mechanism.AES_MAC,
60
+ KeyType.DES2: Mechanism.DES3_MAC,
61
+ KeyType.DES3: Mechanism.DES3_MAC,
62
+ KeyType.DSA: Mechanism.DSA_SHA512,
63
+ KeyType.EC: Mechanism.ECDSA_SHA512,
64
+ KeyType.RSA: Mechanism.SHA512_RSA_PKCS,
65
+ KeyType.EC_EDWARDS: Mechanism.EDDSA,
66
+ }
67
+ """
68
+ Default mechanisms for sign/verify.
69
+ """
70
+
71
+ DEFAULT_WRAP_MECHANISMS = {
72
+ KeyType.AES: Mechanism.AES_KEY_WRAP,
73
+ KeyType.DES2: Mechanism.DES3_ECB,
74
+ KeyType.DES3: Mechanism.DES3_ECB,
75
+ KeyType.RSA: Mechanism.RSA_PKCS_OAEP,
76
+ }
77
+ """
78
+ Default mechanism for wrap/unwrap.
79
+ """
80
+
81
+ DEFAULT_DERIVE_MECHANISMS = {
82
+ KeyType.DH: Mechanism.DH_PKCS_DERIVE,
83
+ KeyType.EC: Mechanism.ECDH1_DERIVE,
84
+ KeyType.X9_42_DH: Mechanism.X9_42_DH_DERIVE,
85
+ }
86
+ """
87
+ Default mechanisms for key derivation
88
+ """
89
+
90
+ DEFAULT_PARAM_GENERATE_MECHANISMS = {
91
+ KeyType.DH: Mechanism.DH_PKCS_PARAMETER_GEN,
92
+ KeyType.DSA: Mechanism.DSA_PARAMETER_GEN,
93
+ KeyType.X9_42_DH: Mechanism.X9_42_DH_PARAMETER_GEN,
94
+ }
95
+ """
96
+ Default mechanisms for domain parameter generation
97
+ """
98
+
99
+
100
+ DEFAULT_MECHANISM_PARAMS = {
101
+ Mechanism.RSA_PKCS_OAEP: (Mechanism.SHA_1, MGF.SHA1, None),
102
+ Mechanism.RSA_PKCS_PSS: (Mechanism.SHA_1, MGF.SHA1, 20),
103
+ }
104
+ """
105
+ Default mechanism parameters
106
+ """