List of usage examples for org.bouncycastle.crypto.prng FixedSecureRandom FixedSecureRandom
public FixedSecureRandom(byte[][] values)
From source file:com.vvote.verifier.component.ballotGen.BallotGenerationVerifier.java
License:Open Source License
/** * Verifies the fiat shamir calculation//from w w w .ja v a 2 s .c om * * @return true if the fiat shamir calculation matches that which is * included in the ballot submit response message for the current * commit */ public boolean verifyFiatShamirCalculation() { logger.info( "Starting Verification of the Fiat Shamir signature which determines the ballots chosen for auditing by each PoD Printer"); final int ballotsToGenerate = this.getDataStore().getBallotGenerationConfig().getBallotsToGenerate(); final int ballotsToAudit = this.getDataStore().getBallotGenerationConfig().getBallotsToAudit(); List<String> serialNumbers = null; BallotAuditCommit auditCommit = null; boolean verified = true; String currentBoothId = null; for (CommitIdentifier identifier : this.getDataStore().getAuditData().keySet()) { logger.info("Verifying the Fiat-Shamir signature for commitment with identifier: {}", identifier); serialNumbers = new ArrayList<String>( this.getDataStore().getGeneratedCiphers().get(identifier).getCommittedBallotsSerialNumbers()); // need to sort the serial numbers to make sure they are in a // 'default' // state i.e. in order Collections.sort(serialNumbers, new BallotSerialNumberComparator()); // check generation size if (serialNumbers.size() != ballotsToGenerate) { logger.error( "The number of ballots generated ({}) doesn't match the number of ballots requested for generation ({})", serialNumbers.size(), ballotsToGenerate); resultsLogger.error( "The number of ballots generated ({}) doesn't match the number of ballots requested for generation ({})", serialNumbers.size(), ballotsToGenerate); return false; } auditCommit = this.getDataStore().getAuditData().get(identifier); currentBoothId = auditCommit.getMessage().getBoothID(); // verify sig is created properly: try { if (!verifySignatureMatches(identifier, auditCommit)) { verified = false; } } catch (NoSuchAlgorithmException | NoSuchProviderException | FileHashException e) { logger.error("The Fiat Shamir signature couldn't be calculated. Check the supplied data", e); resultsLogger.error("The Fiat Shamir signature couldn't be calculated. Check the supplied data", e); return false; } logger.info( "Fiat shamir signature was recalculated and matches what was included in the BallotSubmitResponse message for printer: {}", currentBoothId); logger.info( "Verifying that the ballots chosen for auditing were correctly chosen for commitment with identifier: {}", identifier); final byte[] fiatShamirSig = Utils.decodeBase64Data(auditCommit.getResponse().getFiatShamir()); // use fiat shamir sig as the seed for the deterministic random bit // generator FixedSecureRandom fixedSecureRandom = new FixedSecureRandom(fiatShamirSig); SP800SecureRandomBuilder randomBuilder = new SP800SecureRandomBuilder(fixedSecureRandom, false); randomBuilder.setPersonalizationString(auditCommit.getResponse().getPeerID().getBytes()); SP800SecureRandom sp800SecureRandom = randomBuilder.buildHash(new SHA256Digest(), null, false); Collections.shuffle(serialNumbers, sp800SecureRandom); ArrayList<String> serialNumbersToAudit = new ArrayList<String>(); for (int i = 0; i < ballotsToAudit; i++) { serialNumbersToAudit.add(serialNumbers.get(i)); } if (serialNumbersToAudit.size() != ballotsToAudit) { logger.error( "The number of serial numbers calculated for auditing does not match the number of serial numbers requested for auditing for commitment with identifier: {}", identifier); resultsLogger.error( "The number of serial numbers calculated for auditing does not match the number of serial numbers requested for auditing for commitment with identifier: {}", identifier); verified = false; } if (auditCommit.getRandomnessCommitmentSerialNumbers().size() != ballotsToAudit) { logger.error( "The number of serial numbers included in the audit file doesn't match the number of serial numbers requested for auditing for commitment with identifier: {}", identifier); resultsLogger.error( "The number of serial numbers included in the audit file doesn't match the number of serial numbers requested for auditing for commitment with identifier: {}", identifier); verified = false; } if (!auditCommit.getRandomnessCommitmentSerialNumbers().containsAll(serialNumbersToAudit)) { logger.error( "The serial numbers included in the audit file do not match the serial numbers requested for auditing calculated using the fiat shamir signature for commitment with identifier: {}", identifier); resultsLogger.error( "The serial numbers included in the audit file do not match the serial numbers requested for auditing calculated using the fiat shamir signature for commitment with identifier: {}", identifier); verified = false; } logger.debug( "Successfully verified that the serial numbers of ballots for auditing were correctly chosen using the Fiat shamir signature for commitment with identifier: {}", identifier); resultsLogger.info( "Serial numbers for auditing were checked successfully using the Fiat shamir signature for commitment with identifier: {}", identifier); } logger.debug( "Successfully verified the Fiat Shamir signatures were used to choose the required number of ballots for auditing"); resultsLogger.info( "Successfully verified the Fiat Shamir signatures were used to choose the required number of ballots for auditing"); return verified; }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test public void testProcessSMPSucceeded() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final Scalar expectedCp = decodeScalar( new byte[] { -102, -3, -37, 86, 57, -107, -57, 19, 118, 117, -81, 76, -6, -33, 12, 103, 58, 109, -5, 120, 43, -65, -121, -10, -80, 127, 101, 65, -84, -12, 99, -95, -32, -96, -76, -89, -43, 95, -45, -82, 36, 69, 107, 54, -4, -60, 43, 41, -17, -113, 31, -21, 119, 104, 88, 41, 0 }); final Scalar expectedD5 = decodeScalar( new byte[] { 92, -33, 26, 108, 7, 58, 50, 77, 102, -39, 109, 47, -1, -9, 35, -58, -7, 110, -50, 125, -89, -128, 21, -42, -96, 98, 78, -31, 6, 99, -124, -67, -87, -26, -44, -43, -102, -72, 60, 112, -67, -24, 95, 120, 105, 126, 12, 83, -114, -102, 71, -123, -65, 4, 59, 4, 0 }); final Scalar expectedD6 = decodeScalar( new byte[] { -109, -50, 3, -124, 29, 122, 15, -31, 40, 41, 102, -20, 30, 73, 14, 79, 81, -96, -12, -59, -101, -97, -119, -102, 73, 8, -86, 109, 64, -128, 22, -99, 11, 109, -127, 65, 66, -62, -90, 88, -108, 102, -94, -52, 18, -69, -95, 124, 121, 124, 59, 30, 39, 101, 35, 7, 0 }); final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, a2, a3); final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b, c2, d2, g3b, c3, d3, pb, qb, cp, d5, d6); final SMPMessage3 response = state.process(context, message); assertEquals(pa, response.pa);/* w w w .j ava2 s. co m*/ assertEquals(qa, response.qa); assertEquals(expectedCp, response.cp); assertEquals(expectedD5, response.d5); assertEquals(expectedD6, response.d6); assertEquals(ra, response.ra); assertEquals(cr, response.cr); assertEquals(d7, response.d7); verify(context).setState(isA(StateExpect4.class)); }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test public void testProcessMessageBadSecret() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final Scalar expectedCp = decodeScalar( new byte[] { -102, -3, -37, 86, 57, -107, -57, 19, 118, 117, -81, 76, -6, -33, 12, 103, 58, 109, -5, 120, 43, -65, -121, -10, -80, 127, 101, 65, -84, -12, 99, -95, -32, -96, -76, -89, -43, 95, -45, -82, 36, 69, 107, 54, -4, -60, 43, 41, -17, -113, 31, -21, 119, 104, 88, 41, 0 }); final Scalar expectedD5 = decodeScalar( new byte[] { 92, -33, 26, 108, 7, 58, 50, 77, 102, -39, 109, 47, -1, -9, 35, -58, -7, 110, -50, 125, -89, -128, 21, -42, -96, 98, 78, -31, 6, 99, -124, -67, -87, -26, -44, -43, -102, -72, 60, 112, -67, -24, 95, 120, 105, 126, 12, 83, -114, -102, 71, -123, -65, 4, 59, 4, 0 }); final Scalar expectedD6 = decodeScalar( new byte[] { -109, -50, 3, -124, 29, 122, 15, -31, 40, 41, 102, -20, 30, 73, 14, 79, 81, -96, -12, -59, -101, -97, -119, -102, 73, 8, -86, 109, 64, -128, 22, -99, 11, 109, -127, 65, 66, -62, -90, 88, -108, 102, -94, -52, 18, -69, -95, 124, 121, 124, 59, 30, 39, 101, 35, 7, 0 }); final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret.negate(), a2, a3); final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b, c2, d2, g3b, c3, d3, pb, qb, cp, d5, d6); final SMPMessage3 response = state.process(context, message); assertEquals(pa, response.pa);// w ww . j ava 2 s . c om assertNotEquals(qa, response.qa); assertEquals(expectedCp, response.cp); assertEquals(expectedD5, response.d5); assertNotEquals(expectedD6, response.d6); assertNotEquals(ra, response.ra); assertNotEquals(cr, response.cr); assertNotEquals(d7, response.d7); }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test(expected = SMPAbortException.class) public void testProcessMessageBada2() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, Scalars.one(), a3);/*from ww w. j a v a2 s . c o m*/ final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b, c2, d2, g3b, c3, d3, pb, qb, cp, d5, d6); state.process(context, message); }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test(expected = SMPAbortException.class) public void testProcessMessageBada3() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, a2, Scalars.one());/* ww w. j a v a 2 s . c o m*/ final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b, c2, d2, g3b, c3, d3, pb, qb, cp, d5, d6); state.process(context, message); }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test(expected = SMPAbortException.class) public void testProcessMessageIllegalg2b() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, a2, a3); final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(createPoint(BigInteger.ONE, BigInteger.ONE), c2, d2, g3b, c3, d3, pb, qb, cp, d5, d6);// w w w. ja v a 2 s. c o m state.process(context, message); }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test(expected = SMPAbortException.class) public void testProcessMessageBadg2b() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, a2, a3); final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b.negate(), c2, d2, g3b, c3, d3, pb, qb, cp, d5, d6); state.process(context, message);/*from w ww.j a va 2s . c o m*/ }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test(expected = SMPAbortException.class) public void testProcessMessageIllegalg3b() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, a2, a3); final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b, c2, d2, createPoint(BigInteger.ONE, BigInteger.ONE), c3, d3, pb, qb, cp, d5, d6);// ww w .j a va 2 s . c o m state.process(context, message); }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test(expected = SMPAbortException.class) public void testProcessMessageBadg3b() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, a2, a3); final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b, c2, d2, g3b.negate(), c3, d3, pb, qb, cp, d5, d6); state.process(context, message);//from w w w. j a v a 2 s . c om }
From source file:net.java.otr4j.session.smpv4.StateExpect2Test.java
License:LGPL
@Test(expected = SMPAbortException.class) public void testProcessMessageIllegalpb() throws SMPAbortException { final byte[] fakeRandomData = new byte[] { 36, -29, -6, 118, 86, 75, -116, 119, -38, 53, -54, 102, 37, 123, -9, -6, -26, 90, 79, -98, -38, -27, -21, 106, -58, -91, 1, -110, 28, -115, -42, -20, -77, 118, -29, -81, 101, 55, 118, 96, 56, -103, 45, 82, 22, 78, 41, -51, -63, 35, 55, 68, 10, 37, -72, -44, 96, -37, -79, 124, 100, 58, -11, -67, -48, -90, 54, 29, -92, -53, 79, -60, 2, -101, -3, 49, 86, -22, -25, 29, 61, -78, -115, 40, 46, -67, -110, 57, 99, 37, 75, -123, -76, -69, 104, 89, 53, 117, -1, -122, -123, -43, -84, 16, -33, -73, -27, -70, -109, 92, 120, -53, -29, 20, -49, -101, 84, 21, -86, -76, 10, 59, 41, -73, 77, -27, -115, -1, 65, -23, -34, 81, -10, 84, -69, -122, 108, 74, -94, 71, 94, -71, -110, -32, -97, -110, -42, 77, -128, 43, -74, 9, 30, 107, 11, -56, -39, -100, 53, 73, 20, 102, 120, -85, 106, -49, 57, 92, 2, -54, 75, 101, -111, 5, 99, 109, -86, 39, 32, -94, 70, 9, -32, 44, 84, 12, -29, -22, 29, 20, -83, -118, 5, 127, -113, 17, 74, 17, -12, -84, -39, 49, -20, -76, -26, -94, 69, -110, -55, 54, -48, 55, -115, 27, -74, 68, 50, -32, -40, -6, 4, 99, -81, 43, 94, -122, 7, -44 }; final StateExpect2 state = new StateExpect2(new FixedSecureRandom(fakeRandomData), secret, a2, a3); final SMPContext context = mock(SMPContext.class); final SMPMessage2 message = new SMPMessage2(g2b, c2, d2, g3b, c3, d3, createPoint(BigInteger.ONE, BigInteger.ONE), qb, cp, d5, d6); state.process(context, message);/*from w ww . j a v a 2 s. c o m*/ }