swarmauri_signing_hmac 0.3.0.dev48__tar.gz → 0.11.0.dev1__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_signing_hmac-0.3.0.dev48 → swarmauri_signing_hmac-0.11.0.dev1}/PKG-INFO +19 -16
- {swarmauri_signing_hmac-0.3.0.dev48 → swarmauri_signing_hmac-0.11.0.dev1}/README.md +12 -12
- {swarmauri_signing_hmac-0.3.0.dev48 → swarmauri_signing_hmac-0.11.0.dev1}/pyproject.toml +7 -5
- {swarmauri_signing_hmac-0.3.0.dev48 → swarmauri_signing_hmac-0.11.0.dev1}/swarmauri_signing_hmac/HmacEnvelopeSigner.py +35 -11
- {swarmauri_signing_hmac-0.3.0.dev48 → swarmauri_signing_hmac-0.11.0.dev1}/LICENSE +0 -0
- {swarmauri_signing_hmac-0.3.0.dev48 → swarmauri_signing_hmac-0.11.0.dev1}/swarmauri_signing_hmac/__init__.py +0 -0
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swarmauri_signing_hmac
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0.dev1
|
|
4
4
|
Summary: HMAC-based signer for Swarmauri
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Keywords: swarmauri,signing,hmac,symmetric,message-authentication,sdk,standards,cryptography,message-integrity,keyed-hash,token-signing,mac-algorithm
|
|
8
8
|
Author: Jacob Stewart
|
|
9
9
|
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.
|
|
10
|
+
Requires-Python: >=3.10,<3.15
|
|
11
11
|
Classifier: Development Status :: 1 - Planning
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Topic :: Security :: Cryptography
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
14
16
|
Classifier: Programming Language :: Python
|
|
15
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
19
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
21
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
Classifier:
|
|
20
|
-
Classifier:
|
|
21
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
24
|
Provides-Extra: cbor
|
|
23
25
|
Requires-Dist: cbor2 ; extra == "cbor"
|
|
24
26
|
Requires-Dist: swarmauri_base
|
|
@@ -28,22 +30,21 @@ Project-URL: Homepage, https://github.com/swarmauri/swarmauri-sdk
|
|
|
28
30
|
Project-URL: Source, https://github.com/swarmauri/swarmauri-sdk/tree/main/pkgs/standards/swarmauri_signing_hmac
|
|
29
31
|
Description-Content-Type: text/markdown
|
|
30
32
|
|
|
31
|
-

