Class ChecksumUtils

java.lang.Object
com.yubico.yubikit.core.otp.ChecksumUtils

public class ChecksumUtils extends Object
Utility methods for calculating and verifying the CRC13239 checksum used by YubiKeys.
  • Method Details

    • calculateCrc

      public static short calculateCrc(byte[] data, int length)
      Calculate the CRC13239 checksum for a byte buffer.
      Parameters:
      data - byte buffer to be checksummed.
      length - how much of the buffer should be checksummed
      Returns:
      the calculated checksum
    • checkCrc

      public static boolean checkCrc(byte[] data, int length)
      Verifies a checksum.
      Parameters:
      data - the data, ending in the 2 byte CRC checksum to verify
      length - The length of the data, including the checksum at the end
      Returns:
      true if the checksum is correct, false if not