Search in sources :

Example 41 with DSAParameterSpec

use of java.security.spec.DSAParameterSpec in project robovm by robovm.

the class AlgorithmParametersSpi method engineInit.

protected void engineInit(byte[] params) throws IOException {
    try {
        DSAParameter dsaP = DSAParameter.getInstance(ASN1Primitive.fromByteArray(params));
        currentSpec = new DSAParameterSpec(dsaP.getP(), dsaP.getQ(), dsaP.getG());
    } catch (ClassCastException e) {
        throw new IOException("Not a valid DSA Parameter encoding.");
    } catch (ArrayIndexOutOfBoundsException e) {
        throw new IOException("Not a valid DSA Parameter encoding.");
    }
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) DSAParameter(org.bouncycastle.asn1.x509.DSAParameter) IOException(java.io.IOException)

Example 42 with DSAParameterSpec

use of java.security.spec.DSAParameterSpec in project robovm by robovm.

the class BCDSAPrivateKey method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    this.dsaSpec = new DSAParameterSpec((BigInteger) in.readObject(), (BigInteger) in.readObject(), (BigInteger) in.readObject());
    this.attrCarrier = new PKCS12BagAttributeCarrierImpl();
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) PKCS12BagAttributeCarrierImpl(org.bouncycastle.jcajce.provider.asymmetric.util.PKCS12BagAttributeCarrierImpl) BigInteger(java.math.BigInteger)

Example 43 with DSAParameterSpec

use of java.security.spec.DSAParameterSpec in project robovm by robovm.

the class KeyPairGeneratorSpi method initialize.

public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
    if (!(params instanceof DSAParameterSpec)) {
        throw new InvalidAlgorithmParameterException("parameter object not a DSAParameterSpec");
    }
    DSAParameterSpec dsaParams = (DSAParameterSpec) params;
    param = new DSAKeyGenerationParameters(random, new DSAParameters(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG()));
    engine.init(param);
    initialised = true;
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) DSAKeyGenerationParameters(org.bouncycastle.crypto.params.DSAKeyGenerationParameters) DSAParameters(org.bouncycastle.crypto.params.DSAParameters)

Example 44 with DSAParameterSpec

use of java.security.spec.DSAParameterSpec in project robovm by robovm.

the class JDKDSAPublicKey method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    this.y = (BigInteger) in.readObject();
    this.dsaSpec = new DSAParameterSpec((BigInteger) in.readObject(), (BigInteger) in.readObject(), (BigInteger) in.readObject());
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) BigInteger(java.math.BigInteger)

Example 45 with DSAParameterSpec

use of java.security.spec.DSAParameterSpec in project robovm by robovm.

the class OpenSSLDSAKeyPairGenerator method initialize.

@Override
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
    this.random = random;
    if (params instanceof DSAParameterSpec) {
        DSAParameterSpec dsaParams = (DSAParameterSpec) params;
        BigInteger gInt = dsaParams.getG();
        if (gInt != null) {
            g = gInt.toByteArray();
        }
        BigInteger pInt = dsaParams.getP();
        if (pInt != null) {
            p = pInt.toByteArray();
        }
        BigInteger qInt = dsaParams.getQ();
        if (qInt != null) {
            q = qInt.toByteArray();
        }
    } else if (params != null) {
        throw new InvalidAlgorithmParameterException("Params must be DSAParameterSpec");
    }
}
Also used : DSAParameterSpec(java.security.spec.DSAParameterSpec) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) BigInteger(java.math.BigInteger)

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