swarmauri_cipher_suite_jwa 0.11.0.dev2__tar.gz → 0.11.0.dev4__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.
- {swarmauri_cipher_suite_jwa-0.11.0.dev2 → swarmauri_cipher_suite_jwa-0.11.0.dev4}/PKG-INFO +18 -1
- {swarmauri_cipher_suite_jwa-0.11.0.dev2 → swarmauri_cipher_suite_jwa-0.11.0.dev4}/README.md +17 -0
- {swarmauri_cipher_suite_jwa-0.11.0.dev2 → swarmauri_cipher_suite_jwa-0.11.0.dev4}/pyproject.toml +1 -1
- {swarmauri_cipher_suite_jwa-0.11.0.dev2 → swarmauri_cipher_suite_jwa-0.11.0.dev4}/swarmauri_cipher_suite_jwa/JwaCipherSuite.py +29 -1
- {swarmauri_cipher_suite_jwa-0.11.0.dev2 → swarmauri_cipher_suite_jwa-0.11.0.dev4}/LICENSE +0 -0
- {swarmauri_cipher_suite_jwa-0.11.0.dev2 → swarmauri_cipher_suite_jwa-0.11.0.dev4}/swarmauri_cipher_suite_jwa/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swarmauri_cipher_suite_jwa
|
|
3
|
-
Version: 0.11.0.
|
|
3
|
+
Version: 0.11.0.dev4
|
|
4
4
|
Summary: JWA-focused cipher suite for Swarmauri
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
@@ -116,6 +116,23 @@ per-dialect aliases, policy constraints, and defaulted parameters. Crypto and
|
|
|
116
116
|
signing providers consume this descriptor to select the correct primitives
|
|
117
117
|
without re-implementing JWA policy logic.
|
|
118
118
|
|
|
119
|
+
### Opt-in X448 key agreement
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from swarmauri_cipher_suite_jwa import JwaCipherSuite
|
|
123
|
+
|
|
124
|
+
suite = JwaCipherSuite(enable_x448=True)
|
|
125
|
+
agreement = suite.normalize(
|
|
126
|
+
op="key_agreement",
|
|
127
|
+
alg="ECDH-ES",
|
|
128
|
+
key={"kty": "OKP", "crv": "X448"},
|
|
129
|
+
params={"enc": "A256GCM"},
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The suite validates the selection. Use `JweCrypto(enable_x448=True)`
|
|
134
|
+
from `swarmauri-crypto-jwe` to perform compact JWE encryption or decryption.
|
|
135
|
+
|
|
119
136
|
## Entry Point
|
|
120
137
|
|
|
121
138
|
The suite registers under the `swarmauri.cipher_suites` entry point as
|
|
@@ -89,6 +89,23 @@ per-dialect aliases, policy constraints, and defaulted parameters. Crypto and
|
|
|
89
89
|
signing providers consume this descriptor to select the correct primitives
|
|
90
90
|
without re-implementing JWA policy logic.
|
|
91
91
|
|
|
92
|
+
### Opt-in X448 key agreement
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from swarmauri_cipher_suite_jwa import JwaCipherSuite
|
|
96
|
+
|
|
97
|
+
suite = JwaCipherSuite(enable_x448=True)
|
|
98
|
+
agreement = suite.normalize(
|
|
99
|
+
op="key_agreement",
|
|
100
|
+
alg="ECDH-ES",
|
|
101
|
+
key={"kty": "OKP", "crv": "X448"},
|
|
102
|
+
params={"enc": "A256GCM"},
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The suite validates the selection. Use `JweCrypto(enable_x448=True)`
|
|
107
|
+
from `swarmauri-crypto-jwe` to perform compact JWE encryption or decryption.
|
|
108
|
+
|
|
92
109
|
## Entry Point
|
|
93
110
|
|
|
94
111
|
The suite registers under the `swarmauri.cipher_suites` entry point as
|
|
@@ -31,6 +31,8 @@ _JWA_TO_COSE = {
|
|
|
31
31
|
class JwaCipherSuite(CipherSuiteBase):
|
|
32
32
|
"""JSON Web Algorithm policy surface (RFC 7518)."""
|
|
33
33
|
|
|
34
|
+
enable_x448: bool = False
|
|
35
|
+
|
|
34
36
|
def suite_id(self) -> str:
|
|
35
37
|
return "jwa"
|
|
36
38
|
|
|
@@ -58,15 +60,21 @@ class JwaCipherSuite(CipherSuiteBase):
|
|
|
58
60
|
"decrypt": ("A128GCM", "A192GCM", "A256GCM"),
|
|
59
61
|
"wrap": ("RSA-OAEP", "RSA-OAEP-256", "A256KW"),
|
|
60
62
|
"unwrap": ("RSA-OAEP", "RSA-OAEP-256", "A256KW"),
|
|
63
|
+
**({"key_agreement": ("ECDH-ES",)} if self.enable_x448 else {}),
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
def default_alg(
|
|
64
67
|
self, op: CipherOp, *, for_key: Optional[KeyRef] = None
|
|
65
68
|
) -> Alg:
|
|
69
|
+
if op == "key_agreement" and not self.enable_x448:
|
|
70
|
+
raise ValueError(
|
|
71
|
+
"key_agreement is not supported without X448 opt-in."
|
|
72
|
+
)
|
|
66
73
|
defaults = {
|
|
67
74
|
"sign": "EdDSA",
|
|
68
75
|
"encrypt": "A256GCM",
|
|
69
76
|
"wrap": "RSA-OAEP-256",
|
|
77
|
+
"key_agreement": "ECDH-ES",
|
|
70
78
|
}
|
|
71
79
|
return defaults.get(op, "A256GCM")
|
|
72
80
|
|
|
@@ -89,7 +97,20 @@ class JwaCipherSuite(CipherSuiteBase):
|
|
|
89
97
|
for op, values in allowed.items()
|
|
90
98
|
if values
|
|
91
99
|
},
|
|
92
|
-
"constraints": {
|
|
100
|
+
"constraints": {
|
|
101
|
+
"aead": {"tagBits": 128, "nonceLen": 12},
|
|
102
|
+
**(
|
|
103
|
+
{
|
|
104
|
+
"key_agreement": {
|
|
105
|
+
"kty": "OKP",
|
|
106
|
+
"crv": "X448",
|
|
107
|
+
"enc": "A256GCM",
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if self.enable_x448
|
|
111
|
+
else {}
|
|
112
|
+
),
|
|
113
|
+
},
|
|
93
114
|
"compliance": {"fips": False},
|
|
94
115
|
}
|
|
95
116
|
|
|
@@ -108,6 +129,13 @@ class JwaCipherSuite(CipherSuiteBase):
|
|
|
108
129
|
raise ValueError(f"{chosen=} not supported for {op=}")
|
|
109
130
|
|
|
110
131
|
resolved = dict(params or {})
|
|
132
|
+
if chosen == "ECDH-ES":
|
|
133
|
+
if not key or (key.get("kty"), key.get("crv")) != ("OKP", "X448"):
|
|
134
|
+
raise ValueError("ECDH-ES policy requires an OKP/X448 key.")
|
|
135
|
+
if resolved.setdefault("enc", "A256GCM") != "A256GCM":
|
|
136
|
+
raise ValueError("X448 requires A256GCM.")
|
|
137
|
+
if resolved.setdefault("crv", "X448") != "X448":
|
|
138
|
+
raise ValueError("ECDH-ES policy requires X448.")
|
|
111
139
|
if chosen.endswith("GCM"):
|
|
112
140
|
resolved.setdefault("tagBits", 128)
|
|
113
141
|
resolved.setdefault("nonceLen", 12)
|
|
File without changes
|