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
23 changes: 22 additions & 1 deletion fastcrc/crc64.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from .fastcrc import crc_64_go_iso as _crc_64_go_iso
from .fastcrc import crc_64_we as _crc_64_we
from .fastcrc import crc_64_xz as _crc_64_xz
from .fastcrc import crc_64_tms570_iso as _crc_64_tms570_iso

__always_supported = ("ecma_182", "go_iso", "we", "xz")
__always_supported = ("ecma_182", "go_iso", "we", "xz", "tms570_iso")

algorithms_guaranteed = set(__always_supported)
algorithms_available = set(__always_supported)
Expand Down Expand Up @@ -92,3 +93,23 @@ def xz(data: bytes, initial: Optional[int] = None) -> int:
:raises TypeError: if the data is not a bytes-like object
"""
return _crc_64_xz(data, initial)


def tms570_iso(data: bytes, initial: Optional[int] = None) -> int:
"""
Compute a CRC-64 checksum of data with the `tms570_iso` algorithm.

Algorithm parameters:
- poly: 0x000000000000001b
- init: 0x0000000000000000
- xorout: 0x0000000000000000
- refin: False
- refout: False

:param bytes data: The data to be computed
:param Optional[int] initial: The optional starting value of the checksum
:return: The checksum
:rtype: int
:raises TypeError: if the data is not a bytes-like object
"""
return _crc_64_tms570_iso(data, initial)
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const CRC_32_K_REVERSED_RECIPROCAL_REFIN: Algorithm<u32> = Algorithm {
residue: 0x00000000,
};

const CRC_64_TMS570_ISO: Algorithm<u64> = Algorithm {
width: 64,
poly: 0x000000000000001b,
init: 0x0000000000000000,
refin: false,
refout: false,
xorout: 0x0000000000000000,
check: 0xe4ffbea588933790,
residue: 0x0000000000000000,
};

define_crc_fn!(crc_8_autosar, u8, CRC_8_AUTOSAR);
define_crc_fn!(crc_8_bluetooth, u8, CRC_8_BLUETOOTH);
define_crc_fn!(crc_8_cdma2000, u8, CRC_8_CDMA2000);
Expand Down Expand Up @@ -135,6 +146,7 @@ define_crc_fn!(crc_64_ecma_182, u64, CRC_64_ECMA_182);
define_crc_fn!(crc_64_go_iso, u64, CRC_64_GO_ISO);
define_crc_fn!(crc_64_we, u64, CRC_64_WE);
define_crc_fn!(crc_64_xz, u64, CRC_64_XZ);
define_crc_fn!(crc_64_tms570_iso, u64, CRC_64_TMS570_ISO);

#[pymodule(gil_used = false)]
fn fastcrc(m: &Bound<'_, PyModule>) -> PyResult<()> {
Expand Down Expand Up @@ -204,5 +216,6 @@ fn fastcrc(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(crc_64_go_iso, m)?)?;
m.add_function(wrap_pyfunction!(crc_64_we, m)?)?;
m.add_function(wrap_pyfunction!(crc_64_xz, m)?)?;
m.add_function(wrap_pyfunction!(crc_64_tms570_iso, m)?)?;
Ok(())
}
Loading