|
|
32
34
|
|
|
33
35
|
<p align="center">
|
|
34
|
-
<a href="https://
|
|
35
|
-
<img src="https://
|
|
36
|
+
<a href="https://pepy.tech/project/swarmauri_signing_hmac/">
|
|
37
|
+
<img src="https://static.pepy.tech/badge/swarmauri_signing_hmac/month" alt="PyPI - Downloads"/></a>
|
|
36
38
|
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_hmac/">
|
|
37
39
|
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_hmac.svg"/></a>
|
|
38
40
|
<a href="https://pypi.org/project/swarmauri_signing_hmac/">
|
|
39
|
-
<img src="https://img.shields.io/
|
|
41
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
40
42
|
<a href="https://pypi.org/project/swarmauri_signing_hmac/">
|
|
41
43
|
<img src="https://img.shields.io/pypi/l/swarmauri_signing_hmac" alt="PyPI - License"/></a>
|
|
42
44
|
<a href="https://pypi.org/project/swarmauri_signing_hmac/">
|
|
43
45
|
<img src="https://img.shields.io/pypi/v/swarmauri_signing_hmac?label=swarmauri_signing_hmac&color=green" alt="PyPI - swarmauri_signing_hmac"/></a>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
---
|
|
46
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
47
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
47
48
|
|
|
48
49
|
# Swarmauri Signing HMAC
|
|
49
50
|
|
|
@@ -123,12 +124,12 @@ Verification requires providing one or more keys via `opts["keys"]`.
|
|
|
123
124
|
|
|
124
125
|
`HmacEnvelopeSigner` accepts multiple `KeyRef` forms:
|
|
125
126
|
|
|
126
|
-
- `{"kind": "raw", "key": <bytes-or-str>}`
|
|
127
|
-
- `{"kind": "hex", "key": <hex str>}`
|
|
128
|
-
- `{"kind": "env", "name": <ENV_NAME>}`
|
|
127
|
+
- `{"kind": "raw", "key": <bytes-or-str>}` ? direct secret material.
|
|
128
|
+
- `{"kind": "hex", "key": <hex str>}` ? hex encoded secret.
|
|
129
|
+
- `{"kind": "env", "name": <ENV_NAME>}` ? loads the secret from an environment
|
|
129
130
|
variable.
|
|
130
131
|
- `{"kind": "derived", "key": <bytes-or-str>, "hkdf": {"salt": ..., "info": ...}}`
|
|
131
|
-
|
|
132
|
+
? derives the signing secret with HKDF.
|
|
132
133
|
|
|
133
134
|
Provide an optional `"kid"` to control the key identifier or specify
|
|
134
135
|
`"alg"` when verifying to override the default `HS256` digest for a key entry.
|
|
@@ -142,3 +143,5 @@ The signer registers under the `swarmauri.signings` entry point as `HmacEnvelope
|
|
|
142
143
|
If you want to contribute to swarmauri-sdk, read up on our
|
|
143
144
|
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
144
145
|
that will help you get started.
|
|
146
|
+
|
|
147
|
+
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<a href="https://
|
|
5
|
-
<img src="https://
|
|
4
|
+
<a href="https://pepy.tech/project/swarmauri_signing_hmac/">
|
|
5
|
+
<img src="https://static.pepy.tech/badge/swarmauri_signing_hmac/month" alt="PyPI - Downloads"/></a>
|
|
6
6
|
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_hmac/">
|
|
7
7
|
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_hmac.svg"/></a>
|
|
8
8
|
<a href="https://pypi.org/project/swarmauri_signing_hmac/">
|
|
9
|
-
<img src="https://img.shields.io/
|
|
9
|
+
<img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
|
|
10
10
|
<a href="https://pypi.org/project/swarmauri_signing_hmac/">
|
|
11
11
|
<img src="https://img.shields.io/pypi/l/swarmauri_signing_hmac" alt="PyPI - License"/></a>
|
|
12
12
|
<a href="https://pypi.org/project/swarmauri_signing_hmac/">
|
|
13
13
|
<img src="https://img.shields.io/pypi/v/swarmauri_signing_hmac?label=swarmauri_signing_hmac&color=green" alt="PyPI - swarmauri_signing_hmac"/></a>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
---
|
|
14
|
+
<a href="https://discord.gg/N4UpBuQv8T">
|
|
15
|
+
<img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
|
|
17
16
|
|
|
18
17
|
# Swarmauri Signing HMAC
|
|
19
18
|
|
|
@@ -93,12 +92,12 @@ Verification requires providing one or more keys via `opts["keys"]`.
|
|
|
93
92
|
|
|
94
93
|
`HmacEnvelopeSigner` accepts multiple `KeyRef` forms:
|
|
95
94
|
|
|
96
|
-
- `{"kind": "raw", "key": <bytes-or-str>}`
|
|
97
|
-
- `{"kind": "hex", "key": <hex str>}`
|
|
98
|
-
- `{"kind": "env", "name": <ENV_NAME>}`
|
|
95
|
+
- `{"kind": "raw", "key": <bytes-or-str>}` ? direct secret material.
|
|
96
|
+
- `{"kind": "hex", "key": <hex str>}` ? hex encoded secret.
|
|
97
|
+
- `{"kind": "env", "name": <ENV_NAME>}` ? loads the secret from an environment
|
|
99
98
|
variable.
|
|
100
99
|
- `{"kind": "derived", "key": <bytes-or-str>, "hkdf": {"salt": ..., "info": ...}}`
|
|
101
|
-
|
|
100
|
+
? derives the signing secret with HKDF.
|
|
102
101
|
|
|
103
102
|
Provide an optional `"kid"` to control the key identifier or specify
|
|
104
103
|
`"alg"` when verifying to override the default `HS256` digest for a key entry.
|
|
@@ -111,4 +110,5 @@ The signer registers under the `swarmauri.signings` entry point as `HmacEnvelope
|
|
|
111
110
|
|
|
112
111
|
If you want to contribute to swarmauri-sdk, read up on our
|
|
113
112
|
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
114
|
-
that will help you get started.
|
|
113
|
+
that will help you get started.
|
|
114
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_signing_hmac"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.11.0.dev1"
|
|
4
4
|
description = "HMAC-based signer for Swarmauri"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
|
-
requires-python = ">=3.10,<3.
|
|
7
|
+
requires-python = ">=3.10,<3.15"
|
|
8
8
|
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
9
9
|
keywords = [
|
|
10
10
|
"swarmauri",
|
|
@@ -24,14 +24,16 @@ classifiers = [
|
|
|
24
24
|
"Development Status :: 1 - Planning",
|
|
25
25
|
"License :: OSI Approved :: Apache Software License",
|
|
26
26
|
"Natural Language :: English",
|
|
27
|
+
"Topic :: Security :: Cryptography",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
27
29
|
"Programming Language :: Python",
|
|
28
30
|
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
29
32
|
"Programming Language :: Python :: 3.10",
|
|
30
33
|
"Programming Language :: Python :: 3.11",
|
|
31
34
|
"Programming Language :: Python :: 3.12",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"Programming Language :: Python :: 3 :: Only",
|
|
35
|
+
"Programming Language :: Python :: 3.13",
|
|
36
|
+
"Programming Language :: Python :: 3.14",
|
|
35
37
|
]
|
|
36
38
|
dependencies = [
|
|
37
39
|
"swarmauri_core",
|
|
@@ -31,7 +31,10 @@ def _canon_json(obj: Any) -> bytes:
|
|
|
31
31
|
def _canon_cbor(obj: Any) -> bytes:
|
|
32
32
|
if not _CBOR_OK:
|
|
33
33
|
raise RuntimeError(
|
|
34
|
-
|
|
34
|
+
(
|
|
35
|
+
"CBOR canonicalization requires 'cbor2'. Install with: pip "
|
|
36
|
+
"install cbor2"
|
|
37
|
+
)
|
|
35
38
|
)
|
|
36
39
|
return cbor2.dumps(obj)
|
|
37
40
|
|
|
@@ -44,7 +47,7 @@ def _alg_to_hash(alg: JWAAlg):
|
|
|
44
47
|
}
|
|
45
48
|
if alg not in table:
|
|
46
49
|
raise ValueError(
|
|
47
|
-
f"Unsupported HMAC alg '{alg}'. Use one of: {', '.join(a.value for a in table)}"
|
|
50
|
+
f"Unsupported HMAC alg '{alg}'. Use one of: {', '.join(a.value for a in table)}" # noqa: E501
|
|
48
51
|
)
|
|
49
52
|
return table[alg]
|
|
50
53
|
|
|
@@ -97,8 +100,12 @@ def _resolve_secret(key: KeyRef, *, hash_ctor) -> tuple[bytes, str]:
|
|
|
97
100
|
hkdf_cfg = key.get("hkdf", {}) or {}
|
|
98
101
|
salt = hkdf_cfg.get("salt")
|
|
99
102
|
info = hkdf_cfg.get("info")
|
|
100
|
-
salt_b =
|
|
101
|
-
|
|
103
|
+
salt_b = (
|
|
104
|
+
None if salt is None else _ensure_bytes(salt, name="hkdf.salt")
|
|
105
|
+
)
|
|
106
|
+
info_b = (
|
|
107
|
+
None if info is None else _ensure_bytes(info, name="hkdf.info")
|
|
108
|
+
)
|
|
102
109
|
secret = _hkdf(ikm, salt=salt_b, info=info_b, hash_ctor=hash_ctor)
|
|
103
110
|
else:
|
|
104
111
|
raise TypeError(f"Unsupported HMAC KeyRef kind '{kind}'")
|
|
@@ -163,7 +170,9 @@ class HmacEnvelopeSigner(SigningBase):
|
|
|
163
170
|
tag_size = int(opts["tag_size"]) # type: ignore[arg-type]
|
|
164
171
|
digest_size = hash_ctor().digest_size
|
|
165
172
|
if tag_size < 16:
|
|
166
|
-
raise ValueError(
|
|
173
|
+
raise ValueError(
|
|
174
|
+
"tag_size must be at least 16 bytes (128 bits)"
|
|
175
|
+
)
|
|
167
176
|
if tag_size > digest_size:
|
|
168
177
|
raise ValueError(
|
|
169
178
|
f"tag_size cannot exceed digest size ({digest_size} bytes)"
|
|
@@ -182,7 +191,9 @@ class HmacEnvelopeSigner(SigningBase):
|
|
|
182
191
|
req = require or {}
|
|
183
192
|
allowed_algs = {
|
|
184
193
|
(a if isinstance(a, JWAAlg) else JWAAlg(a))
|
|
185
|
-
for a in (
|
|
194
|
+
for a in (
|
|
195
|
+
req.get("algs") or [JWAAlg.HS256, JWAAlg.HS384, JWAAlg.HS512]
|
|
196
|
+
)
|
|
186
197
|
}
|
|
187
198
|
min_signers = int(req.get("min_signers", 1))
|
|
188
199
|
required_kids = set(req.get("kids") or [])
|
|
@@ -191,11 +202,18 @@ class HmacEnvelopeSigner(SigningBase):
|
|
|
191
202
|
key_entries = (opts or {}).get("keys") or []
|
|
192
203
|
if not isinstance(key_entries, (list, tuple)) or not key_entries:
|
|
193
204
|
raise RuntimeError(
|
|
194
|
-
|
|
205
|
+
(
|
|
206
|
+
"HMAC verification requires opts['keys'] with one or more "
|
|
207
|
+
"KeyRef entries."
|
|
208
|
+
)
|
|
195
209
|
)
|
|
196
210
|
for entry in key_entries: # type: ignore[assignment]
|
|
197
211
|
prefer_alg: Optional[JWAAlg] = None
|
|
198
|
-
if
|
|
212
|
+
if (
|
|
213
|
+
isinstance(entry, dict)
|
|
214
|
+
and "alg" in entry
|
|
215
|
+
and entry["alg"] is not None
|
|
216
|
+
):
|
|
199
217
|
prefer_alg = (
|
|
200
218
|
entry["alg"]
|
|
201
219
|
if isinstance(entry["alg"], JWAAlg)
|
|
@@ -234,7 +252,9 @@ class HmacEnvelopeSigner(SigningBase):
|
|
|
234
252
|
|
|
235
253
|
for _, secret in iter_keys:
|
|
236
254
|
calc = hmac.new(secret, payload, hash_ctor).digest()
|
|
237
|
-
if hmac.compare_digest(
|
|
255
|
+
if hmac.compare_digest(
|
|
256
|
+
calc[: len(sig_bytes)], bytes(sig_bytes)
|
|
257
|
+
):
|
|
238
258
|
ok_one = True
|
|
239
259
|
break
|
|
240
260
|
|
|
@@ -263,7 +283,9 @@ class HmacEnvelopeSigner(SigningBase):
|
|
|
263
283
|
require: Optional[Mapping[str, object]] = None,
|
|
264
284
|
opts: Optional[Mapping[str, object]] = None,
|
|
265
285
|
) -> bool:
|
|
266
|
-
return await self.verify_bytes(
|
|
286
|
+
return await self.verify_bytes(
|
|
287
|
+
digest, signatures, require=require, opts=opts
|
|
288
|
+
)
|
|
267
289
|
|
|
268
290
|
async def canonicalize_envelope(
|
|
269
291
|
self,
|
|
@@ -300,4 +322,6 @@ class HmacEnvelopeSigner(SigningBase):
|
|
|
300
322
|
opts: Optional[Mapping[str, object]] = None,
|
|
301
323
|
) -> bool:
|
|
302
324
|
payload = await self.canonicalize_envelope(env, canon=canon, opts=opts)
|
|
303
|
-
return await self.verify_bytes(
|
|
325
|
+
return await self.verify_bytes(
|
|
326
|
+
payload, signatures, require=require, opts=opts
|
|
327
|
+
)
|
|
File without changes
|
|
File without changes
|