void parseHeaderLine(String line, KatResult kr) { Scanner lineScanner = new Scanner(line); lineScanner.findInLine(":Skein-(\\d+):\\s*(\\d+)-.*=\\s*(\\d+) bits(.*)"); MatchResult result = null; try { result = lineScanner.match(); } catch (Exception e) { System.out.println("Header line: " + line); e.printStackTrace(); System.exit(1); } kr.stateSize = Integer.parseInt(result.group(1)); kr.hashBitLength = Integer.parseInt(result.group(2)); kr.msgLength = Integer.parseInt(result.group(3)); kr.restOfLine = result.group(4); if ((kr.msgLength == 0) || (kr.msgLength % 8) != 0) kr.msg = new byte[(kr.msgLength >> 3) + 1]; else kr.msg = new byte[kr.msgLength >> 3]; if ((kr.hashBitLength % 8) != 0) kr.result = new byte[(kr.hashBitLength >> 3) + 1]; else kr.result = new byte[kr.hashBitLength >> 3]; kr.msgFill = 0; kr.resultFill = 0; kr.macKeyFill = 0; }
public static void main(String args[]) { try { SkeinTest skt = new SkeinTest(); skt.setUp(); skt.vectorTest(); } catch (Exception e) { e.printStackTrace(); } System.out.println("Skein test done."); }
void parseResultLine(String line, KatResult kr) { Scanner ls = new Scanner(line); while (ls.hasNext()) { try { kr.result[kr.resultFill++] = (byte) ls.nextInt(16); } catch (Exception e) { System.out.println("Result data: " + line); e.printStackTrace(); System.exit(1); } } }
@Test public void vectorTest() { try { assertTrue(checkKATVectors()); } catch (Exception e) { e.printStackTrace(); } if (notProcessed != 0) System.out.println( "Processed vectors: " + processed + ", some vectors skipped (Tree): " + notProcessed); else System.out.println("Processed vectors: " + processed); }
void parseMacKeyHeaderLine(String line, KatResult kr) { Scanner ls = new Scanner(line); ls.findInLine(".*=\\s*(\\d+) .*"); MatchResult result = null; try { result = ls.match(); } catch (Exception e) { System.out.println("Mac header: " + line); e.printStackTrace(); System.exit(1); } kr.macKeyLen = Integer.parseInt(result.group(1)); kr.macKey = new byte[kr.macKeyLen]; state = MacKey; }
void parseMacKeyLine(String line, KatResult kr) { if (line.contains("(none)")) { return; } Scanner ls = new Scanner(line); while (ls.hasNext()) { try { kr.macKey[kr.macKeyFill++] = (byte) ls.nextInt(16); } catch (Exception e) { System.out.println("Mac key data: " + line); e.printStackTrace(); System.exit(1); } } }