Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Click>=8.5.0
aiohttp>=3.14.5
cryptography>=50.0.2
ecdsa>=0.13
8 changes: 0 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/autograph_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Loading