swarmauri_signing_pgp 0.3.0.dev47__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.
@@ -1,27 +1,30 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: swarmauri_signing_pgp
3
- Version: 0.3.0.dev47
3
+ Version: 0.11.0.dev1
4
4
  Summary: OpenPGP envelope signer for Swarmauri
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
7
7
  Keywords: swarmauri,signing,pgp,openpgp,envelope,sdk,standards,cryptography,digital-signature,pgp-keys,ascii-armor,message-codec,openpgp-format
8
8
  Author: Jacob Stewart
9
9
  Author-email: jacob@swarmauri.com
10
- Requires-Python: >=3.10,<3.13
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: Topic :: Security :: Cryptography
20
- Classifier: Intended Audience :: Developers
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 (>=5.4.6) ; extra == "cbor"
24
26
  Requires-Dist: pgpy (>=0.6.0)
27
+ Requires-Dist: standard-imghdr (>=3.13.0) ; python_version >= "3.13"
25
28
  Requires-Dist: swarmauri_base
26
29
  Requires-Dist: swarmauri_core
27
30
  Requires-Dist: swarmauri_standard
@@ -30,22 +33,21 @@ Project-URL: Homepage, https://github.com/swarmauri/swarmauri-sdk
30
33
  Project-URL: Source, https://github.com/swarmauri/swarmauri-sdk/tree/main/pkgs/standards/swarmauri_signing_pgp
31
34
  Description-Content-Type: text/markdown
32
35
 
33
- ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
36
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
34
37
 
35
38
  <p align="center">
36
- <a href="https://pypi.org/project/swarmauri_signing_pgp/">
37
- <img src="https://img.shields.io/pypi/dm/swarmauri_signing_pgp" alt="PyPI - Downloads"/></a>
39
+ <a href="https://pepy.tech/project/swarmauri_signing_pgp/">
40
+ <img src="https://static.pepy.tech/badge/swarmauri_signing_pgp/month" alt="PyPI - Downloads"/></a>
38
41
  <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_pgp/">
39
42
  <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_pgp.svg"/></a>
40
43
  <a href="https://pypi.org/project/swarmauri_signing_pgp/">
41
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_signing_pgp" alt="PyPI - Python Version"/></a>
44
+ <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>
42
45
  <a href="https://pypi.org/project/swarmauri_signing_pgp/">
43
46
  <img src="https://img.shields.io/pypi/l/swarmauri_signing_pgp" alt="PyPI - License"/></a>
44
47
  <a href="https://pypi.org/project/swarmauri_signing_pgp/">
45
48
  <img src="https://img.shields.io/pypi/v/swarmauri_signing_pgp?label=swarmauri_signing_pgp&color=green" alt="PyPI - swarmauri_signing_pgp"/></a>
46
- </p>
47
-
48
- ---
49
+ <a href="https://discord.gg/N4UpBuQv8T">
50
+ <img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
49
51
 
50
52
  # Swarmauri Signing PGP
51
53
 
@@ -174,3 +176,5 @@ Use `canon="cbor"` to opt into CBOR canonicalization. The `supports()` helper
174
176
  exposes the available algorithms, canonicalization formats, and feature flags at
175
177
  runtime.
176
178
 
179
+
180
+
@@ -1,19 +1,18 @@
1
- ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
1
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
2
2
 
3
3
  <p align="center">
4
- <a href="https://pypi.org/project/swarmauri_signing_pgp/">
5
- <img src="https://img.shields.io/pypi/dm/swarmauri_signing_pgp" alt="PyPI - Downloads"/></a>
4
+ <a href="https://pepy.tech/project/swarmauri_signing_pgp/">
5
+ <img src="https://static.pepy.tech/badge/swarmauri_signing_pgp/month" alt="PyPI - Downloads"/></a>
6
6
  <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_pgp/">
7
7
  <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_signing_pgp.svg"/></a>
8
8
  <a href="https://pypi.org/project/swarmauri_signing_pgp/">
9
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_signing_pgp" alt="PyPI - Python Version"/></a>
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_pgp/">
11
11
  <img src="https://img.shields.io/pypi/l/swarmauri_signing_pgp" alt="PyPI - License"/></a>
