Skip to content

Add documented CRC library to /scapy/libs/#24

Draft
Copilot wants to merge 15 commits intomasterfrom
copilot/add-documentation-and-move-implementation
Draft

Add documented CRC library to /scapy/libs/#24
Copilot wants to merge 15 commits intomasterfrom
copilot/add-documentation-and-move-implementation

Conversation

Copy link

Copilot AI commented Feb 11, 2026

Adds the CRC (Cyclic Redundancy Check) library from PR secdev#4855 to /scapy/libs/ with comprehensive documentation.

Documentation Added

  • Module-level docstring: CRC fundamentals, parameter descriptions, usage patterns, references
  • CRCParam class: Parameter container with signature generation and equality semantics
  • _CRC_metaclass: Automatic table pre-computation, registry management, factory methods
  • CRC base class: Single-shot and incremental (init/update/finish) APIs
  • Pre-defined algorithms: CRC-16, CRC-32, CRC-16-CCITT, CRC-32-AUTOSAR with parameters and test vectors

Code Quality

  • Consistent zero-padding in signature format
  • Descriptive variable naming (data_len vs l)
  • Proper format specifiers for hex output with 0x prefix

Usage

from scapy.libs.crc import CRC_32, CRC

# Single-shot computation
checksum = CRC_32(b"123456789")  # 0xcbf43926

# Incremental computation
crc = CRC_32.create_context()
crc.init()
crc.update(b"12345")
crc.update(b"6789")
checksum = crc.finish()  # 0xcbf43926

# Custom CRC variant
CustomCRC = CRC.from_parameters(
    poly=0x1021, size=16, init_crc=0xFFFF, xor=0,
    reflect_input=False, reflect_output=False
)

All test vectors pass. CodeQL reports 0 alerts.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 11, 2026 21:10
Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
…umentation

Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Copilot AI changed the title [WIP] Add documentation and move implementation to /libs Add documented CRC library to /scapy/libs/ Feb 11, 2026
Copilot AI requested a review from polybassa February 11, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants