Examples of ArmoredOutputStream


Examples of org.bouncycastle.bcpg.ArmoredOutputStream

        boolean         withIntegrityCheck)
        throws IOException, NoSuchProviderException, PGPException
    {   
        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }
       
        ByteArrayOutputStream       bOut = new ByteArrayOutputStream();
       
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

            PGPPublicKeyRing sRing = null;
            sRing = new PGPPublicKeyRing(new ByteArrayInputStream(signPublicKey(secRing.getSecretKey(), secretKeyPass, ring.getPublicKey(), notationName, notationValue, true)));
            ring = sRing;

            // write the created keyRing to file
            ArmoredOutputStream out = new ArmoredOutputStream(new FileOutputStream("SignedKey.asc"));
            sRing.encode(out);
            out.flush();
            out.close();
        }
        else
        {
            System.err.println("usage: DirectKeySignature secretKeyFile secretKeyPass publicKeyFile(key to be signed) NotationName NotationValue");
            System.err.println("or: DirectKeySignature signedPublicKeyFile");
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

    {
        OutputStream out = new ByteArrayOutputStream();

        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }

        PGPPrivateKey pgpPrivKey = secretKey.extractPrivateKey(secretKeyPass.toCharArray(), "BC");

        PGPSignatureGenerator       sGen = new PGPSignatureGenerator(secretKey.getPublicKey().getAlgorithm(), PGPUtil.SHA1, "BC");
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

        boolean         withIntegrityCheck)
        throws IOException, NoSuchProviderException
    {   
        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }
       
        try
        {   
            PGPEncryptedDataGenerator   cPk = new PGPEncryptedDataGenerator(PGPEncryptedData.CAST5, withIntegrityCheck, new SecureRandom(), "BC");
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

        boolean         armor)
        throws IOException, InvalidKeyException, NoSuchProviderException, SignatureException, PGPException
    {
        if (armor)
        {
            secretOut = new ArmoredOutputStream(secretOut);
        }

        PGPKeyPair        dsaKeyPair = new PGPKeyPair(PGPPublicKey.DSA, dsaKp, new Date(), "BC");
        PGPKeyPair        elgKeyPair = new PGPKeyPair(PGPPublicKey.ELGAMAL_ENCRYPT, elgKp, new Date(), "BC");
       
        PGPKeyRingGenerator    keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, dsaKeyPair,
                 identity, PGPEncryptedData.AES_256, passPhrase, true, null, null, new SecureRandom(), "BC");
       
        keyRingGen.addSubKey(elgKeyPair);
       
        keyRingGen.generateSecretKeyRing().encode(secretOut);
       
        secretOut.close();
       
        if (armor)
        {
            publicOut = new ArmoredOutputStream(publicOut);
        }
       
        keyRingGen.generatePublicKeyRing().encode(publicOut);
       
        publicOut.close();
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

        boolean         armor)
        throws IOException, NoSuchAlgorithmException, NoSuchProviderException, PGPException, SignatureException
    {   
        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }
       
        PGPSecretKey             pgpSec = readSecretKey(keyIn);
        PGPPrivateKey            pgpPrivKey = pgpSec.extractPrivateKey(pass, "BC");       
        PGPSignatureGenerator    sGen = new PGPSignatureGenerator(pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1, "BC");
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

            spGen.setSignerUserID(false, (String)it.next());
            sGen.setHashedSubpackets(spGen.generate());
        }
       
        FileInputStream        fIn = new FileInputStream(fileName);
        ArmoredOutputStream    aOut = new ArmoredOutputStream(out);
       
        aOut.beginClearText(digest);

        //
        // note the last \n/\r/\r\n in the file is ignored
        //
        ByteArrayOutputStream lineOut = new ByteArrayOutputStream();
        int lookAhead = readInputLine(lineOut, fIn);

        processLine(aOut, sGen, lineOut.toByteArray());

        if (lookAhead != -1)
        {
            do
            {
                lookAhead = readInputLine(lineOut, lookAhead, fIn);

                sGen.update((byte)'\r');
                sGen.update((byte)'\n');

                processLine(aOut, sGen, lineOut.toByteArray());
            }
            while (lookAhead != -1);
        }
       
        aOut.endClearText();
       
        BCPGOutputStream            bOut = new BCPGOutputStream(aOut);
       
        sGen.generate().encode(bOut);

        aOut.close();
    }
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

        boolean         armor)
        throws IOException, InvalidKeyException, NoSuchProviderException, SignatureException, PGPException
    {   
        if (armor)
        {
            secretOut = new ArmoredOutputStream(secretOut);
        }

        PGPSecretKey    secretKey = new PGPSecretKey(PGPSignature.DEFAULT_CERTIFICATION, PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(), identity, PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC");
       
        secretKey.encode(secretOut);
       
        secretOut.close();
       
        if (armor)
        {
            publicOut = new ArmoredOutputStream(publicOut);
        }

        PGPPublicKey    key = secretKey.getPublicKey();
       
        key.encode(publicOut);
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

        boolean         armor)
        throws IOException, NoSuchAlgorithmException, NoSuchProviderException, PGPException, SignatureException
    {   
        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }
       
        PGPSecretKey                pgpSec = readSecretKey(keyIn);
        PGPPrivateKey               pgpPrivKey = pgpSec.extractPrivateKey(pass, "BC");       
        PGPSignatureGenerator       sGen = new PGPSignatureGenerator(pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1, "BC");
View Full Code Here

Examples of org.bouncycastle.bcpg.ArmoredOutputStream

        ByteArrayOutputStream    encOut = new ByteArrayOutputStream();
       
        OutputStream out = encOut;
        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }

        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();

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.