Examples of ElGamalParameter


Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

         */
        protected byte[] engineGetEncoded()
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            DEROutputStream         dOut = new DEROutputStream(bOut);
            ElGamalParameter        elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG());

            try
            {
                dOut.writeObject(elP);
                dOut.close();
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

            ByteArrayInputStream   bIn = new ByteArrayInputStream(params);
            ASN1InputStream        aIn = new ASN1InputStream(bIn);

            try
            {
                ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)aIn.readObject());

                currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
            }
            catch (ClassCastException e)
            {
                throw new IOException("Not a valid ElGamal Parameter encoding.");
            }
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

            return new DHPrivateKeyParameters(derX.getValue(), new DHParameters(params.getP(), params.getG()));
        }
        else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
        {
            ElGamalParameter    params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
            DERInteger          derX = (DERInteger)keyInfo.getPrivateKey();

            return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(params.getP(), params.getG()));
        }
        else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa))
        {
            DSAParameter    params = new DSAParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
            DERInteger      derX = (DERInteger)keyInfo.getPrivateKey();

            return new DSAPrivateKeyParameters(derX.getValue(), new DSAParameters(params.getP(), params.getQ(), params.getG()));
        }
        else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))
        {
            X962Parameters      params = new X962Parameters((DERObject)keyInfo.getAlgorithmId().getParameters());
            ECDomainParameters  dParams = null;
           
            if (params.isNamedCurve())
            {
                DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters();
                X9ECParameters      ecP = X962NamedCurves.getByOID(oid);

                dParams = new ECDomainParameters(
                                            ecP.getCurve(),
                                            ecP.getG(),
                                            ecP.getN(),
                                            ecP.getH(),
                                            ecP.getSeed());
            }
            else
            {
                X9ECParameters ecP = new X9ECParameters(
                            (ASN1Sequence)params.getParameters());
                dParams = new ECDomainParameters(
                                            ecP.getCurve(),
                                            ecP.getG(),
                                            ecP.getN(),
                                            ecP.getH(),
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

            gen.setIssuer(new X509Name("CN=AU,O=Bouncy Castle"));
            gen.setSubject(new X509Name("CN=AU,O=Bouncy Castle,OU=Test 2"));
           
            gen.setSignature(new AlgorithmIdentifier(PKCSObjectIdentifiers.md5WithRSAEncryption, new DERNull()));
          
            SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(BigInteger.valueOf(1), BigInteger.valueOf(2))), new DERInteger(3));

            gen.setSubjectPublicKeyInfo(info);
           
            //
            // add extensions
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

            //
            // extensions
            //
            Vector                  order = new Vector();
            Hashtable               extensions = new Hashtable();
            SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(BigInteger.valueOf(1), BigInteger.valueOf(2))), new DERInteger(3));

            order.addElement(X509Extensions.AuthorityKeyIdentifier);
            order.addElement(X509Extensions.IssuerAlternativeName);
            order.addElement(X509Extensions.CRLNumber);
            order.addElement(X509Extensions.IssuingDistributionPoint);
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

         *                   base INTEGER, -- g}
         * </pre>
         */
        protected byte[] engineGetEncoded()
        {
            ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG());

            try
            {
                return elP.getEncoded(ASN1Encodable.DER);
            }
            catch (IOException e)
            {
                throw new RuntimeException("Error encoding ElGamalParameters");
            }
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

            byte[] params)
            throws IOException
        {
            try
            {
                ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Object.fromByteArray(params));

                currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
            }
            catch (ClassCastException e)
            {
                throw new IOException("Not a valid ElGamal Parameter encoding.");
            }
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

    }
   
    JCEElGamalPrivateKey(
        PrivateKeyInfo  info)
    {
        ElGamalParameter     params = new ElGamalParameter((ASN1Sequence)info.getAlgorithmId().getParameters());
        DERInteger      derX = (DERInteger)info.getPrivateKey();

        this.x = derX.getValue();
        this.elSpec = new ElGamalParameterSpec(params.getP(), params.getG());
    }
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

     *
     * @return a PKCS8 representation of the key.
     */
    public byte[] getEncoded()
    {
        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG()).getDERObject()), new DERInteger(getX()));

        return info.getDEREncoded();
    }
View Full Code Here

Examples of org.bouncycastle.asn1.oiw.ElGamalParameter

    }

    JCEElGamalPublicKey(
        SubjectPublicKeyInfo    info)
    {
        ElGamalParameter        params = new ElGamalParameter((ASN1Sequence)info.getAlgorithmId().getParameters());
        DERInteger              derY = null;

        try
        {
            derY = (DERInteger)info.getPublicKey();
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("invalid info structure in DSA public key");
        }

        this.y = derY.getValue();
        this.elSpec = new ElGamalParameterSpec(params.getP(), params.getG());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.