webrtc_sctp_crc32c (webrtc v0.1.0)
View SourceCRC32c (Castagnoli) checksum used by SCTP (RFC 9260 Appendix A).
crc32c/1 returns the standard CRC32c value (reflected polynomial 16#82F63B78, initial value and final XOR 16#FFFFFFFF), so crc32c(<<"123456789">>) =:= 16#E3069283.
update/2 continues a finalized value with more data: update(crc32c(A), B) =:= crc32c([A, B]) and crc32c(X) =:= update(0, X).
SCTP computes the checksum over the whole packet with the checksum field set to zero and stores it on the wire as <<Crc:32/little>> (see webrtc_sctp_chunk:encode/2 and webrtc_sctp_chunk:checksum_ok/2).
The implementation is pure Erlang, slicing-by-8 over eight 256 entry tables kept as one literal tuple of 2048 entries (table K holds entry N at index K * 256 + N + 1), with a byte loop for the tail.
Summary
Functions
-spec crc32c(iodata()) -> 0..4294967295.
CRC32c of Data.
-spec update(non_neg_integer(), iodata()) -> non_neg_integer().
Continue the finalized CRC32c value Crc with Data.