Package org.bouncycastle.asn1

Examples of org.bouncycastle.asn1.DERObject


           
            //
            // read back test
            //
            ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(v2CertList));
            DERObject       o = aIn.readObject();
           
            bOut = new ByteArrayOutputStream();
            aOut = new ASN1OutputStream(bOut);
           
            aOut.writeObject(o);
View Full Code Here


            ByteArrayInputStream    bIn = new ByteArrayInputStream(bOut.toByteArray());
            ASN1InputStream         aIn = new ASN1InputStream(bIn);
           
            for (int i = 0; i != values.length; i++)
            {
                DERObject   o = aIn.readObject();
                if (!values[i].equals(o))
                {
                    return new SimpleTestResult(false, getName() + ": Failed equality test for " + o);
                }
               
                if (o.hashCode() != values[i].hashCode())
                {
                    return new SimpleTestResult(false, getName() + ": Failed hashCode test for " + o);
                }
            }
           
View Full Code Here

            }
           
            ByteArrayInputStream    bIn = new ByteArrayInputStream(attrBytes);
            ASN1InputStream         aIn = new ASN1InputStream(bIn);
           
            DERObject   o = aIn.readObject();
            if (!attr.equals(o))
            {
                return new SimpleTestResult(false, getName() + ": Failed equality test for attr");
            }
           
View Full Code Here

            try
            {
                bIn = new ByteArrayInputStream(bytes);
                aIn = new ASN1InputStream(bIn);

                DERObject   obj = aIn.readObject();
   
                return new SimpleTestResult(false, getName() + ": test " + id + " length mismatch - expected " + sample.length + System.getProperty("line.separator") + ASN1Dump.dumpAsString(info) + " got " + bytes.length + System.getProperty("line.separator") + ASN1Dump.dumpAsString(obj));
            }
            catch (Exception e)
            {
View Full Code Here

      e.printStackTrace();
    }
   
    // javni kljuc se sastoji od modula i javnog eksponenta u odgovarajucoj ASN1 strukturi
    ASN1InputStream is = new ASN1InputStream(x509Cert.getPublicKey().getEncoded());
      DERObject obj = null;
    try {
      obj = is.readObject();
    } catch (IOException e) {
      e.printStackTrace();
    }
View Full Code Here

    RSAPrivateCrtKeySpec privKeySpec = null;
    ASN1InputStream asn1InputStream = new ASN1InputStream(privateKey);
    //parsiranje ASN1 strukture
    ArrayList<BigInteger> privateKeyParts = new ArrayList<BigInteger>();
    try {
      DERObject derObject = asn1InputStream.readObject();
      ASN1Sequence asn1Seq = (ASN1Sequence) derObject;
     
      Enumeration<DERObject> en = asn1Seq.getObjects();
      while(en.hasMoreElements()){
        DERObject obj = en.nextElement();
        DERBitString bitString = DERBitString.getInstance(obj);
        byte[] prependZero = new byte[bitString.getBytes().length+1];
        // zbog "cudnog" BigInteger konstruktora mora se dodati 0x0 na pocetak,
        // u suprotnom u pojedinim slucajevima pogresno se protumaci znak i brojevi ispadnu negativni
        prependZero[0] = 0x0;
        System.arraycopy(bitString.getBytes(), 0, prependZero, 1, bitString.getBytes().length);
        privateKeyParts.add(new BigInteger(prependZero));
      }

      // citamo sertifikat zbog podataka o javnom kljucu
      byte[] standardFileBytes = readElementaryFile(STANDARD_CERTIFICATE);
      byte[] certificateBytes = new byte[standardFileBytes.length];
      System.arraycopy(standardFileBytes, 4, certificateBytes, 0, standardFileBytes.length-4);
      ByteArrayInputStream certificateInputStream = new ByteArrayInputStream(certificateBytes);
      CertificateFactory cf = CertificateFactory.getInstance("X.509");
      X509Certificate x509Cert = (X509Certificate) cf.generateCertificate(certificateInputStream);
     
      // javni kljuc se sastoji od modula i javnog eksponenta u odgovarajucoj ASN1 strukturi
      ASN1InputStream is = new ASN1InputStream(x509Cert.getPublicKey().getEncoded());
        DERObject obj = is.readObject();
        ASN1Sequence seq = (ASN1Sequence)obj;
        SubjectPublicKeyInfo pkInfo = SubjectPublicKeyInfo.getInstance(seq);
        RSAPublicKeyStructure pubk = RSAPublicKeyStructure.getInstance(pkInfo.getPublicKey());
        BigInteger expo = pubk.getPublicExponent();
        BigInteger mod = pubk.getModulus();
View Full Code Here

            ASN1InputStream din = new ASN1InputStream(new ByteArrayInputStream(contentsKey));

            //
            // Basic checks to make sure it's a PKCS#7 SignedData Object
            //
            DERObject pkcs;

            try {
                pkcs = din.readObject();
            }
            catch (IOException e) {
View Full Code Here

     * @throws CertificateParsingException on error
     * @since  2.1.6
     */
    public static String getOCSPURL(X509Certificate certificate) throws CertificateParsingException {
        try {
            DERObject obj = getExtensionValue(certificate, X509Extensions.AuthorityInfoAccess.getId());
            if (obj == null) {
                return null;
            }

            ASN1Sequence AccessDescriptions = (ASN1Sequence) obj;
View Full Code Here

        if (!(obj instanceof X509Name || obj instanceof ASN1Sequence))
        {
            return false;
        }

        DERObject derO = ((DEREncodable)obj).getDERObject();

        if (this.getDERObject().equals(derO))
        {
            return true;
        }
View Full Code Here

        if (!(obj instanceof X509Name || obj instanceof ASN1Sequence))
        {
            return false;
        }
       
        DERObject derO = ((DEREncodable)obj).getDERObject();
       
        if (this.getDERObject().equals(derO))
        {
            return true;
        }
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.DERObject

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.