示例#1
0
 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;
 }
示例#2
0
    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;
    }