Skip to content

errors in constants and descriptions in crc/crc64_..._refl_by8.asm #88

@jeffareid

Description

@jeffareid

The constant descriptions in crc/crc64_ecma_refl_by8.asm and crc/crc64_iso_refl_by8.asm, are off by a factor of 2. Since pclmulqdq generates a product in bits 126 to 0, the reflected product is effectively multiplied by 2. This is compensated for in the constants, but the comments describing these constants missed how these constants are compensated. Specifically:

; rk7 = floor(2^128/Q) should be ; rk7 = floor(2^127/(reflected(65 bit polynomial)))
Note that this also means that rk7 is a 64 bit number, without an implied x^64 term.

; rk8 = Q should be ; rk8 = reflected ((65 bit polynomial)>>1 )-1

The rk8 constants will work as is, since only the left most 64 bits are returned for the CRC, but to be technically correct rk8 should be reflected ((65 bit polynomial)>>1 ) (without the -1).
For ecma_refl: rk8 dq 0x92d8af2baf0e1e84 should be rk8 dq 0x92d8af2baf0e1e85
For iso_refl: rk8 dq 0xb000000000000000 should be 0xb000000000000001
For jones_refl: rk8 dq 0x2b5926535897936a should be 0x2b5926535897936b
This will result in the right half of xmm7 == 0 after computing CRC, but since only the left half is returned, the missing 1 in the right most bit (which corresponds to x^64) in rk8 does not affect the returned CRC, but it can be confusing.

The 64 bit rk8 constant has an implied but missing left most bit, which corresponds to a 1. The code computes (q * rk8) + (q * 1) = (q * (65 bit polynomial)) to compensate for the missing left most bit. This isn't documented either.

The other constants are not documented. To deal with pclmulqdq with reflected products, the exponents are (e * 64) - 1:

; rk1 = reflected (2^127 % (65 bit polynomial))
; rk2 = reflected (2^191 % (65 bit polynomial))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions