pysigned 0.2.2__tar.gz → 0.2.4__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.
- {pysigned-0.2.2 → pysigned-0.2.4}/PKG-INFO +1 -1
- {pysigned-0.2.2 → pysigned-0.2.4}/pyproject.toml +1 -1
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/backends.py +1 -1
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/keys.py +10 -6
- {pysigned-0.2.2 → pysigned-0.2.4}/LICENSE +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/README.md +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/THIRD-PARTY-LICENSES +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/__init__.py +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/extensions/__init__.py +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/extensions/fastapi.py +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/py.typed +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/signature.py +0 -0
- {pysigned-0.2.2 → pysigned-0.2.4}/src/pysigned/utils.py +0 -0
|
@@ -37,7 +37,7 @@ class Backend:
|
|
|
37
37
|
def __init__(self, digest: str = DIGEST):
|
|
38
38
|
self.digest = digest
|
|
39
39
|
|
|
40
|
-
def parse_key(self, value: KeyValue) ->
|
|
40
|
+
def parse_key(self, value: KeyValue) -> Key | Ed25519KeyPair:
|
|
41
41
|
"""Wrap a user-supplied key value as a :class:`~pysigned.keys.KeyLike`.
|
|
42
42
|
|
|
43
43
|
Already-wrapped keys pass through; raw ``bytes`` or a ``(bytes, id)``
|
|
@@ -5,11 +5,11 @@ from base64 import urlsafe_b64decode
|
|
|
5
5
|
from collections.abc import Iterable, Mapping
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from types import MappingProxyType
|
|
8
|
-
from typing import TYPE_CHECKING, Any, Self, cast
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Self, cast, Iterator
|
|
9
9
|
from cryptography.hazmat.primitives.asymmetric import ed25519
|
|
10
10
|
|
|
11
11
|
if TYPE_CHECKING:
|
|
12
|
-
from .backends import Backend
|
|
12
|
+
from .backends import Backend, KeyValue
|
|
13
13
|
|
|
14
14
|
DIGEST = "sha512"
|
|
15
15
|
# HMAC keys must be at least the digest's output size (NIST SP 800-107).
|
|
@@ -146,6 +146,10 @@ class Ed25519KeyPair(KeyLike):
|
|
|
146
146
|
"""The verify-only public key for this pair, sharing its id."""
|
|
147
147
|
return Ed25519PublicKey(self.public_key.public_bytes_raw(), self.id)
|
|
148
148
|
|
|
149
|
+
def __bytes__(self) -> bytes:
|
|
150
|
+
"""The raw public-key bytes (its public identity); never the seed."""
|
|
151
|
+
return self.public_key.public_bytes_raw()
|
|
152
|
+
|
|
149
153
|
def _id_bytes(self) -> bytes:
|
|
150
154
|
return self.public_key.public_bytes_raw()
|
|
151
155
|
|
|
@@ -157,7 +161,7 @@ class KeySet:
|
|
|
157
161
|
key dispatches on its type via the backend.
|
|
158
162
|
"""
|
|
159
163
|
|
|
160
|
-
def __init__(self, keys: Iterable, backend: "Backend | None" = None):
|
|
164
|
+
def __init__(self, keys: "Iterable[KeyValue]", backend: "Backend | None" = None):
|
|
161
165
|
if backend is None:
|
|
162
166
|
# Deferred to break the keys <-> backends import cycle: backends
|
|
163
167
|
# imports the key types from this module, so Backend can't be
|
|
@@ -166,14 +170,14 @@ class KeySet:
|
|
|
166
170
|
|
|
167
171
|
backend = Backend()
|
|
168
172
|
self.backend = backend
|
|
169
|
-
self._keys: Mapping[str, Key |
|
|
173
|
+
self._keys: Mapping[str, Key | Ed25519KeyPair] = MappingProxyType(
|
|
170
174
|
{k.id: k for k in map(backend.parse_key, keys)}
|
|
171
175
|
)
|
|
172
176
|
|
|
173
|
-
def __getitem__(self, key: str):
|
|
177
|
+
def __getitem__(self, key: str) -> "Key | Ed25519KeyPair":
|
|
174
178
|
return self._keys[key]
|
|
175
179
|
|
|
176
|
-
def __iter__(self):
|
|
180
|
+
def __iter__(self) -> Iterator[Key | Ed25519KeyPair]:
|
|
177
181
|
return iter(self._keys.values())
|
|
178
182
|
|
|
179
183
|
def __reversed__(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|