@Test public void testBounds() throws Exception { TCNProtoGen tcnGen = new TCNProtoGen(); int ulimit = Short.MAX_VALUE * 2; List<String> tcnsSource = new LinkedList<>(); IntStream.range(0, ulimit).forEach(i -> tcnsSource.add(byte2Hex(tcnGen.getNewTCN()))); List<String> tcnRegenerated = new LinkedList<>(); TCNProtoUtil.generateAllTCNsFromReport(tcnGen.generateReport(tcnGen.getRatchetTickCount()), x -> tcnRegenerated.add(byte2Hex(x)) ); assertEquals(ulimit, tcnRegenerated.size()); assertArrayEquals(tcnsSource.toArray(), tcnRegenerated.toArray()); }
public static void generateAllTCNsFromReport(byte[] report, INextTCNCallback callback) { int from = readUShort(report, 64); byte[] bstartTCK = Arrays.copyOfRange(report, 32, 64); TCNProtoGen ratchet = new TCNProtoGen(report[68], getRvkfromReport(report), bstartTCK, from - 1); int to = readUShort(report, 66); callback.next(ratchet.getCurrentTCN()); for (int i = from; i < to; i++) { callback.next(ratchet.getNewTCN()); } }
TCNProtoUtil { public static void generateAllTCNsFromReport(byte[] report, INextTCNCallback callback) { int from = readUShort(report, 64); byte[] bstartTCK = Arrays.copyOfRange(report, 32, 64); TCNProtoGen ratchet = new TCNProtoGen(report[68], getRvkfromReport(report), bstartTCK, from - 1); int to = readUShort(report, 66); callback.next(ratchet.getCurrentTCN()); for (int i = from; i < to; i++) { callback.next(ratchet.getNewTCN()); } } }
TCNProtoUtil { public static void generateAllTCNsFromReport(byte[] report, INextTCNCallback callback) { int from = readUShort(report, 64); byte[] bstartTCK = Arrays.copyOfRange(report, 32, 64); TCNProtoGen ratchet = new TCNProtoGen(report[68], getRvkfromReport(report), bstartTCK, from - 1); int to = readUShort(report, 66); callback.next(ratchet.getCurrentTCN()); for (int i = from; i < to; i++) { callback.next(ratchet.getNewTCN()); } }  }
TCNProtoUtil { public static void generateAllTCNsFromReport(byte[] report, INextTCNCallback callback) { int from = readUShort(report, 64); byte[] bstartTCK = Arrays.copyOfRange(report, 32, 64); TCNProtoGen ratchet = new TCNProtoGen(report[68], getRvkfromReport(report), bstartTCK, from - 1); int to = readUShort(report, 66); callback.next(ratchet.getCurrentTCN()); for (int i = from; i < to; i++) { callback.next(ratchet.getNewTCN()); } }  static boolean verifySignatureOfReportCorrect(byte[] report); static void generateAllTCNsFromReport(byte[] report, INextTCNCallback callback); static void persistRatchet(TCNProtoGen ratchet); @RequiresApi(api = 24) static List<TCNProtoGen> loadAllRatchets(); }
TCNProtoUtil { public static void generateAllTCNsFromReport(byte[] report, INextTCNCallback callback) { int from = readUShort(report, 64); byte[] bstartTCK = Arrays.copyOfRange(report, 32, 64); TCNProtoGen ratchet = new TCNProtoGen(report[68], getRvkfromReport(report), bstartTCK, from - 1); int to = readUShort(report, 66); callback.next(ratchet.getCurrentTCN()); for (int i = from; i < to; i++) { callback.next(ratchet.getNewTCN()); } }  static boolean verifySignatureOfReportCorrect(byte[] report); static void generateAllTCNsFromReport(byte[] report, INextTCNCallback callback); static void persistRatchet(TCNProtoGen ratchet); @RequiresApi(api = 24) static List<TCNProtoGen> loadAllRatchets();  }