YubikeyOTP.CRC (YubikeyOTP v0.2.1) View Source

Checksums relevant to YubiKeys

Link to this section Summary

Functions

Computes the CRC16 (ISO 13239) checksum used in the YubiOTP.

Checks whether the given buffer has the correct CRC16 residual.

Link to this section Functions

Link to this function

crc16(string, crc \\ 65535)

View Source

Computes the CRC16 (ISO 13239) checksum used in the YubiOTP.

Examples

iex> YubikeyOTP.CRC.crc16("")
65535

iex> YubikeyOTP.CRC.crc16(<<0xffff :: 16>>)
0

iex> YubikeyOTP.CRC.crc16("1234567890")
46316
Link to this function

verify_crc16(string, crc \\ 65535, residual \\ 61624)

View Source

Specs

verify_crc16(binary(), integer(), integer()) :: boolean()

Checks whether the given buffer has the correct CRC16 residual.

Examples

iex> YubikeyOTP.CRC.verify_crc16("") false

iex> YubikeyOTP.CRC.verify_crc16("1234567890" <> <<0x13, 0x4b>>) true