use of java.security.spec.DSAParameterSpec in project robovm by robovm.
the class DSAKeyTest method test_getParams.
/**
* java.security.interfaces.DSAKey
* #getParams()
* test covers following use cases
* Case 1: check private key
* Case 2: check public key
*/
public void test_getParams() throws Exception {
DSAParams param = new DSAParameterSpec(Util.P, Util.Q, Util.G);
KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA");
gen.initialize((DSAParameterSpec) param);
DSAKey key = null;
// Case 1: check private key
key = (DSAKey) gen.generateKeyPair().getPrivate();
assertDSAParamsEquals(param, key.getParams());
// Case 2: check public key
key = (DSAKey) gen.generateKeyPair().getPublic();
assertDSAParamsEquals(param, key.getParams());
}
use of java.security.spec.DSAParameterSpec in project robovm by robovm.
the class DSAParamsTest method test_getG.
/**
* java.security.interfaces.DSAParams
* #getG()
*/
public void test_getG() {
DSAParams params = new DSAParameterSpec(p, q, g);
assertEquals("Invalid G", g, params.getG());
}
use of java.security.spec.DSAParameterSpec in project robovm by robovm.
the class DSAPrivateKeyTest method test_getX.
/**
* java.security.interfaces.DSAPrivateKey
* #getX()
*/
public void test_getX() throws Exception {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
keyGen.initialize(new DSAParameterSpec(Util.P, Util.Q, Util.G), new SecureRandom(new MySecureRandomSpi(), null) {
});
KeyPair keyPair = keyGen.generateKeyPair();
DSAPrivateKey key = (DSAPrivateKey) keyPair.getPrivate();
assertNotNull("Invalid X value", key.getX());
}
use of java.security.spec.DSAParameterSpec in project robovm by robovm.
the class DSAParameterSpecTest method testGetG.
/**
* getG() test
*/
public final void testGetG() {
DSAParameterSpec dps = new DSAParameterSpec(new BigInteger("1"), new BigInteger("2"), new BigInteger("3"));
assertEquals(3, dps.getG().intValue());
}
use of java.security.spec.DSAParameterSpec in project robovm by robovm.
the class DSAParameterSpecTest method testDSAParameterSpec.
/**
* Ctor test
*/
public final void testDSAParameterSpec() {
AlgorithmParameterSpec aps = new DSAParameterSpec(new BigInteger("1"), new BigInteger("2"), new BigInteger("3"));
assertTrue(aps instanceof DSAParameterSpec);
}
Aggregations