Package com.maverick.crypto.asn1

Examples of com.maverick.crypto.asn1.BERSet


        return (X509Extension)extensions.get(oid);
    }

    public DERObject getDERObject()
    {
        ASN1EncodableVector     vec = new ASN1EncodableVector();
        Enumeration             e = ordering.elements();

        while (e.hasMoreElements())
        {
            DERObjectIdentifier     oid = (DERObjectIdentifier)e.nextElement();
            X509Extension           ext = (X509Extension)extensions.get(oid);
            ASN1EncodableVector     v = new ASN1EncodableVector();

            v.add(oid);

            if (ext.isCritical())
            {
                v.add(new DERBoolean(true));
            }

            v.add(ext.getValue());

            vec.add(new DERSequence(v));
        }

        return new DERSequence(vec);
View Full Code Here


     *                          publicKey BIT STRING }
     * </pre>
     */
    public DERObject getDERObject()
    {
        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(algId);
        v.add(keyData);

        return new DERSequence(v);
    }
View Full Code Here

     * </pre>
     * <p>
     */
    public DERObject getDERObject()
    {
        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(new DERInteger(getModulus()));
        v.add(new DERInteger(getPublicExponent()));

        return new DERSequence(v);
    }
View Full Code Here

     * }
     * </pre>
     */
    public DERObject toASN1Object()
    {
        ASN1EncodableVector  v = new ASN1EncodableVector();

    if (cA != null)
    {
          v.add(cA);

          if (pathLenConstraint != null)
          {
              v.add(pathLenConstraint);
          }
    }

        return new DERSequence(v);
    }
View Full Code Here

     *                            parameters ANY DEFINED BY algorithm OPTIONAL }
     * </pre>
     */
    public DERObject toASN1Object()
    {
        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(objectId);

        if (parametersDefined)
        {
            v.add(parameters);
        }

        return new DERSequence(v);
    }
View Full Code Here

                            ASN1Sequence o = (ASN1Sequence) der.readObject();

                            ASN1Sequence o1 = (ASN1Sequence) o.getObjectAt(0);

                            DERObjectIdentifier o2 = (DERObjectIdentifier) o1.getObjectAt(0);
                            ASN1OctetString o3 = (ASN1OctetString) o.getObjectAt(1);

                            byte[] actual = o3.getOctets();

                            for (int i = 0; i < actual.length; i++) {
                                if (actual[i] != hash[i]) {
                                    return false;
                                }
                            }

                        } catch (IOException ex1) {
                            throw new SSLException(SSLException.INTERNAL_ERROR, ex1.getMessage());
                        }

                    } else if (x509.getSigAlgName().equals("SHA1WithRSAEncryption")) { //$NON-NLS-1$

                        try {
                            byte[] blob = x509.getSignature();

                            // Check for signed bit
                            if ((blob[0] & 0x80) == 0x80) {
                                blob = new byte[x509.getSignature().length + 1];
                                blob[0] = 0;
                                System.arraycopy(x509.getSignature(), 0, blob, 1, x509.getSignature().length);
                            }

                            BigInteger input = new BigInteger(blob);
                            RsaPublicKey r = (RsaPublicKey) trusted.getPublicKey();

                            BigInteger decoded = Rsa.doPublic(input, r.getModulus(), r.getPublicExponent());

                            BigInteger result = Rsa.removePKCS1(decoded, 0x01);
                            byte[] sig = result.toByteArray();

                            SHA1Digest digest = new SHA1Digest();
                            digest.update(x509.getTBSCertificate(), 0, x509.getTBSCertificate().length);
                            byte[] hash = new byte[digest.getDigestSize()];
                            digest.doFinal(hash, 0);

                            DERInputStream der = new DERInputStream(new ByteArrayInputStream(sig));

                            ASN1Sequence o = (ASN1Sequence) der.readObject();

                            ASN1Sequence o1 = (ASN1Sequence) o.getObjectAt(0);

                            DERObjectIdentifier o2 = (DERObjectIdentifier) o1.getObjectAt(0);
                            ASN1OctetString o3 = (ASN1OctetString) o.getObjectAt(1);

                            byte[] actual = o3.getOctets();

                            for (int i = 0; i < actual.length; i++) {
                                if (actual[i] != hash[i]) {
                                    return false;
                                }
View Full Code Here

            ByteArrayInputStream bin = new ByteArrayInputStream(x509cert.getEncoded());
            DERInputStream der = null;
            try {
                der = new DERInputStream(bin);

                ASN1Sequence certificate = (ASN1Sequence) der.readObject();
                com.maverick.crypto.asn1.x509.X509Certificate x509 = new com.maverick.crypto.asn1.x509.X509Certificate(
                    X509CertificateStructure.getInstance(certificate));
                return store.isTrustedCertificate(x509, false, false);
            } finally {
                Util.closeStream(der);
View Full Code Here

        issuer = X509Name.getInstance(seq.getObjectAt(seqStart + 3));

        //
        // before and after dates
        //
        ASN1Sequence  dates = (ASN1Sequence)seq.getObjectAt(seqStart + 4);

        startDate = Time.getInstance(dates.getObjectAt(0));
        endDate = Time.getInstance(dates.getObjectAt(1));

        subject = X509Name.getInstance(seq.getObjectAt(seqStart + 5));

        //
        // public key info.
View Full Code Here

    {
        Enumeration e = seq.getObjects();

        while (e.hasMoreElements())
        {
            ASN1Sequence            s = (ASN1Sequence)e.nextElement();

            if (s.size() == 3)
            {
                extensions.put(s.getObjectAt(0), new X509Extension((DERBoolean)s.getObjectAt(1), (ASN1OctetString)s.getObjectAt(2)));
            }
            else
            {
                extensions.put(s.getObjectAt(0), new X509Extension(false, (ASN1OctetString)s.getObjectAt(1)));
            }

            ordering.addElement(s.getObjectAt(0));
        }
    }
View Full Code Here

        if (bytes != null)
        {
            try
            {
                DERInputStream  dIn = new DERInputStream(new ByteArrayInputStream(bytes));
                ASN1Sequence    seq = (ASN1Sequence)dIn.readObject();

                if (seq.size() == 2)
                {
                    if (((DERBoolean)seq.getObjectAt(0)).isTrue())
                    {
                        return ((DERInteger)seq.getObjectAt(1)).getValue().intValue();
                    }
                    else
                    {
                        return -1;
                    }
                }
                else if (seq.size() == 1)
                {
                    if (seq.getObjectAt(0) instanceof DERBoolean)
                    {
                        if (((DERBoolean)seq.getObjectAt(0)).isTrue())
                        {
                            return Integer.MAX_VALUE;
                        }
                        else
                        {
View Full Code Here

TOP

Related Classes of com.maverick.crypto.asn1.BERSet

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.