12
12
  <a href="https://pypi.org/project/swarmauri_signing_pgp/">
13
13
  <img src="https://img.shields.io/pypi/v/swarmauri_signing_pgp?label=swarmauri_signing_pgp&color=green" alt="PyPI - swarmauri_signing_pgp"/></a>
14
- </p>
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 PGP
19
18
 
@@ -141,3 +140,5 @@ await signer.verify_envelope(
141
140
  Use `canon="cbor"` to opt into CBOR canonicalization. The `supports()` helper
142
141
  exposes the available algorithms, canonicalization formats, and feature flags at
143
142
  runtime.
143
+
144
+
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "swarmauri_signing_pgp"
3
- version = "0.3.0.dev47"
3
+ version = "0.11.0.dev1"
4
4
  description = "OpenPGP envelope signer for Swarmauri"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
7
- requires-python = ">=3.10,<3.13"
7
+ requires-python = ">=3.10,<3.15"
8
8
  authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
9
9
  keywords = [
10
10
  "swarmauri",
@@ -25,20 +25,23 @@ classifiers = [
25
25
  "Development Status :: 1 - Planning",
26
26
  "License :: OSI Approved :: Apache Software License",
27
27
  "Natural Language :: English",
28
+ "Topic :: Security :: Cryptography",
29
+ "Intended Audience :: Developers",
28
30
  "Programming Language :: Python",
29
31
  "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3 :: Only",
30
33
  "Programming Language :: Python :: 3.10",
31
34
  "Programming Language :: Python :: 3.11",
32
35
  "Programming Language :: Python :: 3.12",
33
- "Topic :: Security :: Cryptography",
34
- "Intended Audience :: Developers",
35
- "Programming Language :: Python :: 3 :: Only",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Programming Language :: Python :: 3.14",
36
38
  ]
37
39
  dependencies = [
38
40
  "swarmauri_core",
39
41
  "swarmauri_base",
40
42
  "swarmauri_standard",
41
43
  "pgpy>=0.6.0",
44
+ "standard-imghdr>=3.13.0; python_version >= '3.13'",
42
45
  ]
43
46
 
44
47
  [project.urls]
@@ -12,14 +12,24 @@ from __future__ import annotations
12
12
 
13
13
  from dataclasses import dataclass
14
14
  import json
15
- from typing import Any, Dict, Iterable, Mapping, Optional, Sequence, TYPE_CHECKING
15
+ from typing import (
16
+ Any,
17
+ Dict,
18
+ Iterable,
19
+ Mapping,
20
+ Optional,
21
+ Sequence,
22
+ TYPE_CHECKING,
23
+ )
16
24
 
17
25
  try:
18
26
  from swarmauri_base.signing.SigningBase import SigningBase
19
27
  except Exception: # pragma: no cover
20
28
 
21
29
  class SigningBase: # type: ignore[too-many-ancestors]
22
- """Fallback ``SigningBase`` used when :mod:`swarmauri_base` is missing."""
30
+ """
31
+ Fallback ``SigningBase`` used when :mod:`swarmauri_base` is missing.
32
+ """
23
33
 
24
34
  pass
25
35
 
@@ -91,7 +101,9 @@ def _canon_cbor(obj) -> bytes:
91
101
  """
92
102
 
93
103
  if not _CBOR_OK:
94
- raise RuntimeError("CBOR canonicalization requires 'cbor2' to be installed.")
104
+ raise RuntimeError(
105
+ "CBOR canonicalization requires 'cbor2' to be installed."
106
+ )
95
107
  return cbor2.dumps(obj)
96
108
 
97
109
 
@@ -101,10 +113,14 @@ class _Sig:
101
113
 
102
114
  data: Dict[str, Any]
103
115
 
104
- def __getitem__(self, k: str) -> object: # pragma: no cover - simple delegation
116
+ def __getitem__(
117
+ self, k: str
118
+ ) -> object: # pragma: no cover - simple delegation
105
119
  return self.data[k]
106
120
 
107
- def get(self, k: str, default=None): # pragma: no cover - simple delegation
121
+ def get(
122
+ self, k: str, default=None
123
+ ): # pragma: no cover - simple delegation
108
124
  return self.data.get(k, default)
109
125
 
110
126
  def __iter__(self): # pragma: no cover - simple delegation
@@ -122,10 +138,12 @@ class PgpEnvelopeSigner(SigningBase):
122
138
  """
123
139
 
124
140
  def supports(self) -> Mapping[str, Iterable[str]]:
125
- """Describe the algorithms and canonicalizations supported by the signer.
141
+ """
142
+ Describe the algorithms and canonicalizations supported by the signer.
126
143
 
127
144
  Returns:
128
- Mapping[str, Iterable[str]]: Mapping of capability names to supported values.
145
+ Mapping[str, Iterable[str]]: Mapping of capability names to
146
+ supported values.
129
147
  """
130
148
 
131
149
  canons = ("json", "cbor") if _CBOR_OK else ("json",)
@@ -153,7 +171,8 @@ class PgpEnvelopeSigner(SigningBase):
153
171
  Args:
154
172
  key (KeyRef): Reference to the private key used for signing.
155
173
  payload (bytes): Data to sign.
156
- alg (Optional[Alg]): Requested algorithm, defaults to ``"OpenPGP"``.
174
+ alg (Optional[Alg]): Requested algorithm, defaults to
175
+ ``"OpenPGP"``.
157
176
  opts (Optional[Mapping[str, object]]): Additional options such as
158
177
  ``passphrase`` for locked keys.
159
178
 
@@ -161,7 +180,8 @@ class PgpEnvelopeSigner(SigningBase):
161
180
  Sequence[Signature]: A list containing the generated signature.
162
181
 
163
182
  Raises:
164
- RuntimeError: If the private key is locked and no passphrase is provided.
183
+ RuntimeError: If the private key is locked and no passphrase is
184
+ provided.
165
185
  ValueError: If an unsupported algorithm is requested.
166
186
  """
167
187
 
@@ -184,7 +204,14 @@ class PgpEnvelopeSigner(SigningBase):
184
204
  sig_bytes = bytes(sig.__bytes__())
185
205
  sig_asc = str(sig)
186
206
  return [
187
- _Sig({"alg": "OpenPGP", "kid": kid, "sig": sig_bytes, "armored": sig_asc})
207
+ _Sig(
208
+ {
209
+ "alg": "OpenPGP",
210
+ "kid": kid,
211
+ "sig": sig_bytes,
212
+ "armored": sig_asc,
213
+ }
214
+ )
188
215
  ]
189
216
 
190
217
  async def verify_bytes(
@@ -200,13 +227,16 @@ class PgpEnvelopeSigner(SigningBase):
200
227
  Args:
201
228
  payload (bytes): Signed data.
202
229
  signatures (Sequence[Signature]): Signatures to validate.
203
- require (Optional[Mapping[str, object]]): Verification requirements such
230
+ require (Optional[Mapping[str, object]]): Verification requirements
231
+ such
204
232
  as ``min_signers``.
205
- opts (Optional[Mapping[str, object]]): Options containing public keys in
233
+ opts (Optional[Mapping[str, object]]): Options containing public
234
+ keys in
206
235
  ``pubkeys``.
207
236
 
208
237
  Returns:
209
- bool: ``True`` if the signatures satisfy the requirements, ``False`` otherwise.
238
+ bool: ``True`` if the signatures satisfy the requirements,
239
+ ``False`` otherwise.
210
240
 
211
241
  Raises:
212
242
  TypeError: If an unsupported public key is supplied in ``opts``.
@@ -223,7 +253,9 @@ class PgpEnvelopeSigner(SigningBase):
223
253
  elif isinstance(entry, str):
224
254
  pubkeys.append(pgpy.PGPKey.from_blob(entry)[0])
225
255
  else:
226
- raise TypeError("Unsupported public key in opts['pubkeys'].")
256
+ raise TypeError(
257
+ "Unsupported public key in opts['pubkeys']."
258
+ )
227
259
 
228
260
  accepted = 0
229
261
  for sig in signatures:
@@ -267,7 +299,9 @@ class PgpEnvelopeSigner(SigningBase):
267
299
  require: Optional[Mapping[str, object]] = None,
268
300
  opts: Optional[Mapping[str, object]] = None,
269
301
  ) -> bool:
270
- return await self.verify_bytes(digest, signatures, require=require, opts=opts)
302
+ return await self.verify_bytes(
303
+ digest, signatures, require=require, opts=opts
304
+ )
271
305
 
272
306
  # ---------- canonicalization ----------
273
307
  async def canonicalize_envelope(
@@ -281,7 +315,8 @@ class PgpEnvelopeSigner(SigningBase):
281
315
 
282
316
  Args:
283
317
  env (Envelope): Envelope to canonicalize.
284
- canon (Optional[Canon]): Canonicalization format, ``"json"`` or ``"cbor"``.
318
+ canon (Optional[Canon]): Canonicalization format, ``"json"`` or
319
+ ``"cbor"``.
285
320
  opts (Optional[Mapping[str, object]]): Additional options (unused).
286
321
 
287
322
  Returns:
@@ -289,7 +324,8 @@ class PgpEnvelopeSigner(SigningBase):
289
324
 
290
325
  Raises:
291
326
  ValueError: If an unsupported canonicalization format is provided.
292
- RuntimeError: If CBOR canonicalization is requested without ``cbor2``.
327
+ RuntimeError: If CBOR canonicalization is requested without
328
+ ``cbor2``.
293
329
  """
294
330
 
295
331
  if canon in (None, "json"):
@@ -313,12 +349,14 @@ class PgpEnvelopeSigner(SigningBase):
313
349
  Args:
314
350
  key (KeyRef): Private key reference.
315
351
  env (Envelope): Envelope to sign.
316
- alg (Optional[Alg]): Requested algorithm, defaults to ``"OpenPGP"``.
352
+ alg (Optional[Alg]): Requested algorithm, defaults to
353
+ ``"OpenPGP"``.
317
354
  canon (Optional[Canon]): Canonicalization format.
318
355
  opts (Optional[Mapping[str, object]]): Additional options.
319
356
 
320
357
  Returns:
321
- Sequence[Signature]: Detached signature over the canonicalized envelope.
358
+ Sequence[Signature]: Detached signature over the canonicalized
359
+ envelope.
322
360
  """
323
361
 
324
362
  payload = await self.canonicalize_envelope(env, canon=canon, opts=opts)
@@ -339,7 +377,8 @@ class PgpEnvelopeSigner(SigningBase):
339
377
  env (Envelope): Envelope whose signatures are being verified.
340
378
  signatures (Sequence[Signature]): Signatures to check.
341
379
  canon (Optional[Canon]): Canonicalization format used.
342
- require (Optional[Mapping[str, object]]): Verification requirements.
380
+ require (Optional[Mapping[str, object]]): Verification
381
+ requirements.
343
382
  opts (Optional[Mapping[str, object]]): Additional options.
344
383
 
345
384
  Returns:
@@ -347,7 +386,9 @@ class PgpEnvelopeSigner(SigningBase):
347
386
  """
348
387
 
349
388
  payload = await self.canonicalize_envelope(env, canon=canon, opts=opts)
350
- return await self.verify_bytes(payload, signatures, require=require, opts=opts)
389
+ return await self.verify_bytes(
390
+ payload, signatures, require=require, opts=opts
391
+ )
351
392
 
352
393
  # ---------- internal ----------
353
394
  def _load_private_key(
@@ -373,4 +414,6 @@ class PgpEnvelopeSigner(SigningBase):
373
414
  if kind == "pgpy_key_armored" and isinstance(key.get("priv"), str):
374
415
  k, _ = pgpy.PGPKey.from_blob(key["priv"])
375
416
  return k
376
- raise TypeError("Unsupported KeyRef for PgpEnvelopeSigner private key.")
417
+ raise TypeError(
418
+ "Unsupported KeyRef for PgpEnvelopeSigner private key."
419
+ )