Search in sources :

Example 36 with DSAParameterSpec

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());
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) DSAKey(java.security.interfaces.DSAKey) DSAParams(java.security.interfaces.DSAParams) KeyPairGenerator(java.security.KeyPairGenerator)

Example 37 with DSAParameterSpec

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());
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) DSAParams(java.security.interfaces.DSAParams)

Example 38 with DSAParameterSpec

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());
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) KeyPair(java.security.KeyPair) SecureRandom(java.security.SecureRandom) DSAPrivateKey(java.security.interfaces.DSAPrivateKey) KeyPairGenerator(java.security.KeyPairGenerator)

Example 39 with DSAParameterSpec

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());
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) BigInteger(java.math.BigInteger)

Example 40 with DSAParameterSpec

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);
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) BigInteger(java.math.BigInteger) AlgorithmParameterSpec(java.security.spec.AlgorithmParameterSpec)

Aggregations

DSAParameterSpec (java.security.spec.DSAParameterSpec)56 BigInteger (java.math.BigInteger)20 DSAParams (java.security.interfaces.DSAParams)16 KeyPairGenerator (java.security.KeyPairGenerator)12 SecureRandom (java.security.SecureRandom)10 AlgorithmParameters (java.security.AlgorithmParameters)8 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)6 DSAPublicKey (java.security.interfaces.DSAPublicKey)6 InvalidParameterSpecException (java.security.spec.InvalidParameterSpecException)6 KeyPair (java.security.KeyPair)5 InvalidParameterException (java.security.InvalidParameterException)4 DSAPrivateKey (java.security.interfaces.DSAPrivateKey)3 DSAParameters (org.bouncycastle.crypto.params.DSAParameters)3 IOException (java.io.IOException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 NoSuchProviderException (java.security.NoSuchProviderException)2 AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)2 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)2 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)2 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)2