Examples of BerOutputStream


Examples of org.bouncycastle.asn1.BEROutputStream

        AuthenticatedSafe   auth = new AuthenticatedSafe(c);

        bOut.reset();

        BEROutputStream         berOut = new BEROutputStream(bOut);

        berOut.writeObject(auth);

        byte[]              pkg = bOut.toByteArray();

        ContentInfo         mainInfo = new ContentInfo(data, new BERConstructedOctetString(pkg));

        //
        // create the mac
        //
        byte[]                      mSalt = new byte[20];
        int                         itCount = MIN_ITERATIONS;

        random.nextBytes(mSalt);
   
        byte[]  data = ((ASN1OctetString)mainInfo.getContent()).getOctets();

        MacData                 mData;

        try
        {
            Mac                 mac = Mac.getInstance(id_SHA1.getId(), "BC");
            SecretKeyFactory    keyFact = SecretKeyFactory.getInstance(id_SHA1.getId(), "BC");
            PBEParameterSpec    defParams = new PBEParameterSpec(mSalt, itCount);
            PBEKeySpec          pbeSpec = new PBEKeySpec(password);

            mac.init(keyFact.generateSecret(pbeSpec), defParams);

            mac.update(data);

            byte[]      res = mac.doFinal();

            AlgorithmIdentifier     algId = new AlgorithmIdentifier(id_SHA1, new DERNull());
            DigestInfo              dInfo = new DigestInfo(algId, res);

            mData = new MacData(dInfo, mSalt, itCount);
        }
        catch (Exception e)
        {
            throw new IOException("error constructing MAC: " + e.toString());
        }
       
        //
        // output the Pfx
        //
        Pfx                 pfx = new Pfx(mainInfo, mData);

        berOut = new BEROutputStream(stream);

        berOut.writeObject(pfx);
    }
View Full Code Here

Examples of org.bouncycastle2.asn1.BEROutputStream

        };

        AuthenticatedSafe   auth = new AuthenticatedSafe(info);

        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        BEROutputStream         berOut = new BEROutputStream(bOut);

        berOut.writeObject(auth);

        byte[]              pkg = bOut.toByteArray();

        ContentInfo         mainInfo = new ContentInfo(data, new BERConstructedOctetString(pkg));

        //
        // create the mac
        //
        byte[]                      mSalt = new byte[20];
        int                         itCount = MIN_ITERATIONS;

        random.nextBytes(mSalt);
   
        byte[]  data = ((ASN1OctetString)mainInfo.getContent()).getOctets();

        MacData                 mData;

        try
        {
            byte[] res = calculatePbeMac(id_SHA1, mSalt, itCount, password, false, data);

            AlgorithmIdentifier     algId = new AlgorithmIdentifier(id_SHA1, new DERNull());
            DigestInfo              dInfo = new DigestInfo(algId, res);

            mData = new MacData(dInfo, mSalt, itCount);
        }
        catch (Exception e)
        {
            throw new IOException("error constructing MAC: " + e.toString());
        }
       
        //
        // output the Pfx
        //
        Pfx                 pfx = new Pfx(mainInfo, mData);

        berOut = new BEROutputStream(stream);

        berOut.writeObject(pfx);
    }
View Full Code Here

Examples of org.hxzon.asn1.core.parse.BerOutputStream

            /*
             * Write as definite length
             */

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            BerOutputStream tmp = new BerOutputStream(baos, stream.getEncodingMethod());
            it = _fList.iterator();
            while (it.hasNext()) {
                BerNode node = it.next();
                node.writeElement(tmp);
            }
            tmp.close();
            baos.close();

            byte[] data = baos.toByteArray();
            stream.writeBerLength(data.length);
            stream.write(data);
View Full Code Here

Examples of org.jzkit.a2j.codec.runtime.BEROutputStream

                {
                    PDU_type pdu = protocolHandler.produceInitializingRequest();

                    logger.debug("Sending " + ToStringBuilder.reflectionToString(pdu));

                    BEROutputStream encoder = new BEROutputStream(DEFAULT_BUFFER_SIZE, charsetEncoding, ProtocolOIDRegister.getInstance());
                    PDU_codec.getCodec().serialize(encoder, protocolHandler.produceInitializingRequest(), false, "PDU");
                    encoder.flush();
                    encoder.writeTo(outputStream);
                    this.outputStream.flush();
                    protocolHandler.initializingRequestSubmitted();
                }
                catch (ProtocolException e)
                {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.