Example usage for org.bouncycastle.crypto.prng VMPCRandomGenerator nextBytes

List of usage examples for org.bouncycastle.crypto.prng VMPCRandomGenerator nextBytes

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.prng VMPCRandomGenerator nextBytes.

Prototype

public void nextBytes(byte[] bytes) 

Source Link

Usage

From source file:libeac.tests.CPACECoreTest.java

License:Open Source License

public void testCalcX() throws Exception {
    m_pace.calcKPassword(m_szPw);/*w  w w.  j av a 2  s. com*/
    m_pace.decryptNonce(DatatypeConverter.parseHexBinary("4dd3ea7e1d014d9f6c66940d4125496b"));
    IECPoint X = m_pace.calcX();

    byte[] byaRnd = m_pace.getRand();
    VMPCRandomGenerator rndGen = new VMPCRandomGenerator();
    rndGen.nextBytes(byaRnd);
    X9ECParameters params = TeleTrusTNamedCurves.getByName("brainpoolp256r1");
    ECCurve.Fp curve = (ECCurve.Fp) params.getCurve();
    ECPoint base = params.getG();
    ECPoint.Fp Xbc = (ECPoint.Fp) base.multiply(new BigInteger(1, byaRnd));

    assertTrue(Arrays.equals(Xbc.getEncoded(), X.getEncoded()));

}