Documentation ¶
Overview ¶
Package crc provides CRC calculation functions which leverage IAA hardware.
Index ¶
Constants ¶
const ( // ISO polynomial value ISO uint64 = 0xD800000000000000 // ECMA polynomial value ECMA uint64 = 0xC96C5795D7870F42 )
const ( // IEEE polynomial value IEEE uint32 = 0xedb88320 // Castagnoli polynomial value Castagnoli uint32 = 0x82f63b78 // Koopman polynomial value Koopman uint32 = 0xeb31d82e )
const ( // CCITT polynomial value CCITT uint16 = 0x8408 // T10DIF polynomial value T10DIF uint16 = 0x8BB7 )
Variables ¶
This section is empty.
Functions ¶
func YieldProcessor ¶
func YieldProcessor(c *CRC32C)
YieldProcessor yields the processor while submitting the CRC job to hardware, instead of busy polling the result.
Types ¶
type CRC32C ¶
type CRC32C struct {
// contains filtered or unexported fields
}
CRC32C represents a CRC32C calculator. This calculator uses Castagnoli's polynomial, which is widely used in iSCSI. The calculator is compliant with the hash.Hash32 interface.
func NewCRC32C ¶
func NewCRC32C(opts ...CRC32COption) (*CRC32C, error)
NewCRC32C function initializes a new CRC32C hasher. This hasher is compliant with the hash.Hash32 interface. Returns an error if no hardware device is detected (Intel® DSA).
func (*CRC32C) BlockSize ¶
BlockSize returns the hash's underlying block size. The Write method must be able to accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.
type CRC32COption ¶
type CRC32COption func(c *CRC32C)
type Calculator ¶
type Calculator struct {
// contains filtered or unexported fields
}
Calculator is used for CRC64 calculation Notice: the data size should be less than your device's max_transfer_size.
func NewCalculator ¶
func NewCalculator() (*Calculator, error)
NewCalculator creates a new Calculator to be used for CRC64 calculation
func (*Calculator) CheckSum16 ¶
func (calc *Calculator) CheckSum16(data []byte, poly uint16) (uint16, error)
CheckSum16 calculates the CRC16 checksum for the given data and polynomial value
func (*Calculator) CheckSum32 ¶
func (calc *Calculator) CheckSum32(data []byte, poly uint32) (uint32, error)
CheckSum32 calculates the CRC32 checksum for the given data and polynomial value
func (*Calculator) CheckSum64 ¶
func (calc *Calculator) CheckSum64(data []byte, poly uint64) (uint64, error)
CheckSum64 calculates the CRC64 checksum for the given data and polynomial value