tba-bases-encryption 0.4.0.dev2__tar.gz

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.
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: tba-bases-encryption
3
+ Version: 0.4.0.dev2
4
+ Summary: Reusable encryption, decryption, and cipher-policy bases.
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.10,<3.15
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Requires-Dist: tba-bases-protected-artifact (==0.4.0.dev2)
14
+ Requires-Dist: tba-contracts-security-trust (==0.1.0)
15
+ Description-Content-Type: text/markdown
16
+
17
+ # tba-bases-encryption
18
+
19
+ Reusable encryption, decryption, multi-recipient, and cipher-policy behavior.
20
+
@@ -0,0 +1,3 @@
1
+ # tba-bases-encryption
2
+
3
+ Reusable encryption, decryption, multi-recipient, and cipher-policy behavior.
@@ -0,0 +1,13 @@
1
+ [project]
2
+ name = "tba-bases-encryption"
3
+ version = "0.4.0.dev2"
4
+ description = "Reusable encryption, decryption, and cipher-policy bases."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10,<3.15"
7
+ license = "Apache-2.0"
8
+ dependencies = ["tba-bases-protected-artifact==0.4.0.dev2", "tba-contracts-security-trust==0.1.0"]
9
+ [build-system]
10
+ requires = ["poetry-core>=1.0.0"]
11
+ build-backend = "poetry.core.masonry.api"
12
+ [tool.poetry]
13
+ packages = [{ include = "tba_bases_encryption", from = "src" }]
@@ -0,0 +1,86 @@
1
+ """Reusable encryption and cipher-policy bases."""
2
+
3
+ from abc import ABC, abstractmethod
4
+ from typing import Any, Mapping, Sequence
5
+
6
+ from tba_bases_protected_artifact import (
7
+ ProtectedArtifactOpenerBase,
8
+ RecipientSetEditorBase,
9
+ SecurityArtifactIssuerBase,
10
+ )
11
+ from tba_contracts_security_trust import (
12
+ Artifact,
13
+ DecryptRequest,
14
+ EncryptRequest,
15
+ ICapabilityProvider,
16
+ ICipherPolicy,
17
+ IEncryptionProvider,
18
+ KeyRefLike,
19
+ NormalizedDescriptor,
20
+ )
21
+
22
+
23
+ class EncryptionProviderBase(IEncryptionProvider, ICapabilityProvider, ABC):
24
+ async def encrypt(self, request: EncryptRequest) -> Artifact:
25
+ raise NotImplementedError
26
+
27
+ async def decrypt(self, request: DecryptRequest) -> bytes:
28
+ raise NotImplementedError
29
+
30
+
31
+ class CryptoDomainBase(
32
+ ICapabilityProvider,
33
+ SecurityArtifactIssuerBase,
34
+ ProtectedArtifactOpenerBase,
35
+ ABC,
36
+ ):
37
+ """Single-recipient artifact-encryption composition."""
38
+
39
+
40
+ class MreCryptoDomainBase(
41
+ ICapabilityProvider,
42
+ SecurityArtifactIssuerBase,
43
+ ProtectedArtifactOpenerBase,
44
+ RecipientSetEditorBase,
45
+ ABC,
46
+ ):
47
+ """Multi-recipient artifact-encryption composition."""
48
+
49
+
50
+ class CipherPolicyDomainBase(ICipherPolicy, ICapabilityProvider, ABC):
51
+ @abstractmethod
52
+ def suite_id(self) -> str: ...
53
+
54
+ @abstractmethod
55
+ def default_alg(self, op: str, *, for_key: KeyRefLike | None = None) -> str: ...
56
+
57
+ @abstractmethod
58
+ def normalize(
59
+ self,
60
+ *,
61
+ op: str,
62
+ alg: str | None = None,
63
+ key: KeyRefLike | None = None,
64
+ params: Mapping[str, Any] | None = None,
65
+ dialect: str | None = None,
66
+ ) -> NormalizedDescriptor: ...
67
+
68
+ def lint(self) -> Sequence[str]:
69
+ issues: list[str] = []
70
+ for op, allowed in self.supports().ops.items():
71
+ try:
72
+ default = self.default_alg(op)
73
+ except Exception as exc: # pragma: no cover - defensive base behavior
74
+ issues.append(f"default_alg({op}) raised: {exc!r}")
75
+ continue
76
+ if default not in set(allowed):
77
+ issues.append(f"default_alg({op})={default} not in supports().ops[{op}]")
78
+ return tuple(issues)
79
+
80
+
81
+ __all__ = [
82
+ "CipherPolicyDomainBase",
83
+ "CryptoDomainBase",
84
+ "EncryptionProviderBase",
85
+ "MreCryptoDomainBase",
86
+ ]