Package com.yubico.yubikit.core.otp
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 shortcalculateCrc(byte[] data, int length)Calculate the CRC13239 checksum for a byte buffer.static booleancheckCrc(byte[] data, int length)Verifies a checksum.
-
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 verifylength- The length of the data, including the checksum at the end- Returns:
- true if the checksum is correct, false if not
-