Package org.bouncycastle2.asn1.cryptopro

Examples of org.bouncycastle2.asn1.cryptopro.GOST3410PublicKeyAlgParameters


    }

    JDKGOST3410PrivateKey(
        PrivateKeyInfo  info)
    {
        GOST3410PublicKeyAlgParameters    params = new GOST3410PublicKeyAlgParameters((ASN1Sequence)info.getAlgorithmId().getParameters());
        DEROctetString      derX = (DEROctetString)info.getPrivateKey();
        byte[]              keyEnc = derX.getOctets();
        byte[]              keyBytes = new byte[keyEnc.length];
       
        for (int i = 0; i != keyEnc.length; i++)
View Full Code Here


            keyBytes[i] = keyEnc[keyEnc.length - 1 - i]; // must be little endian
        }
       
        if (gost3410Spec instanceof GOST3410ParameterSpec)
        {
            info = new PrivateKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_94, new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(gost3410Spec.getPublicKeyParamSetOID()), new DERObjectIdentifier(gost3410Spec.getDigestParamSetOID())).getDERObject()), new DEROctetString(keyBytes));
        }
        else
        {
            info = new PrivateKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_94), new DEROctetString(keyBytes));
        }
View Full Code Here

         *                   base INTEGER, -- a}
         * </pre>
         */
        protected byte[] engineGetEncoded()
        {
            GOST3410PublicKeyAlgParameters gost3410P = new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(currentSpec.getPublicKeyParamSetOID()), new DERObjectIdentifier(currentSpec.getDigestParamSetOID()), new DERObjectIdentifier(currentSpec.getEncryptionParamSetOID()));

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

            try
            {
                ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(params);

                this.currentSpec = GOST3410ParameterSpec.fromPublicKeyAlg(
                    new GOST3410PublicKeyAlgParameters(seq));
            }
            catch (ClassCastException e)
            {
                throw new IOException("Not a valid GOST3410 Parameter encoding.");
            }
View Full Code Here

            String format)
            throws IOException
        {
            if (isASN1FormatString(format))
            {
                return new CAST5CBCParameters(engineGetEncoded(), keyLength).getEncoded();
            }

            if (format.equals("RAW"))
            {
                return engineGetEncoded();
View Full Code Here

            throws IOException
        {
            if (isASN1FormatString(format))
            {
                ASN1InputStream aIn = new ASN1InputStream(params);
                CAST5CBCParameters      p = CAST5CBCParameters.getInstance(aIn.readObject());

                keyLength = p.getKeyLength();

                iv = p.getIV();

                return;
            }

            if (format.equals("RAW"))
View Full Code Here

            String format)
            throws IOException
        {
            if (isASN1FormatString(format))
            {
                return new IDEACBCPar(engineGetEncoded("RAW")).getEncoded();
            }

            if (format.equals("RAW"))
            {
                byte[]  tmp = new byte[iv.length];
View Full Code Here

                return;
            }
            if (format.equals("ASN.1"))
            {
                ASN1InputStream aIn = new ASN1InputStream(params);
                IDEACBCPar      oct = new IDEACBCPar((ASN1Sequence)aIn.readObject());

                engineInit(oct.getIV());
                return;
            }

            throw new IOException("Unknown parameters format in IV parameters object");
        }
View Full Code Here

    }

    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

        return "X.509";
    }

    public byte[] getEncoded()
    {
        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(OIWObjectIdentifiers.elGamalAlgorithm, new ElGamalParameter(elSpec.getP(), elSpec.getG()).getDERObject()), new DERInteger(y));

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

TOP

Related Classes of org.bouncycastle2.asn1.cryptopro.GOST3410PublicKeyAlgParameters

Copyright © 2018 www.massapicom. 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.