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 ADDED
@@ -0,0 +1,50 @@
1
+ """
2
+ :mod:`pkcs11` defines a high-level, "Pythonic" interface to PKCS#11.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ from typing import TYPE_CHECKING, Any
8
+
9
+ from pkcs11.constants import * # noqa: F403
10
+ from pkcs11.exceptions import * # noqa: F403
11
+ from pkcs11.mechanisms import * # noqa: F403
12
+ from pkcs11.types import * # noqa: F403
13
+ from pkcs11.util import dh, dsa, ec, rsa, x509 # noqa: F401
14
+
15
+ if TYPE_CHECKING:
16
+ from pkcs11._pkcs11 import lib as _lib_type
17
+
18
+
19
+ _loaded: dict[str, Any] = {}
20
+
21
+
22
+ def lib(so: str) -> _lib_type:
23
+ """
24
+ Wrap the main library call coming from Cython with a preemptive
25
+ dynamic loading.
26
+ """
27
+
28
+ try:
29
+ _lib = _loaded[so]
30
+ if not _lib.initialized:
31
+ _lib.initialize()
32
+ return _lib
33
+ except KeyError:
34
+ pass
35
+
36
+ from . import _pkcs11
37
+
38
+ _lib = _pkcs11.lib(so)
39
+ _loaded[so] = _lib
40
+
41
+ return _lib
42
+
43
+
44
+ def unload(so: str) -> None:
45
+ try:
46
+ loaded_lib = _loaded[so]
47
+ except KeyError:
48
+ return
49
+ del _loaded[so]
50
+ loaded_lib.unload()
Binary file