@@ -0,0 +1,2397 @@
+/* Copyright (c) 2012, Yubico AB.  All rights reserved.%0A%0A   Redistribution and use in source and binary forms, with or without%0A   modification, are permitted provided that the following conditions%0A   are met:%0A%0A   * Redistributions of source code must retain the above copyright%0A     notice, this list of conditions and the following disclaimer.%0A%0A   * Redistributions in binary form must reproduce the above copyright%0A     notice, this list of conditions and the following%0A     disclaimer in the documentation and/or other materials provided%0A     with the distribution.%0A%0A   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND%0A   CONTRIBUTORS %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES,%0A   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF%0A   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE%0A   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS%0A   BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,%0A   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED%0A   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON%0A   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR%0A   TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF%0A   THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF%0A   SUCH DAMAGE.%0A*/%0A%0Apackage com.yubico.base.test;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport org.junit.Test;%0A%0Aimport com.yubico.base.CRC13239;%0A%0Apublic class CRC13239Test %7B%0A%09%0A%09@Test%0A%09public void testCrc() %7B%0A%0A%09%09byte%5B%5D data = %7B0x0, 0x1, 0x2, 0x3, 0x4%7D;%0A%09%09short crc = CRC13239.getCRC(data);%0A%09%09assertEquals((short)62919, crc);%0A%09%7D%0A%0A%09@Test%0A%09public void testCrc2() %7B%0A%09%09byte%5B%5D data = %7B(byte) 0xfe%7D;%0A%09%09/*%0A%09%09 * %3E%3E%3E test_common.crc16('fe'.decode('hex'))%0A%09%09 * 4470%0A%09%09 * %3E%3E%3E%0A%09%09 */%0A%09%09short crc = CRC13239.getCRC(data);%0A%09%09assertEquals((short)4470, crc);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testCrc3() %7B%0A%09%09byte%5B%5D data = %7B0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /* uid */%0A%09%09%09%090x30, 0x75, /* use_ctr */%0A%09%09%09%090x00, 0x09, /* ts_low */%0A%09%09%09%090x3d, /* ts_high */%0A%09%09%09%09(byte) 0xfa, /* session_ctr */%0A%09%09%09%090x60, (byte) 0xea /* rnd */%0A%09%09%7D;%0A%09%09short crc = CRC13239.getCRC(data);%0A%0A%09%09assertEquals((short)35339, crc);%0A%09%7D%0A%09%0A%09@Test%0A%09public void testCrc4() %7B%0A%09%09byte%5B%5D data = %7B0x55, (byte) 0xaa, 0x00, (byte) 0xff%7D;%0A%09%09short crc = CRC13239.getCRC(data);%0A%09%09assertEquals((short)52149, crc);%0A%09%7D%0A%7D%0A

add tests of crc implementation