You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/09/02 14:36:08 UTC

(tooling-trusted-releases) branch sbp updated: Remove CRC-24 checking

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new 52dbbc11 Remove CRC-24 checking
52dbbc11 is described below

commit 52dbbc11299d2091970f0c3933269e8e6c03f0a9
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Wed Sep 2 15:35:14 2026 +0100

    Remove CRC-24 checking
---
 atr/pgp.py             | 20 +-------------------
 tests/unit/test_pgp.py |  9 +++++++++
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/atr/pgp.py b/atr/pgp.py
index 1908674a..da32da3f 100644
--- a/atr/pgp.py
+++ b/atr/pgp.py
@@ -512,20 +512,8 @@ def _certificate_groups(
     return groups
 
 
-def _crc24(data: bytes) -> int:
-    crc = 0xB704CE
-    for octet in data:
-        crc ^= octet << 16
-        for _ in range(8):
-            crc <<= 1
-            if crc & 0x1000000:
-                crc ^= 0x1864CFB
-    return crc & 0xFFFFFF
-
-
 def _dearmored(text: str) -> bytes:
     lines = []
-    checksum = None
     in_data = False
     for line in text.splitlines()[1:]:
         stripped = line.strip()
@@ -539,15 +527,9 @@ def _dearmored(text: str) -> bytes:
         if stripped.startswith("-----END"):
             break
         if stripped.startswith("="):
-            checksum = stripped[1:5]
             continue
         lines.append(stripped)
-    data = base64.b64decode("".join(lines), validate=True)
-    if checksum is not None:
-        declared = int.from_bytes(base64.b64decode(checksum, validate=True))
-        if declared != _crc24(data):
-            raise ValueError("Armor checksum mismatch")
-    return data
+    return base64.b64decode("".join(lines), validate=True)
 
 
 def _declares_signing(signature: openpgp.packet.Signature | None) -> bool:
diff --git a/tests/unit/test_pgp.py b/tests/unit/test_pgp.py
index bb1354f3..bbbf1abd 100644
--- a/tests/unit/test_pgp.py
+++ b/tests/unit/test_pgp.py
@@ -161,6 +161,15 @@ def test_certificate_spans_are_the_raw_bytes_of_the_upload() -> None:
     ]
 
 
+@pytest.mark.parametrize("footer", ["=AAAA", "=xyz"])
+def test_dearmored_ignores_the_checksum_footer(footer: str) -> None:
+    block = pgp_fixtures.REVOKED_UID_PUBLIC_KEY_ASC
+    lines = block.splitlines()
+    index = next(i for i, line in enumerate(lines) if line.startswith("="))
+    altered = "\n".join([*lines[:index], footer, *lines[index + 1 :]]) + "\n"
+    assert pgp._dearmored(altered) == pgp._dearmored(block)
+
+
 def test_delta_fragments_are_minimal_and_fold_back_to_the_result() -> None:
     state = pgp.certificate_placements(pgp.merge_certificate_blocks([pgp_fixtures.REVOKED_UID_PUBLIC_KEY_ASC]))
     primary = next(head for head, frame in state if (frame is None) and (head[0] == 6))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org