Class ChecksumUtils

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

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

    Modifier and Type Method Description
    static short calculateCrc​(byte[] data, int length)
    Calculate the CRC13239 checksum for a byte buffer.
    static boolean checkCrc​(byte[] data, int length)
    Verifies a checksum.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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