private void runTestCase(String[] testVector, int macLength) throws InvalidCipherTextException { int pos = 0; String testName = testVector[pos++]; byte[] K = Hex.decode(testVector[pos++]); byte[] P = Hex.decode(testVector[pos++]); byte[] A = Hex.decode(testVector[pos++]); byte[] IV = Hex.decode(testVector[pos++]); byte[] C = Hex.decode(testVector[pos++]); // For short MAC, take leading bytes byte[] t = Hex.decode(testVector[pos++]); byte[] T = new byte[macLength]; System.arraycopy(t, 0, T, 0, T.length); // Default multiplier runTestCase(null, null, testName, K, IV, A, P, C, T); runTestCase(new BasicGCMMultiplier(), new BasicGCMMultiplier(), testName, K, IV, A, P, C, T); runTestCase(new Tables8kGCMMultiplier(), new Tables8kGCMMultiplier(), testName, K, IV, A, P, C, T); runTestCase(new Tables64kGCMMultiplier(), new Tables64kGCMMultiplier(), testName, K, IV, A, P, C, T); }
private void randomTests() throws InvalidCipherTextException { SecureRandom srng = new SecureRandom(); srng.setSeed(Times.nanoTime()); randomTests(srng, null); randomTests(srng, new BasicGCMMultiplier()); randomTests(srng, new Tables8kGCMMultiplier()); randomTests(srng, new Tables64kGCMMultiplier()); }
private void randomTests() throws InvalidCipherTextException { SecureRandom srng = new SecureRandom(); for (int i = 0; i < 10; ++i) { randomTest(srng, null); randomTest(srng, new BasicGCMMultiplier()); randomTest(srng, new Tables8kGCMMultiplier()); randomTest(srng, new Tables64kGCMMultiplier()); } }