diff --git a/requirements.in b/requirements.in index 89493fe..e1c4e2b 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,3 @@ Click>=8.5.0 aiohttp>=3.14.5 cryptography>=50.0.2 -ecdsa>=0.13 diff --git a/requirements.txt b/requirements.txt index 7f3c306..282ee01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -554,10 +554,6 @@ cryptography==50.0.2 \ --hash=sha256:fdd28f912fccfec1846a94e2e1e8f9b0012f557f0c46fe4f3eb0d7a87afcf90b \ --hash=sha256:fdd28f912fccfec1846a94e2e1e8f9b0012f557f0c46fe4f3eb0d7a87afcf90b # via -r requirements.in -ecdsa==0.19.2 \ - --hash=sha256:62635b0ac1ca2e027f82122b5b81cb706edc38cd91c63dda28e4f3455a2bf930 \ - --hash=sha256:840f5dc5e375c68f36c1a7a5b9caad28f95daa65185c9253c0c08dd952bb7399 - # via -r requirements.in frozenlist==1.4.1 \ --hash=sha256:04ced3e6a46b4cfffe20f9ae482818e34eba9b5fb0ce4056e4cc9b6e212d09b7 \ --hash=sha256:0633c8d5337cb5c77acbccc6357ac49a1770b8c487e5b3505c57b949b4b82e98 \ @@ -867,10 +863,6 @@ pycparser==2.22 \ --hash=sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6 \ --hash=sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc # via cffi -six==1.16.0 \ - --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ - --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 - # via ecdsa typing-extensions==4.15.0 \ --hash=sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466 \ --hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548 diff --git a/src/autograph_utils/__init__.py b/src/autograph_utils/__init__.py index cf103d6..6aeb625 100644 --- a/src/autograph_utils/__init__.py +++ b/src/autograph_utils/__init__.py @@ -14,7 +14,6 @@ from datetime import datetime, timezone import cryptography -import ecdsa.util from cryptography import x509 from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import ec as cryptography_ec @@ -88,6 +87,9 @@ def describe(self): return f"matches exactly {self.domain!r}" +# Size in bytes of each of the r and s components of a P-384 signature. +P384_COMPONENT_SIZE = 48 + BASE64_WRONG_LENGTH_RE = re.compile( r"Invalid base64-encoded string: number of data characters \(\d+\) cannot " r"be [123] more than a multiple of 4" @@ -301,10 +303,12 @@ async def verify(self, data, signature, x5u): raise WrongSignatureSize("Base64 encoded signature was not a multiple of 4") raise - try: - r, s = ecdsa.util.sigdecode_string(signature, order=ecdsa.curves.NIST384p.order) - except ecdsa.util.MalformedSignature: + # Raw signature is the concatenation of r and s, each of them + # being the size of the curve order (48 bytes for P-384). + if len(signature) != 2 * P384_COMPONENT_SIZE: raise WrongSignatureSize() + r = int.from_bytes(signature[:P384_COMPONENT_SIZE], "big") + s = int.from_bytes(signature[P384_COMPONENT_SIZE:], "big") # Encode as DER for cryptography signature = encode_dss_signature(r, s)