|
7 | 7 |
|
8 | 8 | from datetime import datetime |
9 | 9 | from struct import Struct |
| 10 | +from typing import Any, Callable |
10 | 11 |
|
11 | | -from .constants import ( |
| 12 | +from pkcs11.constants import ( |
12 | 13 | Attribute, |
13 | 14 | CertificateType, |
14 | 15 | MechanismFlag, |
15 | 16 | ObjectClass, |
16 | 17 | ) |
17 | | -from .mechanisms import MGF, KeyType, Mechanism |
| 18 | +from pkcs11.mechanisms import MGF, KeyType, Mechanism |
18 | 19 |
|
19 | 20 | DEFAULT_GENERATE_MECHANISMS = { |
20 | 21 | KeyType.AES: Mechanism.AES_KEY_GEN, |
|
35 | 36 | _SIGNING = MechanismFlag.SIGN | MechanismFlag.VERIFY |
36 | 37 | _WRAPPING = MechanismFlag.WRAP | MechanismFlag.UNWRAP |
37 | 38 |
|
38 | | -DEFAULT_KEY_CAPABILITIES = { |
| 39 | +DEFAULT_KEY_CAPABILITIES: dict[KeyType, MechanismFlag] = { |
39 | 40 | KeyType.AES: _ENCRYPTION | _SIGNING | _WRAPPING, |
40 | 41 | KeyType.DES2: _ENCRYPTION | _SIGNING | _WRAPPING, |
41 | 42 | KeyType.DES3: _ENCRYPTION | _SIGNING | _WRAPPING, |
42 | 43 | KeyType.DH: MechanismFlag.DERIVE, |
43 | 44 | KeyType.DSA: _SIGNING, |
44 | 45 | KeyType.EC: _SIGNING | MechanismFlag.DERIVE, |
45 | 46 | KeyType.RSA: _ENCRYPTION | _SIGNING | _WRAPPING, |
46 | | - KeyType.GENERIC_SECRET: 0, |
| 47 | + KeyType.GENERIC_SECRET: 0, # type: ignore[dict-item] |
47 | 48 | KeyType.EC_EDWARDS: _SIGNING, |
48 | 49 | } |
| 50 | + |
49 | 51 | """ |
50 | 52 | Default capabilities for generating keys. |
51 | 53 | """ |
|
125 | 127 | _biginteger = _bytes |
126 | 128 |
|
127 | 129 |
|
128 | | -def _enum(type_): |
| 130 | +def _enum(type_: type[Any]) -> tuple[Callable[[Any], bytes], Callable[[Any], Any]]: |
129 | 131 | """Factory to pack/unpack intos into IntEnums.""" |
130 | 132 | pack, unpack = _ulong |
131 | 133 |
|
132 | | - return (lambda v: pack(int(v)), lambda v: type_(unpack(v))) |
| 134 | + return (lambda v: pack(int(v)), lambda v: type_(unpack(v))) # type: ignore[no-untyped-call] |
133 | 135 |
|
134 | 136 |
|
135 | 137 | ATTRIBUTE_TYPES = { |
|
0 commit comments