Package org.bouncycastle.asn1

Examples of org.bouncycastle.asn1.DERBitString


            challenge = ((DERIA5String)pkac.getObjectAt(1)).getString();

            //this could be dangerous, as ASN.1 decoding/encoding
            //could potentially alter the bytes
            content = new DERBitString(pkac);

            SubjectPublicKeyInfo pubkeyinfo = new SubjectPublicKeyInfo(
                    (ASN1Sequence)pkac.getObjectAt(0));

            X509EncodedKeySpec xspec = new X509EncodedKeySpec(new DERBitString(
                    pubkeyinfo).getBytes());

            keyAlg = pubkeyinfo.getAlgorithmId();
            pubkey = KeyFactory.getInstance(keyAlg.getObjectId().getId(), "BC")
                    .generatePublic(xspec);
View Full Code Here


        ASN1EncodableVector content_der = new ASN1EncodableVector();
        content_der.add(getKeySpec());
        //content_der.add(new SubjectPublicKeyInfo(sigAlg, new RSAPublicKeyStructure(pubkey.getModulus(), pubkey.getPublicExponent()).getDERObject()));
        content_der.add(new DERIA5String(challenge));

        content = new DERBitString(new DERSequence(content_der));
    }
View Full Code Here

        pkac.add(new DERIA5String(challenge));

        spkac.add(new DERSequence(pkac));
        spkac.add(sigAlg);
        spkac.add(new DERBitString(sigBits));

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

                new BERConstructedOctetString(data),
                new BERSequence(new DERPrintableString("hello world")),
                new BERSet(new DERPrintableString("hello world")),
                new BERTaggedObject(0, new DERPrintableString("hello world")),
                new DERApplicationSpecific(0 | DERTags.APPLICATION, data),
                new DERBitString(data),
                new DERBMPString("hello world"),
                new DERBoolean(true),
                new DERBoolean(false),
                new DEREnumerated(100),
                new DERGeneralizedTime(new Date()),
View Full Code Here

                        {
                            SubjectKeyIdentifier si = SubjectKeyIdentifier.getInstance(extIn.readObject());
                        }
                        else if (oid.equals(X509Extensions.KeyUsage))
                        {
                            DERBitString ku = KeyUsage.getInstance(extIn.readObject());
                        }
                        else if (oid.equals(X509Extensions.ExtendedKeyUsage))
                        {
                            ExtendedKeyUsage ku = ExtendedKeyUsage.getInstance(extIn.readObject());
                           
                            ASN1Sequence    sq = (ASN1Sequence)ku.getDERObject();
                            for (int i = 0; i != sq.size(); i++)
                            {
                                DERObjectIdentifier    p = KeyPurposeId.getInstance(sq.getObjectAt(i));
                            }
                        }
View Full Code Here

      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);
View Full Code Here

            catch (GeneralSecurityException e)
            {
                throw new OCSPException("exception creating signature: " + e, e);
            }

            DERBitString    bitSig = null;

            try
            {
                ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
                ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

                aOut.writeObject(tbsReq);

                sig.update(bOut.toByteArray());

                bitSig = new DERBitString(sig.sign());
            }
            catch (Exception e)
            {
                throw new OCSPException("exception processing TBSRequest: " + e, e);
            }
View Full Code Here

                buf.append(nl);
            }
        }
        else if (obj instanceof DERBitString)
        {
            DERBitString bt = (DERBitString)obj;
            buf.append(indent + "DER Bit String" + "[" + bt.getBytes().length + ", " + bt.getPadBits() + "] ");
            if (verbose)
            {
                buf.append(dumpBinaryDataAsString(indent, bt.getBytes()));
            }
            else{
                buf.append(nl);
            }
        }
View Full Code Here

        catch (GeneralSecurityException e)
        {
            throw new OCSPException("exception creating signature: " + e, e);
        }

        DERBitString    bitSig = null;

        try
        {
            sig.update(tbsResp.getEncoded(ASN1Encodable.DER));

            bitSig = new DERBitString(sig.sign());
        }
        catch (Exception e)
        {
            throw new OCSPException("exception processing TBSRequest: " + e, e);
        }
View Full Code Here

        if (exts != null)
        {
            X509Extension ext = exts.getExtension(X509Extensions.KeyUsage);
            if (ext != null)
            {
                DERBitString ku = KeyUsage.getInstance(ext);
                int bits = ku.getBytes()[0] & 0xff;
                if ((bits & keyUsageBits) != keyUsageBits)
                {
                    this.failWithError(AL_fatal, AP_certificate_unknown);
                }
            }
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.DERBitString

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.