Package org.apache.harmony.security.x509

Examples of org.apache.harmony.security.x509.AlgorithmIdentifier


        Object[] issuerAndSerialNumber = new Object[] { new Name("CN=test"),
                BigInteger.TEN.toByteArray() };

        SignerInfo signerInfo = new SignerInfo(1, issuerAndSerialNumber,
                new AlgorithmIdentifier("1.3.14.3.2.26"),// SHA1 OID
                null, new AlgorithmIdentifier("1.2.840.10040.4.1"),// DSA OID
                new byte[] { 0x01 },// signature
                null);

        byte[] encoding = SignerInfo.ASN1.encode(signerInfo);
View Full Code Here


    private byte[] getCertEncoding(Name subject, GeneralNames subjectAltNames)
                                                        throws IOException {
        // make the TBSCertificate for Certificate
        int version = 2; //v3
        BigInteger serialNumber = BigInteger.valueOf(555L);
        AlgorithmIdentifier signature = new AlgorithmIdentifier("1.2.3.44.555");
        Name issuer = new Name("O=Certificate Issuer");
        Validity validity = new Validity(new Date(100000000),
                                         new Date(200000000));
        SubjectPublicKeyInfo subjectPublicKeyInfo =
            new SubjectPublicKeyInfo(
                    new AlgorithmIdentifier("1.2.840.113549.1.1.2"),
                                            new byte[10]);
        boolean[] issuerUniqueID  = new boolean[]
                    {true, false, true, false, true, false, true, false};
        boolean[] subjectUniqueID = new boolean[]
                    {false, true, false, true, false, true, false, true};
View Full Code Here

            }
        }
        if (subjectPublicKeyAlgID  != null) {
            try {
                byte[] encoding = cert.getPublicKey().getEncoded();
                AlgorithmIdentifier ai = ((SubjectPublicKeyInfo)
                        SubjectPublicKeyInfo.ASN1.decode(encoding))
                        .getAlgorithmIdentifier();
                if (!subjectPublicKeyAlgID.equals(ai.getAlgorithm())) {
                    return false;
                }
            } catch (IOException e) {
                e.printStackTrace();
                return false;
View Full Code Here

            }
        }
        if (subjectPublicKeyAlgID  != null) {
            try {
                byte[] encoding = cert.getPublicKey().getEncoded();
                AlgorithmIdentifier ai = ((SubjectPublicKeyInfo)
                        SubjectPublicKeyInfo.ASN1.decode(encoding))
                        .getAlgorithmIdentifier();
                if (!subjectPublicKeyAlgID.equals(ai.getAlgorithm())) {
                    return false;
                }
            } catch (IOException e) {
                e.printStackTrace();
                return false;
View Full Code Here

                    + " is not found in the environment.");
        }
        sigAlgName = sigAlgNameAndOID[0];
        String sigAlgOID = sigAlgNameAndOID[1];

        AlgorithmIdentifier algId = new AlgorithmIdentifier(sigAlgOID);

        // generate a distinguished name using the string
        Name subjectDName = null;
        Name issuerDName = null;
        try {
View Full Code Here

            }
        }
        if (subjectPublicKeyAlgID  != null) {
            try {
                byte[] encoding = cert.getPublicKey().getEncoded();
                AlgorithmIdentifier ai = ((SubjectPublicKeyInfo)
                        SubjectPublicKeyInfo.ASN1.decode(encoding))
                        .getAlgorithmIdentifier();
                if (!subjectPublicKeyAlgID.equals(ai.getAlgorithm())) {
                    return false;
                }
            } catch (IOException e) {
                e.printStackTrace();
                return false;
View Full Code Here

                    + " is not found in the environment.");
        }
        sigAlgName = sigAlgNameAndOID[0];
        String sigAlgOID = sigAlgNameAndOID[1];

        AlgorithmIdentifier algId = new AlgorithmIdentifier(sigAlgOID);

        // generate a distinguished name using the string
        Name subjectDName = null;
        Name issuerDName = null;
        try {
View Full Code Here

        g = keySpec.getG();

        ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p
                .toByteArray(), q.toByteArray(), g.toByteArray());

        AlgorithmIdentifier ai = new AlgorithmIdentifier(AlgNameMapper
                .map2OID("DSA"), //$NON-NLS-1$
                threeInts.getEncoded());

        y = keySpec.getY();
View Full Code Here

    public DSAPublicKeyImpl(X509EncodedKeySpec keySpec)
            throws InvalidKeySpecException {

        super("DSA"); //$NON-NLS-1$

        AlgorithmIdentifier ai;
        ThreeIntegerSequence threeInts = null;

        SubjectPublicKeyInfo subjectPublicKeyInfo = null;

        byte encoding[] = keySpec.getEncoded();

        String alg, algName;

        try {
            subjectPublicKeyInfo = (SubjectPublicKeyInfo) SubjectPublicKeyInfo.ASN1
                    .decode(encoding);
        } catch (IOException e) {
            throw new InvalidKeySpecException(Messages.getString(
                    "security.19A", e)); //$NON-NLS-1$
        }

        try {
            y = new BigInteger((byte[]) ASN1Integer.getInstance().decode(
                    subjectPublicKeyInfo.getSubjectPublicKey()));
        } catch (IOException e) {
            throw new InvalidKeySpecException(Messages.getString(
                    "security.19B", e)); //$NON-NLS-1$
        }

        ai = subjectPublicKeyInfo.getAlgorithmIdentifier();

        try {
            threeInts = (ThreeIntegerSequence) ThreeIntegerSequence.ASN1
                    .decode(ai.getParameters());
        } catch (IOException e) {
            throw new InvalidKeySpecException(Messages.getString(
                    "security.19B", e)); //$NON-NLS-1$
        }
        p = new BigInteger(threeInts.p);
        q = new BigInteger(threeInts.q);
        g = new BigInteger(threeInts.g);
        params = (DSAParams) (new DSAParameterSpec(p, q, g));

        setEncoding(encoding);

        /*
         * the following code implements RI behavior
         */
        alg = ai.getAlgorithm();
        algName = AlgNameMapper.map2AlgName(alg);
        setAlgorithm(algName == null ? alg : algName);
    }
View Full Code Here

        q = keySpec.getQ();

        ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p
                .toByteArray(), q.toByteArray(), g.toByteArray());

        AlgorithmIdentifier ai = new AlgorithmIdentifier(AlgNameMapper
                .map2OID("DSA"), //$NON-NLS-1$
                threeInts.getEncoded());
        x = keySpec.getX();

        pki = new PrivateKeyInfo(0, ai, ASN1Integer.getInstance().encode(
View Full Code Here

TOP

Related Classes of org.apache.harmony.security.x509.AlgorithmIdentifier

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.